| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.service.notification; |
| 17 |
|
| 18 |
import android.annotation.NonNull; |
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.os.Parcel; |
| 21 |
import android.os.Parcelable; |
| 22 |
|
| 23 |
import java.util.Objects; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public final class NotifyingApp implements Parcelable, Comparable<NotifyingApp> { |
| 29 |
|
| 30 |
private int mUserId; |
| 31 |
private String mPkg; |
| 32 |
private long mLastNotified; |
| 33 |
|
| 34 |
public NotifyingApp() {} |
| 35 |
|
| 36 |
protected NotifyingApp(Parcel in) { |
| 37 |
mUserId = in.readInt(); |
| 38 |
mPkg = in.readString(); |
| 39 |
mLastNotified = in.readLong(); |
| 40 |
} |
| 41 |
|
| 42 |
public int getUserId() { |
| 43 |
return mUserId; |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public NotifyingApp setUserId(int mUserId) { |
| 50 |
this.mUserId = mUserId; |
| 51 |
return this; |
| 52 |
} |
| 53 |
|
| 54 |
public String getPackage() { |
| 55 |
return mPkg; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
public NotifyingApp setPackage(@NonNull String mPkg) { |
| 62 |
this.mPkg = mPkg; |
| 63 |
return this; |
| 64 |
} |
| 65 |
|
| 66 |
public long getLastNotified() { |
| 67 |
return mLastNotified; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
public NotifyingApp setLastNotified(long mLastNotified) { |
| 74 |
this.mLastNotified = mLastNotified; |
| 75 |
return this; |
| 76 |
} |
| 77 |
|
| 78 |
public static final @NonNull Creator<NotifyingApp> CREATOR = new Creator<NotifyingApp>() { |
| 79 |
@Override |
| 80 |
public NotifyingApp createFromParcel(Parcel in) { |
| 81 |
return new NotifyingApp(in); |
| 82 |
} |
| 83 |
|
| 84 |
@Override |
| 85 |
public NotifyingApp[] newArray(int size) { |
| 86 |
return new NotifyingApp[size]; |
| 87 |
} |
| 88 |
}; |
| 89 |
|
| 90 |
@Override |
| 91 |
public int describeContents() { |
| 92 |
return 0; |
| 93 |
} |
| 94 |
|
| 95 |
@Override |
| 96 |
public void writeToParcel(Parcel dest, int flags) { |
| 97 |
dest.writeInt(mUserId); |
| 98 |
dest.writeString(mPkg); |
| 99 |
dest.writeLong(mLastNotified); |
| 100 |
} |
| 101 |
|
| 102 |
@Override |
| 103 |
public boolean equals(@Nullable Object o) { |
| 104 |
if (this == o) return true; |
| 105 |
if (o == null || getClass() != o.getClass()) return false; |
| 106 |
NotifyingApp that = (NotifyingApp) o; |
| 107 |
return getUserId() == that.getUserId() |
| 108 |
&& getLastNotified() == that.getLastNotified() |
| 109 |
&& Objects.equals(mPkg, that.mPkg); |
| 110 |
} |
| 111 |
|
| 112 |
@Override |
| 113 |
public int hashCode() { |
| 114 |
return Objects.hash(getUserId(), mPkg, getLastNotified()); |
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
@Override |
| 121 |
public int compareTo(NotifyingApp o) { |
| 122 |
if (getLastNotified() == o.getLastNotified()) { |
| 123 |
if (getUserId() == o.getUserId()) { |
| 124 |
return getPackage().compareTo(o.getPackage()); |
| 125 |
} |
| 126 |
return Integer.compare(getUserId(), o.getUserId()); |
| 127 |
} |
| 128 |
|
| 129 |
return -Long.compare(getLastNotified(), o.getLastNotified()); |
| 130 |
} |
| 131 |
|
| 132 |
@Override |
| 133 |
public String toString() { |
| 134 |
return "NotifyingApp{" |
| 135 |
+ "mUserId=" + mUserId |
| 136 |
+ ", mPkg='" + mPkg + '\'' |
| 137 |
+ ", mLastNotified=" + mLastNotified |
| 138 |
+ '}'; |
| 139 |
} |
| 140 |
} |