mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Save media on orientation change so that same image will be reviewed (#2929)
This commit is contained in:
parent
b17c9a75a7
commit
c97764a01d
1 changed files with 17 additions and 1 deletions
|
|
@ -61,6 +61,17 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
@Inject
|
||||
DeleteHelper deleteHelper;
|
||||
|
||||
final String SAVED_MEDIA = "saved_media";
|
||||
private Media media;
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
if (media != null) {
|
||||
outState.putParcelable(SAVED_MEDIA, media);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumers should be simply using this method to use this activity.
|
||||
*
|
||||
|
|
@ -102,7 +113,11 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
pagerIndicator.setViewPager(reviewPager);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
runRandomizer(); //Run randomizer whenever everything is ready so that a first random image will be added
|
||||
if (savedInstanceState != null) {
|
||||
updateImage(savedInstanceState.getParcelable(SAVED_MEDIA)); // Use existing media if we have one
|
||||
} else {
|
||||
runRandomizer(); //Run randomizer whenever everything is ready so that a first random image will be added
|
||||
}
|
||||
|
||||
btnSkipImage.setOnClickListener(view -> runRandomizer());
|
||||
|
||||
|
|
@ -130,6 +145,7 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
|
||||
@SuppressLint("CheckResult")
|
||||
private void updateImage(Media media) {
|
||||
this.media = media;
|
||||
String fileName = media.getFilename();
|
||||
if (fileName.length() == 0) {
|
||||
ViewUtil.showShortSnackbar(drawerLayout, R.string.error_review);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue