Example usage for android.view ContextThemeWrapper getResources

List of usage examples for android.view ContextThemeWrapper getResources

Introduction

In this page you can find the example usage for android.view ContextThemeWrapper getResources.

Prototype

@Override
    public Resources getResources() 

Source Link

Usage

From source file:Main.java

public static float getDensity(ContextThemeWrapper context) {
    return context.getResources().getDisplayMetrics().density;
}

From source file:com.example.domiter.fileexplorer.dialog.BaseDialogFragment.java

private int getIconTintColor() {
    // Resolve AlertDialog theme
    TypedValue outValue = new TypedValue();
    getActivity().getTheme().resolveAttribute(android.R.attr.alertDialogTheme, outValue, true);
    int theme = outValue.resourceId;
    ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(getActivity(), theme);

    // Try to get title color
    int colorId = getThemedResourceId(contextThemeWrapper.getTheme(), textColorPrimary);
    int tintColor;
    if (colorId == -1) {
        tintColor = getThemedColor(contextThemeWrapper.getTheme(), textColorPrimary);
    } else {/* w ww  .j  av a 2 s  .com*/
        tintColor = contextThemeWrapper.getResources().getColor(colorId);
    }

    return tintColor;
}