List of usage examples for android.content Context getTheme
@ViewDebug.ExportedProperty(deepExport = true) public abstract Resources.Theme getTheme();
From source file:android.support.v7.widget.AppCompatSpinner.java
@Override public void setAdapter(SpinnerAdapter adapter) { // The super constructor may call setAdapter before we're prepared. // Postpone doing anything until we've finished construction. if (!mPopupSet) { mTempAdapter = adapter;// www . ja va 2 s .c om return; } super.setAdapter(adapter); if (mPopup != null) { final Context popupContext = mPopupContext == null ? getContext() : mPopupContext; mPopup.setAdapter(new DropDownAdapter(adapter, popupContext.getTheme())); } }
From source file:org.mariotaku.twidere.util.TwidereActionModeForChildListener.java
ActionMode startSupportActionModeFromWindow(ActionMode.Callback callback) { if (mActionMode != null) { mActionMode.finish();//from ww w . ja v a 2s.c o m } final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback); if (mActionModeView == null) { if (mIsFloating && mUsePopup) { // Use the action bar theme. final Context actionBarContext; actionBarContext = ThemeUtils.getActionBarThemedContext(mActivity, mThemed.getCurrentThemeResourceId(), mThemed.getCurrentThemeColor()); mActionModeView = new ActionBarContextView(actionBarContext); mActionModePopup = new PopupWindow(actionBarContext, null, android.support.v7.appcompat.R.attr.actionModePopupWindowStyle); mActionModePopup.setContentView(mActionModeView); mActionModePopup.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); final TypedValue outValue = new TypedValue(); actionBarContext.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, outValue, true); final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics()); mActionModeView.setContentHeight(height); ThemeUtils.setActionBarContextViewBackground(mActionModeView, mThemed.getCurrentThemeResourceId(), mThemed.getCurrentThemeColor(), mThemed.getCurrentThemeBackgroundOption(), false); mActionModePopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); mShowActionModePopup = new Runnable() { @Override public void run() { mActionModePopup.showAtLocation(mWindow.getDecorView(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0); } }; } else { mActionModeView = (ActionBarContextView) mWindow.findViewById(R.id.action_context_bar); } } if (mActionModeView != null) { mActionModeView.killMode(); ActionMode mode = new StandaloneActionMode(mActionModeView.getContext(), mActionModeView, wrappedCallback, mActionModePopup == null); if (callback.onCreateActionMode(mode, mode.getMenu())) { mode.invalidate(); mActionModeView.initForMode(mode); mActionModeView.setVisibility(View.VISIBLE); mActionMode = mode; if (mActionModePopup != null) { mWindow.getDecorView().post(mShowActionModePopup); } mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); if (mActionModeView.getParent() != null) { ViewCompat.requestApplyInsets((View) mActionModeView.getParent()); } } else { mActionMode = null; } } if (mActionMode != null && mAppCompatCallback != null) { mAppCompatCallback.onSupportActionModeStarted(mActionMode); } return mActionMode; }
From source file:io.hefuyi.listener.widget.fastscroller.FastScroller.java
public FastScroller(Context context, FastScrollRecyclerView recyclerView, AttributeSet attrs) { Resources resources = context.getResources(); mRecyclerView = recyclerView;/*from w ww . ja va 2 s. c o m*/ mPopup = new FastScrollPopup(resources, recyclerView); mThumbHeight = DensityUtil.dip2px(context, 48); mWidth = DensityUtil.dip2px(context, 8); mTouchInset = DensityUtil.dip2px(context, -24); mThumb = new Paint(Paint.ANTI_ALIAS_FLAG); mTrack = new Paint(Paint.ANTI_ALIAS_FLAG); TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FastScrollRecyclerView, 0, 0); try { mAutoHideEnabled = typedArray.getBoolean(R.styleable.FastScrollRecyclerView_fastScrollAutoHide, true); mAutoHideDelay = typedArray.getInteger(R.styleable.FastScrollRecyclerView_fastScrollAutoHideDelay, DEFAULT_AUTO_HIDE_DELAY); int trackColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollTrackColor, 0x1f000000); int thumbColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollThumbColor, ATEUtil.getThemePrimaryColor(context)); int popupBgColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupBgColor, ATEUtil.getThemePrimaryColor(context)); int popupTextColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupTextColor, 0xffffffff); int popupTextSize = typedArray.getDimensionPixelSize( R.styleable.FastScrollRecyclerView_fastScrollPopupTextSize, DensityUtil.dip2sp(context, 56)); int popupBackgroundSize = typedArray.getDimensionPixelSize( R.styleable.FastScrollRecyclerView_fastScrollPopupBackgroundSize, DensityUtil.dip2px(context, 88)); mTrack.setColor(trackColor); mThumb.setColor(thumbColor); mPopup.setBgColor(popupBgColor); mPopup.setTextColor(popupTextColor); mPopup.setTextSize(popupTextSize); mPopup.setBackgroundSize(popupBackgroundSize); } finally { typedArray.recycle(); } mHideRunnable = new Runnable() { @Override public void run() { if (!mIsDragging) { if (mAutoHideAnimator != null) { mAutoHideAnimator.cancel(); } mAutoHideAnimator = ObjectAnimator.ofInt(FastScroller.this, "offsetX", (ListenerUtil.isRtl(mRecyclerView.getResources()) ? -1 : 1) * mWidth); mAutoHideAnimator.setInterpolator(new FastOutLinearInInterpolator()); mAutoHideAnimator.setDuration(200); mAutoHideAnimator.start(); } } }; mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); show(); } }); if (mAutoHideEnabled) { postAutoHideDelayed(); } }
From source file:com.gxy.fastscrollrecyclerview.views.FastScroller.java
public FastScroller(Context context, FastScrollRecyclerView recyclerView, AttributeSet attrs) { Resources resources = context.getResources(); mRecyclerView = recyclerView;//from w w w . j a v a 2 s. co m mPopup = new FastScrollPopup(resources, recyclerView); mThumbHeight = Utils.toPixels(resources, 32); mWidth = Utils.toPixels(resources, 4); mWidthBg = Utils.toPixels(resources, 2); mTouchInset = Utils.toPixels(resources, -30); mThumb = new Paint(Paint.ANTI_ALIAS_FLAG); mTrack = new Paint(Paint.ANTI_ALIAS_FLAG); TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FastScrollRecyclerView, 0, 0); try { mAutoHideEnabled = typedArray.getBoolean(R.styleable.FastScrollRecyclerView_fastScrollAutoHide, true); mAutoHideDelay = typedArray.getInteger(R.styleable.FastScrollRecyclerView_fastScrollAutoHideDelay, DEFAULT_AUTO_HIDE_DELAY); int trackColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollTrackColor, 0x1f000000); int thumbColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollThumbColor, 0xff000000); int popupBgColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupBgColor, 0xff000000); int popupTextColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupTextColor, 0xffffffff); mTrack.setColor(trackColor); mThumb.setColor(thumbColor); mPopup.setBgColor(popupBgColor); mPopup.setTextColor(popupTextColor); } finally { typedArray.recycle(); } mHideRunnable = new Runnable() { @Override public void run() { if (!mIsDragging) { if (mAutoHideAnimator != null) { mAutoHideAnimator.cancel(); } mAutoHideAnimator = ObjectAnimator.ofInt(FastScroller.this, "offsetX", (Utils.isRtl(mRecyclerView.getResources()) ? -1 : 1) * mWidth); mAutoHideAnimator.setInterpolator(new FastOutLinearInInterpolator()); mAutoHideAnimator.setDuration(200); mAutoHideAnimator.start(); } } }; mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); show(); } }); if (mAutoHideEnabled) { postAutoHideDelayed(); } }
From source file:com.gm.grecyclerview.GmRecyclerView.java
private void initAttrs(Context context, AttributeSet attrs, int defStyle) { TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.grv_GRecyclerView, defStyle, 0);/*from w w w . ja v a2s . co m*/ layoutMode = typedArray.getInt(R.styleable.grv_GRecyclerView_grv_layoutMode, 0); gridSpanCount = typedArray.getInt(R.styleable.grv_GRecyclerView_grv_gridSpanCount, 0); gridSpanSequence = typedArray.getString(R.styleable.grv_GRecyclerView_grv_gridSpanSequence); spacing = typedArray.getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_spacing, 0); verticalSpacing = typedArray.getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_verticalSpacing, 0); horizontalSpacing = typedArray.getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_horizontalSpacing, 0); isSpacingIncludeEdge = typedArray.getBoolean(R.styleable.grv_GRecyclerView_grv_isSpacingIncludeEdge, false); showDivider = typedArray.getBoolean(R.styleable.grv_GRecyclerView_grv_showDivider, false); showLastDivider = typedArray.getBoolean(R.styleable.grv_GRecyclerView_grv_showLastDivider, false); dividerColor = typedArray.getColor(R.styleable.grv_GRecyclerView_grv_dividerColor, 0); dividerOrientation = typedArray.getInt(R.styleable.grv_GRecyclerView_grv_dividerOrientation, 2); dividerPaddingLeft = typedArray.getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_dividerPaddingLeft, 0); dividerPaddingRight = typedArray .getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_dividerPaddingRight, 0); dividerPaddingTop = typedArray.getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_dividerPaddingTop, 0); dividerPaddingBottom = typedArray .getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_dividerPaddingBottom, 0); isSnappyEnabled = typedArray.getBoolean(R.styleable.grv_GRecyclerView_grv_snappy, false); snapAlignment = typedArray.getInt(R.styleable.grv_GRecyclerView_grv_snap_alignment, 0); showEmptyStateView = typedArray.getBoolean(R.styleable.grv_GRecyclerView_grv_showEmptyStateView, false); emptyStateViewRes = typedArray.getResourceId(R.styleable.grv_GRecyclerView_grv_emptyStateView, 0); loadMoreViewRes = typedArray.getResourceId(R.styleable.grv_GRecyclerView_grv_loadMoreView, 0); typedArray.recycle(); }
From source file:com.simplecityapps.recyclerview_fastscroll.views.FastScroller.java
public FastScroller(Context context, FastScrollRecyclerView recyclerView, AttributeSet attrs) { Resources resources = context.getResources(); mRecyclerView = recyclerView;//from w ww .ja v a2 s .c o m mPopup = new FastScrollPopup(resources, recyclerView); mThumbHeight = Utils.toPixels(resources, 48); mWidth = Utils.toPixels(resources, 8); mTouchInset = Utils.toPixels(resources, -24); mThumb = new Paint(Paint.ANTI_ALIAS_FLAG); mTrack = new Paint(Paint.ANTI_ALIAS_FLAG); TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FastScrollRecyclerView, 0, 0); try { mAutoHideEnabled = typedArray.getBoolean(R.styleable.FastScrollRecyclerView_fastScrollAutoHide, true); mAutoHideDelay = typedArray.getInteger(R.styleable.FastScrollRecyclerView_fastScrollAutoHideDelay, DEFAULT_AUTO_HIDE_DELAY); int trackColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollTrackColor, 0x1f000000); int thumbColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollThumbColor, 0xff000000); int popupBgColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupBgColor, 0xff000000); int popupTextColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupTextColor, 0xffffffff); mTrack.setColor(trackColor); mThumb.setColor(thumbColor); mPopup.setBgColor(popupBgColor); mPopup.setTextColor(popupTextColor); } finally { typedArray.recycle(); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mFastScrollerOffsetxObjectAnimator = new FastScrollerApi14OffsetXAnimatorImp(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mFastScrollerOffsetxObjectAnimator = new FastScrollerPreApi14OffsetXAnimatorImp(); } mHideRunnable = new Runnable() { @Override public void run() { if (mIsDragging) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { hideRunnable_11(); } else { FastScroller.this.setOffsetX((Utils.isRtl(mRecyclerView.getResources()) ? -1 : 1) * mWidth); } } }; mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); show(); } }); if (mAutoHideEnabled) { postAutoHideDelayed(); } }
From source file:ru.tinkoff.acquiring.sdk.EnterCardFragment.java
@Override public void onAttach(Context context) { super.onAttach(context); TypedArray typedArray = context.getTheme().obtainStyledAttributes(new int[] { R.attr.acqPayAmountPosition, R.attr.acqPayButtonAndIconPosition, R.attr.acqPayWithAmountFormat, R.attr.acqMoneyAmountFormat }); amountPositionMode = typedArray.getInt(AMOUNT_POSITION_INDEX, AMOUNT_POSITION_OVER_FIELDS); buttonAndIconsPositionMode = typedArray.getInt(BUTTON_POSITION_INDEX, BUTTON_UNDER_FIELDS_ICONS_ON_BOTTOM); payAmountFormat = typedArray.getString(PAY_WITH_AMOUNT_FORMAT_INDEX); moneyAmountFormat = typedArray.getString(MONEY_AMOUNT_FORMAT_INDEX); typedArray.recycle();/* ww w . j av a 2 s. co m*/ }
From source file:io.github.marktony.espresso.component.FastScroller.java
public FastScroller(Context context, FastScrollRecyclerView recyclerView, AttributeSet attrs) { Resources resources = context.getResources(); mRecyclerView = recyclerView;//from w w w .j ava2 s .co m mPopup = new FastScrollPopup(resources, recyclerView); mThumbHeight = DensityUtil.dip2px(context, 48); mWidth = DensityUtil.dip2px(context, 8); mTouchInset = DensityUtil.dip2px(context, -24); mThumb = new Paint(Paint.ANTI_ALIAS_FLAG); mTrack = new Paint(Paint.ANTI_ALIAS_FLAG); TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FastScrollRecyclerView, 0, 0); try { mAutoHideEnabled = typedArray.getBoolean(R.styleable.FastScrollRecyclerView_fastScrollAutoHide, true); mAutoHideDelay = typedArray.getInteger(R.styleable.FastScrollRecyclerView_fastScrollAutoHideDelay, DEFAULT_AUTO_HIDE_DELAY); int trackColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollTrackColor, 0x1f000000); int thumbColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollThumbColor, ContextCompat.getColor(context, R.color.colorPrimary)); int popupBgColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupBgColor, ContextCompat.getColor(context, R.color.colorPrimary)); int popupTextColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupTextColor, 0xffffffff); int popupTextSize = typedArray.getDimensionPixelSize( R.styleable.FastScrollRecyclerView_fastScrollPopupTextSize, DensityUtil.dip2sp(context, 56)); int popupBackgroundSize = typedArray.getDimensionPixelSize( R.styleable.FastScrollRecyclerView_fastScrollPopupBackgroundSize, DensityUtil.dip2px(context, 88)); mTrack.setColor(trackColor); mThumb.setColor(thumbColor); mPopup.setBgColor(popupBgColor); mPopup.setTextColor(popupTextColor); mPopup.setTextSize(popupTextSize); mPopup.setBackgroundSize(popupBackgroundSize); } finally { typedArray.recycle(); } mHideRunnable = new Runnable() { @Override public void run() { if (!mIsDragging) { if (mAutoHideAnimator != null) { mAutoHideAnimator.cancel(); } mAutoHideAnimator = ObjectAnimator.ofInt(FastScroller.this, "offsetX", (mRecyclerView.getResources().getConfiguration() .getLayoutDirection() == View.LAYOUT_DIRECTION_RTL ? -1 : 1) * mWidth); mAutoHideAnimator.setInterpolator(new FastOutLinearInInterpolator()); mAutoHideAnimator.setDuration(200); mAutoHideAnimator.start(); } } }; mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); show(); } }); if (mAutoHideEnabled) { postAutoHideDelayed(); } }
From source file:com.albedinsky.android.ui.navigation.NavigationLayout.java
/** * Ensures that a toolbar widget is contained within the current view hierarchy of this navigation * layout. If not it will be inflated from a layout resource presented within the current theme * and inserted into this layout at the proper place. */// ww w. j av a 2 s .com private void ensureToolbarWithinLayout() { final View toolbar = findViewById(R.id.ui_toolbar); if (toolbar == null) { final ViewGroup contentLayout = (ViewGroup) findViewById(R.id.ui_navigation_layout_content); if (contentLayout != null) { final Context context = getContext(); final TypedValue typedValue = new TypedValue(); if (context.getTheme().resolveAttribute(R.attr.uiNavigationToolbarLayout, typedValue, true)) { // Insert the Toolbar above the content container. contentLayout.addView(mLayoutInflater.inflate(typedValue.resourceId, contentLayout, false), 0); } } } }