mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
* Regenerated Parcealable for all possible fields for Contribution & Media
This commit is contained in:
parent
5e3760a899
commit
677191c805
2 changed files with 111 additions and 97 deletions
|
|
@ -29,17 +29,6 @@ import fr.free.nrw.commons.utils.MediaDataExtractorUtil;
|
|||
public class Media implements Parcelable {
|
||||
|
||||
public static final Media EMPTY = new Media("");
|
||||
public static Creator<Media> CREATOR = new Creator<Media>() {
|
||||
@Override
|
||||
public Media createFromParcel(Parcel parcel) {
|
||||
return new Media(parcel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Media[] newArray(int i) {
|
||||
return new Media[0];
|
||||
}
|
||||
};
|
||||
|
||||
// Primary metadata fields
|
||||
protected Uri localUri;
|
||||
|
|
@ -107,27 +96,6 @@ public class Media implements Parcelable {
|
|||
this.descriptions = new HashMap<>();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Media(Parcel in) {
|
||||
localUri = in.readParcelable(Uri.class.getClassLoader());
|
||||
thumbUrl = in.readString();
|
||||
imageUrl = in.readString();
|
||||
filename = in.readString();
|
||||
description = in.readString();
|
||||
dataLength = in.readLong();
|
||||
dateCreated = (Date) in.readSerializable();
|
||||
dateUploaded = (Date) in.readSerializable();
|
||||
creator = in.readString();
|
||||
tags = (HashMap<String, Object>) in.readSerializable();
|
||||
width = in.readInt();
|
||||
height = in.readInt();
|
||||
license = in.readString();
|
||||
if (categories != null) {
|
||||
in.readStringList(categories);
|
||||
}
|
||||
descriptions = in.readHashMap(ClassLoader.getSystemClassLoader());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating Media object from MWQueryPage.
|
||||
* Earlier only basic details were set for the media object but going forward,
|
||||
|
|
@ -499,40 +467,6 @@ public class Media implements Parcelable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method of Parcelable interface
|
||||
* @return zero
|
||||
*/
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a way to transfer information between two or more
|
||||
* activities.
|
||||
* @param parcel Instance of Parcel
|
||||
* @param flags Parcel flag
|
||||
*/
|
||||
@Override
|
||||
public void writeToParcel(Parcel parcel, int flags) {
|
||||
parcel.writeParcelable(localUri, flags);
|
||||
parcel.writeString(thumbUrl);
|
||||
parcel.writeString(imageUrl);
|
||||
parcel.writeString(filename);
|
||||
parcel.writeString(description);
|
||||
parcel.writeLong(dataLength);
|
||||
parcel.writeSerializable(dateCreated);
|
||||
parcel.writeSerializable(dateUploaded);
|
||||
parcel.writeString(creator);
|
||||
parcel.writeSerializable(tags);
|
||||
parcel.writeInt(width);
|
||||
parcel.writeInt(height);
|
||||
parcel.writeString(license);
|
||||
parcel.writeStringList(categories);
|
||||
parcel.writeMap(descriptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set requested deletion to true
|
||||
*/
|
||||
|
|
@ -556,4 +490,68 @@ public class Media implements Parcelable {
|
|||
public void setLicense(String license) {
|
||||
this.license = license;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeParcelable(this.localUri, flags);
|
||||
dest.writeString(this.thumbUrl);
|
||||
dest.writeString(this.imageUrl);
|
||||
dest.writeString(this.filename);
|
||||
dest.writeString(this.description);
|
||||
dest.writeString(this.discussion);
|
||||
dest.writeLong(this.dataLength);
|
||||
dest.writeLong(this.dateCreated != null ? this.dateCreated.getTime() : -1);
|
||||
dest.writeLong(this.dateUploaded != null ? this.dateUploaded.getTime() : -1);
|
||||
dest.writeInt(this.width);
|
||||
dest.writeInt(this.height);
|
||||
dest.writeString(this.license);
|
||||
dest.writeString(this.licenseUrl);
|
||||
dest.writeString(this.creator);
|
||||
dest.writeStringList(this.categories);
|
||||
dest.writeByte(this.requestedDeletion ? (byte) 1 : (byte) 0);
|
||||
dest.writeInt(this.descriptions.size());
|
||||
for (Map.Entry<String, String> entry : this.descriptions.entrySet()) {
|
||||
dest.writeString(entry.getKey());
|
||||
dest.writeString(entry.getValue());
|
||||
}
|
||||
dest.writeSerializable(this.tags);
|
||||
dest.writeParcelable(this.coordinates, flags);
|
||||
}
|
||||
|
||||
protected Media(Parcel in) {
|
||||
this.localUri = in.readParcelable(Uri.class.getClassLoader());
|
||||
this.thumbUrl = in.readString();
|
||||
this.imageUrl = in.readString();
|
||||
this.filename = in.readString();
|
||||
this.description = in.readString();
|
||||
this.discussion = in.readString();
|
||||
this.dataLength = in.readLong();
|
||||
long tmpDateCreated = in.readLong();
|
||||
this.dateCreated = tmpDateCreated == -1 ? null : new Date(tmpDateCreated);
|
||||
long tmpDateUploaded = in.readLong();
|
||||
this.dateUploaded = tmpDateUploaded == -1 ? null : new Date(tmpDateUploaded);
|
||||
this.width = in.readInt();
|
||||
this.height = in.readInt();
|
||||
this.license = in.readString();
|
||||
this.licenseUrl = in.readString();
|
||||
this.creator = in.readString();
|
||||
this.categories = in.createStringArrayList();
|
||||
this.requestedDeletion = in.readByte() != 0;
|
||||
int descriptionsSize = in.readInt();
|
||||
this.descriptions = new HashMap<>(descriptionsSize);
|
||||
for (int i = 0; i < descriptionsSize; i++) {
|
||||
String key = in.readString();
|
||||
String value = in.readString();
|
||||
this.descriptions.put(key, value);
|
||||
}
|
||||
this.tags = (HashMap<String, Object>) in.readSerializable();
|
||||
this.coordinates = in.readParcelable(LatLng.class.getClassLoader());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,18 +31,6 @@ public class Contribution extends Media {
|
|||
//2009-01-09 → 9 January 2009
|
||||
private static final String TEMPLATE_DATA_OTHER_SOURCE = "%s";
|
||||
|
||||
public static Creator<Contribution> CREATOR = new Creator<Contribution>() {
|
||||
@Override
|
||||
public Contribution createFromParcel(Parcel parcel) {
|
||||
return new Contribution(parcel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Contribution[] newArray(int i) {
|
||||
return new Contribution[0];
|
||||
}
|
||||
};
|
||||
|
||||
// No need to be bitwise - they're mutually exclusive
|
||||
public static final int STATE_COMPLETED = -1;
|
||||
public static final int STATE_FAILED = 1;
|
||||
|
|
@ -101,25 +89,6 @@ public class Contribution extends Media {
|
|||
this.state=state;
|
||||
}
|
||||
|
||||
public Contribution(Parcel in) {
|
||||
super(in);
|
||||
contentUri = in.readParcelable(Uri.class.getClassLoader());
|
||||
source = in.readString();
|
||||
state = in.readInt();
|
||||
transferred = in.readLong();
|
||||
isMultiple = in.readInt() == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel parcel, int flags) {
|
||||
super.writeToParcel(parcel, flags);
|
||||
parcel.writeParcelable(contentUri, flags);
|
||||
parcel.writeString(source);
|
||||
parcel.writeInt(state);
|
||||
parcel.writeLong(transferred);
|
||||
parcel.writeInt(isMultiple ? 1 : 0);
|
||||
}
|
||||
|
||||
public String getDateCreatedSource() {
|
||||
return dateCreatedSource;
|
||||
}
|
||||
|
|
@ -287,4 +256,51 @@ public class Contribution extends Media {
|
|||
public Uri getContentProviderUri() {
|
||||
return contentProviderUri;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeParcelable(this.contentUri, flags);
|
||||
dest.writeString(this.source);
|
||||
dest.writeString(this.editSummary);
|
||||
dest.writeInt(this.state);
|
||||
dest.writeLong(this.transferred);
|
||||
dest.writeString(this.decimalCoords);
|
||||
dest.writeByte(this.isMultiple ? (byte) 1 : (byte) 0);
|
||||
dest.writeString(this.wikiDataEntityId);
|
||||
dest.writeParcelable(this.contentProviderUri, flags);
|
||||
dest.writeString(this.dateCreatedSource);
|
||||
}
|
||||
|
||||
protected Contribution(Parcel in) {
|
||||
super(in);
|
||||
this.contentUri = in.readParcelable(Uri.class.getClassLoader());
|
||||
this.source = in.readString();
|
||||
this.editSummary = in.readString();
|
||||
this.state = in.readInt();
|
||||
this.transferred = in.readLong();
|
||||
this.decimalCoords = in.readString();
|
||||
this.isMultiple = in.readByte() != 0;
|
||||
this.wikiDataEntityId = in.readString();
|
||||
this.contentProviderUri = in.readParcelable(Uri.class.getClassLoader());
|
||||
this.dateCreatedSource = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<Contribution> CREATOR = new Creator<Contribution>() {
|
||||
@Override
|
||||
public Contribution createFromParcel(Parcel source) {
|
||||
return new Contribution(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Contribution[] newArray(int size) {
|
||||
return new Contribution[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue