update the given medium after editing it
This commit is contained in:
parent
a5def53373
commit
f4655761bd
7 changed files with 22 additions and 21 deletions
|
@ -58,7 +58,7 @@ public class PhotoVideoActivity extends SimpleActivity implements ViewPagerFragm
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
mFragment.confChanged();
|
mFragment.updateItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -174,7 +174,7 @@ public class ViewPagerActivity extends SimpleActivity
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
final MyPagerAdapter adapter = (MyPagerAdapter) mPager.getAdapter();
|
final MyPagerAdapter adapter = (MyPagerAdapter) mPager.getAdapter();
|
||||||
adapter.confChanged(mPos);
|
adapter.updateItems(mPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openEditor() {
|
private void openEditor() {
|
||||||
|
@ -187,7 +187,8 @@ public class ViewPagerActivity extends SimpleActivity
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (requestCode == EDIT_IMAGE) {
|
if (requestCode == EDIT_IMAGE) {
|
||||||
if (resultCode == RESULT_OK && data != null) {
|
if (resultCode == RESULT_OK && data != null) {
|
||||||
|
final MyPagerAdapter adapter = (MyPagerAdapter) mPager.getAdapter();
|
||||||
|
adapter.updateItems(mPos);
|
||||||
} else {
|
} else {
|
||||||
Utils.showToast(getApplicationContext(), R.string.image_editing_failed);
|
Utils.showToast(getApplicationContext(), R.string.image_editing_failed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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++) {
|
for (int i = -1; i <= 1; i++) {
|
||||||
final ViewPagerFragment fragment = mFragments.get(pos + i);
|
final ViewPagerFragment fragment = mFragments.get(pos + i);
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
fragment.confChanged();
|
fragment.updateItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,33 +15,33 @@ import com.simplemobiletools.gallery.R;
|
||||||
import com.simplemobiletools.gallery.models.Medium;
|
import com.simplemobiletools.gallery.models.Medium;
|
||||||
|
|
||||||
public class PhotoFragment extends ViewPagerFragment implements View.OnClickListener {
|
public class PhotoFragment extends ViewPagerFragment implements View.OnClickListener {
|
||||||
private View mView;
|
|
||||||
private SubsamplingScaleImageView mSubsamplingView;
|
private SubsamplingScaleImageView mSubsamplingView;
|
||||||
|
private Medium mMedium;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
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);
|
mMedium = (Medium) getArguments().getSerializable(Constants.MEDIUM);
|
||||||
if (medium == null)
|
if (mMedium == null)
|
||||||
return mView;
|
return view;
|
||||||
|
|
||||||
mSubsamplingView = (SubsamplingScaleImageView) mView.findViewById(R.id.photo_view);
|
mSubsamplingView = (SubsamplingScaleImageView) view.findViewById(R.id.photo_view);
|
||||||
if (medium.isGif()) {
|
if (mMedium.isGif()) {
|
||||||
mSubsamplingView.setVisibility(View.GONE);
|
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);
|
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);
|
imageView.setOnClickListener(this);
|
||||||
} else {
|
} else {
|
||||||
mSubsamplingView.setOrientation(SubsamplingScaleImageView.ORIENTATION_USE_EXIF);
|
mSubsamplingView.setOrientation(SubsamplingScaleImageView.ORIENTATION_USE_EXIF);
|
||||||
mSubsamplingView.setImage(ImageSource.uri(medium.getPath()));
|
mSubsamplingView.setImage(ImageSource.uri(mMedium.getPath()));
|
||||||
mSubsamplingView.setMaxScale(4f);
|
mSubsamplingView.setMaxScale(4f);
|
||||||
mSubsamplingView.setMinimumTileDpi(200);
|
mSubsamplingView.setMinimumTileDpi(200);
|
||||||
mSubsamplingView.setOnClickListener(this);
|
mSubsamplingView.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mView;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,8 +55,8 @@ public class PhotoFragment extends ViewPagerFragment implements View.OnClickList
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void confChanged() {
|
public void updateItem() {
|
||||||
|
mSubsamplingView.setImage(ImageSource.uri(mMedium.getPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class VideoFragment extends ViewPagerFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void confChanged() {
|
public void updateItem() {
|
||||||
setVideoSize();
|
setVideoSize();
|
||||||
initTimeHolder();
|
initTimeHolder();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public abstract class ViewPagerFragment extends Fragment {
|
||||||
|
|
||||||
public abstract void systemUiVisibilityChanged(boolean toFullscreen);
|
public abstract void systemUiVisibilityChanged(boolean toFullscreen);
|
||||||
|
|
||||||
public abstract void confChanged();
|
public abstract void updateItem();
|
||||||
|
|
||||||
public interface FragmentClickListener {
|
public interface FragmentClickListener {
|
||||||
void fragmentClicked();
|
void fragmentClicked();
|
||||||
|
|
|
@ -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()
|
finish()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue