public class TabletTabSwitcherLayout extends AbstractTabSwitcherLayout implements Tab.Callback
TabSwitcher
on tablets.AbstractTabSwitcherLayout.AnimationListenerWrapper, AbstractTabSwitcherLayout.Callback, AbstractTabSwitcherLayout.InitialItemIterator, AbstractTabSwitcherLayout.InitialItemIteratorBuilder, AbstractTabSwitcherLayout.LayoutListenerWrapper
Constructor and Description |
---|
TabletTabSwitcherLayout(TabSwitcher tabSwitcher,
TabSwitcherModel model,
Arithmetics arithmetics,
TabSwitcherStyle style,
TouchEventDispatcher touchEventDispatcher)
Creates a new layout, which implements the functionality of a
TabSwitcher on tablets. |
Modifier and Type | Method and Description |
---|---|
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 float |
calculateMinStartPosition(int index)
The method, which is invoked on implementing subclasses in order to retrieve the minimum
position of a specific item, when dragging towards the start.
|
protected android.support.v4.util.Pair<java.lang.Float,State> |
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 android.support.v4.util.Pair<java.lang.Float,State> |
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 de.mrapp.android.util.view.AbstractViewRecycler<Tab,java.lang.Void> |
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 de.mrapp.android.util.view.AttachedViewRecycler<AbstractItem,java.lang.Integer> |
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.
|
android.support.v7.widget.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.
|
void |
onAddTabButtonVisibilityChanged(boolean visible)
The method, which is invoked, when it has been changed, whether the button, which allows
to add a new tab, should be shown, or not.
|
void |
onAllTabsAdded(int index,
Tab[] tabs,
int previousSelectedTabIndex,
int selectedTabIndex,
boolean selectionChanged,
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 |
onApplyPaddingToTabsChanged(boolean applyPaddingToTabs)
The method, which is invoked, when it has been changed, whether the padding of the tab
switcher is applied to the content of its tabs, or not.
|
void |
onBackgroundColorChanged(Tab tab)
The method, which is invoked, when the tab's background color has been changed.
|
void |
onCloseableChanged(Tab tab)
The method, which is invoked, when it has been changed, whether the tab is closeable, or
not.
|
void |
onCloseButtonIconChanged(Tab tab)
The method, which is invoked, when the icon of the tab's close button has been changed.
|
void |
onContentBackgroundColorChanged(Tab tab)
The method, which is invoked, when the background color of the tab's content has been
changed.
|
protected de.mrapp.android.util.view.AbstractViewRecycler.Adapter<Tab,java.lang.Void> |
onCreateContentRecyclerAdapter()
The method, which is invoked on implementing subclasses in order to create the view recycler
adapter, which allows to inflate the views, which are associated with tabs.
|
protected android.support.v4.util.Pair<java.lang.Integer,java.lang.Float> |
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() |
void |
onIconChanged(Tab tab)
The method, which is invoked, when the tab's icon has been changed.
|
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 |
onProgressBarColorChanged(Tab tab)
The method, which is invoked, when the color of the tab's progress bar has been changed.
|
void |
onProgressBarVisibilityChanged(Tab tab)
The method, which is invoked, when the visibility of the tab's progress bar has been
changed.
|
void |
onSelectionChanged(int previousIndex,
int index,
Tab selectedTab,
boolean switcherHidden)
The method, which is invoked, when the currently selected tab has been changed.
|
void |
onSwitchingBetweenTabs(int selectedTabIndex,
float distance)
The method, which is invoked, when switching between neighboring tabs.
|
void |
onSwitchingBetweenTabsEnded(int selectedTabIndex,
int previousSelectedTabIndex,
boolean selectionChanged,
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 selectionChanged,
boolean switcherVisibilityChanged,
Animation animation)
The method, which is invoked, when a tab has been added to the model.
|
void |
onTabBackgroundColorChanged(android.content.res.ColorStateList colorStateList)
The method, which is invoked, when the background color of a tab has been changed.
|
void |
onTabRemoved(int index,
Tab tab,
int previousSelectedTabIndex,
int selectedTabIndex,
boolean selectionChanged,
Animation animation)
The method, which is invoked, when a tab has been removed from the model.
|
void |
onTitleChanged(Tab tab)
The method, which is invoked, when the tab's title has been changed.
|
void |
onTitleTextColorChanged(Tab tab)
The method, which is invoked, when the text color of the tab's title has been changed.
|
protected void |
secondLayoutPass(AbstractItemIterator.AbstractBuilder builder)
The method, which is called when dragging after the positions and states of all tabs have
been calculated.
|
protected void |
updateView(AbstractItem item,
boolean dragging)
Updates the view, which is used to visualize a specific item.
|
calculateAttachedPosition, calculatePositionAndStateWhenStackedAtStart, clipPosition, clipPosition, detachLayout, getArithmetics, getContext, getFirstVisibleIndex, getItemCount, getLogger, getModel, getStackedTabSpacing, getStyle, getTabSwitcher, getToolbarMenu, inflateLayout, inflateOrRemoveView, inflateView, isAnimationRunning, isOvershootingAtEnd, isOvershootingAtStart, isStackedAtStart, onAddedEventHandler, onAddTabButtonColorChanged, onCancelFling, onClick, onDecoratorChanged, onDrag, onFling, onLogLevelChanged, onPressEnded, onPressStarted, onPulledDown, onRemovedEventHandler, onRevertEndOvershoot, onRevertStartOvershoot, onSwipe, onSwipeEnded, onSwitcherHidden, onSwitcherShown, onTabCloseButtonIconChanged, onTabContentBackgroundColorChanged, onTabIconChanged, onTabProgressBarColorChanged, onTabTitleColorChanged, onToolbarMenuInflated, onToolbarNavigationIconChanged, onToolbarTitleChanged, onToolbarVisibilityChanged, setCallback, setFirstVisibleIndex
public TabletTabSwitcherLayout(@NonNull TabSwitcher tabSwitcher, @NonNull TabSwitcherModel model, @NonNull Arithmetics arithmetics, @NonNull TabSwitcherStyle style, @NonNull TouchEventDispatcher touchEventDispatcher)
TabSwitcher
on tablets.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 type
Arithmetics
. 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()
AbstractTabSwitcherLayout
getDragHandler
in class AbstractTabSwitcherLayout
AbstractDragTabsEventHandler
or null, if the drag handler has not been initialized yetprotected final void onInflateLayout(@NonNull android.view.LayoutInflater inflater, boolean tabsOnly)
AbstractTabSwitcherLayout
onInflateLayout
in class AbstractTabSwitcherLayout
inflater
- 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 otherwise@Nullable protected final android.support.v4.util.Pair<java.lang.Integer,java.lang.Float> onDetachLayout(boolean tabsOnly)
AbstractTabSwitcherLayout
onDetachLayout
in class AbstractTabSwitcherLayout
tabsOnly
- True, if only the tabs should be detached, false otherwiseprotected final de.mrapp.android.util.view.AbstractViewRecycler<Tab,java.lang.Void> getContentViewRecycler()
AbstractTabSwitcherLayout
getContentViewRecycler
in class AbstractTabSwitcherLayout
protected final de.mrapp.android.util.view.AttachedViewRecycler<AbstractItem,java.lang.Integer> getTabViewRecycler()
AbstractTabSwitcherLayout
getTabViewRecycler
in class AbstractTabSwitcherLayout
protected final AbstractTabRecyclerAdapter getTabRecyclerAdapter()
AbstractTabSwitcherLayout
getTabRecyclerAdapter
in class AbstractTabSwitcherLayout
AbstractTabRecyclerAdapter
or
null, if the view recycler has not been initialized yetprotected final void inflateAndUpdateView(@NonNull AbstractItem item, boolean dragging, @Nullable android.view.ViewTreeObserver.OnGlobalLayoutListener listener)
AbstractTabSwitcherLayout
inflateAndUpdateView
in class AbstractTabSwitcherLayout
item
- 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()
AbstractTabSwitcherLayout
getStackedTabCount
in class AbstractTabSwitcherLayout
Integer
value@NonNull protected final android.support.v4.util.Pair<java.lang.Float,State> calculatePositionAndStateWhenStackedAtStart(int count, int index, @Nullable State predecessorState)
AbstractTabSwitcherLayout
calculatePositionAndStateWhenStackedAtStart
in class AbstractTabSwitcherLayout
count
- 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 predecessor@NonNull protected final android.support.v4.util.Pair<java.lang.Float,State> calculatePositionAndStateWhenStackedAtEnd(int index)
AbstractTabSwitcherLayout
calculatePositionAndStateWhenStackedAtEnd
in class AbstractTabSwitcherLayout
index
- The index of the item, whose position and state should be returned, as an Integer
valueprotected final float calculateMinStartPosition(int index)
AbstractTabSwitcherLayout
calculateMinStartPosition
in class AbstractTabSwitcherLayout
index
- The index of the item, whose position should be calculated, as an Integer
valueFloat
value or -1, if no
minimum position is availableprotected final float calculateMaxEndPosition(int index)
AbstractTabSwitcherLayout
calculateMaxEndPosition
in class AbstractTabSwitcherLayout
index
- 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(@NonNull AbstractItem item, @NonNull AbstractItem predecessor)
AbstractTabSwitcherLayout
calculateSuccessorPosition
in class AbstractTabSwitcherLayout
item
- 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(@NonNull AbstractItem item, @NonNull AbstractItem successor)
AbstractTabSwitcherLayout
calculatePredecessorPosition
in class AbstractTabSwitcherLayout
item
- 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
valueprotected final void secondLayoutPass(@NonNull AbstractItemIterator.AbstractBuilder builder)
AbstractTabSwitcherLayout
secondLayoutPass
in class AbstractTabSwitcherLayout
builder
- The builder, which allows to create the iterator, which should be used to iterate the
tabs, as an instance of the class AbstractItemIterator.AbstractBuilder
. The
builder may not be null@NonNull protected final de.mrapp.android.util.view.AbstractViewRecycler.Adapter<Tab,java.lang.Void> onCreateContentRecyclerAdapter()
AbstractTabSwitcherLayout
onCreateContentRecyclerAdapter
in class AbstractTabSwitcherLayout
public final void onGlobalLayout()
onGlobalLayout
in interface android.view.ViewTreeObserver.OnGlobalLayoutListener
@Nullable public final android.view.ViewGroup getTabContainer()
TabSwitcherLayout
getTabContainer
in interface TabSwitcherLayout
ViewGroup
or null, if the view has not been laid out yet@Nullable public final android.support.v7.widget.Toolbar[] getToolbars()
TabSwitcherLayout
TabSwitcher.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 TabSwitcherLayout
public final void onSelectionChanged(int previousIndex, int index, @Nullable Tab selectedTab, boolean switcherHidden)
Model.Listener
onSelectionChanged
in interface Model.Listener
previousIndex
- 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 otherwiseprotected final void updateView(@NonNull AbstractItem item, boolean dragging)
AbstractTabSwitcherLayout
updateView
in class AbstractTabSwitcherLayout
item
- 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 otherwisepublic final void onTabAdded(int index, @NonNull Tab tab, int previousSelectedTabIndex, int selectedTabIndex, boolean selectionChanged, boolean switcherVisibilityChanged, @NonNull Animation animation)
Model.Listener
onTabAdded
in interface Model.Listener
index
- 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 tabsselectionChanged
- True, if the selection has changed, false otherwiseswitcherVisibilityChanged
- 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, @NonNull Tab[] tabs, int previousSelectedTabIndex, int selectedTabIndex, boolean selectionChanged, @NonNull Animation animation)
Model.Listener
onAllTabsAdded
in interface Model.Listener
index
- 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 tabsselectionChanged
- True, if the selection has changed, false otherwiseanimation
- 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, @NonNull Tab tab, int previousSelectedTabIndex, int selectedTabIndex, boolean selectionChanged, @NonNull Animation animation)
Model.Listener
onTabRemoved
in interface Model.Listener
index
- 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 tabsselectionChanged
- True, if the selection changed, false otherwiseanimation
- 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(@NonNull Tab[] tabs, @NonNull Animation animation)
Model.Listener
onAllTabsRemoved
in interface Model.Listener
tabs
- 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.Listener
onPaddingChanged
in interface Model.Listener
left
- 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 onApplyPaddingToTabsChanged(boolean applyPaddingToTabs)
Model.Listener
onApplyPaddingToTabsChanged
in interface Model.Listener
applyPaddingToTabs
- True, if the padding of the tab switcher is applied to the content of its tabs,
false otherwisepublic void onTabBackgroundColorChanged(@Nullable android.content.res.ColorStateList colorStateList)
Model.Listener
onTabBackgroundColorChanged
in interface Model.Listener
onTabBackgroundColorChanged
in class AbstractTabSwitcherLayout
colorStateList
- The color state list, which has been set, as an instance of the class ColorStateList
or null, if the default color should be usedpublic final void onAddTabButtonVisibilityChanged(boolean visible)
Model.Listener
onAddTabButtonVisibilityChanged
in interface Model.Listener
onAddTabButtonVisibilityChanged
in class AbstractTabSwitcherLayout
visible
- True, if the button, which allows to add a new tab, should be shown, false
otherwisepublic final void onEmptyViewChanged(@Nullable android.view.View view, long animationDuration)
Model.Listener
onEmptyViewChanged
in interface Model.Listener
view
- 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 onSwitchingBetweenTabs(int selectedTabIndex, float distance)
SwipeGestureEventHandler.Callback
onSwitchingBetweenTabs
in interface SwipeGestureEventHandler.Callback
selectedTabIndex
- 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, boolean selectionChanged, float velocity, long animationDuration)
SwipeGestureEventHandler.Callback
onSwitchingBetweenTabsEnded
in interface SwipeGestureEventHandler.Callback
selectedTabIndex
- The index of the tab, which should become selected, as an Integer
valuepreviousSelectedTabIndex
- The index of the previously selected tab as an Integer
valueselectionChanged
- True, if the selection has changed, false otherwisevelocity
- 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 onTitleChanged(@NonNull Tab tab)
Tab.Callback
onTitleChanged
in interface Tab.Callback
tab
- The observed tab as an instance of the class Tab
. The tab may not be
nullpublic final void onIconChanged(@NonNull Tab tab)
Tab.Callback
onIconChanged
in interface Tab.Callback
tab
- The observed tab as an instance of the class Tab
. The tab may not be
nullpublic final void onCloseableChanged(@NonNull Tab tab)
Tab.Callback
onCloseableChanged
in interface Tab.Callback
tab
- The observed tab as an instance of the class Tab
. The tab may not be
nullpublic final void onCloseButtonIconChanged(@NonNull Tab tab)
Tab.Callback
onCloseButtonIconChanged
in interface Tab.Callback
tab
- The observed tab as an instance of the class Tab
. The tab may not be
nullpublic final void onBackgroundColorChanged(@NonNull Tab tab)
Tab.Callback
onBackgroundColorChanged
in interface Tab.Callback
tab
- The observed tab as an instance of the class Tab
. The tab may not be
nullpublic final void onContentBackgroundColorChanged(@NonNull Tab tab)
Tab.Callback
onContentBackgroundColorChanged
in interface Tab.Callback
tab
- The observed tab as an instance of the class Tab
. The tab may not be
nullpublic final void onTitleTextColorChanged(@NonNull Tab tab)
Tab.Callback
onTitleTextColorChanged
in interface Tab.Callback
tab
- The observed tab as an instance of the class Tab
. The tab may not be
nullpublic final void onProgressBarVisibilityChanged(@NonNull Tab tab)
Tab.Callback
onProgressBarVisibilityChanged
in interface Tab.Callback
tab
- The observed tab as an instance of the class Tab
. The tab may not be
nullpublic final void onProgressBarColorChanged(@NonNull Tab tab)
Tab.Callback
onProgressBarColorChanged
in interface Tab.Callback
tab
- The observed tab as an instance of the class Tab
. The tab may not be
null