| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
package android.widget; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
class RtlSpacingHelper { |
| 26 |
public static final int UNDEFINED = Integer.MIN_VALUE; |
| 27 |
|
| 28 |
private int mLeft = 0; |
| 29 |
private int mRight = 0; |
| 30 |
private int mStart = UNDEFINED; |
| 31 |
private int mEnd = UNDEFINED; |
| 32 |
private int mExplicitLeft = 0; |
| 33 |
private int mExplicitRight = 0; |
| 34 |
|
| 35 |
private boolean mIsRtl = false; |
| 36 |
private boolean mIsRelative = false; |
| 37 |
|
| 38 |
public int getLeft() { |
| 39 |
return mLeft; |
| 40 |
} |
| 41 |
|
| 42 |
public int getRight() { |
| 43 |
return mRight; |
| 44 |
} |
| 45 |
|
| 46 |
public int getStart() { |
| 47 |
return mIsRtl ? mRight : mLeft; |
| 48 |
} |
| 49 |
|
| 50 |
public int getEnd() { |
| 51 |
return mIsRtl ? mLeft : mRight; |
| 52 |
} |
| 53 |
|
| 54 |
public void setRelative(int start, int end) { |
| 55 |
mStart = start; |
| 56 |
mEnd = end; |
| 57 |
mIsRelative = true; |
| 58 |
if (mIsRtl) { |
| 59 |
if (end != UNDEFINED) mLeft = end; |
| 60 |
if (start != UNDEFINED) mRight = start; |
| 61 |
} else { |
| 62 |
if (start != UNDEFINED) mLeft = start; |
| 63 |
if (end != UNDEFINED) mRight = end; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
public void setAbsolute(int left, int right) { |
| 68 |
mIsRelative = false; |
| 69 |
if (left != UNDEFINED) mLeft = mExplicitLeft = left; |
| 70 |
if (right != UNDEFINED) mRight = mExplicitRight = right; |
| 71 |
} |
| 72 |
|
| 73 |
public void setDirection(boolean isRtl) { |
| 74 |
if (isRtl == mIsRtl) { |
| 75 |
return; |
| 76 |
} |
| 77 |
mIsRtl = isRtl; |
| 78 |
if (mIsRelative) { |
| 79 |
if (isRtl) { |
| 80 |
mLeft = mEnd != UNDEFINED ? mEnd : mExplicitLeft; |
| 81 |
mRight = mStart != UNDEFINED ? mStart : mExplicitRight; |
| 82 |
} else { |
| 83 |
mLeft = mStart != UNDEFINED ? mStart : mExplicitLeft; |
| 84 |
mRight = mEnd != UNDEFINED ? mEnd : mExplicitRight; |
| 85 |
} |
| 86 |
} else { |
| 87 |
mLeft = mExplicitLeft; |
| 88 |
mRight = mExplicitRight; |
| 89 |
} |
| 90 |
} |
| 91 |
} |