mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Remove unused code in ApacheHttpClientMediaWikiApi (#2722)
This commit is contained in:
parent
052d09e08a
commit
8a1a92d44d
1 changed files with 0 additions and 44 deletions
|
|
@ -771,50 +771,6 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
||||||
return CategoryImageUtils.getMediaList(childNodes);
|
return CategoryImageUtils.getMediaList(childNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method takes search keyword as input and returns a list of Media objects filtered using search query
|
|
||||||
* It uses the generator query API to get the images searched using a query, 25 at a time.
|
|
||||||
* @param query keyword to search images on commons
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
// @Override
|
|
||||||
@NonNull
|
|
||||||
public List<Media> searchImages(String query, int offset) {
|
|
||||||
List<CustomApiResult> imageNodes = null;
|
|
||||||
List<CustomApiResult> authorNodes = null;
|
|
||||||
CustomApiResult customApiResult;
|
|
||||||
try {
|
|
||||||
customApiResult= api.action("query")
|
|
||||||
.param("format", "xml")
|
|
||||||
.param("generator", "search")
|
|
||||||
.param("gsrwhat", "text")
|
|
||||||
.param("gsrnamespace", "6")
|
|
||||||
.param("gsrlimit", "25")
|
|
||||||
.param("gsroffset",offset)
|
|
||||||
.param("gsrsearch", query)
|
|
||||||
.param("prop", "imageinfo")
|
|
||||||
.get();
|
|
||||||
imageNodes= customApiResult.getNodes("/api/query/pages/page/@title");
|
|
||||||
authorNodes= customApiResult.getNodes("/api/query/pages/page/imageinfo/ii/@user");
|
|
||||||
} catch (IOException e) {
|
|
||||||
Timber.e(e, "Failed to obtain searchImages");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (imageNodes == null) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Media> images = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i=0; i< imageNodes.size();i++){
|
|
||||||
String imgName = imageNodes.get(i).getDocument().getTextContent();
|
|
||||||
Media media = new Media(imgName);
|
|
||||||
media.setCreator(authorNodes.get(i).getDocument().getTextContent());
|
|
||||||
images.add(media);
|
|
||||||
}
|
|
||||||
return images;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method takes search keyword as input and returns a list of categories objects filtered using search query
|
* This method takes search keyword as input and returns a list of categories objects filtered using search query
|
||||||
* It uses the generator query API to get the categories searched using a query, 25 at a time.
|
* It uses the generator query API to get the categories searched using a query, 25 at a time.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue