645 lines
		
	
	
		
			24 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			645 lines
		
	
	
		
			24 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package androidx.appcompat.widget;
 | |
| 
 | |
| import android.content.Context;
 | |
| import android.graphics.drawable.Drawable;
 | |
| import android.os.Parcelable;
 | |
| import android.text.TextUtils;
 | |
| import android.util.Log;
 | |
| import android.util.SparseArray;
 | |
| import android.view.LayoutInflater;
 | |
| import android.view.Menu;
 | |
| import android.view.View;
 | |
| import android.view.ViewGroup;
 | |
| import android.view.ViewParent;
 | |
| import android.view.Window;
 | |
| import android.widget.AdapterView;
 | |
| import android.widget.Spinner;
 | |
| import android.widget.SpinnerAdapter;
 | |
| import androidx.appcompat.R;
 | |
| import androidx.appcompat.content.res.AppCompatResources;
 | |
| import androidx.appcompat.view.menu.ActionMenuItem;
 | |
| import androidx.appcompat.view.menu.MenuBuilder;
 | |
| import androidx.appcompat.view.menu.MenuPresenter;
 | |
| import androidx.appcompat.widget.Toolbar;
 | |
| import androidx.core.view.ViewCompat;
 | |
| import androidx.core.view.ViewPropertyAnimatorCompat;
 | |
| import androidx.core.view.ViewPropertyAnimatorListenerAdapter;
 | |
| 
 | |
| /* loaded from: classes.dex */
 | |
| public class ToolbarWidgetWrapper implements DecorToolbar {
 | |
|     private static final int AFFECTS_LOGO_MASK = 3;
 | |
|     private static final long DEFAULT_FADE_DURATION_MS = 200;
 | |
|     private static final String TAG = "ToolbarWidgetWrapper";
 | |
|     private ActionMenuPresenter mActionMenuPresenter;
 | |
|     private View mCustomView;
 | |
|     private int mDefaultNavigationContentDescription;
 | |
|     private Drawable mDefaultNavigationIcon;
 | |
|     private int mDisplayOpts;
 | |
|     private CharSequence mHomeDescription;
 | |
|     private Drawable mIcon;
 | |
|     private Drawable mLogo;
 | |
|     boolean mMenuPrepared;
 | |
|     private Drawable mNavIcon;
 | |
|     private int mNavigationMode;
 | |
|     private Spinner mSpinner;
 | |
|     private CharSequence mSubtitle;
 | |
|     private View mTabView;
 | |
|     CharSequence mTitle;
 | |
|     private boolean mTitleSet;
 | |
|     Toolbar mToolbar;
 | |
|     Window.Callback mWindowCallback;
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public View getCustomView() {
 | |
|         return this.mCustomView;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public int getDisplayOptions() {
 | |
|         return this.mDisplayOpts;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public int getNavigationMode() {
 | |
|         return this.mNavigationMode;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public ViewGroup getViewGroup() {
 | |
|         return this.mToolbar;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public boolean hasEmbeddedTabs() {
 | |
|         return this.mTabView != null;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public boolean hasIcon() {
 | |
|         return this.mIcon != null;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public boolean hasLogo() {
 | |
|         return this.mLogo != null;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setHomeButtonEnabled(boolean z) {
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setMenuPrepared() {
 | |
|         this.mMenuPrepared = true;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setWindowCallback(Window.Callback callback) {
 | |
|         this.mWindowCallback = callback;
 | |
|     }
 | |
| 
 | |
|     public ToolbarWidgetWrapper(Toolbar toolbar, boolean z) {
 | |
|         this(toolbar, z, R.string.abc_action_bar_up_description, R.drawable.abc_ic_ab_back_material);
 | |
|     }
 | |
| 
 | |
|     public ToolbarWidgetWrapper(Toolbar toolbar, boolean z, int i, int i2) {
 | |
|         Drawable drawable;
 | |
|         this.mNavigationMode = 0;
 | |
|         this.mDefaultNavigationContentDescription = 0;
 | |
|         this.mToolbar = toolbar;
 | |
|         this.mTitle = toolbar.getTitle();
 | |
|         this.mSubtitle = toolbar.getSubtitle();
 | |
|         this.mTitleSet = this.mTitle != null;
 | |
|         this.mNavIcon = toolbar.getNavigationIcon();
 | |
|         TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(toolbar.getContext(), null, R.styleable.ActionBar, R.attr.actionBarStyle, 0);
 | |
|         this.mDefaultNavigationIcon = obtainStyledAttributes.getDrawable(R.styleable.ActionBar_homeAsUpIndicator);
 | |
|         if (z) {
 | |
|             CharSequence text = obtainStyledAttributes.getText(R.styleable.ActionBar_title);
 | |
|             if (!TextUtils.isEmpty(text)) {
 | |
|                 setTitle(text);
 | |
|             }
 | |
|             CharSequence text2 = obtainStyledAttributes.getText(R.styleable.ActionBar_subtitle);
 | |
|             if (!TextUtils.isEmpty(text2)) {
 | |
|                 setSubtitle(text2);
 | |
|             }
 | |
|             Drawable drawable2 = obtainStyledAttributes.getDrawable(R.styleable.ActionBar_logo);
 | |
|             if (drawable2 != null) {
 | |
|                 setLogo(drawable2);
 | |
|             }
 | |
|             Drawable drawable3 = obtainStyledAttributes.getDrawable(R.styleable.ActionBar_icon);
 | |
|             if (drawable3 != null) {
 | |
|                 setIcon(drawable3);
 | |
|             }
 | |
|             if (this.mNavIcon == null && (drawable = this.mDefaultNavigationIcon) != null) {
 | |
|                 setNavigationIcon(drawable);
 | |
|             }
 | |
|             setDisplayOptions(obtainStyledAttributes.getInt(R.styleable.ActionBar_displayOptions, 0));
 | |
|             int resourceId = obtainStyledAttributes.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0);
 | |
|             if (resourceId != 0) {
 | |
|                 setCustomView(LayoutInflater.from(this.mToolbar.getContext()).inflate(resourceId, (ViewGroup) this.mToolbar, false));
 | |
|                 setDisplayOptions(this.mDisplayOpts | 16);
 | |
|             }
 | |
|             int layoutDimension = obtainStyledAttributes.getLayoutDimension(R.styleable.ActionBar_height, 0);
 | |
|             if (layoutDimension > 0) {
 | |
|                 ViewGroup.LayoutParams layoutParams = this.mToolbar.getLayoutParams();
 | |
|                 layoutParams.height = layoutDimension;
 | |
|                 this.mToolbar.setLayoutParams(layoutParams);
 | |
|             }
 | |
|             int dimensionPixelOffset = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetStart, -1);
 | |
|             int dimensionPixelOffset2 = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetEnd, -1);
 | |
|             if (dimensionPixelOffset >= 0 || dimensionPixelOffset2 >= 0) {
 | |
|                 this.mToolbar.setContentInsetsRelative(Math.max(dimensionPixelOffset, 0), Math.max(dimensionPixelOffset2, 0));
 | |
|             }
 | |
|             int resourceId2 = obtainStyledAttributes.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
 | |
|             if (resourceId2 != 0) {
 | |
|                 Toolbar toolbar2 = this.mToolbar;
 | |
|                 toolbar2.setTitleTextAppearance(toolbar2.getContext(), resourceId2);
 | |
|             }
 | |
|             int resourceId3 = obtainStyledAttributes.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
 | |
|             if (resourceId3 != 0) {
 | |
|                 Toolbar toolbar3 = this.mToolbar;
 | |
|                 toolbar3.setSubtitleTextAppearance(toolbar3.getContext(), resourceId3);
 | |
|             }
 | |
|             int resourceId4 = obtainStyledAttributes.getResourceId(R.styleable.ActionBar_popupTheme, 0);
 | |
|             if (resourceId4 != 0) {
 | |
|                 this.mToolbar.setPopupTheme(resourceId4);
 | |
|             }
 | |
|         } else {
 | |
|             this.mDisplayOpts = detectDisplayOptions();
 | |
|         }
 | |
|         obtainStyledAttributes.recycle();
 | |
|         setDefaultNavigationContentDescription(i);
 | |
|         this.mHomeDescription = this.mToolbar.getNavigationContentDescription();
 | |
|         this.mToolbar.setNavigationOnClickListener(new View.OnClickListener() { // from class: androidx.appcompat.widget.ToolbarWidgetWrapper.1
 | |
|             final ActionMenuItem mNavItem;
 | |
| 
 | |
|             {
 | |
|                 this.mNavItem = new ActionMenuItem(ToolbarWidgetWrapper.this.mToolbar.getContext(), 0, android.R.id.home, 0, 0, ToolbarWidgetWrapper.this.mTitle);
 | |
|             }
 | |
| 
 | |
|             @Override // android.view.View.OnClickListener
 | |
|             public void onClick(View view) {
 | |
|                 if (ToolbarWidgetWrapper.this.mWindowCallback == null || !ToolbarWidgetWrapper.this.mMenuPrepared) {
 | |
|                     return;
 | |
|                 }
 | |
|                 ToolbarWidgetWrapper.this.mWindowCallback.onMenuItemSelected(0, this.mNavItem);
 | |
|             }
 | |
|         });
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setDefaultNavigationContentDescription(int i) {
 | |
|         if (i == this.mDefaultNavigationContentDescription) {
 | |
|             return;
 | |
|         }
 | |
|         this.mDefaultNavigationContentDescription = i;
 | |
|         if (TextUtils.isEmpty(this.mToolbar.getNavigationContentDescription())) {
 | |
|             setNavigationContentDescription(this.mDefaultNavigationContentDescription);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private int detectDisplayOptions() {
 | |
|         if (this.mToolbar.getNavigationIcon() == null) {
 | |
|             return 11;
 | |
|         }
 | |
|         this.mDefaultNavigationIcon = this.mToolbar.getNavigationIcon();
 | |
|         return 15;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public Context getContext() {
 | |
|         return this.mToolbar.getContext();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public boolean hasExpandedActionView() {
 | |
|         return this.mToolbar.hasExpandedActionView();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void collapseActionView() {
 | |
|         this.mToolbar.collapseActionView();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setWindowTitle(CharSequence charSequence) {
 | |
|         if (this.mTitleSet) {
 | |
|             return;
 | |
|         }
 | |
|         setTitleInt(charSequence);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public CharSequence getTitle() {
 | |
|         return this.mToolbar.getTitle();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setTitle(CharSequence charSequence) {
 | |
|         this.mTitleSet = true;
 | |
|         setTitleInt(charSequence);
 | |
|     }
 | |
| 
 | |
|     private void setTitleInt(CharSequence charSequence) {
 | |
|         this.mTitle = charSequence;
 | |
|         if ((this.mDisplayOpts & 8) != 0) {
 | |
|             this.mToolbar.setTitle(charSequence);
 | |
|             if (this.mTitleSet) {
 | |
|                 ViewCompat.setAccessibilityPaneTitle(this.mToolbar.getRootView(), charSequence);
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public CharSequence getSubtitle() {
 | |
|         return this.mToolbar.getSubtitle();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setSubtitle(CharSequence charSequence) {
 | |
|         this.mSubtitle = charSequence;
 | |
|         if ((this.mDisplayOpts & 8) != 0) {
 | |
|             this.mToolbar.setSubtitle(charSequence);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void initProgress() {
 | |
|         Log.i(TAG, "Progress display unsupported");
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void initIndeterminateProgress() {
 | |
|         Log.i(TAG, "Progress display unsupported");
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setIcon(int i) {
 | |
|         setIcon(i != 0 ? AppCompatResources.getDrawable(getContext(), i) : null);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setIcon(Drawable drawable) {
 | |
|         this.mIcon = drawable;
 | |
|         updateToolbarLogo();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setLogo(int i) {
 | |
|         setLogo(i != 0 ? AppCompatResources.getDrawable(getContext(), i) : null);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setLogo(Drawable drawable) {
 | |
|         this.mLogo = drawable;
 | |
|         updateToolbarLogo();
 | |
|     }
 | |
| 
 | |
|     private void updateToolbarLogo() {
 | |
|         Drawable drawable;
 | |
|         int i = this.mDisplayOpts;
 | |
|         if ((i & 2) == 0) {
 | |
|             drawable = null;
 | |
|         } else if ((i & 1) != 0) {
 | |
|             drawable = this.mLogo;
 | |
|             if (drawable == null) {
 | |
|                 drawable = this.mIcon;
 | |
|             }
 | |
|         } else {
 | |
|             drawable = this.mIcon;
 | |
|         }
 | |
|         this.mToolbar.setLogo(drawable);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public boolean canShowOverflowMenu() {
 | |
|         return this.mToolbar.canShowOverflowMenu();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public boolean isOverflowMenuShowing() {
 | |
|         return this.mToolbar.isOverflowMenuShowing();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public boolean isOverflowMenuShowPending() {
 | |
|         return this.mToolbar.isOverflowMenuShowPending();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public boolean showOverflowMenu() {
 | |
|         return this.mToolbar.showOverflowMenu();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public boolean hideOverflowMenu() {
 | |
|         return this.mToolbar.hideOverflowMenu();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setMenu(Menu menu, MenuPresenter.Callback callback) {
 | |
|         if (this.mActionMenuPresenter == null) {
 | |
|             ActionMenuPresenter actionMenuPresenter = new ActionMenuPresenter(this.mToolbar.getContext());
 | |
|             this.mActionMenuPresenter = actionMenuPresenter;
 | |
|             actionMenuPresenter.setId(R.id.action_menu_presenter);
 | |
|         }
 | |
|         this.mActionMenuPresenter.setCallback(callback);
 | |
|         this.mToolbar.setMenu((MenuBuilder) menu, this.mActionMenuPresenter);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void dismissPopupMenus() {
 | |
|         this.mToolbar.dismissPopupMenus();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setDisplayOptions(int i) {
 | |
|         View view;
 | |
|         int i2 = this.mDisplayOpts ^ i;
 | |
|         this.mDisplayOpts = i;
 | |
|         if (i2 != 0) {
 | |
|             if ((i2 & 4) != 0) {
 | |
|                 if ((i & 4) != 0) {
 | |
|                     updateHomeAccessibility();
 | |
|                 }
 | |
|                 updateNavigationIcon();
 | |
|             }
 | |
|             if ((i2 & 3) != 0) {
 | |
|                 updateToolbarLogo();
 | |
|             }
 | |
|             if ((i2 & 8) != 0) {
 | |
|                 if ((i & 8) != 0) {
 | |
|                     this.mToolbar.setTitle(this.mTitle);
 | |
|                     this.mToolbar.setSubtitle(this.mSubtitle);
 | |
|                 } else {
 | |
|                     this.mToolbar.setTitle((CharSequence) null);
 | |
|                     this.mToolbar.setSubtitle((CharSequence) null);
 | |
|                 }
 | |
|             }
 | |
|             if ((i2 & 16) == 0 || (view = this.mCustomView) == null) {
 | |
|                 return;
 | |
|             }
 | |
|             if ((i & 16) != 0) {
 | |
|                 this.mToolbar.addView(view);
 | |
|             } else {
 | |
|                 this.mToolbar.removeView(view);
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setEmbeddedTabView(ScrollingTabContainerView scrollingTabContainerView) {
 | |
|         View view = this.mTabView;
 | |
|         if (view != null) {
 | |
|             ViewParent parent = view.getParent();
 | |
|             Toolbar toolbar = this.mToolbar;
 | |
|             if (parent == toolbar) {
 | |
|                 toolbar.removeView(this.mTabView);
 | |
|             }
 | |
|         }
 | |
|         this.mTabView = scrollingTabContainerView;
 | |
|         if (scrollingTabContainerView == null || this.mNavigationMode != 2) {
 | |
|             return;
 | |
|         }
 | |
|         this.mToolbar.addView(scrollingTabContainerView, 0);
 | |
|         Toolbar.LayoutParams layoutParams = (Toolbar.LayoutParams) this.mTabView.getLayoutParams();
 | |
|         layoutParams.width = -2;
 | |
|         layoutParams.height = -2;
 | |
|         layoutParams.gravity = 8388691;
 | |
|         scrollingTabContainerView.setAllowCollapse(true);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public boolean isTitleTruncated() {
 | |
|         return this.mToolbar.isTitleTruncated();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setCollapsible(boolean z) {
 | |
|         this.mToolbar.setCollapsible(z);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setNavigationMode(int i) {
 | |
|         View view;
 | |
|         int i2 = this.mNavigationMode;
 | |
|         if (i != i2) {
 | |
|             if (i2 == 1) {
 | |
|                 Spinner spinner = this.mSpinner;
 | |
|                 if (spinner != null) {
 | |
|                     ViewParent parent = spinner.getParent();
 | |
|                     Toolbar toolbar = this.mToolbar;
 | |
|                     if (parent == toolbar) {
 | |
|                         toolbar.removeView(this.mSpinner);
 | |
|                     }
 | |
|                 }
 | |
|             } else if (i2 == 2 && (view = this.mTabView) != null) {
 | |
|                 ViewParent parent2 = view.getParent();
 | |
|                 Toolbar toolbar2 = this.mToolbar;
 | |
|                 if (parent2 == toolbar2) {
 | |
|                     toolbar2.removeView(this.mTabView);
 | |
|                 }
 | |
|             }
 | |
|             this.mNavigationMode = i;
 | |
|             if (i != 0) {
 | |
|                 if (i == 1) {
 | |
|                     ensureSpinner();
 | |
|                     this.mToolbar.addView(this.mSpinner, 0);
 | |
|                     return;
 | |
|                 }
 | |
|                 if (i != 2) {
 | |
|                     throw new IllegalArgumentException("Invalid navigation mode " + i);
 | |
|                 }
 | |
|                 View view2 = this.mTabView;
 | |
|                 if (view2 != null) {
 | |
|                     this.mToolbar.addView(view2, 0);
 | |
|                     Toolbar.LayoutParams layoutParams = (Toolbar.LayoutParams) this.mTabView.getLayoutParams();
 | |
|                     layoutParams.width = -2;
 | |
|                     layoutParams.height = -2;
 | |
|                     layoutParams.gravity = 8388691;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void ensureSpinner() {
 | |
|         if (this.mSpinner == null) {
 | |
|             this.mSpinner = new AppCompatSpinner(getContext(), null, R.attr.actionDropDownStyle);
 | |
|             this.mSpinner.setLayoutParams(new Toolbar.LayoutParams(-2, -2, 8388627));
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setDropdownParams(SpinnerAdapter spinnerAdapter, AdapterView.OnItemSelectedListener onItemSelectedListener) {
 | |
|         ensureSpinner();
 | |
|         this.mSpinner.setAdapter(spinnerAdapter);
 | |
|         this.mSpinner.setOnItemSelectedListener(onItemSelectedListener);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setDropdownSelectedPosition(int i) {
 | |
|         Spinner spinner = this.mSpinner;
 | |
|         if (spinner == null) {
 | |
|             throw new IllegalStateException("Can't set dropdown selected position without an adapter");
 | |
|         }
 | |
|         spinner.setSelection(i);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public int getDropdownSelectedPosition() {
 | |
|         Spinner spinner = this.mSpinner;
 | |
|         if (spinner != null) {
 | |
|             return spinner.getSelectedItemPosition();
 | |
|         }
 | |
|         return 0;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public int getDropdownItemCount() {
 | |
|         Spinner spinner = this.mSpinner;
 | |
|         if (spinner != null) {
 | |
|             return spinner.getCount();
 | |
|         }
 | |
|         return 0;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setCustomView(View view) {
 | |
|         View view2 = this.mCustomView;
 | |
|         if (view2 != null && (this.mDisplayOpts & 16) != 0) {
 | |
|             this.mToolbar.removeView(view2);
 | |
|         }
 | |
|         this.mCustomView = view;
 | |
|         if (view == null || (this.mDisplayOpts & 16) == 0) {
 | |
|             return;
 | |
|         }
 | |
|         this.mToolbar.addView(view);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void animateToVisibility(int i) {
 | |
|         ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = setupAnimatorToVisibility(i, DEFAULT_FADE_DURATION_MS);
 | |
|         if (viewPropertyAnimatorCompat != null) {
 | |
|             viewPropertyAnimatorCompat.start();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public ViewPropertyAnimatorCompat setupAnimatorToVisibility(final int i, long j) {
 | |
|         return ViewCompat.animate(this.mToolbar).alpha(i == 0 ? 1.0f : 0.0f).setDuration(j).setListener(new ViewPropertyAnimatorListenerAdapter() { // from class: androidx.appcompat.widget.ToolbarWidgetWrapper.2
 | |
|             private boolean mCanceled = false;
 | |
| 
 | |
|             @Override // androidx.core.view.ViewPropertyAnimatorListenerAdapter, androidx.core.view.ViewPropertyAnimatorListener
 | |
|             public void onAnimationCancel(View view) {
 | |
|                 this.mCanceled = true;
 | |
|             }
 | |
| 
 | |
|             @Override // androidx.core.view.ViewPropertyAnimatorListenerAdapter, androidx.core.view.ViewPropertyAnimatorListener
 | |
|             public void onAnimationStart(View view) {
 | |
|                 ToolbarWidgetWrapper.this.mToolbar.setVisibility(0);
 | |
|             }
 | |
| 
 | |
|             @Override // androidx.core.view.ViewPropertyAnimatorListenerAdapter, androidx.core.view.ViewPropertyAnimatorListener
 | |
|             public void onAnimationEnd(View view) {
 | |
|                 if (this.mCanceled) {
 | |
|                     return;
 | |
|                 }
 | |
|                 ToolbarWidgetWrapper.this.mToolbar.setVisibility(i);
 | |
|             }
 | |
|         });
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setNavigationIcon(Drawable drawable) {
 | |
|         this.mNavIcon = drawable;
 | |
|         updateNavigationIcon();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setNavigationIcon(int i) {
 | |
|         setNavigationIcon(i != 0 ? AppCompatResources.getDrawable(getContext(), i) : null);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setDefaultNavigationIcon(Drawable drawable) {
 | |
|         if (this.mDefaultNavigationIcon != drawable) {
 | |
|             this.mDefaultNavigationIcon = drawable;
 | |
|             updateNavigationIcon();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void updateNavigationIcon() {
 | |
|         if ((this.mDisplayOpts & 4) != 0) {
 | |
|             Toolbar toolbar = this.mToolbar;
 | |
|             Drawable drawable = this.mNavIcon;
 | |
|             if (drawable == null) {
 | |
|                 drawable = this.mDefaultNavigationIcon;
 | |
|             }
 | |
|             toolbar.setNavigationIcon(drawable);
 | |
|             return;
 | |
|         }
 | |
|         this.mToolbar.setNavigationIcon((Drawable) null);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setNavigationContentDescription(CharSequence charSequence) {
 | |
|         this.mHomeDescription = charSequence;
 | |
|         updateHomeAccessibility();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setNavigationContentDescription(int i) {
 | |
|         setNavigationContentDescription(i == 0 ? null : getContext().getString(i));
 | |
|     }
 | |
| 
 | |
|     private void updateHomeAccessibility() {
 | |
|         if ((this.mDisplayOpts & 4) != 0) {
 | |
|             if (TextUtils.isEmpty(this.mHomeDescription)) {
 | |
|                 this.mToolbar.setNavigationContentDescription(this.mDefaultNavigationContentDescription);
 | |
|             } else {
 | |
|                 this.mToolbar.setNavigationContentDescription(this.mHomeDescription);
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void saveHierarchyState(SparseArray<Parcelable> sparseArray) {
 | |
|         this.mToolbar.saveHierarchyState(sparseArray);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void restoreHierarchyState(SparseArray<Parcelable> sparseArray) {
 | |
|         this.mToolbar.restoreHierarchyState(sparseArray);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setBackgroundDrawable(Drawable drawable) {
 | |
|         ViewCompat.setBackground(this.mToolbar, drawable);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public int getHeight() {
 | |
|         return this.mToolbar.getHeight();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setVisibility(int i) {
 | |
|         this.mToolbar.setVisibility(i);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public int getVisibility() {
 | |
|         return this.mToolbar.getVisibility();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public void setMenuCallbacks(MenuPresenter.Callback callback, MenuBuilder.Callback callback2) {
 | |
|         this.mToolbar.setMenuCallbacks(callback, callback2);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.DecorToolbar
 | |
|     public Menu getMenu() {
 | |
|         return this.mToolbar.getMenu();
 | |
|     }
 | |
| }
 |