update the given medium after editing it

This commit is contained in:
tibbi 2016-10-06 20:05:44 +02:00
parent a5def53373
commit f4655761bd
7 changed files with 22 additions and 21 deletions

View file

@ -58,7 +58,7 @@ public class PhotoVideoActivity extends SimpleActivity implements ViewPagerFragm
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mFragment.confChanged();
mFragment.updateItem();
}
@Override

View file

@ -174,7 +174,7 @@ public class ViewPagerActivity extends SimpleActivity
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
final MyPagerAdapter adapter = (MyPagerAdapter) mPager.getAdapter();
adapter.confChanged(mPos);
adapter.updateItems(mPos);
}
private void openEditor() {
@ -187,7 +187,8 @@ public class ViewPagerActivity extends SimpleActivity
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == EDIT_IMAGE) {
if (resultCode == RESULT_OK && data != null) {
final MyPagerAdapter adapter = (MyPagerAdapter) mPager.getAdapter();
adapter.updateItems(mPos);
} else {
Utils.showToast(getApplicationContext(), R.string.image_editing_failed);
}

View file

@ -67,11 +67,11 @@ public class MyPagerAdapter extends FragmentStatePagerAdapter {
}
}
public void confChanged(int pos) {
public void updateItems(int pos) {
for (int i = -1; i <= 1; i++) {
final ViewPagerFragment fragment = mFragments.get(pos + i);
if (fragment != null) {
fragment.confChanged();
fragment.updateItem();
}
}
}

View file

@ -15,33 +15,33 @@ import com.simplemobiletools.gallery.R;
import com.simplemobiletools.gallery.models.Medium;
public class PhotoFragment extends ViewPagerFragment implements View.OnClickListener {
private View mView;
private SubsamplingScaleImageView mSubsamplingView;
private Medium mMedium;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.pager_photo_item, container, false);
final View view = inflater.inflate(R.layout.pager_photo_item, container, false);
final Medium medium = (Medium) getArguments().getSerializable(Constants.MEDIUM);
if (medium == null)
return mView;
mMedium = (Medium) getArguments().getSerializable(Constants.MEDIUM);
if (mMedium == null)
return view;
mSubsamplingView = (SubsamplingScaleImageView) mView.findViewById(R.id.photo_view);
if (medium.isGif()) {
mSubsamplingView = (SubsamplingScaleImageView) view.findViewById(R.id.photo_view);
if (mMedium.isGif()) {
mSubsamplingView.setVisibility(View.GONE);
final ImageView imageView = (ImageView) mView.findViewById(R.id.gif_view);
final ImageView imageView = (ImageView) view.findViewById(R.id.gif_view);
imageView.setVisibility(View.VISIBLE);
Glide.with(getContext()).load(medium.getPath()).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).into(imageView);
Glide.with(getContext()).load(mMedium.getPath()).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).into(imageView);
imageView.setOnClickListener(this);
} else {
mSubsamplingView.setOrientation(SubsamplingScaleImageView.ORIENTATION_USE_EXIF);
mSubsamplingView.setImage(ImageSource.uri(medium.getPath()));
mSubsamplingView.setImage(ImageSource.uri(mMedium.getPath()));
mSubsamplingView.setMaxScale(4f);
mSubsamplingView.setMinimumTileDpi(200);
mSubsamplingView.setOnClickListener(this);
}
return mView;
return view;
}
@Override
@ -55,8 +55,8 @@ public class PhotoFragment extends ViewPagerFragment implements View.OnClickList
}
@Override
public void confChanged() {
public void updateItem() {
mSubsamplingView.setImage(ImageSource.uri(mMedium.getPath()));
}
@Override

View file

@ -100,7 +100,7 @@ public class VideoFragment extends ViewPagerFragment
}
@Override
public void confChanged() {
public void updateItem() {
setVideoSize();
initTimeHolder();
}

View file

@ -13,7 +13,7 @@ public abstract class ViewPagerFragment extends Fragment {
public abstract void systemUiVisibilityChanged(boolean toFullscreen);
public abstract void confChanged();
public abstract void updateItem();
public interface FragmentClickListener {
void fragmentClicked();

View file

@ -75,7 +75,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
}
}
MediaScannerConnection.scanFile(applicationContext, arrayOf(path), null, { s: String, uri: Uri ->
MediaScannerConnection.scanFile(applicationContext, arrayOf(path), null, { path: String, uri: Uri ->
finish()
})
} else {