public class PhoneArithmetics extends AbstractArithmetics
TabSwitcher
's tabs, when using the smartphone layout.Arithmetics.Axis
Constructor and Description |
---|
PhoneArithmetics(TabSwitcher tabSwitcher)
Creates a new class, which provides methods, which allow to calculate the position, size and
rotation of a
TabSwitcher 's tabs, when using the smartphone layout. |
Modifier and Type | Method and Description |
---|---|
void |
animatePosition(Arithmetics.Axis axis,
android.view.ViewPropertyAnimator animator,
AbstractItem item,
float position,
boolean includePadding)
Animates the position of an item on a specific axis.
|
void |
animateRotation(Arithmetics.Axis axis,
android.view.ViewPropertyAnimator animator,
float angle)
Animates the rotation of an item on a specific axis.
|
void |
animateScale(Arithmetics.Axis axis,
android.view.ViewPropertyAnimator animator,
float scale)
Animates the scale of an item on a specific axis.
|
float |
getPivot(Arithmetics.Axis axis,
AbstractItem item,
AbstractDragTabsEventHandler.DragState dragState)
Returns the pivot of an item on a specific axis, depending on the current drag state.
|
float |
getPosition(Arithmetics.Axis axis,
AbstractItem item)
Returns the position of a specific item on a specific axis.
|
float |
getRotation(Arithmetics.Axis axis,
AbstractItem item)
Returns the rotation of an item on a specific axis.
|
float |
getScale(AbstractItem item,
boolean includePadding)
Returns the scale of an item, depending on its margin.
|
float |
getSize(Arithmetics.Axis axis,
AbstractItem item)
Returns the size of an item on a specific axis.
|
float |
getTabContainerSize(Arithmetics.Axis axis,
boolean includePadding)
Returns the size of the container, which contains the tab switcher's tabs, on a specific
axis.
|
int |
getTabSwitcherPadding(Arithmetics.Axis axis,
int gravity)
Returns the padding of the tab switcher on a specific axis and using a specific gravity.
|
float |
getTouchPosition(Arithmetics.Axis axis,
android.view.MotionEvent event)
Returns the position of a touch event on a specific axis.
|
void |
setPivot(Arithmetics.Axis axis,
AbstractItem item,
float pivot)
Sets the pivot of an item on a specific axis.
|
void |
setPosition(Arithmetics.Axis axis,
AbstractItem item,
float position)
Sets the position of an item on a specific axis.
|
void |
setRotation(Arithmetics.Axis axis,
AbstractItem item,
float angle)
Sets the rotation of an item on a specific axis.
|
void |
setScale(Arithmetics.Axis axis,
AbstractItem item,
float scale)
Sets the scale of an item on a specific axis.
|
animatePosition, getScale, getTabContainerSize, getTabSwitcher
public PhoneArithmetics(@NonNull TabSwitcher tabSwitcher)
TabSwitcher
's tabs, when using the smartphone layout.tabSwitcher
- The tab switcher, the arithmetics should be calculated for, as an instance of the
class TabSwitcher
. The tab switcher may not be nullpublic final int getTabSwitcherPadding(@NonNull Arithmetics.Axis axis, int gravity)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullgravity
- The gravity as an Integer
value. The gravity must be
Gravity.START
or Gravity.END
Integer
valuepublic final float getTabContainerSize(@NonNull Arithmetics.Axis axis, boolean includePadding)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullincludePadding
- True, if the padding and the size of the toolbars should be included, false
otherwiseFloat
valuepublic final float getTouchPosition(@NonNull Arithmetics.Axis axis, @NonNull android.view.MotionEvent event)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullevent
- The touch event, whose position should be returned, as an instance of the class
MotionEvent
. The motion event may not be nullFloat
valuepublic final float getPosition(@NonNull Arithmetics.Axis axis, @NonNull AbstractItem item)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullitem
- The item, whose position should be returned, as an instance of the class AbstractItem
. The item may not be nullFloat
valuepublic final void setPosition(@NonNull Arithmetics.Axis axis, @NonNull AbstractItem item, float position)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullitem
- The item, whose position should be set, as an instance of the class AbstractItem
. The item may not be nullposition
- The position, which should be set, as a Float
valuepublic final void animatePosition(@NonNull Arithmetics.Axis axis, @NonNull android.view.ViewPropertyAnimator animator, @NonNull AbstractItem item, float position, boolean includePadding)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullanimator
- The animator, which should be used to animate the position, as an instance of the
class ViewPropertyAnimator
. The animator may not be nullitem
- The item, whose position should be animated, as an instance of the class View
. The view may not be nullposition
- The position, which should be set by the animation, as a Float
valueincludePadding
- True, if the item's padding should be taken into account, false otherwisepublic final float getScale(@NonNull AbstractItem item, boolean includePadding)
Arithmetics
item
- The item, whose scale should be returned, as an instance of the class AbstractItem
. The item may not be nullincludePadding
- True, if the item's padding should be taken into account as well, false otherwiseFloat
valuepublic final void setScale(@NonNull Arithmetics.Axis axis, @NonNull AbstractItem item, float scale)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullitem
- The item, whose scale should be set, as an instance of the class AbstractItem
. The item may not be nullscale
- The scale, which should be set, as a Float
valuepublic final void animateScale(@NonNull Arithmetics.Axis axis, @NonNull android.view.ViewPropertyAnimator animator, float scale)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullanimator
- The animator, which should be used to animate the scale, as an instance of the class
ViewPropertyAnimator
. The animator may not be nullscale
- The scale, which should be set by the animation, as a Float
valuepublic final float getSize(@NonNull Arithmetics.Axis axis, @NonNull AbstractItem item)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullitem
- The item, whose size should be returned, as an instance of the class AbstractItem
. The item may not be nullFloat
valuepublic final float getPivot(@NonNull Arithmetics.Axis axis, @NonNull AbstractItem item, @NonNull AbstractDragTabsEventHandler.DragState dragState)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullitem
- The item, whose pivot should be returned, as an instance of the class AbstractItem
. The item may not be nulldragState
- The current drag state as a value of the enum AbstractDragTabsEventHandler.DragState
. The drag state may
not be nullFloat
valuepublic final void setPivot(@NonNull Arithmetics.Axis axis, @NonNull AbstractItem item, float pivot)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullitem
- The item, whose pivot should be set, as an instance of the class View
. The
item may not be nullpivot
- The pivot, which should be set, as a Float
valuepublic final float getRotation(@NonNull Arithmetics.Axis axis, @NonNull AbstractItem item)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullitem
- The item, whose rotation should be returned, as an instance of the class AbstractItem
. The item may not be nullFloat
valuepublic final void setRotation(@NonNull Arithmetics.Axis axis, @NonNull AbstractItem item, float angle)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullitem
- The item, whose rotation should be set, as an instance of the class AbstractItem
. The item may not be nullangle
- The rotation, which should be set, as a Float
valuepublic final void animateRotation(@NonNull Arithmetics.Axis axis, @NonNull android.view.ViewPropertyAnimator animator, float angle)
Arithmetics
axis
- The axis as a value of the enum Arithmetics.Axis
. The axis may not be nullanimator
- The animator, should be used to animate the rotation, as an instance of the class
ViewPropertyAnimator
. The animator may not be nullangle
- The rotation, which should be set by the animation, as a Float
value