mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 22:03:55 +01:00
* In media search results, rotating screen triggers crash fixed #1753 * Updated API to get Author name too * Crash fixed due to notifyDataSetChange * search API duplicate images fixed
This commit is contained in:
parent
a5d4e8f739
commit
bf50e749ec
9 changed files with 154 additions and 23 deletions
|
|
@ -736,17 +736,21 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
@NonNull
|
||||
public List<Media> searchImages(String query, int offset) {
|
||||
List<CustomApiResult> imageNodes = null;
|
||||
List<CustomApiResult> authorNodes = null;
|
||||
CustomApiResult customApiResult;
|
||||
try {
|
||||
imageNodes = api.action("query")
|
||||
customApiResult= api.action("query")
|
||||
.param("format", "xml")
|
||||
.param("list", "search")
|
||||
.param("srwhat", "text")
|
||||
.param("srnamespace", "6")
|
||||
.param("srlimit", "25")
|
||||
.param("sroffset",offset)
|
||||
.param("srsearch", query)
|
||||
.get()
|
||||
.getNodes("/api/query/search/p/@title");
|
||||
.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("Failed to obtain searchImages", e);
|
||||
}
|
||||
|
|
@ -756,11 +760,13 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
}
|
||||
|
||||
List<Media> images = new ArrayList<>();
|
||||
for (CustomApiResult imageNode : imageNodes) {
|
||||
String imgName = imageNode.getDocument().getTextContent();
|
||||
images.add(new Media(imgName));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue