Tabnine Logo
Context.getTheme
Code IndexAdd Tabnine to your IDE (free)

How to use
getTheme
method
in
android.content.Context

Best Java code snippets using android.content.Context.getTheme (Showing top 20 results out of 5,436)

origin: chrisbanes/cheesesquare

public SimpleStringRecyclerViewAdapter(Context context, List<String> items) {
  context.getTheme().resolveAttribute(R.attr.selectableItemBackground, mTypedValue, true);
  mBackground = mTypedValue.resourceId;
  mValues = items;
}
origin: Bearded-Hen/Android-Bootstrap

@SuppressWarnings("deprecation")
public static Drawable resolveDrawable(@DrawableRes int resId, Context context) {
  Resources resources = context.getResources();
  Resources.Theme theme = context.getTheme();
  if (Build.VERSION.SDK_INT >= 22) {
    return resources.getDrawable(resId, theme);
  }
  else {
    return resources.getDrawable(resId);
  }
}
origin: aa112901/remusic

  public void setIconColor(Drawable icon) {
    int textColorSecondary = android.R.attr.textColorSecondary;
    TypedValue value = new TypedValue();
    if (!mContext.getTheme().resolveAttribute(textColorSecondary, value, true)) {
      return;
    }
    int baseColor = mContext.getResources().getColor(value.resourceId);
    icon.setColorFilter(baseColor, PorterDuff.Mode.MULTIPLY);
  }
}
origin: nickbutcher/plaid

public static int getActionBarSize(@NonNull Context context) {
  TypedValue value = new TypedValue();
  context.getTheme().resolveAttribute(android.R.attr.actionBarSize, value, true);
  int actionBarSize = TypedValue.complexToDimensionPixelSize(
      value.data, context.getResources().getDisplayMetrics());
  return actionBarSize;
}
origin: mikepenz/MaterialDrawer

/**
 * Get the boolean value of a given styleable.
 *
 * @param ctx
 * @param styleable
 * @param def
 * @return
 */
public static boolean getBooleanStyleable(Context ctx, @StyleableRes int styleable, boolean def) {
  TypedArray ta = ctx.getTheme().obtainStyledAttributes(R.styleable.MaterialDrawer);
  return ta.getBoolean(styleable, def);
}
origin: roughike/BottomBar

@NonNull protected static TypedValue getTypedValue(@NonNull Context context, @AttrRes int resId) {
  TypedValue tv = new TypedValue();
  context.getTheme().resolveAttribute(resId, tv, true);
  return tv;
}
origin: zhihu/Matisse

public AlbumMediaAdapter(Context context, SelectedItemCollection selectedCollection, RecyclerView recyclerView) {
  super(null);
  mSelectionSpec = SelectionSpec.getInstance();
  mSelectedCollection = selectedCollection;
  TypedArray ta = context.getTheme().obtainStyledAttributes(new int[]{R.attr.item_placeholder});
  mPlaceholder = ta.getDrawable(0);
  ta.recycle();
  mRecyclerView = recyclerView;
}
origin: google/ExoPlayer

public AspectRatioFrameLayout(Context context, AttributeSet attrs) {
 super(context, attrs);
 resizeMode = RESIZE_MODE_FIT;
 if (attrs != null) {
  TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
    R.styleable.AspectRatioFrameLayout, 0, 0);
  try {
   resizeMode = a.getInt(R.styleable.AspectRatioFrameLayout_resize_mode, RESIZE_MODE_FIT);
  } finally {
   a.recycle();
  }
 }
 aspectRatioUpdateDispatcher = new AspectRatioUpdateDispatcher();
}
origin: naman14/Timber

public static int getActionBarHeight(Context context) {
  int mActionBarHeight;
  TypedValue mTypedValue = new TypedValue();
  context.getTheme().resolveAttribute(R.attr.actionBarSize, mTypedValue, true);
  mActionBarHeight = TypedValue.complexToDimensionPixelSize(mTypedValue.data, context.getResources().getDisplayMetrics());
  return mActionBarHeight;
}
origin: TeamNewPipe/NewPipe

/**
 * Get a color from an attr styled according to the the context's theme.
 */
public static int resolveColorFromAttr(Context context, @AttrRes int attrColor) {
  final TypedValue value = new TypedValue();
  context.getTheme().resolveAttribute(attrColor, value, true);
  if (value.resourceId != 0) {
    return ContextCompat.getColor(context, value.resourceId);
  }
  return value.data;
}
origin: scwang90/SmartRefreshLayout

@SuppressWarnings("deprecation")
public void setColorSchemeColorIds(@IdRes int... resources) {
  final View thisView = this;
  final Resources res = thisView.getResources();
  final int[] colorRes = new int[resources.length];
  for (int i = 0; i < resources.length; i++) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
      colorRes[i] = res.getColor(resources[i], getContext().getTheme());
    } else {
      colorRes[i] = res.getColor(resources[i]);
    }
  }
  mProgress.setColorSchemeColors(colorRes);
}
//</editor-fold>
origin: bumptech/glide

private static Drawable getDrawable(
  Context ourContext, Context targetContext, @DrawableRes int id, @Nullable Theme theme) {
 try {
  // Race conditions may cause us to attempt to load using v7 more than once. That's ok since
  // this check is a modest optimization and the output will be correct anyway.
  if (shouldCallAppCompatResources) {
   return loadDrawableV7(targetContext, id, theme);
  }
 } catch (NoClassDefFoundError error) {
  shouldCallAppCompatResources = false;
 } catch (IllegalStateException e) {
  if (ourContext.getPackageName().equals(targetContext.getPackageName())) {
   throw e;
  }
  return ContextCompat.getDrawable(targetContext, id);
 } catch (Resources.NotFoundException e) {
  // Ignored, this can be thrown when drawable compat attempts to decode a canary resource. If
  // that decode attempt fails, we still want to try with the v4 ResourcesCompat below.
 }
 return loadDrawableV4(targetContext, id, theme != null ? theme : targetContext.getTheme());
}
origin: bumptech/glide

private Drawable loadDrawable(@DrawableRes int resourceId) {
 Theme theme = requestOptions.getTheme() != null
   ? requestOptions.getTheme() : context.getTheme();
 return DrawableDecoderCompat.getDrawable(glideContext, resourceId, theme);
}
origin: aa112901/remusic

static int getAttrDimensionPixelOffset(Context context, AttributeSet attrs, int attr, int defaultValue) {
  TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
  final int value = a.getDimensionPixelOffset(0, defaultValue);
  a.recycle();
  return value;
}
origin: aa112901/remusic

static int getAttrColor(Context context, AttributeSet attrs, int attr, int defaultValue) {
  TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
  final int colorId = a.getResourceId(0, 0);
  final int value = colorId != 0 ? ThemeUtils.replaceColorById(context, colorId) : ThemeUtils.replaceColor(context, a.getColor(0, defaultValue));
  a.recycle();
  return value;
}
origin: facebook/litho

public void init(ComponentContext context) {
 mResources = context.getAndroidContext().getResources();
 mTheme = context.getAndroidContext().getTheme();
 mResourceCache = context.getResourceCache();
}
origin: zhihu/Matisse

private void init() {
  mSelectedColor = ResourcesCompat.getColor(
      getResources(), R.color.zhihu_item_checkCircle_backgroundColor,
      getContext().getTheme());
  mUnSelectUdColor = ResourcesCompat.getColor(
      getResources(), R.color.zhihu_check_original_radio_disable,
      getContext().getTheme());
  setChecked(false);
}
origin: bumptech/glide

public void sameAs(@DrawableRes int resourceId) {
 Context context = InstrumentationRegistry.getTargetContext();
 Drawable drawable =
   ResourcesCompat.getDrawable(context.getResources(), resourceId, context.getTheme());
 sameAs(drawable);
}
origin: JakeWharton/butterknife

@UiThread // Implicit synchronization for use of shared resource VALUE.
public static Drawable getTintedDrawable(Context context,
  @DrawableRes int id, @AttrRes int tintAttrId) {
 boolean attributeFound = context.getTheme().resolveAttribute(tintAttrId, VALUE, true);
 if (!attributeFound) {
  throw new Resources.NotFoundException("Required tint color attribute with name "
    + context.getResources().getResourceEntryName(tintAttrId)
    + " and attribute ID "
    + tintAttrId
    + " was not found.");
 }
 Drawable drawable = ContextCompat.getDrawable(context, id);
 drawable = DrawableCompat.wrap(drawable.mutate());
 int color = ContextCompat.getColor(context, VALUE.resourceId);
 DrawableCompat.setTint(drawable, color);
 return drawable;
}
origin: googlesamples/easypermissions

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
             @Nullable ViewGroup container,
             @Nullable Bundle savedInstanceState) {
  getContext().getTheme().applyStyle(R.style.Theme_AppCompat, true);
  return super.onCreateView(inflater, container, savedInstanceState);
}
android.contentContextgetTheme

Popular methods of Context

  • getPackageName
  • getResources
  • getSystemService
  • obtainStyledAttributes
  • getApplicationContext
  • getString
  • getPackageManager
  • startActivity
  • getContentResolver
  • getSharedPreferences
  • getAssets
  • getCacheDir
  • getAssets,
  • getCacheDir,
  • startService,
  • sendBroadcast,
  • getFilesDir,
  • registerReceiver,
  • getApplicationInfo,
  • unregisterReceiver,
  • getExternalCacheDir

Popular in Java

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • scheduleAtFixedRate (Timer)
  • findViewById (Activity)
  • String (java.lang)
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now