18
18
19
19
import javax .inject .Inject ;
20
20
21
- import androidx .appcompat .app .AlertDialog ;
22
21
import androidx .appcompat .widget .Toolbar ;
23
22
import androidx .drawerlayout .widget .DrawerLayout ;
24
23
import butterknife .BindView ;
25
24
import butterknife .ButterKnife ;
26
- import butterknife .OnClick ;
27
25
import fr .free .nrw .commons .Media ;
28
26
import fr .free .nrw .commons .R ;
29
- import fr .free .nrw .commons .Utils ;
30
- import fr .free .nrw .commons .achievements .AchievementsActivity ;
31
27
import fr .free .nrw .commons .auth .AuthenticatedActivity ;
32
28
import fr .free .nrw .commons .delete .DeleteHelper ;
33
29
import fr .free .nrw .commons .mwapi .MediaWikiApi ;
34
30
import fr .free .nrw .commons .utils .DialogUtil ;
35
- import fr .free .nrw .commons .utils .MediaDataExtractorUtil ;
36
31
import fr .free .nrw .commons .utils .ViewUtil ;
37
32
import io .reactivex .android .schedulers .AndroidSchedulers ;
38
33
import io .reactivex .disposables .CompositeDisposable ;
39
- import io .reactivex .disposables .Disposable ;
40
34
import io .reactivex .schedulers .Schedulers ;
41
- import timber .log .Timber ;
42
35
43
36
public class ReviewActivity extends AuthenticatedActivity {
44
37
@@ -125,45 +118,34 @@ public boolean runRandomizer() {
125
118
progressBar .setVisibility (View .VISIBLE );
126
119
reviewPager .setCurrentItem (0 );
127
120
compositeDisposable .add (reviewHelper .getRandomMedia ()
128
- .map (Media ::getFilename )
129
121
.subscribeOn (Schedulers .io ())
130
122
.observeOn (AndroidSchedulers .mainThread ())
131
123
.subscribe (this ::updateImage ));
132
124
return true ;
133
125
}
134
126
135
127
@ SuppressLint ("CheckResult" )
136
- private void updateImage (String fileName ) {
128
+ private void updateImage (Media media ) {
129
+ String fileName = media .getFilename ();
137
130
if (fileName .length () == 0 ) {
138
131
ViewUtil .showShortSnackbar (drawerLayout , R .string .error_review );
139
132
return ;
140
133
}
141
- simpleDraweeView .setImageURI (Utils .makeThumbBaseUrl (fileName ));
134
+
135
+ simpleDraweeView .setImageURI (media .getImageUrl ());
136
+
142
137
reviewController .onImageRefreshed (fileName ); //file name is updated
143
- compositeDisposable .add (reviewHelper .getFirstRevisionOfFile ("File:" + fileName )
138
+ compositeDisposable .add (reviewHelper .getFirstRevisionOfFile (fileName )
144
139
.subscribeOn (Schedulers .io ())
145
140
.observeOn (AndroidSchedulers .mainThread ())
146
141
.subscribe (revision -> {
147
142
reviewController .firstRevision = revision ;
148
143
reviewPagerAdapter .updateFileInformation (fileName );
149
- (( TextView ) imageCaption ) .setText (fileName + " is uploaded by: " + revision .getUser ());
144
+ imageCaption .setText (fileName + " is uploaded by: " + revision .getUser ());
150
145
progressBar .setVisibility (View .GONE );
151
146
}));
152
147
reviewPager .setCurrentItem (0 );
153
-
154
- Disposable disposable = mwApi .fetchMediaByFilename ("File:" + fileName )
155
- .subscribeOn (Schedulers .io ())
156
- .observeOn (AndroidSchedulers .mainThread ())
157
- .subscribe (mediaResult -> {
158
- ArrayList <String > categories = MediaDataExtractorUtil .extractCategories (mediaResult .getWikiSource ());
159
- updateCategories (categories );
160
- }, this ::categoryFetchError );
161
- compositeDisposable .add (disposable );
162
- }
163
-
164
- private void categoryFetchError (Throwable throwable ) {
165
- Timber .e (throwable , "Error fetching categories" );
166
- ViewUtil .showShortSnackbar (drawerLayout , R .string .error_review_categories );
148
+ updateCategories (media .getCategories ());
167
149
}
168
150
169
151
private void updateCategories (ArrayList <String > categories ) {
@@ -180,6 +162,12 @@ public void swipeToNext() {
180
162
}
181
163
}
182
164
165
+ @ Override
166
+ public void onDestroy () {
167
+ super .onDestroy ();
168
+ compositeDisposable .clear ();
169
+ }
170
+
183
171
public void showSkipImageInfo (){
184
172
DialogUtil .showAlertDialog (ReviewActivity .this ,
185
173
getString (R .string .skip_image ),
0 commit comments