mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Change result type to Boolean
This commit is contained in:
parent
9b2b3c7861
commit
a2b3be5959
1 changed files with 5 additions and 11 deletions
|
|
@ -15,7 +15,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
|
||||||
*/
|
*/
|
||||||
public class ExistingFileAsync extends AsyncTask<Void, Void, ArrayList<String>> {
|
public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
|
||||||
|
|
||||||
private static final String TAG = fr.free.nrw.commons.upload.ExistingFileAsync.class.getName();
|
private static final String TAG = fr.free.nrw.commons.upload.ExistingFileAsync.class.getName();
|
||||||
private String fileSHA1;
|
private String fileSHA1;
|
||||||
|
|
@ -31,25 +31,19 @@ public class ExistingFileAsync extends AsyncTask<Void, Void, ArrayList<String>>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ArrayList<String> doInBackground(Void... voids) {
|
protected Boolean doInBackground(Void... voids) {
|
||||||
|
|
||||||
MWApi api = CommonsApplication.createMWApi();
|
MWApi api = CommonsApplication.createMWApi();
|
||||||
ApiResult result;
|
ApiResult result;
|
||||||
|
|
||||||
ArrayList<String> items = new ArrayList<>();
|
|
||||||
|
|
||||||
// https://commons.wikimedia.org/w/api.php?action=query&list=allimages&aisha1=801957214aba50cb63bb6eb1b0effa50188900ba
|
// https://commons.wikimedia.org/w/api.php?action=query&list=allimages&aisha1=801957214aba50cb63bb6eb1b0effa50188900ba
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = api.action("query")
|
result = api.action("query")
|
||||||
.param("format", "xml")
|
.param("format", "xml")
|
||||||
.param("list", "search")
|
.param("list", "allimages")
|
||||||
.param("srwhat", "text")
|
.param("aisha1", fileSHA1)
|
||||||
.param("srnamespace", "14")
|
|
||||||
.param("srlimit", SEARCH_CATS_LIMIT)
|
|
||||||
.param("srsearch", title)
|
|
||||||
.get();
|
.get();
|
||||||
Log.d(TAG, "Searching for cats for title: " + 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 empty arraylist
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue