mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
2155 lines
80 KiB
Java
2155 lines
80 KiB
Java
package com.google.android.material.tabs;
|
|
|
|
import android.animation.Animator;
|
|
import android.animation.TimeInterpolator;
|
|
import android.animation.ValueAnimator;
|
|
import android.content.Context;
|
|
import android.content.res.ColorStateList;
|
|
import android.database.DataSetObserver;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.Rect;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.graphics.drawable.GradientDrawable;
|
|
import android.graphics.drawable.RippleDrawable;
|
|
import android.text.Layout;
|
|
import android.text.TextUtils;
|
|
import android.util.AttributeSet;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewParent;
|
|
import android.view.accessibility.AccessibilityNodeInfo;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.HorizontalScrollView;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.appcompat.content.res.AppCompatResources;
|
|
import androidx.appcompat.widget.TooltipCompat;
|
|
import androidx.core.graphics.drawable.DrawableCompat;
|
|
import androidx.core.util.Pools;
|
|
import androidx.core.view.GravityCompat;
|
|
import androidx.core.view.MarginLayoutParamsCompat;
|
|
import androidx.core.view.PointerIconCompat;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
|
import androidx.core.widget.TextViewCompat;
|
|
import androidx.viewpager.widget.PagerAdapter;
|
|
import androidx.viewpager.widget.ViewPager;
|
|
import com.google.android.material.R;
|
|
import com.google.android.material.badge.BadgeDrawable;
|
|
import com.google.android.material.badge.BadgeUtils;
|
|
import com.google.android.material.drawable.DrawableUtils;
|
|
import com.google.android.material.internal.ViewUtils;
|
|
import com.google.android.material.ripple.RippleUtils;
|
|
import com.google.android.material.shape.MaterialShapeUtils;
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.RetentionPolicy;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
|
|
@ViewPager.DecorView
|
|
/* loaded from: classes2.dex */
|
|
public class TabLayout extends HorizontalScrollView {
|
|
private static final int ANIMATION_DURATION = 300;
|
|
static final int DEFAULT_GAP_TEXT_ICON = 8;
|
|
private static final int DEFAULT_HEIGHT = 48;
|
|
private static final int DEFAULT_HEIGHT_WITH_TEXT_ICON = 72;
|
|
static final int FIXED_WRAP_GUTTER_MIN = 16;
|
|
public static final int GRAVITY_CENTER = 1;
|
|
public static final int GRAVITY_FILL = 0;
|
|
public static final int GRAVITY_START = 2;
|
|
public static final int INDICATOR_ANIMATION_MODE_ELASTIC = 1;
|
|
public static final int INDICATOR_ANIMATION_MODE_FADE = 2;
|
|
public static final int INDICATOR_ANIMATION_MODE_LINEAR = 0;
|
|
public static final int INDICATOR_GRAVITY_BOTTOM = 0;
|
|
public static final int INDICATOR_GRAVITY_CENTER = 1;
|
|
public static final int INDICATOR_GRAVITY_STRETCH = 3;
|
|
public static final int INDICATOR_GRAVITY_TOP = 2;
|
|
private static final int INVALID_WIDTH = -1;
|
|
private static final String LOG_TAG = "TabLayout";
|
|
public static final int MODE_AUTO = 2;
|
|
public static final int MODE_FIXED = 1;
|
|
public static final int MODE_SCROLLABLE = 0;
|
|
private static final int SELECTED_INDICATOR_HEIGHT_DEFAULT = -1;
|
|
public static final int TAB_LABEL_VISIBILITY_LABELED = 1;
|
|
public static final int TAB_LABEL_VISIBILITY_UNLABELED = 0;
|
|
private static final int TAB_MIN_WIDTH_MARGIN = 56;
|
|
private AdapterChangeListener adapterChangeListener;
|
|
private int contentInsetStart;
|
|
private BaseOnTabSelectedListener currentVpSelectedListener;
|
|
private final int defaultTabTextAppearance;
|
|
int indicatorPosition;
|
|
boolean inlineLabel;
|
|
int mode;
|
|
private TabLayoutOnPageChangeListener pageChangeListener;
|
|
private PagerAdapter pagerAdapter;
|
|
private DataSetObserver pagerAdapterObserver;
|
|
private final int requestedTabMaxWidth;
|
|
private final int requestedTabMinWidth;
|
|
private ValueAnimator scrollAnimator;
|
|
private final int scrollableTabMinWidth;
|
|
private BaseOnTabSelectedListener selectedListener;
|
|
private final ArrayList<BaseOnTabSelectedListener> selectedListeners;
|
|
private Tab selectedTab;
|
|
private int selectedTabTextAppearance;
|
|
float selectedTabTextSize;
|
|
private boolean setupViewPagerImplicitly;
|
|
final SlidingTabIndicator slidingTabIndicator;
|
|
final int tabBackgroundResId;
|
|
int tabGravity;
|
|
ColorStateList tabIconTint;
|
|
PorterDuff.Mode tabIconTintMode;
|
|
int tabIndicatorAnimationDuration;
|
|
int tabIndicatorAnimationMode;
|
|
boolean tabIndicatorFullWidth;
|
|
int tabIndicatorGravity;
|
|
int tabIndicatorHeight;
|
|
private TabIndicatorInterpolator tabIndicatorInterpolator;
|
|
private final TimeInterpolator tabIndicatorTimeInterpolator;
|
|
int tabMaxWidth;
|
|
int tabPaddingBottom;
|
|
int tabPaddingEnd;
|
|
int tabPaddingStart;
|
|
int tabPaddingTop;
|
|
ColorStateList tabRippleColorStateList;
|
|
Drawable tabSelectedIndicator;
|
|
private int tabSelectedIndicatorColor;
|
|
private final int tabTextAppearance;
|
|
ColorStateList tabTextColors;
|
|
float tabTextMultiLineSize;
|
|
float tabTextSize;
|
|
private final Pools.Pool<TabView> tabViewPool;
|
|
private final ArrayList<Tab> tabs;
|
|
boolean unboundedRipple;
|
|
ViewPager viewPager;
|
|
private int viewPagerScrollState;
|
|
private static final int DEF_STYLE_RES = R.style.Widget_Design_TabLayout;
|
|
private static final Pools.Pool<Tab> tabPool = new Pools.SynchronizedPool(16);
|
|
|
|
@Deprecated
|
|
/* loaded from: classes2.dex */
|
|
public interface BaseOnTabSelectedListener<T extends Tab> {
|
|
void onTabReselected(T t);
|
|
|
|
void onTabSelected(T t);
|
|
|
|
void onTabUnselected(T t);
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public @interface LabelVisibility {
|
|
}
|
|
|
|
@Retention(RetentionPolicy.SOURCE)
|
|
/* loaded from: classes2.dex */
|
|
public @interface Mode {
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public interface OnTabSelectedListener extends BaseOnTabSelectedListener<Tab> {
|
|
}
|
|
|
|
@Retention(RetentionPolicy.SOURCE)
|
|
/* loaded from: classes2.dex */
|
|
public @interface TabGravity {
|
|
}
|
|
|
|
@Retention(RetentionPolicy.SOURCE)
|
|
/* loaded from: classes2.dex */
|
|
public @interface TabIndicatorAnimationMode {
|
|
}
|
|
|
|
@Retention(RetentionPolicy.SOURCE)
|
|
/* loaded from: classes2.dex */
|
|
public @interface TabIndicatorGravity {
|
|
}
|
|
|
|
private int getTabMinWidth() {
|
|
int i = this.requestedTabMinWidth;
|
|
if (i != -1) {
|
|
return i;
|
|
}
|
|
int i2 = this.mode;
|
|
if (i2 == 0 || i2 == 2) {
|
|
return this.scrollableTabMinWidth;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public int getTabGravity() {
|
|
return this.tabGravity;
|
|
}
|
|
|
|
public ColorStateList getTabIconTint() {
|
|
return this.tabIconTint;
|
|
}
|
|
|
|
public int getTabIndicatorAnimationMode() {
|
|
return this.tabIndicatorAnimationMode;
|
|
}
|
|
|
|
public int getTabIndicatorGravity() {
|
|
return this.tabIndicatorGravity;
|
|
}
|
|
|
|
int getTabMaxWidth() {
|
|
return this.tabMaxWidth;
|
|
}
|
|
|
|
public int getTabMode() {
|
|
return this.mode;
|
|
}
|
|
|
|
public ColorStateList getTabRippleColor() {
|
|
return this.tabRippleColorStateList;
|
|
}
|
|
|
|
public Drawable getTabSelectedIndicator() {
|
|
return this.tabSelectedIndicator;
|
|
}
|
|
|
|
public ColorStateList getTabTextColors() {
|
|
return this.tabTextColors;
|
|
}
|
|
|
|
public boolean hasUnboundedRipple() {
|
|
return this.unboundedRipple;
|
|
}
|
|
|
|
public boolean isInlineLabel() {
|
|
return this.inlineLabel;
|
|
}
|
|
|
|
public boolean isTabIndicatorFullWidth() {
|
|
return this.tabIndicatorFullWidth;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void updateViewPagerScrollState(int i) {
|
|
this.viewPagerScrollState = i;
|
|
}
|
|
|
|
public TabLayout(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
public TabLayout(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, R.attr.tabStyle);
|
|
}
|
|
|
|
/* JADX WARN: Illegal instructions before constructor call */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public TabLayout(android.content.Context r10, android.util.AttributeSet r11, int r12) {
|
|
/*
|
|
Method dump skipped, instructions count: 546
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.tabs.TabLayout.<init>(android.content.Context, android.util.AttributeSet, int):void");
|
|
}
|
|
|
|
public void setSelectedTabIndicatorColor(int i) {
|
|
this.tabSelectedIndicatorColor = i;
|
|
DrawableUtils.setTint(this.tabSelectedIndicator, i);
|
|
updateTabViews(false);
|
|
}
|
|
|
|
@Deprecated
|
|
public void setSelectedTabIndicatorHeight(int i) {
|
|
this.tabIndicatorHeight = i;
|
|
this.slidingTabIndicator.setSelectedIndicatorHeight(i);
|
|
}
|
|
|
|
public void setScrollPosition(int i, float f, boolean z) {
|
|
setScrollPosition(i, f, z, true);
|
|
}
|
|
|
|
public void setScrollPosition(int i, float f, boolean z, boolean z2) {
|
|
setScrollPosition(i, f, z, z2, true);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* JADX WARN: Code restructure failed: missing block: B:36:0x006e, code lost:
|
|
|
|
if (r10 == false) goto L42;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public void setScrollPosition(int r6, float r7, boolean r8, boolean r9, boolean r10) {
|
|
/*
|
|
r5 = this;
|
|
float r0 = (float) r6
|
|
float r0 = r0 + r7
|
|
int r0 = java.lang.Math.round(r0)
|
|
if (r0 < 0) goto L7b
|
|
com.google.android.material.tabs.TabLayout$SlidingTabIndicator r1 = r5.slidingTabIndicator
|
|
int r1 = r1.getChildCount()
|
|
if (r0 < r1) goto L12
|
|
goto L7b
|
|
L12:
|
|
if (r9 == 0) goto L19
|
|
com.google.android.material.tabs.TabLayout$SlidingTabIndicator r9 = r5.slidingTabIndicator
|
|
r9.setIndicatorPositionFromTabPosition(r6, r7)
|
|
L19:
|
|
android.animation.ValueAnimator r9 = r5.scrollAnimator
|
|
if (r9 == 0) goto L28
|
|
boolean r9 = r9.isRunning()
|
|
if (r9 == 0) goto L28
|
|
android.animation.ValueAnimator r9 = r5.scrollAnimator
|
|
r9.cancel()
|
|
L28:
|
|
int r7 = r5.calculateScrollXForTab(r6, r7)
|
|
int r9 = r5.getScrollX()
|
|
int r1 = r5.getSelectedTabPosition()
|
|
r2 = 0
|
|
r3 = 1
|
|
if (r6 >= r1) goto L3a
|
|
if (r7 >= r9) goto L48
|
|
L3a:
|
|
int r1 = r5.getSelectedTabPosition()
|
|
if (r6 <= r1) goto L42
|
|
if (r7 <= r9) goto L48
|
|
L42:
|
|
int r1 = r5.getSelectedTabPosition()
|
|
if (r6 != r1) goto L4a
|
|
L48:
|
|
r1 = r3
|
|
goto L4b
|
|
L4a:
|
|
r1 = r2
|
|
L4b:
|
|
int r4 = androidx.core.view.ViewCompat.getLayoutDirection(r5)
|
|
if (r4 != r3) goto L68
|
|
int r1 = r5.getSelectedTabPosition()
|
|
if (r6 >= r1) goto L59
|
|
if (r7 <= r9) goto L70
|
|
L59:
|
|
int r1 = r5.getSelectedTabPosition()
|
|
if (r6 <= r1) goto L61
|
|
if (r7 >= r9) goto L70
|
|
L61:
|
|
int r9 = r5.getSelectedTabPosition()
|
|
if (r6 != r9) goto L6a
|
|
goto L70
|
|
L68:
|
|
if (r1 != 0) goto L70
|
|
L6a:
|
|
int r9 = r5.viewPagerScrollState
|
|
if (r9 == r3) goto L70
|
|
if (r10 == 0) goto L76
|
|
L70:
|
|
if (r6 >= 0) goto L73
|
|
r7 = r2
|
|
L73:
|
|
r5.scrollTo(r7, r2)
|
|
L76:
|
|
if (r8 == 0) goto L7b
|
|
r5.setSelectedTabView(r0)
|
|
L7b:
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.tabs.TabLayout.setScrollPosition(int, float, boolean, boolean, boolean):void");
|
|
}
|
|
|
|
public void addTab(Tab tab) {
|
|
addTab(tab, this.tabs.isEmpty());
|
|
}
|
|
|
|
public void addTab(Tab tab, int i) {
|
|
addTab(tab, i, this.tabs.isEmpty());
|
|
}
|
|
|
|
public void addTab(Tab tab, boolean z) {
|
|
addTab(tab, this.tabs.size(), z);
|
|
}
|
|
|
|
public void addTab(Tab tab, int i, boolean z) {
|
|
if (tab.parent != this) {
|
|
throw new IllegalArgumentException("Tab belongs to a different TabLayout.");
|
|
}
|
|
configureTab(tab, i);
|
|
addTabView(tab);
|
|
if (z) {
|
|
tab.select();
|
|
}
|
|
}
|
|
|
|
private void addTabFromItemView(TabItem tabItem) {
|
|
Tab newTab = newTab();
|
|
if (tabItem.text != null) {
|
|
newTab.setText(tabItem.text);
|
|
}
|
|
if (tabItem.icon != null) {
|
|
newTab.setIcon(tabItem.icon);
|
|
}
|
|
if (tabItem.customLayout != 0) {
|
|
newTab.setCustomView(tabItem.customLayout);
|
|
}
|
|
if (!TextUtils.isEmpty(tabItem.getContentDescription())) {
|
|
newTab.setContentDescription(tabItem.getContentDescription());
|
|
}
|
|
addTab(newTab);
|
|
}
|
|
|
|
private boolean isScrollingEnabled() {
|
|
return getTabMode() == 0 || getTabMode() == 2;
|
|
}
|
|
|
|
@Override // android.widget.HorizontalScrollView, android.view.ViewGroup
|
|
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
|
|
return isScrollingEnabled() && super.onInterceptTouchEvent(motionEvent);
|
|
}
|
|
|
|
@Override // android.widget.HorizontalScrollView, android.view.View
|
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
|
if (motionEvent.getActionMasked() != 8 || isScrollingEnabled()) {
|
|
return super.onTouchEvent(motionEvent);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Deprecated
|
|
public void setOnTabSelectedListener(OnTabSelectedListener onTabSelectedListener) {
|
|
setOnTabSelectedListener((BaseOnTabSelectedListener) onTabSelectedListener);
|
|
}
|
|
|
|
@Deprecated
|
|
public void setOnTabSelectedListener(BaseOnTabSelectedListener baseOnTabSelectedListener) {
|
|
BaseOnTabSelectedListener baseOnTabSelectedListener2 = this.selectedListener;
|
|
if (baseOnTabSelectedListener2 != null) {
|
|
removeOnTabSelectedListener(baseOnTabSelectedListener2);
|
|
}
|
|
this.selectedListener = baseOnTabSelectedListener;
|
|
if (baseOnTabSelectedListener != null) {
|
|
addOnTabSelectedListener(baseOnTabSelectedListener);
|
|
}
|
|
}
|
|
|
|
public void addOnTabSelectedListener(OnTabSelectedListener onTabSelectedListener) {
|
|
addOnTabSelectedListener((BaseOnTabSelectedListener) onTabSelectedListener);
|
|
}
|
|
|
|
@Deprecated
|
|
public void addOnTabSelectedListener(BaseOnTabSelectedListener baseOnTabSelectedListener) {
|
|
if (this.selectedListeners.contains(baseOnTabSelectedListener)) {
|
|
return;
|
|
}
|
|
this.selectedListeners.add(baseOnTabSelectedListener);
|
|
}
|
|
|
|
public void removeOnTabSelectedListener(OnTabSelectedListener onTabSelectedListener) {
|
|
removeOnTabSelectedListener((BaseOnTabSelectedListener) onTabSelectedListener);
|
|
}
|
|
|
|
@Deprecated
|
|
public void removeOnTabSelectedListener(BaseOnTabSelectedListener baseOnTabSelectedListener) {
|
|
this.selectedListeners.remove(baseOnTabSelectedListener);
|
|
}
|
|
|
|
public void clearOnTabSelectedListeners() {
|
|
this.selectedListeners.clear();
|
|
}
|
|
|
|
public Tab newTab() {
|
|
Tab createTabFromPool = createTabFromPool();
|
|
createTabFromPool.parent = this;
|
|
createTabFromPool.view = createTabView(createTabFromPool);
|
|
if (createTabFromPool.id != -1) {
|
|
createTabFromPool.view.setId(createTabFromPool.id);
|
|
}
|
|
return createTabFromPool;
|
|
}
|
|
|
|
protected Tab createTabFromPool() {
|
|
Tab acquire = tabPool.acquire();
|
|
return acquire == null ? new Tab() : acquire;
|
|
}
|
|
|
|
protected boolean releaseFromTabPool(Tab tab) {
|
|
return tabPool.release(tab);
|
|
}
|
|
|
|
public int getTabCount() {
|
|
return this.tabs.size();
|
|
}
|
|
|
|
public Tab getTabAt(int i) {
|
|
if (i < 0 || i >= getTabCount()) {
|
|
return null;
|
|
}
|
|
return this.tabs.get(i);
|
|
}
|
|
|
|
public int getSelectedTabPosition() {
|
|
Tab tab = this.selectedTab;
|
|
if (tab != null) {
|
|
return tab.getPosition();
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public void removeTab(Tab tab) {
|
|
if (tab.parent != this) {
|
|
throw new IllegalArgumentException("Tab does not belong to this TabLayout.");
|
|
}
|
|
removeTabAt(tab.getPosition());
|
|
}
|
|
|
|
public void removeTabAt(int i) {
|
|
Tab tab = this.selectedTab;
|
|
int position = tab != null ? tab.getPosition() : 0;
|
|
removeTabViewAt(i);
|
|
Tab remove = this.tabs.remove(i);
|
|
if (remove != null) {
|
|
remove.reset();
|
|
releaseFromTabPool(remove);
|
|
}
|
|
int size = this.tabs.size();
|
|
int i2 = -1;
|
|
for (int i3 = i; i3 < size; i3++) {
|
|
if (this.tabs.get(i3).getPosition() == this.indicatorPosition) {
|
|
i2 = i3;
|
|
}
|
|
this.tabs.get(i3).setPosition(i3);
|
|
}
|
|
this.indicatorPosition = i2;
|
|
if (position == i) {
|
|
selectTab(this.tabs.isEmpty() ? null : this.tabs.get(Math.max(0, i - 1)));
|
|
}
|
|
}
|
|
|
|
public void removeAllTabs() {
|
|
for (int childCount = this.slidingTabIndicator.getChildCount() - 1; childCount >= 0; childCount--) {
|
|
removeTabViewAt(childCount);
|
|
}
|
|
Iterator<Tab> it = this.tabs.iterator();
|
|
while (it.hasNext()) {
|
|
Tab next = it.next();
|
|
it.remove();
|
|
next.reset();
|
|
releaseFromTabPool(next);
|
|
}
|
|
this.selectedTab = null;
|
|
}
|
|
|
|
public void setTabMode(int i) {
|
|
if (i != this.mode) {
|
|
this.mode = i;
|
|
applyModeAndGravity();
|
|
}
|
|
}
|
|
|
|
public void setTabGravity(int i) {
|
|
if (this.tabGravity != i) {
|
|
this.tabGravity = i;
|
|
applyModeAndGravity();
|
|
}
|
|
}
|
|
|
|
public void setSelectedTabIndicatorGravity(int i) {
|
|
if (this.tabIndicatorGravity != i) {
|
|
this.tabIndicatorGravity = i;
|
|
ViewCompat.postInvalidateOnAnimation(this.slidingTabIndicator);
|
|
}
|
|
}
|
|
|
|
public void setTabIndicatorAnimationMode(int i) {
|
|
this.tabIndicatorAnimationMode = i;
|
|
if (i == 0) {
|
|
this.tabIndicatorInterpolator = new TabIndicatorInterpolator();
|
|
} else if (i == 1) {
|
|
this.tabIndicatorInterpolator = new ElasticTabIndicatorInterpolator();
|
|
} else {
|
|
if (i == 2) {
|
|
this.tabIndicatorInterpolator = new FadeTabIndicatorInterpolator();
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException(i + " is not a valid TabIndicatorAnimationMode");
|
|
}
|
|
}
|
|
|
|
public void setTabIndicatorFullWidth(boolean z) {
|
|
this.tabIndicatorFullWidth = z;
|
|
this.slidingTabIndicator.jumpIndicatorToSelectedPosition();
|
|
ViewCompat.postInvalidateOnAnimation(this.slidingTabIndicator);
|
|
}
|
|
|
|
public void setInlineLabel(boolean z) {
|
|
if (this.inlineLabel != z) {
|
|
this.inlineLabel = z;
|
|
for (int i = 0; i < this.slidingTabIndicator.getChildCount(); i++) {
|
|
View childAt = this.slidingTabIndicator.getChildAt(i);
|
|
if (childAt instanceof TabView) {
|
|
((TabView) childAt).updateOrientation();
|
|
}
|
|
}
|
|
applyModeAndGravity();
|
|
}
|
|
}
|
|
|
|
public void setInlineLabelResource(int i) {
|
|
setInlineLabel(getResources().getBoolean(i));
|
|
}
|
|
|
|
public void setUnboundedRipple(boolean z) {
|
|
if (this.unboundedRipple != z) {
|
|
this.unboundedRipple = z;
|
|
for (int i = 0; i < this.slidingTabIndicator.getChildCount(); i++) {
|
|
View childAt = this.slidingTabIndicator.getChildAt(i);
|
|
if (childAt instanceof TabView) {
|
|
((TabView) childAt).updateBackgroundDrawable(getContext());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setUnboundedRippleResource(int i) {
|
|
setUnboundedRipple(getResources().getBoolean(i));
|
|
}
|
|
|
|
public void setTabTextColors(ColorStateList colorStateList) {
|
|
if (this.tabTextColors != colorStateList) {
|
|
this.tabTextColors = colorStateList;
|
|
updateAllTabs();
|
|
}
|
|
}
|
|
|
|
public void setTabTextColors(int i, int i2) {
|
|
setTabTextColors(createColorStateList(i, i2));
|
|
}
|
|
|
|
public void setTabIconTint(ColorStateList colorStateList) {
|
|
if (this.tabIconTint != colorStateList) {
|
|
this.tabIconTint = colorStateList;
|
|
updateAllTabs();
|
|
}
|
|
}
|
|
|
|
public void setTabIconTintResource(int i) {
|
|
setTabIconTint(AppCompatResources.getColorStateList(getContext(), i));
|
|
}
|
|
|
|
public void setTabRippleColor(ColorStateList colorStateList) {
|
|
if (this.tabRippleColorStateList != colorStateList) {
|
|
this.tabRippleColorStateList = colorStateList;
|
|
for (int i = 0; i < this.slidingTabIndicator.getChildCount(); i++) {
|
|
View childAt = this.slidingTabIndicator.getChildAt(i);
|
|
if (childAt instanceof TabView) {
|
|
((TabView) childAt).updateBackgroundDrawable(getContext());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setTabRippleColorResource(int i) {
|
|
setTabRippleColor(AppCompatResources.getColorStateList(getContext(), i));
|
|
}
|
|
|
|
public void setSelectedTabIndicator(Drawable drawable) {
|
|
if (drawable == null) {
|
|
drawable = new GradientDrawable();
|
|
}
|
|
Drawable mutate = DrawableCompat.wrap(drawable).mutate();
|
|
this.tabSelectedIndicator = mutate;
|
|
DrawableUtils.setTint(mutate, this.tabSelectedIndicatorColor);
|
|
int i = this.tabIndicatorHeight;
|
|
if (i == -1) {
|
|
i = this.tabSelectedIndicator.getIntrinsicHeight();
|
|
}
|
|
this.slidingTabIndicator.setSelectedIndicatorHeight(i);
|
|
}
|
|
|
|
public void setSelectedTabIndicator(int i) {
|
|
if (i != 0) {
|
|
setSelectedTabIndicator(AppCompatResources.getDrawable(getContext(), i));
|
|
} else {
|
|
setSelectedTabIndicator((Drawable) null);
|
|
}
|
|
}
|
|
|
|
public void setupWithViewPager(ViewPager viewPager) {
|
|
setupWithViewPager(viewPager, true);
|
|
}
|
|
|
|
public void setupWithViewPager(ViewPager viewPager, boolean z) {
|
|
setupWithViewPager(viewPager, z, false);
|
|
}
|
|
|
|
private void setupWithViewPager(ViewPager viewPager, boolean z, boolean z2) {
|
|
ViewPager viewPager2 = this.viewPager;
|
|
if (viewPager2 != null) {
|
|
TabLayoutOnPageChangeListener tabLayoutOnPageChangeListener = this.pageChangeListener;
|
|
if (tabLayoutOnPageChangeListener != null) {
|
|
viewPager2.removeOnPageChangeListener(tabLayoutOnPageChangeListener);
|
|
}
|
|
AdapterChangeListener adapterChangeListener = this.adapterChangeListener;
|
|
if (adapterChangeListener != null) {
|
|
this.viewPager.removeOnAdapterChangeListener(adapterChangeListener);
|
|
}
|
|
}
|
|
BaseOnTabSelectedListener baseOnTabSelectedListener = this.currentVpSelectedListener;
|
|
if (baseOnTabSelectedListener != null) {
|
|
removeOnTabSelectedListener(baseOnTabSelectedListener);
|
|
this.currentVpSelectedListener = null;
|
|
}
|
|
if (viewPager != null) {
|
|
this.viewPager = viewPager;
|
|
if (this.pageChangeListener == null) {
|
|
this.pageChangeListener = new TabLayoutOnPageChangeListener(this);
|
|
}
|
|
this.pageChangeListener.reset();
|
|
viewPager.addOnPageChangeListener(this.pageChangeListener);
|
|
ViewPagerOnTabSelectedListener viewPagerOnTabSelectedListener = new ViewPagerOnTabSelectedListener(viewPager);
|
|
this.currentVpSelectedListener = viewPagerOnTabSelectedListener;
|
|
addOnTabSelectedListener((BaseOnTabSelectedListener) viewPagerOnTabSelectedListener);
|
|
PagerAdapter adapter = viewPager.getAdapter();
|
|
if (adapter != null) {
|
|
setPagerAdapter(adapter, z);
|
|
}
|
|
if (this.adapterChangeListener == null) {
|
|
this.adapterChangeListener = new AdapterChangeListener();
|
|
}
|
|
this.adapterChangeListener.setAutoRefresh(z);
|
|
viewPager.addOnAdapterChangeListener(this.adapterChangeListener);
|
|
setScrollPosition(viewPager.getCurrentItem(), 0.0f, true);
|
|
} else {
|
|
this.viewPager = null;
|
|
setPagerAdapter(null, false);
|
|
}
|
|
this.setupViewPagerImplicitly = z2;
|
|
}
|
|
|
|
@Deprecated
|
|
public void setTabsFromPagerAdapter(PagerAdapter pagerAdapter) {
|
|
setPagerAdapter(pagerAdapter, false);
|
|
}
|
|
|
|
@Override // android.widget.HorizontalScrollView, android.widget.FrameLayout, android.view.ViewGroup
|
|
public boolean shouldDelayChildPressedState() {
|
|
return getTabScrollRange() > 0;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void onAttachedToWindow() {
|
|
super.onAttachedToWindow();
|
|
MaterialShapeUtils.setParentAbsoluteElevation(this);
|
|
if (this.viewPager == null) {
|
|
ViewParent parent = getParent();
|
|
if (parent instanceof ViewPager) {
|
|
setupWithViewPager((ViewPager) parent, true, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void onDetachedFromWindow() {
|
|
super.onDetachedFromWindow();
|
|
if (this.setupViewPagerImplicitly) {
|
|
setupWithViewPager(null);
|
|
this.setupViewPagerImplicitly = false;
|
|
}
|
|
}
|
|
|
|
private int getTabScrollRange() {
|
|
return Math.max(0, ((this.slidingTabIndicator.getWidth() - getWidth()) - getPaddingLeft()) - getPaddingRight());
|
|
}
|
|
|
|
void setPagerAdapter(PagerAdapter pagerAdapter, boolean z) {
|
|
DataSetObserver dataSetObserver;
|
|
PagerAdapter pagerAdapter2 = this.pagerAdapter;
|
|
if (pagerAdapter2 != null && (dataSetObserver = this.pagerAdapterObserver) != null) {
|
|
pagerAdapter2.unregisterDataSetObserver(dataSetObserver);
|
|
}
|
|
this.pagerAdapter = pagerAdapter;
|
|
if (z && pagerAdapter != null) {
|
|
if (this.pagerAdapterObserver == null) {
|
|
this.pagerAdapterObserver = new PagerAdapterObserver();
|
|
}
|
|
pagerAdapter.registerDataSetObserver(this.pagerAdapterObserver);
|
|
}
|
|
populateFromPagerAdapter();
|
|
}
|
|
|
|
void populateFromPagerAdapter() {
|
|
int currentItem;
|
|
removeAllTabs();
|
|
PagerAdapter pagerAdapter = this.pagerAdapter;
|
|
if (pagerAdapter != null) {
|
|
int count = pagerAdapter.getCount();
|
|
for (int i = 0; i < count; i++) {
|
|
addTab(newTab().setText(this.pagerAdapter.getPageTitle(i)), false);
|
|
}
|
|
ViewPager viewPager = this.viewPager;
|
|
if (viewPager == null || count <= 0 || (currentItem = viewPager.getCurrentItem()) == getSelectedTabPosition() || currentItem >= getTabCount()) {
|
|
return;
|
|
}
|
|
selectTab(getTabAt(currentItem));
|
|
}
|
|
}
|
|
|
|
private void updateAllTabs() {
|
|
int size = this.tabs.size();
|
|
for (int i = 0; i < size; i++) {
|
|
this.tabs.get(i).updateView();
|
|
}
|
|
}
|
|
|
|
private TabView createTabView(Tab tab) {
|
|
Pools.Pool<TabView> pool = this.tabViewPool;
|
|
TabView acquire = pool != null ? pool.acquire() : null;
|
|
if (acquire == null) {
|
|
acquire = new TabView(getContext());
|
|
}
|
|
acquire.setTab(tab);
|
|
acquire.setFocusable(true);
|
|
acquire.setMinimumWidth(getTabMinWidth());
|
|
if (TextUtils.isEmpty(tab.contentDesc)) {
|
|
acquire.setContentDescription(tab.text);
|
|
} else {
|
|
acquire.setContentDescription(tab.contentDesc);
|
|
}
|
|
return acquire;
|
|
}
|
|
|
|
private void configureTab(Tab tab, int i) {
|
|
tab.setPosition(i);
|
|
this.tabs.add(i, tab);
|
|
int size = this.tabs.size();
|
|
int i2 = -1;
|
|
for (int i3 = i + 1; i3 < size; i3++) {
|
|
if (this.tabs.get(i3).getPosition() == this.indicatorPosition) {
|
|
i2 = i3;
|
|
}
|
|
this.tabs.get(i3).setPosition(i3);
|
|
}
|
|
this.indicatorPosition = i2;
|
|
}
|
|
|
|
private void addTabView(Tab tab) {
|
|
TabView tabView = tab.view;
|
|
tabView.setSelected(false);
|
|
tabView.setActivated(false);
|
|
this.slidingTabIndicator.addView(tabView, tab.getPosition(), createLayoutParamsForTabs());
|
|
}
|
|
|
|
@Override // android.widget.HorizontalScrollView, android.view.ViewGroup
|
|
public void addView(View view) {
|
|
addViewInternal(view);
|
|
}
|
|
|
|
@Override // android.widget.HorizontalScrollView, android.view.ViewGroup
|
|
public void addView(View view, int i) {
|
|
addViewInternal(view);
|
|
}
|
|
|
|
@Override // android.widget.HorizontalScrollView, android.view.ViewGroup, android.view.ViewManager
|
|
public void addView(View view, ViewGroup.LayoutParams layoutParams) {
|
|
addViewInternal(view);
|
|
}
|
|
|
|
@Override // android.widget.HorizontalScrollView, android.view.ViewGroup
|
|
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
|
|
addViewInternal(view);
|
|
}
|
|
|
|
private void addViewInternal(View view) {
|
|
if (view instanceof TabItem) {
|
|
addTabFromItemView((TabItem) view);
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("Only TabItem instances can be added to TabLayout");
|
|
}
|
|
|
|
private LinearLayout.LayoutParams createLayoutParamsForTabs() {
|
|
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -1);
|
|
updateTabViewLayoutParams(layoutParams);
|
|
return layoutParams;
|
|
}
|
|
|
|
private void updateTabViewLayoutParams(LinearLayout.LayoutParams layoutParams) {
|
|
if (this.mode == 1 && this.tabGravity == 0) {
|
|
layoutParams.width = 0;
|
|
layoutParams.weight = 1.0f;
|
|
} else {
|
|
layoutParams.width = -2;
|
|
layoutParams.weight = 0.0f;
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void setElevation(float f) {
|
|
super.setElevation(f);
|
|
MaterialShapeUtils.setElevation(this, f);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
|
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
|
AccessibilityNodeInfoCompat.wrap(accessibilityNodeInfo).setCollectionInfo(AccessibilityNodeInfoCompat.CollectionInfoCompat.obtain(1, getTabCount(), false, 1));
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onDraw(Canvas canvas) {
|
|
for (int i = 0; i < this.slidingTabIndicator.getChildCount(); i++) {
|
|
View childAt = this.slidingTabIndicator.getChildAt(i);
|
|
if (childAt instanceof TabView) {
|
|
((TabView) childAt).drawBackground(canvas);
|
|
}
|
|
}
|
|
super.onDraw(canvas);
|
|
}
|
|
|
|
@Override // android.widget.HorizontalScrollView, android.widget.FrameLayout, android.view.View
|
|
protected void onMeasure(int i, int i2) {
|
|
int round = Math.round(ViewUtils.dpToPx(getContext(), getDefaultHeight()));
|
|
int mode = View.MeasureSpec.getMode(i2);
|
|
if (mode != Integer.MIN_VALUE) {
|
|
if (mode == 0) {
|
|
i2 = View.MeasureSpec.makeMeasureSpec(round + getPaddingTop() + getPaddingBottom(), 1073741824);
|
|
}
|
|
} else if (getChildCount() == 1 && View.MeasureSpec.getSize(i2) >= round) {
|
|
getChildAt(0).setMinimumHeight(round);
|
|
}
|
|
int size = View.MeasureSpec.getSize(i);
|
|
if (View.MeasureSpec.getMode(i) != 0) {
|
|
int i3 = this.requestedTabMaxWidth;
|
|
if (i3 <= 0) {
|
|
i3 = (int) (size - ViewUtils.dpToPx(getContext(), TAB_MIN_WIDTH_MARGIN));
|
|
}
|
|
this.tabMaxWidth = i3;
|
|
}
|
|
super.onMeasure(i, i2);
|
|
if (getChildCount() == 1) {
|
|
View childAt = getChildAt(0);
|
|
int i4 = this.mode;
|
|
if (i4 != 0) {
|
|
if (i4 == 1) {
|
|
if (childAt.getMeasuredWidth() == getMeasuredWidth()) {
|
|
return;
|
|
}
|
|
childAt.measure(View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 1073741824), getChildMeasureSpec(i2, getPaddingTop() + getPaddingBottom(), childAt.getLayoutParams().height));
|
|
}
|
|
if (i4 != 2) {
|
|
return;
|
|
}
|
|
}
|
|
if (childAt.getMeasuredWidth() >= getMeasuredWidth()) {
|
|
return;
|
|
}
|
|
childAt.measure(View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 1073741824), getChildMeasureSpec(i2, getPaddingTop() + getPaddingBottom(), childAt.getLayoutParams().height));
|
|
}
|
|
}
|
|
|
|
private void removeTabViewAt(int i) {
|
|
TabView tabView = (TabView) this.slidingTabIndicator.getChildAt(i);
|
|
this.slidingTabIndicator.removeViewAt(i);
|
|
if (tabView != null) {
|
|
tabView.reset();
|
|
this.tabViewPool.release(tabView);
|
|
}
|
|
requestLayout();
|
|
}
|
|
|
|
private void animateToTab(int i) {
|
|
if (i == -1) {
|
|
return;
|
|
}
|
|
if (getWindowToken() == null || !ViewCompat.isLaidOut(this) || this.slidingTabIndicator.childrenNeedLayout()) {
|
|
setScrollPosition(i, 0.0f, true);
|
|
return;
|
|
}
|
|
int scrollX = getScrollX();
|
|
int calculateScrollXForTab = calculateScrollXForTab(i, 0.0f);
|
|
if (scrollX != calculateScrollXForTab) {
|
|
ensureScrollAnimator();
|
|
this.scrollAnimator.setIntValues(scrollX, calculateScrollXForTab);
|
|
this.scrollAnimator.start();
|
|
}
|
|
this.slidingTabIndicator.animateIndicatorToPosition(i, this.tabIndicatorAnimationDuration);
|
|
}
|
|
|
|
private void ensureScrollAnimator() {
|
|
if (this.scrollAnimator == null) {
|
|
ValueAnimator valueAnimator = new ValueAnimator();
|
|
this.scrollAnimator = valueAnimator;
|
|
valueAnimator.setInterpolator(this.tabIndicatorTimeInterpolator);
|
|
this.scrollAnimator.setDuration(this.tabIndicatorAnimationDuration);
|
|
this.scrollAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.tabs.TabLayout.1
|
|
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
|
public void onAnimationUpdate(ValueAnimator valueAnimator2) {
|
|
TabLayout.this.scrollTo(((Integer) valueAnimator2.getAnimatedValue()).intValue(), 0);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
void setScrollAnimatorListener(Animator.AnimatorListener animatorListener) {
|
|
ensureScrollAnimator();
|
|
this.scrollAnimator.addListener(animatorListener);
|
|
}
|
|
|
|
private void setSelectedTabView(int i) {
|
|
int childCount = this.slidingTabIndicator.getChildCount();
|
|
if (i < childCount) {
|
|
int i2 = 0;
|
|
while (i2 < childCount) {
|
|
View childAt = this.slidingTabIndicator.getChildAt(i2);
|
|
if ((i2 == i && !childAt.isSelected()) || (i2 != i && childAt.isSelected())) {
|
|
childAt.setSelected(i2 == i);
|
|
childAt.setActivated(i2 == i);
|
|
if (childAt instanceof TabView) {
|
|
((TabView) childAt).updateTab();
|
|
}
|
|
} else {
|
|
childAt.setSelected(i2 == i);
|
|
childAt.setActivated(i2 == i);
|
|
}
|
|
i2++;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void selectTab(Tab tab) {
|
|
selectTab(tab, true);
|
|
}
|
|
|
|
public void selectTab(Tab tab, boolean z) {
|
|
Tab tab2 = this.selectedTab;
|
|
if (tab2 == tab) {
|
|
if (tab2 != null) {
|
|
dispatchTabReselected(tab);
|
|
animateToTab(tab.getPosition());
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
int position = tab != null ? tab.getPosition() : -1;
|
|
if (z) {
|
|
if ((tab2 == null || tab2.getPosition() == -1) && position != -1) {
|
|
setScrollPosition(position, 0.0f, true);
|
|
} else {
|
|
animateToTab(position);
|
|
}
|
|
if (position != -1) {
|
|
setSelectedTabView(position);
|
|
}
|
|
}
|
|
this.selectedTab = tab;
|
|
if (tab2 != null && tab2.parent != null) {
|
|
dispatchTabUnselected(tab2);
|
|
}
|
|
if (tab != null) {
|
|
dispatchTabSelected(tab);
|
|
}
|
|
}
|
|
|
|
private void dispatchTabSelected(Tab tab) {
|
|
for (int size = this.selectedListeners.size() - 1; size >= 0; size--) {
|
|
this.selectedListeners.get(size).onTabSelected(tab);
|
|
}
|
|
}
|
|
|
|
private void dispatchTabUnselected(Tab tab) {
|
|
for (int size = this.selectedListeners.size() - 1; size >= 0; size--) {
|
|
this.selectedListeners.get(size).onTabUnselected(tab);
|
|
}
|
|
}
|
|
|
|
private void dispatchTabReselected(Tab tab) {
|
|
for (int size = this.selectedListeners.size() - 1; size >= 0; size--) {
|
|
this.selectedListeners.get(size).onTabReselected(tab);
|
|
}
|
|
}
|
|
|
|
private int calculateScrollXForTab(int i, float f) {
|
|
View childAt;
|
|
int i2 = this.mode;
|
|
if ((i2 != 0 && i2 != 2) || (childAt = this.slidingTabIndicator.getChildAt(i)) == null) {
|
|
return 0;
|
|
}
|
|
int i3 = i + 1;
|
|
View childAt2 = i3 < this.slidingTabIndicator.getChildCount() ? this.slidingTabIndicator.getChildAt(i3) : null;
|
|
int width = childAt.getWidth();
|
|
int width2 = childAt2 != null ? childAt2.getWidth() : 0;
|
|
int left = (childAt.getLeft() + (width / 2)) - (getWidth() / 2);
|
|
int i4 = (int) ((width + width2) * 0.5f * f);
|
|
return ViewCompat.getLayoutDirection(this) == 0 ? left + i4 : left - i4;
|
|
}
|
|
|
|
private void applyModeAndGravity() {
|
|
int i = this.mode;
|
|
ViewCompat.setPaddingRelative(this.slidingTabIndicator, (i == 0 || i == 2) ? Math.max(0, this.contentInsetStart - this.tabPaddingStart) : 0, 0, 0, 0);
|
|
int i2 = this.mode;
|
|
if (i2 == 0) {
|
|
applyGravityForModeScrollable(this.tabGravity);
|
|
} else if (i2 == 1 || i2 == 2) {
|
|
if (this.tabGravity == 2) {
|
|
Log.w(LOG_TAG, "GRAVITY_START is not supported with the current tab mode, GRAVITY_CENTER will be used instead");
|
|
}
|
|
this.slidingTabIndicator.setGravity(1);
|
|
}
|
|
updateTabViews(true);
|
|
}
|
|
|
|
private void applyGravityForModeScrollable(int i) {
|
|
if (i == 0) {
|
|
Log.w(LOG_TAG, "MODE_SCROLLABLE + GRAVITY_FILL is not supported, GRAVITY_START will be used instead");
|
|
} else if (i == 1) {
|
|
this.slidingTabIndicator.setGravity(1);
|
|
return;
|
|
} else if (i != 2) {
|
|
return;
|
|
}
|
|
this.slidingTabIndicator.setGravity(GravityCompat.START);
|
|
}
|
|
|
|
void updateTabViews(boolean z) {
|
|
for (int i = 0; i < this.slidingTabIndicator.getChildCount(); i++) {
|
|
View childAt = this.slidingTabIndicator.getChildAt(i);
|
|
childAt.setMinimumWidth(getTabMinWidth());
|
|
updateTabViewLayoutParams((LinearLayout.LayoutParams) childAt.getLayoutParams());
|
|
if (z) {
|
|
childAt.requestLayout();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static class Tab {
|
|
public static final int INVALID_POSITION = -1;
|
|
private CharSequence contentDesc;
|
|
private View customView;
|
|
private Drawable icon;
|
|
public TabLayout parent;
|
|
private Object tag;
|
|
private CharSequence text;
|
|
public TabView view;
|
|
private int position = -1;
|
|
private int labelVisibilityMode = 1;
|
|
private int id = -1;
|
|
|
|
public View getCustomView() {
|
|
return this.customView;
|
|
}
|
|
|
|
public Drawable getIcon() {
|
|
return this.icon;
|
|
}
|
|
|
|
public int getId() {
|
|
return this.id;
|
|
}
|
|
|
|
public int getPosition() {
|
|
return this.position;
|
|
}
|
|
|
|
public int getTabLabelVisibility() {
|
|
return this.labelVisibilityMode;
|
|
}
|
|
|
|
public Object getTag() {
|
|
return this.tag;
|
|
}
|
|
|
|
public CharSequence getText() {
|
|
return this.text;
|
|
}
|
|
|
|
void reset() {
|
|
this.parent = null;
|
|
this.view = null;
|
|
this.tag = null;
|
|
this.icon = null;
|
|
this.id = -1;
|
|
this.text = null;
|
|
this.contentDesc = null;
|
|
this.position = -1;
|
|
this.customView = null;
|
|
}
|
|
|
|
void setPosition(int i) {
|
|
this.position = i;
|
|
}
|
|
|
|
public Tab setTag(Object obj) {
|
|
this.tag = obj;
|
|
return this;
|
|
}
|
|
|
|
public Tab setId(int i) {
|
|
this.id = i;
|
|
TabView tabView = this.view;
|
|
if (tabView != null) {
|
|
tabView.setId(i);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public Tab setCustomView(View view) {
|
|
this.customView = view;
|
|
updateView();
|
|
return this;
|
|
}
|
|
|
|
public Tab setCustomView(int i) {
|
|
return setCustomView(LayoutInflater.from(this.view.getContext()).inflate(i, (ViewGroup) this.view, false));
|
|
}
|
|
|
|
public Tab setIcon(Drawable drawable) {
|
|
this.icon = drawable;
|
|
if (this.parent.tabGravity == 1 || this.parent.mode == 2) {
|
|
this.parent.updateTabViews(true);
|
|
}
|
|
updateView();
|
|
if (BadgeUtils.USE_COMPAT_PARENT && this.view.hasBadgeDrawable() && this.view.badgeDrawable.isVisible()) {
|
|
this.view.invalidate();
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public Tab setIcon(int i) {
|
|
TabLayout tabLayout = this.parent;
|
|
if (tabLayout == null) {
|
|
throw new IllegalArgumentException("Tab not attached to a TabLayout");
|
|
}
|
|
return setIcon(AppCompatResources.getDrawable(tabLayout.getContext(), i));
|
|
}
|
|
|
|
public Tab setText(CharSequence charSequence) {
|
|
if (TextUtils.isEmpty(this.contentDesc) && !TextUtils.isEmpty(charSequence)) {
|
|
this.view.setContentDescription(charSequence);
|
|
}
|
|
this.text = charSequence;
|
|
updateView();
|
|
return this;
|
|
}
|
|
|
|
public Tab setText(int i) {
|
|
TabLayout tabLayout = this.parent;
|
|
if (tabLayout == null) {
|
|
throw new IllegalArgumentException("Tab not attached to a TabLayout");
|
|
}
|
|
return setText(tabLayout.getResources().getText(i));
|
|
}
|
|
|
|
public BadgeDrawable getOrCreateBadge() {
|
|
return this.view.getOrCreateBadge();
|
|
}
|
|
|
|
public void removeBadge() {
|
|
this.view.removeBadge();
|
|
}
|
|
|
|
public BadgeDrawable getBadge() {
|
|
return this.view.getBadge();
|
|
}
|
|
|
|
public Tab setTabLabelVisibility(int i) {
|
|
this.labelVisibilityMode = i;
|
|
if (this.parent.tabGravity == 1 || this.parent.mode == 2) {
|
|
this.parent.updateTabViews(true);
|
|
}
|
|
updateView();
|
|
if (BadgeUtils.USE_COMPAT_PARENT && this.view.hasBadgeDrawable() && this.view.badgeDrawable.isVisible()) {
|
|
this.view.invalidate();
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public void select() {
|
|
TabLayout tabLayout = this.parent;
|
|
if (tabLayout == null) {
|
|
throw new IllegalArgumentException("Tab not attached to a TabLayout");
|
|
}
|
|
tabLayout.selectTab(this);
|
|
}
|
|
|
|
public boolean isSelected() {
|
|
TabLayout tabLayout = this.parent;
|
|
if (tabLayout == null) {
|
|
throw new IllegalArgumentException("Tab not attached to a TabLayout");
|
|
}
|
|
int selectedTabPosition = tabLayout.getSelectedTabPosition();
|
|
return selectedTabPosition != -1 && selectedTabPosition == this.position;
|
|
}
|
|
|
|
public Tab setContentDescription(int i) {
|
|
TabLayout tabLayout = this.parent;
|
|
if (tabLayout == null) {
|
|
throw new IllegalArgumentException("Tab not attached to a TabLayout");
|
|
}
|
|
return setContentDescription(tabLayout.getResources().getText(i));
|
|
}
|
|
|
|
public Tab setContentDescription(CharSequence charSequence) {
|
|
this.contentDesc = charSequence;
|
|
updateView();
|
|
return this;
|
|
}
|
|
|
|
public CharSequence getContentDescription() {
|
|
TabView tabView = this.view;
|
|
if (tabView == null) {
|
|
return null;
|
|
}
|
|
return tabView.getContentDescription();
|
|
}
|
|
|
|
void updateView() {
|
|
TabView tabView = this.view;
|
|
if (tabView != null) {
|
|
tabView.update();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class TabView extends LinearLayout {
|
|
private View badgeAnchorView;
|
|
private BadgeDrawable badgeDrawable;
|
|
private Drawable baseBackgroundDrawable;
|
|
private ImageView customIconView;
|
|
private TextView customTextView;
|
|
private View customView;
|
|
private int defaultMaxLines;
|
|
private ImageView iconView;
|
|
private Tab tab;
|
|
private TextView textView;
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public BadgeDrawable getBadge() {
|
|
return this.badgeDrawable;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public boolean hasBadgeDrawable() {
|
|
return this.badgeDrawable != null;
|
|
}
|
|
|
|
public Tab getTab() {
|
|
return this.tab;
|
|
}
|
|
|
|
public TabView(Context context) {
|
|
super(context);
|
|
this.defaultMaxLines = 2;
|
|
updateBackgroundDrawable(context);
|
|
ViewCompat.setPaddingRelative(this, TabLayout.this.tabPaddingStart, TabLayout.this.tabPaddingTop, TabLayout.this.tabPaddingEnd, TabLayout.this.tabPaddingBottom);
|
|
setGravity(17);
|
|
setOrientation(!TabLayout.this.inlineLabel ? 1 : 0);
|
|
setClickable(true);
|
|
ViewCompat.setPointerIcon(this, PointerIconCompat.getSystemIcon(getContext(), 1002));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARN: Type inference failed for: r3v0, types: [android.graphics.drawable.RippleDrawable] */
|
|
public void updateBackgroundDrawable(Context context) {
|
|
if (TabLayout.this.tabBackgroundResId != 0) {
|
|
Drawable drawable = AppCompatResources.getDrawable(context, TabLayout.this.tabBackgroundResId);
|
|
this.baseBackgroundDrawable = drawable;
|
|
if (drawable != null && drawable.isStateful()) {
|
|
this.baseBackgroundDrawable.setState(getDrawableState());
|
|
}
|
|
} else {
|
|
this.baseBackgroundDrawable = null;
|
|
}
|
|
GradientDrawable gradientDrawable = new GradientDrawable();
|
|
gradientDrawable.setColor(0);
|
|
if (TabLayout.this.tabRippleColorStateList != null) {
|
|
GradientDrawable gradientDrawable2 = new GradientDrawable();
|
|
gradientDrawable2.setCornerRadius(1.0E-5f);
|
|
gradientDrawable2.setColor(-1);
|
|
ColorStateList convertToRippleDrawableColor = RippleUtils.convertToRippleDrawableColor(TabLayout.this.tabRippleColorStateList);
|
|
if (TabLayout.this.unboundedRipple) {
|
|
gradientDrawable = null;
|
|
}
|
|
gradientDrawable = new RippleDrawable(convertToRippleDrawableColor, gradientDrawable, TabLayout.this.unboundedRipple ? null : gradientDrawable2);
|
|
}
|
|
ViewCompat.setBackground(this, gradientDrawable);
|
|
TabLayout.this.invalidate();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void drawBackground(Canvas canvas) {
|
|
Drawable drawable = this.baseBackgroundDrawable;
|
|
if (drawable != null) {
|
|
drawable.setBounds(getLeft(), getTop(), getRight(), getBottom());
|
|
this.baseBackgroundDrawable.draw(canvas);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void drawableStateChanged() {
|
|
super.drawableStateChanged();
|
|
int[] drawableState = getDrawableState();
|
|
Drawable drawable = this.baseBackgroundDrawable;
|
|
if (drawable != null && drawable.isStateful() && this.baseBackgroundDrawable.setState(drawableState)) {
|
|
invalidate();
|
|
TabLayout.this.invalidate();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean performClick() {
|
|
boolean performClick = super.performClick();
|
|
if (this.tab == null) {
|
|
return performClick;
|
|
}
|
|
if (!performClick) {
|
|
playSoundEffect(0);
|
|
}
|
|
this.tab.select();
|
|
return true;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void setSelected(boolean z) {
|
|
isSelected();
|
|
super.setSelected(z);
|
|
TextView textView = this.textView;
|
|
if (textView != null) {
|
|
textView.setSelected(z);
|
|
}
|
|
ImageView imageView = this.iconView;
|
|
if (imageView != null) {
|
|
imageView.setSelected(z);
|
|
}
|
|
View view = this.customView;
|
|
if (view != null) {
|
|
view.setSelected(z);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
|
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
|
BadgeDrawable badgeDrawable = this.badgeDrawable;
|
|
if (badgeDrawable != null && badgeDrawable.isVisible()) {
|
|
accessibilityNodeInfo.setContentDescription(((Object) getContentDescription()) + ", " + ((Object) this.badgeDrawable.getContentDescription()));
|
|
}
|
|
AccessibilityNodeInfoCompat wrap = AccessibilityNodeInfoCompat.wrap(accessibilityNodeInfo);
|
|
wrap.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(0, 1, this.tab.getPosition(), 1, false, isSelected()));
|
|
if (isSelected()) {
|
|
wrap.setClickable(false);
|
|
wrap.removeAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CLICK);
|
|
}
|
|
wrap.setRoleDescription(getResources().getString(R.string.item_view_role_description));
|
|
}
|
|
|
|
@Override // android.widget.LinearLayout, android.view.View
|
|
public void onMeasure(int i, int i2) {
|
|
Layout layout;
|
|
int size = View.MeasureSpec.getSize(i);
|
|
int mode = View.MeasureSpec.getMode(i);
|
|
int tabMaxWidth = TabLayout.this.getTabMaxWidth();
|
|
if (tabMaxWidth > 0 && (mode == 0 || size > tabMaxWidth)) {
|
|
i = View.MeasureSpec.makeMeasureSpec(TabLayout.this.tabMaxWidth, Integer.MIN_VALUE);
|
|
}
|
|
super.onMeasure(i, i2);
|
|
if (this.textView != null) {
|
|
float f = TabLayout.this.tabTextSize;
|
|
int i3 = this.defaultMaxLines;
|
|
ImageView imageView = this.iconView;
|
|
if (imageView == null || imageView.getVisibility() != 0) {
|
|
TextView textView = this.textView;
|
|
if (textView != null && textView.getLineCount() > 1) {
|
|
f = TabLayout.this.tabTextMultiLineSize;
|
|
}
|
|
} else {
|
|
i3 = 1;
|
|
}
|
|
float textSize = this.textView.getTextSize();
|
|
int lineCount = this.textView.getLineCount();
|
|
int maxLines = TextViewCompat.getMaxLines(this.textView);
|
|
if (f != textSize || (maxLines >= 0 && i3 != maxLines)) {
|
|
if (TabLayout.this.mode != 1 || f <= textSize || lineCount != 1 || ((layout = this.textView.getLayout()) != null && approximateLineWidth(layout, 0, f) <= (getMeasuredWidth() - getPaddingLeft()) - getPaddingRight())) {
|
|
this.textView.setTextSize(0, f);
|
|
this.textView.setMaxLines(i3);
|
|
super.onMeasure(i, i2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void setTab(Tab tab) {
|
|
if (tab != this.tab) {
|
|
this.tab = tab;
|
|
update();
|
|
}
|
|
}
|
|
|
|
void reset() {
|
|
setTab(null);
|
|
setSelected(false);
|
|
}
|
|
|
|
final void updateTab() {
|
|
ViewParent parent;
|
|
Tab tab = this.tab;
|
|
View customView = tab != null ? tab.getCustomView() : null;
|
|
if (customView != null) {
|
|
ViewParent parent2 = customView.getParent();
|
|
if (parent2 != this) {
|
|
if (parent2 != null) {
|
|
((ViewGroup) parent2).removeView(customView);
|
|
}
|
|
View view = this.customView;
|
|
if (view != null && (parent = view.getParent()) != null) {
|
|
((ViewGroup) parent).removeView(this.customView);
|
|
}
|
|
addView(customView);
|
|
}
|
|
this.customView = customView;
|
|
TextView textView = this.textView;
|
|
if (textView != null) {
|
|
textView.setVisibility(8);
|
|
}
|
|
ImageView imageView = this.iconView;
|
|
if (imageView != null) {
|
|
imageView.setVisibility(8);
|
|
this.iconView.setImageDrawable(null);
|
|
}
|
|
TextView textView2 = (TextView) customView.findViewById(android.R.id.text1);
|
|
this.customTextView = textView2;
|
|
if (textView2 != null) {
|
|
this.defaultMaxLines = TextViewCompat.getMaxLines(textView2);
|
|
}
|
|
this.customIconView = (ImageView) customView.findViewById(android.R.id.icon);
|
|
} else {
|
|
View view2 = this.customView;
|
|
if (view2 != null) {
|
|
removeView(view2);
|
|
this.customView = null;
|
|
}
|
|
this.customTextView = null;
|
|
this.customIconView = null;
|
|
}
|
|
if (this.customView == null) {
|
|
if (this.iconView == null) {
|
|
inflateAndAddDefaultIconView();
|
|
}
|
|
if (this.textView == null) {
|
|
inflateAndAddDefaultTextView();
|
|
this.defaultMaxLines = TextViewCompat.getMaxLines(this.textView);
|
|
}
|
|
TextViewCompat.setTextAppearance(this.textView, TabLayout.this.defaultTabTextAppearance);
|
|
if (!isSelected() || TabLayout.this.selectedTabTextAppearance == -1) {
|
|
TextViewCompat.setTextAppearance(this.textView, TabLayout.this.tabTextAppearance);
|
|
} else {
|
|
TextViewCompat.setTextAppearance(this.textView, TabLayout.this.selectedTabTextAppearance);
|
|
}
|
|
if (TabLayout.this.tabTextColors != null) {
|
|
this.textView.setTextColor(TabLayout.this.tabTextColors);
|
|
}
|
|
updateTextAndIcon(this.textView, this.iconView, true);
|
|
tryUpdateBadgeAnchor();
|
|
addOnLayoutChangeListener(this.iconView);
|
|
addOnLayoutChangeListener(this.textView);
|
|
} else {
|
|
TextView textView3 = this.customTextView;
|
|
if (textView3 != null || this.customIconView != null) {
|
|
updateTextAndIcon(textView3, this.customIconView, false);
|
|
}
|
|
}
|
|
if (tab == null || TextUtils.isEmpty(tab.contentDesc)) {
|
|
return;
|
|
}
|
|
setContentDescription(tab.contentDesc);
|
|
}
|
|
|
|
final void update() {
|
|
updateTab();
|
|
Tab tab = this.tab;
|
|
setSelected(tab != null && tab.isSelected());
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
private void inflateAndAddDefaultIconView() {
|
|
FrameLayout frameLayout;
|
|
if (BadgeUtils.USE_COMPAT_PARENT) {
|
|
frameLayout = createPreApi18BadgeAnchorRoot();
|
|
addView(frameLayout, 0);
|
|
} else {
|
|
frameLayout = this;
|
|
}
|
|
ImageView imageView = (ImageView) LayoutInflater.from(getContext()).inflate(R.layout.design_layout_tab_icon, (ViewGroup) frameLayout, false);
|
|
this.iconView = imageView;
|
|
frameLayout.addView(imageView, 0);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
private void inflateAndAddDefaultTextView() {
|
|
FrameLayout frameLayout;
|
|
if (BadgeUtils.USE_COMPAT_PARENT) {
|
|
frameLayout = createPreApi18BadgeAnchorRoot();
|
|
addView(frameLayout);
|
|
} else {
|
|
frameLayout = this;
|
|
}
|
|
TextView textView = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.design_layout_tab_text, (ViewGroup) frameLayout, false);
|
|
this.textView = textView;
|
|
frameLayout.addView(textView);
|
|
}
|
|
|
|
private FrameLayout createPreApi18BadgeAnchorRoot() {
|
|
FrameLayout frameLayout = new FrameLayout(getContext());
|
|
frameLayout.setLayoutParams(new FrameLayout.LayoutParams(-2, -2));
|
|
return frameLayout;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public BadgeDrawable getOrCreateBadge() {
|
|
if (this.badgeDrawable == null) {
|
|
this.badgeDrawable = BadgeDrawable.create(getContext());
|
|
}
|
|
tryUpdateBadgeAnchor();
|
|
BadgeDrawable badgeDrawable = this.badgeDrawable;
|
|
if (badgeDrawable != null) {
|
|
return badgeDrawable;
|
|
}
|
|
throw new IllegalStateException("Unable to create badge");
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void removeBadge() {
|
|
if (this.badgeAnchorView != null) {
|
|
tryRemoveBadgeFromAnchor();
|
|
}
|
|
this.badgeDrawable = null;
|
|
}
|
|
|
|
private void addOnLayoutChangeListener(final View view) {
|
|
if (view == null) {
|
|
return;
|
|
}
|
|
view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { // from class: com.google.android.material.tabs.TabLayout.TabView.1
|
|
@Override // android.view.View.OnLayoutChangeListener
|
|
public void onLayoutChange(View view2, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
|
|
if (view.getVisibility() == 0) {
|
|
TabView.this.tryUpdateBadgeDrawableBounds(view);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
private void tryUpdateBadgeAnchor() {
|
|
Tab tab;
|
|
Tab tab2;
|
|
if (hasBadgeDrawable()) {
|
|
if (this.customView != null) {
|
|
tryRemoveBadgeFromAnchor();
|
|
return;
|
|
}
|
|
if (this.iconView != null && (tab2 = this.tab) != null && tab2.getIcon() != null) {
|
|
View view = this.badgeAnchorView;
|
|
ImageView imageView = this.iconView;
|
|
if (view != imageView) {
|
|
tryRemoveBadgeFromAnchor();
|
|
tryAttachBadgeToAnchor(this.iconView);
|
|
return;
|
|
} else {
|
|
tryUpdateBadgeDrawableBounds(imageView);
|
|
return;
|
|
}
|
|
}
|
|
if (this.textView == null || (tab = this.tab) == null || tab.getTabLabelVisibility() != 1) {
|
|
tryRemoveBadgeFromAnchor();
|
|
return;
|
|
}
|
|
View view2 = this.badgeAnchorView;
|
|
TextView textView = this.textView;
|
|
if (view2 != textView) {
|
|
tryRemoveBadgeFromAnchor();
|
|
tryAttachBadgeToAnchor(this.textView);
|
|
} else {
|
|
tryUpdateBadgeDrawableBounds(textView);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void tryAttachBadgeToAnchor(View view) {
|
|
if (hasBadgeDrawable() && view != null) {
|
|
clipViewToPaddingForBadge(false);
|
|
BadgeUtils.attachBadgeDrawable(this.badgeDrawable, view, getCustomParentForBadge(view));
|
|
this.badgeAnchorView = view;
|
|
}
|
|
}
|
|
|
|
private void tryRemoveBadgeFromAnchor() {
|
|
if (hasBadgeDrawable()) {
|
|
clipViewToPaddingForBadge(true);
|
|
View view = this.badgeAnchorView;
|
|
if (view != null) {
|
|
BadgeUtils.detachBadgeDrawable(this.badgeDrawable, view);
|
|
this.badgeAnchorView = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void clipViewToPaddingForBadge(boolean z) {
|
|
setClipChildren(z);
|
|
setClipToPadding(z);
|
|
ViewGroup viewGroup = (ViewGroup) getParent();
|
|
if (viewGroup != null) {
|
|
viewGroup.setClipChildren(z);
|
|
viewGroup.setClipToPadding(z);
|
|
}
|
|
}
|
|
|
|
final void updateOrientation() {
|
|
setOrientation(!TabLayout.this.inlineLabel ? 1 : 0);
|
|
TextView textView = this.customTextView;
|
|
if (textView != null || this.customIconView != null) {
|
|
updateTextAndIcon(textView, this.customIconView, false);
|
|
} else {
|
|
updateTextAndIcon(this.textView, this.iconView, true);
|
|
}
|
|
}
|
|
|
|
private void updateTextAndIcon(TextView textView, ImageView imageView, boolean z) {
|
|
boolean z2;
|
|
Tab tab = this.tab;
|
|
Drawable mutate = (tab == null || tab.getIcon() == null) ? null : DrawableCompat.wrap(this.tab.getIcon()).mutate();
|
|
if (mutate != null) {
|
|
DrawableCompat.setTintList(mutate, TabLayout.this.tabIconTint);
|
|
if (TabLayout.this.tabIconTintMode != null) {
|
|
DrawableCompat.setTintMode(mutate, TabLayout.this.tabIconTintMode);
|
|
}
|
|
}
|
|
Tab tab2 = this.tab;
|
|
CharSequence text = tab2 != null ? tab2.getText() : null;
|
|
if (imageView != null) {
|
|
if (mutate != null) {
|
|
imageView.setImageDrawable(mutate);
|
|
imageView.setVisibility(0);
|
|
setVisibility(0);
|
|
} else {
|
|
imageView.setVisibility(8);
|
|
imageView.setImageDrawable(null);
|
|
}
|
|
}
|
|
boolean z3 = !TextUtils.isEmpty(text);
|
|
if (textView != null) {
|
|
z2 = z3 && this.tab.labelVisibilityMode == 1;
|
|
textView.setText(z3 ? text : null);
|
|
textView.setVisibility(z2 ? 0 : 8);
|
|
if (z3) {
|
|
setVisibility(0);
|
|
}
|
|
} else {
|
|
z2 = false;
|
|
}
|
|
if (z && imageView != null) {
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) imageView.getLayoutParams();
|
|
int dpToPx = (z2 && imageView.getVisibility() == 0) ? (int) ViewUtils.dpToPx(getContext(), 8) : 0;
|
|
if (TabLayout.this.inlineLabel) {
|
|
if (dpToPx != MarginLayoutParamsCompat.getMarginEnd(marginLayoutParams)) {
|
|
MarginLayoutParamsCompat.setMarginEnd(marginLayoutParams, dpToPx);
|
|
marginLayoutParams.bottomMargin = 0;
|
|
imageView.setLayoutParams(marginLayoutParams);
|
|
imageView.requestLayout();
|
|
}
|
|
} else if (dpToPx != marginLayoutParams.bottomMargin) {
|
|
marginLayoutParams.bottomMargin = dpToPx;
|
|
MarginLayoutParamsCompat.setMarginEnd(marginLayoutParams, 0);
|
|
imageView.setLayoutParams(marginLayoutParams);
|
|
imageView.requestLayout();
|
|
}
|
|
}
|
|
Tab tab3 = this.tab;
|
|
CharSequence charSequence = tab3 != null ? tab3.contentDesc : null;
|
|
if (!z3) {
|
|
text = charSequence;
|
|
}
|
|
TooltipCompat.setTooltipText(this, text);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void tryUpdateBadgeDrawableBounds(View view) {
|
|
if (hasBadgeDrawable() && view == this.badgeAnchorView) {
|
|
BadgeUtils.setBadgeDrawableBounds(this.badgeDrawable, view, getCustomParentForBadge(view));
|
|
}
|
|
}
|
|
|
|
private FrameLayout getCustomParentForBadge(View view) {
|
|
if ((view == this.iconView || view == this.textView) && BadgeUtils.USE_COMPAT_PARENT) {
|
|
return (FrameLayout) view.getParent();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public int getContentWidth() {
|
|
View[] viewArr = {this.textView, this.iconView, this.customView};
|
|
int i = 0;
|
|
int i2 = 0;
|
|
boolean z = false;
|
|
for (int i3 = 0; i3 < 3; i3++) {
|
|
View view = viewArr[i3];
|
|
if (view != null && view.getVisibility() == 0) {
|
|
i2 = z ? Math.min(i2, view.getLeft()) : view.getLeft();
|
|
i = z ? Math.max(i, view.getRight()) : view.getRight();
|
|
z = true;
|
|
}
|
|
}
|
|
return i - i2;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public int getContentHeight() {
|
|
View[] viewArr = {this.textView, this.iconView, this.customView};
|
|
int i = 0;
|
|
int i2 = 0;
|
|
boolean z = false;
|
|
for (int i3 = 0; i3 < 3; i3++) {
|
|
View view = viewArr[i3];
|
|
if (view != null && view.getVisibility() == 0) {
|
|
i2 = z ? Math.min(i2, view.getTop()) : view.getTop();
|
|
i = z ? Math.max(i, view.getBottom()) : view.getBottom();
|
|
z = true;
|
|
}
|
|
}
|
|
return i - i2;
|
|
}
|
|
|
|
private float approximateLineWidth(Layout layout, int i, float f) {
|
|
return layout.getLineWidth(i) * (f / layout.getPaint().getTextSize());
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class SlidingTabIndicator extends LinearLayout {
|
|
ValueAnimator indicatorAnimator;
|
|
private int layoutDirection;
|
|
|
|
SlidingTabIndicator(Context context) {
|
|
super(context);
|
|
this.layoutDirection = -1;
|
|
setWillNotDraw(false);
|
|
}
|
|
|
|
void setSelectedIndicatorHeight(int i) {
|
|
Rect bounds = TabLayout.this.tabSelectedIndicator.getBounds();
|
|
TabLayout.this.tabSelectedIndicator.setBounds(bounds.left, 0, bounds.right, i);
|
|
requestLayout();
|
|
}
|
|
|
|
boolean childrenNeedLayout() {
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
if (getChildAt(i).getWidth() <= 0) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void setIndicatorPositionFromTabPosition(int i, float f) {
|
|
TabLayout.this.indicatorPosition = Math.round(i + f);
|
|
ValueAnimator valueAnimator = this.indicatorAnimator;
|
|
if (valueAnimator != null && valueAnimator.isRunning()) {
|
|
this.indicatorAnimator.cancel();
|
|
}
|
|
tweenIndicatorPosition(getChildAt(i), getChildAt(i + 1), f);
|
|
}
|
|
|
|
@Override // android.widget.LinearLayout, android.view.View
|
|
public void onRtlPropertiesChanged(int i) {
|
|
super.onRtlPropertiesChanged(i);
|
|
}
|
|
|
|
@Override // android.widget.LinearLayout, android.view.View
|
|
protected void onMeasure(int i, int i2) {
|
|
super.onMeasure(i, i2);
|
|
if (View.MeasureSpec.getMode(i) != 1073741824) {
|
|
return;
|
|
}
|
|
if (TabLayout.this.tabGravity == 1 || TabLayout.this.mode == 2) {
|
|
int childCount = getChildCount();
|
|
int i3 = 0;
|
|
for (int i4 = 0; i4 < childCount; i4++) {
|
|
View childAt = getChildAt(i4);
|
|
if (childAt.getVisibility() == 0) {
|
|
i3 = Math.max(i3, childAt.getMeasuredWidth());
|
|
}
|
|
}
|
|
if (i3 <= 0) {
|
|
return;
|
|
}
|
|
if (i3 * childCount <= getMeasuredWidth() - (((int) ViewUtils.dpToPx(getContext(), 16)) * 2)) {
|
|
boolean z = false;
|
|
for (int i5 = 0; i5 < childCount; i5++) {
|
|
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) getChildAt(i5).getLayoutParams();
|
|
if (layoutParams.width != i3 || layoutParams.weight != 0.0f) {
|
|
layoutParams.width = i3;
|
|
layoutParams.weight = 0.0f;
|
|
z = true;
|
|
}
|
|
}
|
|
if (!z) {
|
|
return;
|
|
}
|
|
} else {
|
|
TabLayout.this.tabGravity = 0;
|
|
TabLayout.this.updateTabViews(false);
|
|
}
|
|
super.onMeasure(i, i2);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.LinearLayout, android.view.ViewGroup, android.view.View
|
|
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
|
super.onLayout(z, i, i2, i3, i4);
|
|
ValueAnimator valueAnimator = this.indicatorAnimator;
|
|
if (valueAnimator != null && valueAnimator.isRunning()) {
|
|
updateOrRecreateIndicatorAnimation(false, TabLayout.this.getSelectedTabPosition(), -1);
|
|
} else {
|
|
jumpIndicatorToIndicatorPosition();
|
|
}
|
|
}
|
|
|
|
private void jumpIndicatorToPosition(int i) {
|
|
if (TabLayout.this.viewPagerScrollState == 0 || (TabLayout.this.getTabSelectedIndicator().getBounds().left == -1 && TabLayout.this.getTabSelectedIndicator().getBounds().right == -1)) {
|
|
View childAt = getChildAt(i);
|
|
TabIndicatorInterpolator tabIndicatorInterpolator = TabLayout.this.tabIndicatorInterpolator;
|
|
TabLayout tabLayout = TabLayout.this;
|
|
tabIndicatorInterpolator.setIndicatorBoundsForTab(tabLayout, childAt, tabLayout.tabSelectedIndicator);
|
|
TabLayout.this.indicatorPosition = i;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void jumpIndicatorToSelectedPosition() {
|
|
jumpIndicatorToPosition(TabLayout.this.getSelectedTabPosition());
|
|
}
|
|
|
|
private void jumpIndicatorToIndicatorPosition() {
|
|
if (TabLayout.this.indicatorPosition == -1) {
|
|
TabLayout tabLayout = TabLayout.this;
|
|
tabLayout.indicatorPosition = tabLayout.getSelectedTabPosition();
|
|
}
|
|
jumpIndicatorToPosition(TabLayout.this.indicatorPosition);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void tweenIndicatorPosition(View view, View view2, float f) {
|
|
if (view != null && view.getWidth() > 0) {
|
|
TabIndicatorInterpolator tabIndicatorInterpolator = TabLayout.this.tabIndicatorInterpolator;
|
|
TabLayout tabLayout = TabLayout.this;
|
|
tabIndicatorInterpolator.updateIndicatorForOffset(tabLayout, view, view2, f, tabLayout.tabSelectedIndicator);
|
|
} else {
|
|
TabLayout.this.tabSelectedIndicator.setBounds(-1, TabLayout.this.tabSelectedIndicator.getBounds().top, -1, TabLayout.this.tabSelectedIndicator.getBounds().bottom);
|
|
}
|
|
ViewCompat.postInvalidateOnAnimation(this);
|
|
}
|
|
|
|
void animateIndicatorToPosition(int i, int i2) {
|
|
ValueAnimator valueAnimator = this.indicatorAnimator;
|
|
if (valueAnimator != null && valueAnimator.isRunning() && TabLayout.this.indicatorPosition != i) {
|
|
this.indicatorAnimator.cancel();
|
|
}
|
|
updateOrRecreateIndicatorAnimation(true, i, i2);
|
|
}
|
|
|
|
private void updateOrRecreateIndicatorAnimation(boolean z, int i, int i2) {
|
|
if (TabLayout.this.indicatorPosition == i) {
|
|
return;
|
|
}
|
|
final View childAt = getChildAt(TabLayout.this.getSelectedTabPosition());
|
|
final View childAt2 = getChildAt(i);
|
|
if (childAt2 == null) {
|
|
jumpIndicatorToSelectedPosition();
|
|
return;
|
|
}
|
|
TabLayout.this.indicatorPosition = i;
|
|
ValueAnimator.AnimatorUpdateListener animatorUpdateListener = new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.tabs.TabLayout.SlidingTabIndicator.1
|
|
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
|
public void onAnimationUpdate(ValueAnimator valueAnimator) {
|
|
SlidingTabIndicator.this.tweenIndicatorPosition(childAt, childAt2, valueAnimator.getAnimatedFraction());
|
|
}
|
|
};
|
|
if (z) {
|
|
ValueAnimator valueAnimator = new ValueAnimator();
|
|
this.indicatorAnimator = valueAnimator;
|
|
valueAnimator.setInterpolator(TabLayout.this.tabIndicatorTimeInterpolator);
|
|
valueAnimator.setDuration(i2);
|
|
valueAnimator.setFloatValues(0.0f, 1.0f);
|
|
valueAnimator.addUpdateListener(animatorUpdateListener);
|
|
valueAnimator.start();
|
|
return;
|
|
}
|
|
this.indicatorAnimator.removeAllUpdateListeners();
|
|
this.indicatorAnimator.addUpdateListener(animatorUpdateListener);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void draw(Canvas canvas) {
|
|
int height;
|
|
int height2 = TabLayout.this.tabSelectedIndicator.getBounds().height();
|
|
if (height2 < 0) {
|
|
height2 = TabLayout.this.tabSelectedIndicator.getIntrinsicHeight();
|
|
}
|
|
int i = TabLayout.this.tabIndicatorGravity;
|
|
if (i == 0) {
|
|
height = getHeight() - height2;
|
|
height2 = getHeight();
|
|
} else if (i != 1) {
|
|
height = 0;
|
|
if (i != 2) {
|
|
height2 = i != 3 ? 0 : getHeight();
|
|
}
|
|
} else {
|
|
height = (getHeight() - height2) / 2;
|
|
height2 = (getHeight() + height2) / 2;
|
|
}
|
|
if (TabLayout.this.tabSelectedIndicator.getBounds().width() > 0) {
|
|
Rect bounds = TabLayout.this.tabSelectedIndicator.getBounds();
|
|
TabLayout.this.tabSelectedIndicator.setBounds(bounds.left, height, bounds.right, height2);
|
|
TabLayout.this.tabSelectedIndicator.draw(canvas);
|
|
}
|
|
super.draw(canvas);
|
|
}
|
|
}
|
|
|
|
private static ColorStateList createColorStateList(int i, int i2) {
|
|
return new ColorStateList(new int[][]{SELECTED_STATE_SET, EMPTY_STATE_SET}, new int[]{i2, i});
|
|
}
|
|
|
|
private int getDefaultHeight() {
|
|
int size = this.tabs.size();
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= size) {
|
|
break;
|
|
}
|
|
Tab tab = this.tabs.get(i);
|
|
if (tab == null || tab.getIcon() == null || TextUtils.isEmpty(tab.getText())) {
|
|
i++;
|
|
} else if (!this.inlineLabel) {
|
|
return DEFAULT_HEIGHT_WITH_TEXT_ICON;
|
|
}
|
|
}
|
|
return 48;
|
|
}
|
|
|
|
@Override // android.widget.FrameLayout, android.view.ViewGroup
|
|
public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
|
|
return generateDefaultLayoutParams();
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static class TabLayoutOnPageChangeListener implements ViewPager.OnPageChangeListener {
|
|
private int previousScrollState;
|
|
private int scrollState;
|
|
private final WeakReference<TabLayout> tabLayoutRef;
|
|
|
|
void reset() {
|
|
this.scrollState = 0;
|
|
this.previousScrollState = 0;
|
|
}
|
|
|
|
public TabLayoutOnPageChangeListener(TabLayout tabLayout) {
|
|
this.tabLayoutRef = new WeakReference<>(tabLayout);
|
|
}
|
|
|
|
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
|
public void onPageScrollStateChanged(int i) {
|
|
this.previousScrollState = this.scrollState;
|
|
this.scrollState = i;
|
|
TabLayout tabLayout = this.tabLayoutRef.get();
|
|
if (tabLayout != null) {
|
|
tabLayout.updateViewPagerScrollState(this.scrollState);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
|
public void onPageScrolled(int i, float f, int i2) {
|
|
TabLayout tabLayout = this.tabLayoutRef.get();
|
|
if (tabLayout != null) {
|
|
int i3 = this.scrollState;
|
|
tabLayout.setScrollPosition(i, f, i3 != 2 || this.previousScrollState == 1, (i3 == 2 && this.previousScrollState == 0) ? false : true, false);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
|
public void onPageSelected(int i) {
|
|
TabLayout tabLayout = this.tabLayoutRef.get();
|
|
if (tabLayout == null || tabLayout.getSelectedTabPosition() == i || i >= tabLayout.getTabCount()) {
|
|
return;
|
|
}
|
|
int i2 = this.scrollState;
|
|
tabLayout.selectTab(tabLayout.getTabAt(i), i2 == 0 || (i2 == 2 && this.previousScrollState == 0));
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static class ViewPagerOnTabSelectedListener implements OnTabSelectedListener {
|
|
private final ViewPager viewPager;
|
|
|
|
@Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
|
|
public void onTabReselected(Tab tab) {
|
|
}
|
|
|
|
@Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
|
|
public void onTabUnselected(Tab tab) {
|
|
}
|
|
|
|
public ViewPagerOnTabSelectedListener(ViewPager viewPager) {
|
|
this.viewPager = viewPager;
|
|
}
|
|
|
|
@Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
|
|
public void onTabSelected(Tab tab) {
|
|
this.viewPager.setCurrentItem(tab.getPosition());
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes2.dex */
|
|
public class PagerAdapterObserver extends DataSetObserver {
|
|
PagerAdapterObserver() {
|
|
}
|
|
|
|
@Override // android.database.DataSetObserver
|
|
public void onChanged() {
|
|
TabLayout.this.populateFromPagerAdapter();
|
|
}
|
|
|
|
@Override // android.database.DataSetObserver
|
|
public void onInvalidated() {
|
|
TabLayout.this.populateFromPagerAdapter();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes2.dex */
|
|
public class AdapterChangeListener implements ViewPager.OnAdapterChangeListener {
|
|
private boolean autoRefresh;
|
|
|
|
void setAutoRefresh(boolean z) {
|
|
this.autoRefresh = z;
|
|
}
|
|
|
|
AdapterChangeListener() {
|
|
}
|
|
|
|
@Override // androidx.viewpager.widget.ViewPager.OnAdapterChangeListener
|
|
public void onAdapterChanged(ViewPager viewPager, PagerAdapter pagerAdapter, PagerAdapter pagerAdapter2) {
|
|
if (TabLayout.this.viewPager == viewPager) {
|
|
TabLayout.this.setPagerAdapter(pagerAdapter2, this.autoRefresh);
|
|
}
|
|
}
|
|
}
|
|
}
|