mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Use JSON SPARQL query for fetching nearby places (#2398)
* Use JSON response for nearby places * Move okhttp calls to a different class * wip * Fetch picture of the day using JSON API * Search images using JSON APIs * tests * Fix injection based on code review comments
This commit is contained in:
parent
323527b3be
commit
f12837650a
44 changed files with 1472 additions and 418 deletions
|
|
@ -14,6 +14,10 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
import fr.free.nrw.commons.media.model.ImageInfo;
|
||||
import fr.free.nrw.commons.media.model.MwQueryPage;
|
||||
import fr.free.nrw.commons.utils.DateUtils;
|
||||
import fr.free.nrw.commons.utils.StringUtils;
|
||||
|
||||
public class Media implements Parcelable {
|
||||
|
||||
|
|
@ -428,4 +432,24 @@ public class Media implements Parcelable {
|
|||
public boolean getRequestedDeletion(){
|
||||
return requestedDeletion;
|
||||
}
|
||||
|
||||
public static Media from(MwQueryPage page) {
|
||||
ImageInfo imageInfo = page.imageInfo();
|
||||
if(imageInfo == null) {
|
||||
return null;
|
||||
}
|
||||
Media media = new Media(null,
|
||||
imageInfo.getOriginalUrl(),
|
||||
page.title(),
|
||||
imageInfo.getMetadata().imageDescription().value(),
|
||||
0,
|
||||
DateUtils.getDateFromString(imageInfo.getMetadata().getDateTimeOriginal().value()),
|
||||
DateUtils.getDateFromString(imageInfo.getMetadata().getDateTime().value()),
|
||||
StringUtils.getParsedStringFromHtml(imageInfo.getMetadata().getArtist().value())
|
||||
);
|
||||
|
||||
media.setLicense(imageInfo.getMetadata().getLicenseShortName().value());
|
||||
|
||||
return media;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue