| 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.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
import android.view.RemoteAnimationTarget; |
| 25 |
|
| 26 |
import java.lang.annotation.Retention; |
| 27 |
import java.lang.annotation.RetentionPolicy; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public class BackEvent implements Parcelable { |
| 37 |
|
| 38 |
public static final int EDGE_LEFT = 0; |
| 39 |
|
| 40 |
public static final int EDGE_RIGHT = 1; |
| 41 |
|
| 42 |
@IntDef({ |
| 43 |
EDGE_LEFT, |
| 44 |
EDGE_RIGHT, |
| 45 |
}) |
| 46 |
@Retention(RetentionPolicy.SOURCE) |
| 47 |
public @interface SwipeEdge{} |
| 48 |
|
| 49 |
private final float mTouchX; |
| 50 |
private final float mTouchY; |
| 51 |
private final float mProgress; |
| 52 |
|
| 53 |
@SwipeEdge |
| 54 |
private final int mSwipeEdge; |
| 55 |
@Nullable |
| 56 |
private final RemoteAnimationTarget mDepartingAnimationTarget; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
public BackEvent(float touchX, float touchY, float progress, @SwipeEdge int swipeEdge, |
| 69 |
@Nullable RemoteAnimationTarget departingAnimationTarget) { |
| 70 |
mTouchX = touchX; |
| 71 |
mTouchY = touchY; |
| 72 |
mProgress = progress; |
| 73 |
mSwipeEdge = swipeEdge; |
| 74 |
mDepartingAnimationTarget = departingAnimationTarget; |
| 75 |
} |
| 76 |
|
| 77 |
private BackEvent(@NonNull Parcel in) { |
| 78 |
mTouchX = in.readFloat(); |
| 79 |
mTouchY = in.readFloat(); |
| 80 |
mProgress = in.readFloat(); |
| 81 |
mSwipeEdge = in.readInt(); |
| 82 |
mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR); |
| 83 |
} |
| 84 |
|
| 85 |
public static final Creator<BackEvent> CREATOR = new Creator<BackEvent>() { |
| 86 |
@Override |
| 87 |
public BackEvent createFromParcel(Parcel in) { |
| 88 |
return new BackEvent(in); |
| 89 |
} |
| 90 |
|
| 91 |
@Override |
| 92 |
public BackEvent[] newArray(int size) { |
| 93 |
return new BackEvent[size]; |
| 94 |
} |
| 95 |
}; |
| 96 |
|
| 97 |
@Override |
| 98 |
public int describeContents() { |
| 99 |
return 0; |
| 100 |
} |
| 101 |
|
| 102 |
@Override |
| 103 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 104 |
dest.writeFloat(mTouchX); |
| 105 |
dest.writeFloat(mTouchY); |
| 106 |
dest.writeFloat(mProgress); |
| 107 |
dest.writeInt(mSwipeEdge); |
| 108 |
dest.writeTypedObject(mDepartingAnimationTarget, flags); |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
public float getProgress() { |
| 115 |
return mProgress; |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
public float getTouchX() { |
| 122 |
return mTouchX; |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
public float getTouchY() { |
| 129 |
return mTouchY; |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
public int getSwipeEdge() { |
| 136 |
return mSwipeEdge; |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
@Nullable |
| 145 |
public RemoteAnimationTarget getDepartingAnimationTarget() { |
| 146 |
return mDepartingAnimationTarget; |
| 147 |
} |
| 148 |
|
| 149 |
@Override |
| 150 |
public String toString() { |
| 151 |
return "BackEvent{" |
| 152 |
+ "mTouchX=" + mTouchX |
| 153 |
+ ", mTouchY=" + mTouchY |
| 154 |
+ ", mProgress=" + mProgress |
| 155 |
+ ", mSwipeEdge" + mSwipeEdge |
| 156 |
+ ", mDepartingAnimationTarget" + mDepartingAnimationTarget |
| 157 |
+ "}"; |
| 158 |
} |
| 159 |
} |