1 package expo.modules.notifications.notifications.model; 2 3 import android.os.Parcel; 4 import android.os.Parcelable; 5 6 import java.util.Date; 7 8 /** 9 * A class representing a single notification received at a particular moment ({@link #mDate}). 10 */ 11 public class Notification implements Parcelable { 12 private NotificationRequest mRequest; 13 private Date mDate; 14 Notification(NotificationRequest request)15 public Notification(NotificationRequest request) { 16 this(request, new Date()); 17 } 18 Notification(NotificationRequest request, Date date)19 public Notification(NotificationRequest request, Date date) { 20 mRequest = request; 21 mDate = date; 22 } 23 Notification(Parcel in)24 protected Notification(Parcel in) { 25 mRequest = in.readParcelable(getClass().getClassLoader()); 26 mDate = new Date(in.readLong()); 27 } 28 getDate()29 public Date getDate() { 30 return mDate; 31 } 32 getNotificationRequest()33 public NotificationRequest getNotificationRequest() { 34 return mRequest; 35 } 36 37 public static final Creator<Notification> CREATOR = new Creator<Notification>() { 38 @Override 39 public Notification createFromParcel(Parcel in) { 40 return new Notification(in); 41 } 42 43 @Override 44 public Notification[] newArray(int size) { 45 return new Notification[size]; 46 } 47 }; 48 49 @Override describeContents()50 public int describeContents() { 51 return 0; 52 } 53 54 @Override writeToParcel(Parcel dest, int flags)55 public void writeToParcel(Parcel dest, int flags) { 56 dest.writeParcelable(mRequest, 0); 57 dest.writeLong(mDate.getTime()); 58 } 59 } 60