Skip to content

Commit c97764a

Browse files
neslihanturanmaskaravivek
authored andcommitted
Save media on orientation change so that same image will be reviewed (commons-app#2929)
1 parent b17c9a7 commit c97764a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

app/src/main/java/fr/free/nrw/commons/review/ReviewActivity.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ public class ReviewActivity extends AuthenticatedActivity {
6161
@Inject
6262
DeleteHelper deleteHelper;
6363

64+
final String SAVED_MEDIA = "saved_media";
65+
private Media media;
66+
67+
@Override
68+
protected void onSaveInstanceState(Bundle outState) {
69+
super.onSaveInstanceState(outState);
70+
if (media != null) {
71+
outState.putParcelable(SAVED_MEDIA, media);
72+
}
73+
}
74+
6475
/**
6576
* Consumers should be simply using this method to use this activity.
6677
*
@@ -102,7 +113,11 @@ protected void onCreate(Bundle savedInstanceState) {
102113
pagerIndicator.setViewPager(reviewPager);
103114
progressBar.setVisibility(View.VISIBLE);
104115

105-
runRandomizer(); //Run randomizer whenever everything is ready so that a first random image will be added
116+
if (savedInstanceState != null) {
117+
updateImage(savedInstanceState.getParcelable(SAVED_MEDIA)); // Use existing media if we have one
118+
} else {
119+
runRandomizer(); //Run randomizer whenever everything is ready so that a first random image will be added
120+
}
106121

107122
btnSkipImage.setOnClickListener(view -> runRandomizer());
108123

@@ -130,6 +145,7 @@ public boolean runRandomizer() {
130145

131146
@SuppressLint("CheckResult")
132147
private void updateImage(Media media) {
148+
this.media = media;
133149
String fileName = media.getFilename();
134150
if (fileName.length() == 0) {
135151
ViewUtil.showShortSnackbar(drawerLayout, R.string.error_review);

0 commit comments

Comments
 (0)