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) { if (imageTitle != null) {
boolean deletionStatus = pageExists("Commons:Deletion_requests/" + imageTitle); boolean deletionStatus = pageExists("Commons:Deletion_requests/" + imageTitle);
if (!deletionStatus) { if (!deletionStatus) {
// strip File: prefix
imageTitle = imageTitle.replace("File:", "");
media = new Media(imageTitle); media = new Media(imageTitle);
//media = fetchMediaByFilename(fileName); //media = fetchMediaByFilename(fileName);
} }

View file

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

View file

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

View file

@ -231,7 +231,7 @@ public abstract class NavigationBaseActivity extends BaseActivity
case R.id.action_review: case R.id.action_review:
drawerLayout.closeDrawer(navigationView); 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; return true;
default: default:
Timber.e("Unknown option [%s] selected from the navigation menu", itemId); Timber.e("Unknown option [%s] selected from the navigation menu", itemId);

View file

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