| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.window; |
| 18 |
|
| 19 |
import android.annotation.IntDef; |
| 20 |
import android.annotation.NonNull; |
| 21 |
import android.annotation.Nullable; |
| 22 |
import android.os.IBinder; |
| 23 |
import android.os.Parcel; |
| 24 |
import android.os.Parcelable; |
| 25 |
|
| 26 |
import java.lang.annotation.Retention; |
| 27 |
import java.lang.annotation.RetentionPolicy; |
| 28 |
import java.util.Objects; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public final class TaskFragmentOperation implements Parcelable { |
| 38 |
|
| 39 |
|
| 40 |
public static final int OP_TYPE_SET_ANIMATION_PARAMS = 0; |
| 41 |
|
| 42 |
@IntDef(prefix = { "OP_TYPE_" }, value = { |
| 43 |
OP_TYPE_SET_ANIMATION_PARAMS |
| 44 |
}) |
| 45 |
@Retention(RetentionPolicy.SOURCE) |
| 46 |
@interface OperationType {} |
| 47 |
|
| 48 |
@OperationType |
| 49 |
private final int mOpType; |
| 50 |
|
| 51 |
@Nullable |
| 52 |
private final TaskFragmentAnimationParams mAnimationParams; |
| 53 |
|
| 54 |
private TaskFragmentOperation(@OperationType int opType, |
| 55 |
@Nullable TaskFragmentAnimationParams animationParams) { |
| 56 |
mOpType = opType; |
| 57 |
mAnimationParams = animationParams; |
| 58 |
} |
| 59 |
|
| 60 |
private TaskFragmentOperation(Parcel in) { |
| 61 |
mOpType = in.readInt(); |
| 62 |
mAnimationParams = in.readTypedObject(TaskFragmentAnimationParams.CREATOR); |
| 63 |
} |
| 64 |
|
| 65 |
@Override |
| 66 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 67 |
dest.writeInt(mOpType); |
| 68 |
dest.writeTypedObject(mAnimationParams, flags); |
| 69 |
} |
| 70 |
|
| 71 |
@NonNull |
| 72 |
public static final Creator<TaskFragmentOperation> CREATOR = |
| 73 |
new Creator<TaskFragmentOperation>() { |
| 74 |
@Override |
| 75 |
public TaskFragmentOperation createFromParcel(Parcel in) { |
| 76 |
return new TaskFragmentOperation(in); |
| 77 |
} |
| 78 |
|
| 79 |
@Override |
| 80 |
public TaskFragmentOperation[] newArray(int size) { |
| 81 |
return new TaskFragmentOperation[size]; |
| 82 |
} |
| 83 |
}; |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
@OperationType |
| 89 |
public int getOpType() { |
| 90 |
return mOpType; |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
@Nullable |
| 97 |
public TaskFragmentAnimationParams getAnimationParams() { |
| 98 |
return mAnimationParams; |
| 99 |
} |
| 100 |
|
| 101 |
@Override |
| 102 |
public String toString() { |
| 103 |
final StringBuilder sb = new StringBuilder(); |
| 104 |
sb.append("TaskFragmentOperation{ opType=").append(mOpType); |
| 105 |
if (mAnimationParams != null) { |
| 106 |
sb.append(", animationParams=").append(mAnimationParams); |
| 107 |
} |
| 108 |
|
| 109 |
sb.append('}'); |
| 110 |
return sb.toString(); |
| 111 |
} |
| 112 |
|
| 113 |
@Override |
| 114 |
public int hashCode() { |
| 115 |
int result = mOpType; |
| 116 |
result = result * 31 + mAnimationParams.hashCode(); |
| 117 |
return result; |
| 118 |
} |
| 119 |
|
| 120 |
@Override |
| 121 |
public boolean equals(@Nullable Object obj) { |
| 122 |
if (!(obj instanceof TaskFragmentOperation)) { |
| 123 |
return false; |
| 124 |
} |
| 125 |
final TaskFragmentOperation other = (TaskFragmentOperation) obj; |
| 126 |
return mOpType == other.mOpType |
| 127 |
&& Objects.equals(mAnimationParams, other.mAnimationParams); |
| 128 |
} |
| 129 |
|
| 130 |
@Override |
| 131 |
public int describeContents() { |
| 132 |
return 0; |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
public static final class Builder { |
| 137 |
|
| 138 |
@OperationType |
| 139 |
private final int mOpType; |
| 140 |
|
| 141 |
@Nullable |
| 142 |
private TaskFragmentAnimationParams mAnimationParams; |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
public Builder(@OperationType int opType) { |
| 148 |
mOpType = opType; |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
@NonNull |
| 155 |
public Builder setAnimationParams(@Nullable TaskFragmentAnimationParams animationParams) { |
| 156 |
mAnimationParams = animationParams; |
| 157 |
return this; |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
@NonNull |
| 164 |
public TaskFragmentOperation build() { |
| 165 |
return new TaskFragmentOperation(mOpType, mAnimationParams); |
| 166 |
} |
| 167 |
} |
| 168 |
} |