/** * Returns the adapter, which allows to inflate the views, which are associated with tabs. * * @return The adapter, which allows to inflate the views, which are associated with tabs, as an * instance of the class {@link ContentRecyclerAdapter} */ public final ContentRecyclerAdapter getContentRecyclerAdapter() { Condition.INSTANCE.ensureNotNull(contentRecyclerAdapter, "No decorator has been set", IllegalStateException.class); return contentRecyclerAdapter; }
/** * Sets the view recycler, which allows to inflate the views, which are used to visualize tabs. * * @param viewRecycler * The view recycler, which should be set, as an instance of the class * AttachedViewRecycler. The view recycler may not be null */ public final void setViewRecycler( @NonNull final AttachedViewRecycler<AbstractItem, Integer> viewRecycler) { Condition.INSTANCE.ensureNotNull(viewRecycler, "The view recycler may not be null"); this.viewRecycler = viewRecycler; }
/** * Creates a new comparator, which allows to compare two instances of the class {@link * AbstractItem}. * * @param tabSwitcher * The tab switcher, the tab items, which should be compared by the comparator, belong * to, as a instance of the class {@link TabSwitcher}. The tab switcher may not be null */ public ItemComparator(@NonNull final TabSwitcher tabSwitcher) { Condition.INSTANCE.ensureNotNull(tabSwitcher, "The tab switcher may not be null"); this.tabSwitcher = tabSwitcher; }
/** * Creates a new builder, which allows to configure and create instances of the class {@link * InitialItemIterator}. * * @param backingArray * The backing array, which should be used to store items, once their initial * position and state has been calculated. The backing array may not be null */ public InitialItemIteratorBuilder(@NonNull final AbstractItem[] backingArray) { Condition.INSTANCE.ensureNotNull(backingArray, "The backing array may not be null"); this.backingArray = backingArray; }
@Override public final float getTouchPosition(@NonNull final Axis axis, @NonNull final MotionEvent event) { Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null"); Condition.INSTANCE.ensureNotNull(event, "The motion event may not be null"); if (axis == Axis.DRAGGING_AXIS) { return event.getX(); } else { return event.getY(); } }
/** * Adds a new listener, which should be notified about the model's events. * * @param listener * The listener, which should be added, as an instance of the type {@link Listener}. The * listener may not be null */ public final void addListener(@NonNull final Listener listener) { Condition.INSTANCE.ensureNotNull(listener, "The listener may not be null"); listeners.add(listener); }
/** * Adds a listener, which should be notified about the tab switcher's events. * * @param listener * The listener, which should be added, as an instance of the type {@link * TabSwitcherListener}. The listener may not be null */ public final void addListener(@NonNull final TabSwitcherListener listener) { Condition.INSTANCE.ensureNotNull(listener, "The listener may not be null"); this.listeners.add(listener); }
/** * Removes a specific listener, which should not be notified about the tab switcher's events, * anymore. * * @param listener * The listener, which should be removed, as an instance of the type {@link * TabSwitcherListener}. The listener may not be null */ public final void removeListener(@NonNull final TabSwitcherListener listener) { Condition.INSTANCE.ensureNotNull(listener, "The listener may not be null"); this.listeners.remove(listener); }
@Override public final int indexOf(@NonNull final Tab tab) { Condition.INSTANCE.ensureNotNull(tab, "The tab may not be null"); return tabs.indexOf(tab); }
/** * Removes a specific listener, which should not be notified about the model's events, anymore. * * @param listener * The listener, which should be removed, as an instance of the type {@link Listener}. * The listener may not be null */ public final void removeListener(@NonNull final Listener listener) { Condition.INSTANCE.ensureNotNull(listener, "The listener may not be null"); listeners.remove(listener); }
/** * Clears the saved state of a specific tab. * * @param tab * The tab, whose saved state should be cleared, as an instance of the class {@link * Tab}. The tab may not be null */ public void clearSavedState(@NonNull final Tab tab) { Condition.INSTANCE.ensureNotNull(tab, "The tab may not be null"); savedInstanceStates.remove(tab.hashCode()); }
/** * Adds a new callback, which should be notified, when the tab's properties have been changed. * * @param callback * The callback, which should be added, as an instance of the type {@link Callback}. The * callback may not be null */ public final void addCallback(@NonNull final Callback callback) { Condition.INSTANCE.ensureNotNull(callback, "The callback may not be null"); this.callbacks.add(callback); }
@Override public final void setScale(@NonNull final Axis axis, @NonNull final AbstractItem item, final float scale) { Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null"); Condition.INSTANCE.ensureNotNull(item, "The item may not be null"); View view = item.getView(); if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) { view.setScaleY(scale); } else { view.setScaleX(scale); } }
@Override public final void setLogLevel(@NonNull final LogLevel logLevel) { Condition.INSTANCE.ensureNotNull(logLevel, "The log level may not be null"); this.logLevel = logLevel; notifyOnLogLevelChanged(logLevel); }
@Override public final void addCloseTabListener(@NonNull final TabCloseListener listener) { Condition.INSTANCE.ensureNotNull(listener, "The listener may not be null"); tabCloseListeners.add(listener); }
/** * Enqueues a specific action to be executed, when no animation is running. * * @param action * The action, which should be enqueued as an instance of the type {@link Runnable}. The * action may not be null */ private void enqueuePendingAction(@NonNull final Runnable action) { Condition.INSTANCE.ensureNotNull(action, "The action may not be null"); pendingActions.add(action); executePendingAction(); }
@Override public final void clear(@NonNull final Animation animation) { Condition.INSTANCE.ensureNotNull(animation, "The animation may not be null"); Tab[] result = new Tab[tabs.size()]; tabs.toArray(result); tabs.clear(); notifyOnAllTabsRemoved(result, animation); selectedTab = null; }
@Override public final void animateScale(@NonNull final Axis axis, @NonNull final ViewPropertyAnimator animator, final float scale) { Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null"); Condition.INSTANCE.ensureNotNull(animator, "The animator may not be null"); if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) { animator.scaleY(scale); } else { animator.scaleX(scale); } }
@Override public final float getSize(@NonNull final Axis axis, @NonNull final AbstractItem item) { Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null"); Condition.INSTANCE.ensureNotNull(item, "The item may not be null"); View view = item.getView(); if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) { return view.getHeight() * getScale(item); } else { return view.getWidth() * getScale(item); } }
@Override public final float getRotation(@NonNull final Axis axis, @NonNull final AbstractItem item) { Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null"); Condition.INSTANCE.ensureNotNull(item, "The view may not be null"); View view = item.getView(); if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) { return view.getRotationY(); } else { return view.getRotationX(); } }