am 485ac778: Merge "Slide supports Gravity.START and Gravity.END." into lmp-mr1-dev
* commit '485ac7782ed7605507bf2186246f59c537f8b578': Slide supports Gravity.START and Gravity.END.
This commit is contained in:
@@ -44,8 +44,8 @@ public class SidePropagation extends VisibilityPropagation {
|
|||||||
* farther from the edge. The default is {@link Gravity#BOTTOM}.
|
* farther from the edge. The default is {@link Gravity#BOTTOM}.
|
||||||
*
|
*
|
||||||
* @param side The side that is used to calculate the transition propagation. Must be one of
|
* @param side The side that is used to calculate the transition propagation. Must be one of
|
||||||
* {@link Gravity#LEFT}, {@link Gravity#TOP}, {@link Gravity#RIGHT}, or
|
* {@link Gravity#LEFT}, {@link Gravity#TOP}, {@link Gravity#RIGHT},
|
||||||
* {@link Gravity#BOTTOM}.
|
* {@link Gravity#BOTTOM}, {@link Gravity#START}, or {@link Gravity#END}.
|
||||||
*/
|
*/
|
||||||
public void setSide(int side) {
|
public void setSide(int side) {
|
||||||
mSide = side;
|
mSide = side;
|
||||||
@@ -106,7 +106,7 @@ public class SidePropagation extends VisibilityPropagation {
|
|||||||
epicenterY = (top + bottom) / 2;
|
epicenterY = (top + bottom) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
float distance = distance(viewCenterX, viewCenterY, epicenterX, epicenterY,
|
float distance = distance(sceneRoot, viewCenterX, viewCenterY, epicenterX, epicenterY,
|
||||||
left, top, right, bottom);
|
left, top, right, bottom);
|
||||||
float maxDistance = getMaxDistance(sceneRoot);
|
float maxDistance = getMaxDistance(sceneRoot);
|
||||||
float distanceFraction = distance/maxDistance;
|
float distanceFraction = distance/maxDistance;
|
||||||
@@ -119,10 +119,20 @@ public class SidePropagation extends VisibilityPropagation {
|
|||||||
return Math.round(duration * directionMultiplier / mPropagationSpeed * distanceFraction);
|
return Math.round(duration * directionMultiplier / mPropagationSpeed * distanceFraction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int distance(int viewX, int viewY, int epicenterX, int epicenterY,
|
private int distance(View sceneRoot, int viewX, int viewY, int epicenterX, int epicenterY,
|
||||||
int left, int top, int right, int bottom) {
|
int left, int top, int right, int bottom) {
|
||||||
|
final int side;
|
||||||
|
if (mSide == Gravity.START) {
|
||||||
|
final boolean isRtl = sceneRoot.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
|
||||||
|
side = isRtl ? Gravity.RIGHT : Gravity.LEFT;
|
||||||
|
} else if (mSide == Gravity.END) {
|
||||||
|
final boolean isRtl = sceneRoot.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
|
||||||
|
side = isRtl ? Gravity.LEFT : Gravity.RIGHT;
|
||||||
|
} else {
|
||||||
|
side = mSide;
|
||||||
|
}
|
||||||
int distance = 0;
|
int distance = 0;
|
||||||
switch (mSide) {
|
switch (side) {
|
||||||
case Gravity.LEFT:
|
case Gravity.LEFT:
|
||||||
distance = right - viewX + Math.abs(epicenterY - viewY);
|
distance = right - viewX + Math.abs(epicenterY - viewY);
|
||||||
break;
|
break;
|
||||||
@@ -143,6 +153,8 @@ public class SidePropagation extends VisibilityPropagation {
|
|||||||
switch (mSide) {
|
switch (mSide) {
|
||||||
case Gravity.LEFT:
|
case Gravity.LEFT:
|
||||||
case Gravity.RIGHT:
|
case Gravity.RIGHT:
|
||||||
|
case Gravity.START:
|
||||||
|
case Gravity.END:
|
||||||
return sceneRoot.getWidth();
|
return sceneRoot.getWidth();
|
||||||
default:
|
default:
|
||||||
return sceneRoot.getHeight();
|
return sceneRoot.getHeight();
|
||||||
|
|||||||
@@ -76,6 +76,20 @@ public class Slide extends Visibility {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final CalculateSlide sCalculateStart = new CalculateSlideHorizontal() {
|
||||||
|
@Override
|
||||||
|
public float getGoneX(ViewGroup sceneRoot, View view) {
|
||||||
|
final boolean isRtl = sceneRoot.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
|
||||||
|
final float x;
|
||||||
|
if (isRtl) {
|
||||||
|
x = view.getTranslationX() + sceneRoot.getWidth();
|
||||||
|
} else {
|
||||||
|
x = view.getTranslationX() - sceneRoot.getWidth();
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private static final CalculateSlide sCalculateTop = new CalculateSlideVertical() {
|
private static final CalculateSlide sCalculateTop = new CalculateSlideVertical() {
|
||||||
@Override
|
@Override
|
||||||
public float getGoneY(ViewGroup sceneRoot, View view) {
|
public float getGoneY(ViewGroup sceneRoot, View view) {
|
||||||
@@ -90,6 +104,20 @@ public class Slide extends Visibility {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final CalculateSlide sCalculateEnd = new CalculateSlideHorizontal() {
|
||||||
|
@Override
|
||||||
|
public float getGoneX(ViewGroup sceneRoot, View view) {
|
||||||
|
final boolean isRtl = sceneRoot.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
|
||||||
|
final float x;
|
||||||
|
if (isRtl) {
|
||||||
|
x = view.getTranslationX() - sceneRoot.getWidth();
|
||||||
|
} else {
|
||||||
|
x = view.getTranslationX() + sceneRoot.getWidth();
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private static final CalculateSlide sCalculateBottom = new CalculateSlideVertical() {
|
private static final CalculateSlide sCalculateBottom = new CalculateSlideVertical() {
|
||||||
@Override
|
@Override
|
||||||
public float getGoneY(ViewGroup sceneRoot, View view) {
|
public float getGoneY(ViewGroup sceneRoot, View view) {
|
||||||
@@ -144,7 +172,8 @@ public class Slide extends Visibility {
|
|||||||
*
|
*
|
||||||
* @param slideEdge The edge of the scene to use for Views appearing and disappearing. One of
|
* @param slideEdge The edge of the scene to use for Views appearing and disappearing. One of
|
||||||
* {@link android.view.Gravity#LEFT}, {@link android.view.Gravity#TOP},
|
* {@link android.view.Gravity#LEFT}, {@link android.view.Gravity#TOP},
|
||||||
* {@link android.view.Gravity#RIGHT}, {@link android.view.Gravity#BOTTOM}.
|
* {@link android.view.Gravity#RIGHT}, {@link android.view.Gravity#BOTTOM},
|
||||||
|
* {@link android.view.Gravity#START}, {@link android.view.Gravity#END}.
|
||||||
* @attr ref android.R.styleable#Slide_slideEdge
|
* @attr ref android.R.styleable#Slide_slideEdge
|
||||||
*/
|
*/
|
||||||
public void setSlideEdge(int slideEdge) {
|
public void setSlideEdge(int slideEdge) {
|
||||||
@@ -161,6 +190,12 @@ public class Slide extends Visibility {
|
|||||||
case Gravity.BOTTOM:
|
case Gravity.BOTTOM:
|
||||||
mSlideCalculator = sCalculateBottom;
|
mSlideCalculator = sCalculateBottom;
|
||||||
break;
|
break;
|
||||||
|
case Gravity.START:
|
||||||
|
mSlideCalculator = sCalculateStart;
|
||||||
|
break;
|
||||||
|
case Gravity.END:
|
||||||
|
mSlideCalculator = sCalculateEnd;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Invalid slide direction");
|
throw new IllegalArgumentException("Invalid slide direction");
|
||||||
}
|
}
|
||||||
@@ -175,7 +210,8 @@ public class Slide extends Visibility {
|
|||||||
*
|
*
|
||||||
* @return the edge of the scene to use for Views appearing and disappearing. One of
|
* @return the edge of the scene to use for Views appearing and disappearing. One of
|
||||||
* {@link android.view.Gravity#LEFT}, {@link android.view.Gravity#TOP},
|
* {@link android.view.Gravity#LEFT}, {@link android.view.Gravity#TOP},
|
||||||
* {@link android.view.Gravity#RIGHT}, {@link android.view.Gravity#BOTTOM}.
|
* {@link android.view.Gravity#RIGHT}, {@link android.view.Gravity#BOTTOM},
|
||||||
|
* {@link android.view.Gravity#START}, {@link android.view.Gravity#END}.
|
||||||
* @attr ref android.R.styleable#Slide_slideEdge
|
* @attr ref android.R.styleable#Slide_slideEdge
|
||||||
*/
|
*/
|
||||||
public int getSlideEdge() {
|
public int getSlideEdge() {
|
||||||
|
|||||||
@@ -5665,6 +5665,10 @@
|
|||||||
<enum name="right" value="0x05" />
|
<enum name="right" value="0x05" />
|
||||||
<!-- Slide to and from the bottom edge of the Scene. -->
|
<!-- Slide to and from the bottom edge of the Scene. -->
|
||||||
<enum name="bottom" value="0x50" />
|
<enum name="bottom" value="0x50" />
|
||||||
|
<!-- Slide to and from the x-axis position at the start of the Scene root. -->
|
||||||
|
<enum name="start" value="0x00800003"/>
|
||||||
|
<!-- Slide to and from the x-axis position at the end of the Scene root. -->
|
||||||
|
<enum name="end" value="0x00800005"/>
|
||||||
</attr>
|
</attr>
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user