AdapterHelper(Callback callback, boolean disableRecycler) { this.mUpdateOpPool = new SimplePool(30); this.mPendingUpdates = new ArrayList(); this.mPostponedList = new ArrayList(); this.mExistingUpdateTypes = 0; this.mCallback = callback; this.mDisableRecycler = disableRecycler; this.mOpReorderer = new OpReorderer(this); }
public TabLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.mTabs = new ArrayList(); this.mTabMaxWidth = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED; this.mTabViewPool = new SimplePool(12); ThemeUtils.checkAppCompatTheme(context); setHorizontalScrollBarEnabled(false); this.mTabStrip = new SlidingTabStrip(context); super.addView(this.mTabStrip, 0, new FrameLayout.LayoutParams(-2, -1)); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout, defStyleAttr, R.style.Widget_Design_TabLayout); this.mTabStrip.setSelectedIndicatorHeight(a.getDimensionPixelSize(R.styleable.TabLayout_tabIndicatorHeight, 0)); this.mTabStrip.setSelectedIndicatorColor(a.getColor(R.styleable.TabLayout_tabIndicatorColor, 0)); int dimensionPixelSize = a.getDimensionPixelSize(R.styleable.TabLayout_tabPadding, 0); this.mTabPaddingBottom = dimensionPixelSize; this.mTabPaddingEnd = dimensionPixelSize; this.mTabPaddingTop = dimensionPixelSize; this.mTabPaddingStart = dimensionPixelSize; this.mTabPaddingStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingStart, this.mTabPaddingStart); this.mTabPaddingTop = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingTop, this.mTabPaddingTop); this.mTabPaddingEnd = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingEnd, this.mTabPaddingEnd); this.mTabPaddingBottom = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingBottom, this.mTabPaddingBottom); this.mTabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab); TypedArray ta = context.obtainStyledAttributes(this.mTabTextAppearance, R.styleable.TextAppearance); try { this.mTabTextSize = (float) ta.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0); this.mTabTextColors = ta.getColorStateList(R.styleable.TextAppearance_android_textColor); if (a.hasValue(R.styleable.TabLayout_tabTextColor)) { this.mTabTextColors = a.getColorStateList(R.styleable.TabLayout_tabTextColor); } if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) { this.mTabTextColors = createColorStateList(this.mTabTextColors.getDefaultColor(), a.getColor(R.styleable.TabLayout_tabSelectedTextColor, 0)); } this.mRequestedTabMinWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMinWidth, -1); this.mRequestedTabMaxWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMaxWidth, -1); this.mTabBackgroundResId = a.getResourceId(R.styleable.TabLayout_tabBackground, 0); this.mContentInsetStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabContentStart, 0); this.mMode = a.getInt(R.styleable.TabLayout_tabMode, 1); this.mTabGravity = a.getInt(R.styleable.TabLayout_tabGravity, 0); a.recycle(); Resources res = getResources(); this.mTabTextMultiLineSize = (float) res.getDimensionPixelSize(R.dimen.design_tab_text_size_2line); this.mScrollableTabMinWidth = res.getDimensionPixelSize(R.dimen.design_tab_scrollable_min_width); applyModeAndGravity(); } finally { ta.recycle(); } }
/** * Returns a non-thread safe {@link Pool} that never returns {@code null} from * {@link Pool#acquire()} and that contains objects of the type created by the given * {@link Factory} with the given maximum size. * * <p>If the pool is empty when {@link Pool#acquire()} is called, the given {@link Factory} will * be used to create a new instance. * * @param <T> The type of object the pool will contains. */ public static <T extends Poolable> Pool<T> simple(int size, Factory<T> factory) { return build(new SimplePool<T>(size), factory); }