Fix ExistingFileAsync call in ShareActivity

This commit is contained in:
misaochan 2016-12-14 16:46:10 +13:00
parent c34b8300c4
commit 4bcc9d7ddd
2 changed files with 2 additions and 10 deletions

View file

@ -14,6 +14,7 @@ import fr.free.nrw.commons.CommonsApplication;
/** /**
* Sends asynchronous queries to the Commons MediaWiki API to check that file doesn't already exist * Sends asynchronous queries to the Commons MediaWiki API to check that file doesn't already exist
* Returns true if file exists, false if it doesn't
*/ */
public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> { public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
@ -46,11 +47,9 @@ public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
Log.d(TAG, "Searching Commons API for existing file: " + result.toString()); Log.d(TAG, "Searching Commons API for existing file: " + result.toString());
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, "IO Exception: ", e); Log.e(TAG, "IO Exception: ", e);
//Return empty arraylist
return false; return false;
} }
//ArrayList<ApiResult> categoryNodes = result.getNodes("/api/query/search/p/@title");
ArrayList<ApiResult> resultNodes = result.getNodes("/api/query/allimages/"); ArrayList<ApiResult> resultNodes = result.getNodes("/api/query/allimages/");
boolean fileExists = !resultNodes.isEmpty(); boolean fileExists = !resultNodes.isEmpty();
Log.d(TAG, "File already exists in Commons:" + fileExists); Log.d(TAG, "File already exists in Commons:" + fileExists);

View file

@ -251,14 +251,7 @@ public class ShareActivity
//FIXME: Replace hardcoded string with call to Commons API instead (use TitleCategories.java as template) //FIXME: Replace hardcoded string with call to Commons API instead (use TitleCategories.java as template)
ExistingFileAsync fileAsyncTask = new ExistingFileAsync(fileSHA1); ExistingFileAsync fileAsyncTask = new ExistingFileAsync(fileSHA1);
fileAsyncTask.execute(url1, url2, url3); fileAsyncTask.execute();
String debugSHA1 = "801957214aba50cb63bb6eb1b0effa50188900ba";
boolean fileSHA1Found = fileSHA1.equals(debugSHA1);
Log.d(TAG, "File found in Commons: " + fileSHA1Found);
} catch (IOException e) { } catch (IOException e) {
Log.d(TAG, "IO Exception: ", e); Log.d(TAG, "IO Exception: ", e);