Skip to content

Commit e5db79e

Browse files
ejeggmaskara
authored and
maskara
committed
Wmhack2018 (commons-app#1534)
* tiny fixes * Load pictures into activities
1 parent 7dde464 commit e5db79e

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

app/src/main/java/fr/free/nrw/commons/mwapi/ApacheHttpClientMediaWikiApi.java

+2
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,8 @@ public Media getRecentRandomImage() throws IOException {
11301130
if (imageTitle != null) {
11311131
boolean deletionStatus = pageExists("Commons:Deletion_requests/" + imageTitle);
11321132
if (!deletionStatus) {
1133+
// strip File: prefix
1134+
imageTitle = imageTitle.replace("File:", "");
11331135
media = new Media(imageTitle);
11341136
//media = fetchMediaByFilename(fileName);
11351137
}

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

+12-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import android.view.View;
1717

1818
import java.io.IOException;
19+
import java.util.List;
1920

2021
import javax.inject.Inject;
2122

@@ -91,10 +92,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
9192

9293
if (id == R.id.action_review_randomizer) {
9394
Observable.fromCallable(() -> {
95+
Media result = null;
9496
try {
95-
Media result = mwApi.getRecentRandomImage();
96-
reviewController.onImageRefreshed(result.getFilename()); //file name is updated
97-
reviewPagerAdapter.getItem(0); //new fragment with this new filename created
97+
result = mwApi.getRecentRandomImage();
9898

9999
//String thumBaseUrl = Utils.makeThumbBaseUrl(result.getFilename());
100100
//reviewPagerAdapter.currentThumbBasedUrl = thumBaseUrl;
@@ -104,17 +104,22 @@ public boolean onOptionsItemSelected(MenuItem item) {
104104
} catch (IOException e) {
105105
Log.d("review", e.toString());
106106
}
107-
return "Booga!";
107+
return result;
108108
})
109109
.subscribeOn(Schedulers.io())
110110
.observeOn(AndroidSchedulers.mainThread())
111-
.subscribe();
111+
.subscribe(this::updateImage);
112112
return true;
113113
}
114114

115115
return super.onOptionsItemSelected(item);
116116
}
117117

118+
private void updateImage(Media result) {
119+
120+
reviewController.onImageRefreshed(result.getFilename()); //file name is updated
121+
reviewPagerAdapter.getItem(0); //new fragment with this new filename created
122+
}
118123

119124

120125
/**
@@ -130,9 +135,8 @@ public void onDestroy() {
130135
* Consumers should be simply using this method to use this activity.
131136
* @param context
132137
* @param title Page title
133-
* @param categoryName Name of the category for displaying its images
134138
*/
135-
public static void startYourself(Context context, String title, String categoryName) {
139+
public static void startYourself(Context context, String title) {
136140
Intent reviewActivity = new Intent(context, ReviewActivity.class);
137141
context.startActivity(reviewActivity);
138142
}
@@ -143,7 +147,7 @@ interface ReviewCallback {
143147
void onSurveyFinished();
144148
void onImproperImageReported();
145149
void onLicenceViolationReported();
146-
void oWrongCategoryReported();
150+
void onWrongCategoryReported();
147151
void onThankSent();
148152
}
149153
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void onLicenceViolationReported() {
3333
}
3434

3535
@Override
36-
public void oWrongCategoryReported() {
36+
public void onWrongCategoryReported() {
3737

3838
}
3939

app/src/main/java/fr/free/nrw/commons/theme/NavigationBaseActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
231231

232232
case R.id.action_review:
233233
drawerLayout.closeDrawer(navigationView);
234-
ReviewActivity.startYourself(this, getString(R.string.title_activity_featured_images), FEATURED_IMAGES_CATEGORY);
234+
ReviewActivity.startYourself(this, getString(R.string.title_activity_review));
235235
return true;
236236
default:
237237
Timber.e("Unknown option [%s] selected from the navigation menu", itemId);

app/src/main/res/layout/activity_review.xml

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
xmlns:tools="http://schemas.android.com/tools"
54
android:id="@+id/drawer_layout"
65
android:layout_width="match_parent"
76
android:layout_height="match_parent">

0 commit comments

Comments
 (0)