From f4655761bda6be7ea86d8348e3197c45afe6e5fd Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 6 Oct 2016 20:05:44 +0200 Subject: [PATCH] update the given medium after editing it --- .../activities/PhotoVideoActivity.java | 2 +- .../gallery/activities/ViewPagerActivity.java | 5 ++-- .../gallery/adapters/MyPagerAdapter.java | 4 +-- .../gallery/fragments/PhotoFragment.java | 26 +++++++++---------- .../gallery/fragments/VideoFragment.java | 2 +- .../gallery/fragments/ViewPagerFragment.java | 2 +- .../gallery/activities/EditActivity.kt | 2 +- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java index bb4414322..b83179c28 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java @@ -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 diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java index f7ffc5077..d8e60af7f 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java @@ -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); } diff --git a/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java b/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java index 63cd7214b..b448abb2a 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java +++ b/app/src/main/java/com/simplemobiletools/gallery/adapters/MyPagerAdapter.java @@ -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(); } } } diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java index 629f76b77..7b7d48078 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java @@ -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 diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java index a9e31de63..ab165eb45 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java @@ -100,7 +100,7 @@ public class VideoFragment extends ViewPagerFragment } @Override - public void confChanged() { + public void updateItem() { setVideoSize(); initTimeHolder(); } diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/ViewPagerFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/ViewPagerFragment.java index 31062b032..0e46e301f 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/ViewPagerFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/ViewPagerFragment.java @@ -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(); diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index a5d298cbd..e265937cb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -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 {