public class PhoneTabSwitcherLayout extends AbstractTabSwitcherLayout implements PhoneDragTabsEventHandler.Callback
TabSwitcher on smartphones.AbstractTabSwitcherLayout.AnimationListenerWrapper, AbstractTabSwitcherLayout.Callback, AbstractTabSwitcherLayout.InitialItemIterator, AbstractTabSwitcherLayout.InitialItemIteratorBuilder, AbstractTabSwitcherLayout.LayoutListenerWrapper| Constructor and Description |
|---|
PhoneTabSwitcherLayout(TabSwitcher tabSwitcher,
TabSwitcherModel model,
PhoneArithmetics arithmetics,
TabSwitcherStyle style,
TouchEventDispatcher touchEventDispatcher)
Creates a new layout, which implements the functionality of a
TabSwitcher on
smartphones. |
| Modifier and Type | Method and Description |
|---|---|
protected float |
calculateAttachedPosition(int count)
Calculates and returns the position on the dragging axis, where the distance between an item
and its predecessor should have reached the maximum.
|
protected float |
calculateMaxEndPosition(int index)
The method, which is invoked on implementing subclasses in order to retrieve the maximum
position of a specific item, when dragging towards the end.
|
protected <any> |
calculatePositionAndStateWhenStackedAtEnd(int index)
The method, which is invoked on implementing subclasses in order to retrieve the position and
state of a specific item, when stacked at the end.
|
protected <any> |
calculatePositionAndStateWhenStackedAtStart(int count,
int index,
State predecessorState)
The method, which is invoked on implementing subclasses in order to retrieve the position and
state of a specific item, when stacked at the start.
|
protected float |
calculatePredecessorPosition(AbstractItem item,
AbstractItem successor)
Calculates the position of an item in relation to the position of its successor.
|
protected float |
calculateSuccessorPosition(AbstractItem item,
AbstractItem predecessor)
Calculates the position of an item in relation to the position of its predecessor.
|
protected <any> |
getContentViewRecycler()
The method, which is invoked on implementing subclasses in order to retrieve the view
recycler, which allows to recycle the views, which are associated with tabs.
|
AbstractDragTabsEventHandler<?> |
getDragHandler()
The method, which is invoked on implementing subclasses in order to retrieve the drag
handler, which is used by the layout.
|
protected int |
getStackedTabCount()
The method, which is invoked on implementing subclasses in order to retrieve the number of
tabs, which are contained by a stack.
|
android.view.ViewGroup |
getTabContainer()
Returns the view group, which contains the tab switcher's tabs.
|
protected AbstractTabRecyclerAdapter |
getTabRecyclerAdapter()
The method, which is invoked on implementing subclasses in order to retrieve the adapter of
the view recycler, which allows to inflate the views, which are used to visualize the tabs.
|
protected <any> |
getTabViewRecycler()
The method, which is invoked on implementing subclasses in order to retrieve the view
recycler, which allows to inflate the views, which are used to visualize the tabs.
|
Toolbar[] |
getToolbars()
Returns the toolbars, which are shown, when the tab switcher is shown.
|
protected void |
inflateAndUpdateView(AbstractItem item,
boolean dragging,
android.view.ViewTreeObserver.OnGlobalLayoutListener listener)
The method, which is invoked on implementing subclasses in order to inflate and update the
view, which is used to visualize a specific item.
|
protected boolean |
isOvershootingAtEnd(AbstractDragTabsEventHandler.DragState dragState,
AbstractItemIterator iterator)
The method, which is invoked on implementing subclasses in order to retrieve, whether the
items are overshooting at the end.
|
protected boolean |
isOvershootingAtStart()
The method, which is invoked on implementing subclasses in order to retrieve, whether the
items are overshooting at the start.
|
void |
onAllTabsAdded(int index,
Tab[] tabs,
int previousSelectedTabIndex,
int selectedTabIndex,
Animation animation)
The method, which is invoked, when multiple tabs have been added to the model.
|
void |
onAllTabsRemoved(Tab[] tabs,
Animation animation)
The method, which is invoked, when all tabs have been removed from the tab switcher.
|
void |
onDecoratorChanged(TabSwitcherDecorator decorator)
The method, which is invoked, when the decorator has been changed.
|
protected <any> |
onDetachLayout(boolean tabsOnly)
The method, which is invoked on implementing subclasses in order to detach the layout.
|
void |
onEmptyViewChanged(android.view.View view,
long animationDuration)
The method, which is invoked, when the view, which is shown, when the tab switcher is
empty, has been changed.
|
void |
onGlobalLayout() |
protected void |
onInflateLayout(android.view.LayoutInflater inflater,
boolean tabsOnly)
The method, which is invoked on implementing subclasses in order to inflate the layout.
|
void |
onPaddingChanged(int left,
int top,
int right,
int bottom)
The method, which is invoked, when the padding has been changed.
|
void |
onPulledDown()
The method, which is notified, when the currently selected tab has been pulled down.
|
void |
onRevertEndOvershoot()
The method, which is invoked, when an overshoot at the end should be reverted.
|
void |
onRevertStartOvershoot()
The method, which is invoked, when an overshoot at the start should be reverted.
|
void |
onSelectionChanged(int previousIndex,
int index,
Tab selectedTab,
boolean switcherHidden)
The method, which is invoked, when the currently selected tab has been changed.
|
void |
onStartOvershoot(float position)
The method, which is invoked, when tabs are overshooting at the start.
|
void |
onSwipe(TabItem tabItem,
float distance)
The method, which is invoked, when a tab is swiped.
|
void |
onSwipeEnded(TabItem tabItem,
boolean remove,
float velocity)
The method, which is invoked, when swiping a tab ended.
|
void |
onSwitcherHidden()
The method, which is invoked, when the tab switcher has been hidden.
|
void |
onSwitcherShown()
The method, which is invoked, when the tab switcher has been shown.
|
void |
onSwitchingBetweenTabs(int selectedTabIndex,
float distance)
The method, which is invoked, when switching between neighboring tabs.
|
void |
onSwitchingBetweenTabsEnded(int selectedTabIndex,
int previousSelectedTabIndex,
float velocity,
long animationDuration)
The method, which is invoked, when switching between neighboring tabs ended.
|
void |
onTabAdded(int index,
Tab tab,
int previousSelectedTabIndex,
int selectedTabIndex,
boolean switcherVisibilityChanged,
Animation animation)
The method, which is invoked, when a tab has been added to the model.
|
void |
onTabRemoved(int index,
Tab tab,
int previousSelectedTabIndex,
int selectedTabIndex,
Animation animation)
The method, which is invoked, when a tab has been removed from the model.
|
void |
onTiltOnEndOvershoot(float angle)
The method, which is invoked, when the tabs should be tilted when overshooting at the
end.
|
void |
onTiltOnStartOvershoot(float angle)
The method, which is invoked, when the tabs should be tilted when overshooting at the
start.
|
protected void |
updateView(AbstractItem item,
boolean dragging)
Updates the view, which is used to visualize a specific item.
|
calculateMinStartPosition, calculatePositionAndStateWhenStackedAtStart, clipPosition, clipPosition, detachLayout, getArithmetics, getContext, getFirstVisibleIndex, getItemCount, getLogger, getModel, getStackedTabSpacing, getStyle, getTabSwitcher, getToolbarMenu, inflateLayout, inflateOrRemoveView, inflateView, isAnimationRunning, isStackedAtStart, onAddedEventHandler, onAddTabButtonColorChanged, onAddTabButtonVisibilityChanged, onCancelFling, onClick, onCreateContentRecyclerAdapter, onDrag, onFling, onLogLevelChanged, onPressEnded, onPressStarted, onRemovedEventHandler, onTabBackgroundColorChanged, onTabCloseButtonIconChanged, onTabContentBackgroundColorChanged, onTabIconChanged, onTabProgressBarColorChanged, onTabTitleColorChanged, onToolbarMenuInflated, onToolbarNavigationIconChanged, onToolbarTitleChanged, onToolbarVisibilityChanged, secondLayoutPass, setCallback, setFirstVisibleIndexclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonCancelFling, onClick, onDrag, onFling, onPressEnded, onPressStartedpublic PhoneTabSwitcherLayout(TabSwitcher tabSwitcher, TabSwitcherModel model, PhoneArithmetics arithmetics, TabSwitcherStyle style, TouchEventDispatcher touchEventDispatcher)
TabSwitcher on
smartphones.tabSwitcher - The tab switcher, the layout belongs to, as an instance of the class TabSwitcher. The tab switcher may not be nullmodel - The model of the tab switcher, the layout belongs to, as an instance of the class
TabSwitcherModel. The model may not be nullarithmetics - The arithmetics, which should be used by the layout, as an instance of the class
PhoneArithmetics. The arithmetics may not be nullstyle - The style, which allows to retrieve style attributes of the tab switcher, as an
instance of the class TabSwitcherStyle. The style may not be nulltouchEventDispatcher - The dispatcher, which is used to dispatch touch events to event handlers, as an
instance of the class TouchEventDispatcher. The dispatcher may not be nullpublic final AbstractDragTabsEventHandler<?> getDragHandler()
AbstractTabSwitcherLayoutgetDragHandler in class AbstractTabSwitcherLayoutAbstractDragTabsEventHandler or null, if the drag handler has not been initialized yetprotected final void onInflateLayout(android.view.LayoutInflater inflater,
boolean tabsOnly)
AbstractTabSwitcherLayoutonInflateLayout in class AbstractTabSwitcherLayoutinflater - The layout inflater, which should be used, as an instance of the class LayoutInflater. The layout inflater may not be nulltabsOnly - True, if only the tabs should be inflated, false otherwiseprotected final <any> onDetachLayout(boolean tabsOnly)
AbstractTabSwitcherLayoutonDetachLayout in class AbstractTabSwitcherLayouttabsOnly - True, if only the tabs should be detached, false otherwiseprotected final <any> getContentViewRecycler()
AbstractTabSwitcherLayoutgetContentViewRecycler in class AbstractTabSwitcherLayoutprotected final <any> getTabViewRecycler()
AbstractTabSwitcherLayoutgetTabViewRecycler in class AbstractTabSwitcherLayoutprotected final AbstractTabRecyclerAdapter getTabRecyclerAdapter()
AbstractTabSwitcherLayoutgetTabRecyclerAdapter in class AbstractTabSwitcherLayoutAbstractTabRecyclerAdapter or
null, if the view recycler has not been initialized yetprotected final void updateView(AbstractItem item, boolean dragging)
AbstractTabSwitcherLayoutupdateView in class AbstractTabSwitcherLayoutitem - The item, whose view should be updated, as an instance of the class AbstractItem. The item may not be nulldragging - True, if the item is currently being dragged, false otherwiseprotected final float calculateAttachedPosition(int count)
AbstractTabSwitcherLayoutcalculateAttachedPosition in class AbstractTabSwitcherLayoutcount - The total number of items, which are contained by the tab switcher, as an Integer valueFloat value or -1,
if no attached position is usedprotected final void inflateAndUpdateView(AbstractItem item, boolean dragging, android.view.ViewTreeObserver.OnGlobalLayoutListener listener)
AbstractTabSwitcherLayoutinflateAndUpdateView in class AbstractTabSwitcherLayoutitem - The item, whose view should be inflated, as an instance of the class AbstractItem. The item may not be nulldragging - True, if the view is currently being dragged, false otherwiselistener - The layout listener, which should be notified, when the view has been inflated, as an
instance of the type ViewTreeObserver.OnGlobalLayoutListener or null, if no listener should be
notifiedprotected final int getStackedTabCount()
AbstractTabSwitcherLayoutgetStackedTabCount in class AbstractTabSwitcherLayoutInteger valueprotected final <any> calculatePositionAndStateWhenStackedAtStart(int count,
int index,
State predecessorState)
AbstractTabSwitcherLayoutcalculatePositionAndStateWhenStackedAtStart in class AbstractTabSwitcherLayoutcount - The total number of items, which are currently contained by the tab switcher, as an
Integer valueindex - The index of the item, whose position and state should be returned, as an Integer valuepredecessorState - The state of the predecessor of the given item as a value of the enum State
or null, if the item does not have a predecessorprotected final <any> calculatePositionAndStateWhenStackedAtEnd(int index)
AbstractTabSwitcherLayoutcalculatePositionAndStateWhenStackedAtEnd in class AbstractTabSwitcherLayoutindex - The index of the item, whose position and state should be returned, as an Integer valueprotected final boolean isOvershootingAtStart()
AbstractTabSwitcherLayoutisOvershootingAtStart in class AbstractTabSwitcherLayoutprotected final boolean isOvershootingAtEnd(AbstractDragTabsEventHandler.DragState dragState, AbstractItemIterator iterator)
AbstractTabSwitcherLayoutisOvershootingAtEnd in class AbstractTabSwitcherLayoutdragState - The current drag state as an instance of the enum AbstractDragTabsEventHandler.DragState. The drag state
may not be nulliterator - An iterator, which allows to iterate the items, which are contained by the tab
switcher, as an instance of the class AbstractItemIterator. The iterator may
not be nullprotected final float calculateMaxEndPosition(int index)
AbstractTabSwitcherLayoutcalculateMaxEndPosition in class AbstractTabSwitcherLayoutindex - The index of the item, whose position should be calculated, as an Integer
valueFloat value or -1, if no
maximum position is availableprotected final float calculateSuccessorPosition(AbstractItem item, AbstractItem predecessor)
AbstractTabSwitcherLayoutcalculateSuccessorPosition in class AbstractTabSwitcherLayoutitem - The item, whose position should be calculated, as an instance of the class AbstractItem. The item may not be nullpredecessor - The predecessor as an instance of the class AbstractItem. The predecessor may
not be nullFloat valueprotected final float calculatePredecessorPosition(AbstractItem item, AbstractItem successor)
AbstractTabSwitcherLayoutcalculatePredecessorPosition in class AbstractTabSwitcherLayoutitem - The item, whose position should be calculated, as an instance of the class AbstractItem. The item may not be nullsuccessor - The successor as an instance of the class AbstractItem. The successor may not
be nullFloat valuepublic final android.view.ViewGroup getTabContainer()
TabSwitcherLayoutgetTabContainer in interface TabSwitcherLayoutViewGroup or null, if the view has not been laid out yetpublic final Toolbar[] getToolbars()
TabSwitcherLayoutTabSwitcher.PRIMARY_TOOLBAR_INDEX
of the returned array corresponds to the primary toolbar and the index TabSwitcher.SECONDARY_TOOLBAR_INDEX corresponds to the secondary toolbar.getToolbars in interface TabSwitcherLayoutpublic final void onDecoratorChanged(TabSwitcherDecorator decorator)
Model.ListeneronDecoratorChanged in interface Model.ListeneronDecoratorChanged in class AbstractTabSwitcherLayoutdecorator - The decorator, which has been set, as an instance of the class TabSwitcherDecorator. The decorator may not be nullpublic final void onSwitcherShown()
Model.ListeneronSwitcherShown in interface Model.ListeneronSwitcherShown in class AbstractTabSwitcherLayoutpublic final void onSwitcherHidden()
Model.ListeneronSwitcherHidden in interface Model.ListeneronSwitcherHidden in class AbstractTabSwitcherLayoutpublic final void onSelectionChanged(int previousIndex,
int index,
Tab selectedTab,
boolean switcherHidden)
Model.ListeneronSelectionChanged in interface Model.ListenerpreviousIndex - The index of the previously selected tab as an Integer value or -1, if no
tab was previously selectedindex - The index of the currently selected tab as an Integer value or -1, if the
tab switcher does not contain any tabsselectedTab - The currently selected tab as an instance of the class Tab or null, if
the tab switcher does not contain any tabsswitcherHidden - True, if selecting the tab caused the tab switcher to be hidden, false otherwisepublic final void onTabAdded(int index,
Tab tab,
int previousSelectedTabIndex,
int selectedTabIndex,
boolean switcherVisibilityChanged,
Animation animation)
Model.ListeneronTabAdded in interface Model.Listenerindex - The index of the tab, which has been added, as an Integer valuetab - The tab, which has been added, as an instance of the class Tab. The tab
may not be nullpreviousSelectedTabIndex - The index of the previously selected tab as an Integer value or -1, if no
tab was selectedselectedTabIndex - The index of the currently selected tab as an Integer value or -1, if the
tab switcher does not contain any tabsswitcherVisibilityChanged - True, if adding the tab caused the visibility of the tab switcher to be changed,
false otherwiseanimation - The animation, which has been used to add the tab, as an instance of the class
Animation. The animation may not be nullpublic final void onAllTabsAdded(int index,
Tab[] tabs,
int previousSelectedTabIndex,
int selectedTabIndex,
Animation animation)
Model.ListeneronAllTabsAdded in interface Model.Listenerindex - The index of the first tab, which has been added, as an Integer valuetabs - An array, which contains the tabs, which have been added, as an array of the type
Tab or an empty array, if no tabs have been addedpreviousSelectedTabIndex - The index of the previously selected tab as an Integer value or -1, if no
tab was selectedselectedTabIndex - The index of the currently selected tab as an Integer value or -1, if the
tab switcher does not contain any tabsanimation - The animation, which has been used to add the tabs, as an instance of the class
Animation. The animation may not be nullpublic final void onTabRemoved(int index,
Tab tab,
int previousSelectedTabIndex,
int selectedTabIndex,
Animation animation)
Model.ListeneronTabRemoved in interface Model.Listenerindex - The index of the tab, which has been removed, as an Integer valuetab - The tab, which has been removed, as an instance of the class Tab. The tab
may not be nullpreviousSelectedTabIndex - The index of the previously selected tab as an Integer value or -1, if no
tab was selectedselectedTabIndex - The index of the currently selected tab as an Integer value or -1, if the
tab switcher does not contain any tabsanimation - The animation, which has been used to remove the tab, as an instance of the class
Animation. The animation may not be nullpublic final void onAllTabsRemoved(Tab[] tabs, Animation animation)
Model.ListeneronAllTabsRemoved in interface Model.Listenertabs - An array, which contains the tabs, which have been removed, as an array of the
type Tab or an empty array, if no tabs have been removedanimation - The animation, which has been used to remove the tabs, as an instance of the
class Animation. The animation may not be nullpublic final void onPaddingChanged(int left,
int top,
int right,
int bottom)
Model.ListeneronPaddingChanged in interface Model.Listenerleft - The left padding, which has been set, in pixels as an Integer valuetop - The top padding, which has been set, in pixels as an Integer valueright - The right padding, which has been set, in pixels as an Integer valuebottom - The bottom padding, which has been set, in pixels as an Integer valuepublic final void onEmptyViewChanged(android.view.View view,
long animationDuration)
Model.ListeneronEmptyViewChanged in interface Model.Listenerview - The view, which has been set, as an instance of the class View or null,
if no view should be shown, when the tab switcher is emptyanimationDuration - The duration of the fade animation, which is used to show or hide the view, in
milliseconds as a Long value. The duration must be at least 0 or -1, if
the default duration should be usedpublic final void onGlobalLayout()
onGlobalLayout in interface android.view.ViewTreeObserver.OnGlobalLayoutListenerpublic final void onRevertStartOvershoot()
AbstractDragTabsEventHandler.CallbackonRevertStartOvershoot in interface AbstractDragTabsEventHandler.CallbackonRevertStartOvershoot in class AbstractTabSwitcherLayoutpublic final void onRevertEndOvershoot()
AbstractDragTabsEventHandler.CallbackonRevertEndOvershoot in interface AbstractDragTabsEventHandler.CallbackonRevertEndOvershoot in class AbstractTabSwitcherLayoutpublic final void onStartOvershoot(float position)
PhoneDragTabsEventHandler.CallbackonStartOvershoot in interface PhoneDragTabsEventHandler.Callbackposition - The position of the first tab in pixels as a Float valuepublic final void onTiltOnStartOvershoot(float angle)
PhoneDragTabsEventHandler.CallbackonTiltOnStartOvershoot in interface PhoneDragTabsEventHandler.Callbackangle - The angle, the tabs should be tilted by, in degrees as a Float valuepublic final void onTiltOnEndOvershoot(float angle)
PhoneDragTabsEventHandler.CallbackonTiltOnEndOvershoot in interface PhoneDragTabsEventHandler.Callbackangle - The angle, the tabs should be tilted by, in degrees as a Float valuepublic final void onSwipe(TabItem tabItem, float distance)
AbstractDragTabsEventHandler.CallbackonSwipe in interface AbstractDragTabsEventHandler.CallbackonSwipe in class AbstractTabSwitcherLayouttabItem - The tab item, which corresponds to the swiped tab, as an instance of the class
TabItem. The tab item may not be nulldistance - The distance, the tab is swiped by, in pixels as a Float valuepublic final void onSwipeEnded(TabItem tabItem, boolean remove, float velocity)
AbstractDragTabsEventHandler.CallbackonSwipeEnded in interface AbstractDragTabsEventHandler.CallbackonSwipeEnded in class AbstractTabSwitcherLayouttabItem - The tab item, which corresponds to the swiped tab, as an instance of the class
TabItem. The tab item may not be nullremove - True, if the tab should be removed, false otherwisevelocity - The velocity of the swipe gesture in pixels per second as a Float valuepublic final void onSwitchingBetweenTabs(int selectedTabIndex,
float distance)
SwipeGestureEventHandler.CallbackonSwitchingBetweenTabs in interface SwipeGestureEventHandler.CallbackselectedTabIndex - The index of the currently selected tab as an Integer valuedistance - The distance, the currently selected tab is swiped by, in pixels as a Float valuepublic final void onSwitchingBetweenTabsEnded(int selectedTabIndex,
int previousSelectedTabIndex,
float velocity,
long animationDuration)
SwipeGestureEventHandler.CallbackonSwitchingBetweenTabsEnded in interface SwipeGestureEventHandler.CallbackselectedTabIndex - The index of the tab, which should become selected, as an Integer valuepreviousSelectedTabIndex - The index of the previously selected tab as an Integer valuevelocity - The velocity of the swipe gesture in pixels per second as a Float valueanimationDuration - The duration of the swipe animation in milliseconds as a Long valuepublic final void onPulledDown()
PullDownGestureEventHandler.CallbackonPulledDown in interface PullDownGestureEventHandler.CallbackonPulledDown in class AbstractTabSwitcherLayout