3232public class Media implements Parcelable {
3333
3434 public static final Media EMPTY = new Media ("" );
35- public static Creator <Media > CREATOR = new Creator <Media >() {
36- @ Override
37- public Media createFromParcel (Parcel parcel ) {
38- return new Media (parcel );
39- }
40-
41- @ Override
42- public Media [] newArray (int i ) {
43- return new Media [0 ];
44- }
45- };
4635
4736 // Primary metadata fields
4837 @ Nullable
@@ -111,27 +100,6 @@ public Media(Uri localUri, String imageUrl, String filename, String description,
111100 this .descriptions = new HashMap <>();
112101 }
113102
114- @ SuppressWarnings ("unchecked" )
115- public Media (Parcel in ) {
116- localUri = in .readParcelable (Uri .class .getClassLoader ());
117- thumbUrl = in .readString ();
118- imageUrl = in .readString ();
119- filename = in .readString ();
120- description = in .readString ();
121- dataLength = in .readLong ();
122- dateCreated = (Date ) in .readSerializable ();
123- dateUploaded = (Date ) in .readSerializable ();
124- creator = in .readString ();
125- tags = (HashMap <String , String >) in .readSerializable ();
126- width = in .readInt ();
127- height = in .readInt ();
128- license = in .readString ();
129- if (categories != null ) {
130- in .readStringList (categories );
131- }
132- descriptions = in .readHashMap (ClassLoader .getSystemClassLoader ());
133- }
134-
135103 /**
136104 * Creating Media object from MWQueryPage.
137105 * Earlier only basic details were set for the media object but going forward,
@@ -503,40 +471,6 @@ public String getDescription(String preferredLanguage) {
503471 }
504472 }
505473
506- /**
507- * Method of Parcelable interface
508- * @return zero
509- */
510- @ Override
511- public int describeContents () {
512- return 0 ;
513- }
514-
515- /**
516- * Creates a way to transfer information between two or more
517- * activities.
518- * @param parcel Instance of Parcel
519- * @param flags Parcel flag
520- */
521- @ Override
522- public void writeToParcel (Parcel parcel , int flags ) {
523- parcel .writeParcelable (localUri , flags );
524- parcel .writeString (thumbUrl );
525- parcel .writeString (imageUrl );
526- parcel .writeString (filename );
527- parcel .writeString (description );
528- parcel .writeLong (dataLength );
529- parcel .writeSerializable (dateCreated );
530- parcel .writeSerializable (dateUploaded );
531- parcel .writeString (creator );
532- parcel .writeSerializable (tags );
533- parcel .writeInt (width );
534- parcel .writeInt (height );
535- parcel .writeString (license );
536- parcel .writeStringList (categories );
537- parcel .writeMap (descriptions );
538- }
539-
540474 /**
541475 * Set requested deletion to true
542476 */
@@ -560,4 +494,75 @@ public boolean getRequestedDeletion(){
560494 public void setLicense (String license ) {
561495 this .license = license ;
562496 }
497+
498+
499+ @ Override
500+ public int describeContents () {
501+ return 0 ;
502+ }
503+
504+ /**
505+ * Creates a way to transfer information between two or more
506+ * activities.
507+ * @param dest Instance of Parcel
508+ * @param flags Parcel flag
509+ */
510+ @ Override
511+ public void writeToParcel (Parcel dest , int flags ) {
512+ dest .writeParcelable (this .localUri , flags );
513+ dest .writeString (this .thumbUrl );
514+ dest .writeString (this .imageUrl );
515+ dest .writeString (this .filename );
516+ dest .writeString (this .description );
517+ dest .writeString (this .discussion );
518+ dest .writeLong (this .dataLength );
519+ dest .writeLong (this .dateCreated != null ? this .dateCreated .getTime () : -1 );
520+ dest .writeLong (this .dateUploaded != null ? this .dateUploaded .getTime () : -1 );
521+ dest .writeInt (this .width );
522+ dest .writeInt (this .height );
523+ dest .writeString (this .license );
524+ dest .writeString (this .licenseUrl );
525+ dest .writeString (this .creator );
526+ dest .writeStringList (this .categories );
527+ dest .writeByte (this .requestedDeletion ? (byte ) 1 : (byte ) 0 );
528+ dest .writeSerializable (this .descriptions );
529+ dest .writeSerializable (this .tags );
530+ dest .writeParcelable (this .coordinates , flags );
531+ }
532+
533+ protected Media (Parcel in ) {
534+ this .localUri = in .readParcelable (Uri .class .getClassLoader ());
535+ this .thumbUrl = in .readString ();
536+ this .imageUrl = in .readString ();
537+ this .filename = in .readString ();
538+ this .description = in .readString ();
539+ this .discussion = in .readString ();
540+ this .dataLength = in .readLong ();
541+ long tmpDateCreated = in .readLong ();
542+ this .dateCreated = tmpDateCreated == -1 ? null : new Date (tmpDateCreated );
543+ long tmpDateUploaded = in .readLong ();
544+ this .dateUploaded = tmpDateUploaded == -1 ? null : new Date (tmpDateUploaded );
545+ this .width = in .readInt ();
546+ this .height = in .readInt ();
547+ this .license = in .readString ();
548+ this .licenseUrl = in .readString ();
549+ this .creator = in .readString ();
550+ this .categories = in .createStringArrayList ();
551+ this .requestedDeletion = in .readByte () != 0 ;
552+ this .descriptions = (HashMap <String , String >) in .readSerializable ();
553+ this .tags = (HashMap <String , String >) in .readSerializable ();
554+ this .coordinates = in .readParcelable (LatLng .class .getClassLoader ());
555+ }
556+
557+ public static final Creator <Media > CREATOR = new Creator <Media >() {
558+ @ Override
559+ public Media createFromParcel (Parcel source ) {
560+ return new Media (source );
561+ }
562+
563+ @ Override
564+ public Media [] newArray (int size ) {
565+ return new Media [size ];
566+ }
567+ };
563568}
0 commit comments