Wmhack2018 (#1534)

* tiny fixes

* Load pictures into activities
This commit is contained in:
Elliott Eggleston 2018-05-19 12:18:59 -05:00 committed by maskara
parent 7dde464d9d
commit e5db79e652
5 changed files with 16 additions and 11 deletions

View file

@ -1130,6 +1130,8 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
if (imageTitle != null) {
boolean deletionStatus = pageExists("Commons:Deletion_requests/" + imageTitle);
if (!deletionStatus) {
// strip File: prefix
imageTitle = imageTitle.replace("File:", "");
media = new Media(imageTitle);
//media = fetchMediaByFilename(fileName);
}

View file

@ -16,6 +16,7 @@ import android.view.MenuItem;
import android.view.View;
import java.io.IOException;
import java.util.List;
import javax.inject.Inject;
@ -91,10 +92,9 @@ public class ReviewActivity extends AuthenticatedActivity {
if (id == R.id.action_review_randomizer) {
Observable.fromCallable(() -> {
Media result = null;
try {
Media result = mwApi.getRecentRandomImage();
reviewController.onImageRefreshed(result.getFilename()); //file name is updated
reviewPagerAdapter.getItem(0); //new fragment with this new filename created
result = mwApi.getRecentRandomImage();
//String thumBaseUrl = Utils.makeThumbBaseUrl(result.getFilename());
//reviewPagerAdapter.currentThumbBasedUrl = thumBaseUrl;
@ -104,17 +104,22 @@ public class ReviewActivity extends AuthenticatedActivity {
} catch (IOException e) {
Log.d("review", e.toString());
}
return "Booga!";
return result;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe();
.subscribe(this::updateImage);
return true;
}
return super.onOptionsItemSelected(item);
}
private void updateImage(Media result) {
reviewController.onImageRefreshed(result.getFilename()); //file name is updated
reviewPagerAdapter.getItem(0); //new fragment with this new filename created
}
/**
@ -130,9 +135,8 @@ public class ReviewActivity extends AuthenticatedActivity {
* Consumers should be simply using this method to use this activity.
* @param context
* @param title Page title
* @param categoryName Name of the category for displaying its images
*/
public static void startYourself(Context context, String title, String categoryName) {
public static void startYourself(Context context, String title) {
Intent reviewActivity = new Intent(context, ReviewActivity.class);
context.startActivity(reviewActivity);
}
@ -143,7 +147,7 @@ public class ReviewActivity extends AuthenticatedActivity {
void onSurveyFinished();
void onImproperImageReported();
void onLicenceViolationReported();
void oWrongCategoryReported();
void onWrongCategoryReported();
void onThankSent();
}
}

View file

@ -33,7 +33,7 @@ public class ReviewController implements ReviewActivity.ReviewCallback {
}
@Override
public void oWrongCategoryReported() {
public void onWrongCategoryReported() {
}

View file

@ -231,7 +231,7 @@ public abstract class NavigationBaseActivity extends BaseActivity
case R.id.action_review:
drawerLayout.closeDrawer(navigationView);
ReviewActivity.startYourself(this, getString(R.string.title_activity_featured_images), FEATURED_IMAGES_CATEGORY);
ReviewActivity.startYourself(this, getString(R.string.title_activity_review));
return true;
default:
Timber.e("Unknown option [%s] selected from the navigation menu", itemId);

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">