Example usage for android.app Activity getTheme

List of usage examples for android.app Activity getTheme

Introduction

In this page you can find the example usage for android.app Activity getTheme.

Prototype

@Override
    public Resources.Theme getTheme() 

Source Link

Usage

From source file:Main.java

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public static void setActionBar(Activity activity, int background, String title) {

    // Action Bar Icon
    activity.getActionBar()/* w ww  .  j  av a  2  s. c  o m*/
            .setIcon(new ColorDrawable(activity.getResources().getColor(android.R.color.transparent)));

    // Action Bar Title
    activity.getActionBar().setTitle(title);

    // Action Bar Background
    Drawable draw;
    if (android.os.Build.VERSION.SDK_INT >= 21) {
        draw = activity.getResources().getDrawable(background, activity.getTheme());
        activity.getActionBar().setBackgroundDrawable(draw);
    } else {
        draw = activity.getResources().getDrawable(background);
        activity.getActionBar().setBackgroundDrawable(draw);
    }
}

From source file:com.docd.purefm.utils.BookmarksHelper.java

@NonNull
public static BookmarkItem createUserBookmarkItem(@NonNull final Activity activity,
        @NonNull final String path) {
    final BookmarkItem item = new BookmarkItem();
    item.mDisplayName = FilenameUtils.getName(path);
    if (item.mDisplayName.equals(Environment.sRootDirectory.getAbsolutePath())) {
        item.mDisplayName = activity.getText(R.string.root);
    }/*from   www.j  a  v  a2  s.  c o  m*/
    item.mDisplayPath = path;
    item.mIcon = ThemeUtils.getDrawableNonNull(activity.getTheme(), R.attr.ic_bookmark);
    return item;
}

From source file:com.google.android.gms.common.C0270e.java

private static Dialog m3391b(int i, Activity activity, Fragment fragment, int i2,
        OnCancelListener onCancelListener) {
    Builder builder;/*from  www. j av a2s.com*/
    Intent a;
    OnClickListener c0420i;
    CharSequence c;
    if (C0516u.m4166a((Context) activity) && i == 2) {
        i = 42;
    }
    if (C0519x.m4174c()) {
        TypedValue typedValue = new TypedValue();
        activity.getTheme().resolveAttribute(16843529, typedValue, true);
        if ("Theme.Dialog.Alert".equals(activity.getResources().getResourceEntryName(typedValue.resourceId))) {
            builder = new Builder(activity, 5);
            if (builder == null) {
                builder = new Builder(activity);
            }
            builder.setMessage(C0270e.m3392b(activity, i));
            if (onCancelListener != null) {
                builder.setOnCancelListener(onCancelListener);
            }
            a = C0270e.m3382a(i);
            c0420i = fragment != null ? new C0420i(activity, a, i2) : new C0420i(fragment, a, i2);
            c = C0270e.m3397c(activity, i);
            if (c != null) {
                builder.setPositiveButton(c, c0420i);
            }
            switch (i) {
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoPanelHeight /*0*/:
                return null;
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoShadowHeight /*1*/:
                return builder.setTitle(R.common_google_play_services_install_title).create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoParalaxOffset /*2*/:
                return builder.setTitle(R.common_google_play_services_update_title).create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoFadeColor /*3*/:
                return builder.setTitle(R.common_google_play_services_enable_title).create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoFlingVelocity /*4*/:
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoOverlay /*6*/:
                return builder.create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoDragView /*5*/:
                Log.e("GooglePlayServicesUtil",
                        "An invalid account was specified when connecting. Please provide a valid account.");
                return builder.setTitle(R.common_google_play_services_invalid_account_title).create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoClipPanel /*7*/:
                Log.e("GooglePlayServicesUtil", "Network error occurred. Please retry request later.");
                return builder.setTitle(R.common_google_play_services_network_error_title).create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoAnchorPoint /*8*/:
                Log.e("GooglePlayServicesUtil",
                        "Internal error occurred. Please see logs for detailed information");
                return builder.create();
            case HTTP.HT /*9*/:
                Log.e("GooglePlayServicesUtil", "Google Play services is invalid. Cannot recover.");
                return builder.setTitle(R.common_google_play_services_unsupported_title).create();
            case HTTP.LF /*10*/:
                Log.e("GooglePlayServicesUtil",
                        "Developer error occurred. Please see logs for detailed information");
                return builder.create();
            case com.olacabs.customer.R.R.MapM4bAttrs_m4b_uiZoomControls /*11*/:
                Log.e("GooglePlayServicesUtil", "The application is not licensed to the user.");
                return builder.create();
            case Constants.DEFAULT_MAP_ZOOM_LEVEL /*16*/:
                Log.e("GooglePlayServicesUtil",
                        "One of the API components you attempted to connect to is not available.");
                return builder.create();
            case LangUtils.HASH_SEED /*17*/:
                Log.e("GooglePlayServicesUtil", "The specified account could not be signed in.");
                return builder.setTitle(R.common_google_play_services_sign_in_failed_title).create();
            case 42:
                return builder.setTitle(R.common_android_wear_update_title).create();
            default:
                Log.e("GooglePlayServicesUtil", "Unexpected error code " + i);
                return builder.create();
            }
        }
    }
    builder = null;
    if (builder == null) {
        builder = new Builder(activity);
    }
    builder.setMessage(C0270e.m3392b(activity, i));
    if (onCancelListener != null) {
        builder.setOnCancelListener(onCancelListener);
    }
    a = C0270e.m3382a(i);
    if (fragment != null) {
    }
    c = C0270e.m3397c(activity, i);
    if (c != null) {
        builder.setPositiveButton(c, c0420i);
    }
    switch (i) {
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoPanelHeight /*0*/:
        return null;
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoShadowHeight /*1*/:
        return builder.setTitle(R.common_google_play_services_install_title).create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoParalaxOffset /*2*/:
        return builder.setTitle(R.common_google_play_services_update_title).create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoFadeColor /*3*/:
        return builder.setTitle(R.common_google_play_services_enable_title).create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoFlingVelocity /*4*/:
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoOverlay /*6*/:
        return builder.create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoDragView /*5*/:
        Log.e("GooglePlayServicesUtil",
                "An invalid account was specified when connecting. Please provide a valid account.");
        return builder.setTitle(R.common_google_play_services_invalid_account_title).create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoClipPanel /*7*/:
        Log.e("GooglePlayServicesUtil", "Network error occurred. Please retry request later.");
        return builder.setTitle(R.common_google_play_services_network_error_title).create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoAnchorPoint /*8*/:
        Log.e("GooglePlayServicesUtil", "Internal error occurred. Please see logs for detailed information");
        return builder.create();
    case HTTP.HT /*9*/:
        Log.e("GooglePlayServicesUtil", "Google Play services is invalid. Cannot recover.");
        return builder.setTitle(R.common_google_play_services_unsupported_title).create();
    case HTTP.LF /*10*/:
        Log.e("GooglePlayServicesUtil", "Developer error occurred. Please see logs for detailed information");
        return builder.create();
    case com.olacabs.customer.R.R.MapM4bAttrs_m4b_uiZoomControls /*11*/:
        Log.e("GooglePlayServicesUtil", "The application is not licensed to the user.");
        return builder.create();
    case Constants.DEFAULT_MAP_ZOOM_LEVEL /*16*/:
        Log.e("GooglePlayServicesUtil",
                "One of the API components you attempted to connect to is not available.");
        return builder.create();
    case LangUtils.HASH_SEED /*17*/:
        Log.e("GooglePlayServicesUtil", "The specified account could not be signed in.");
        return builder.setTitle(R.common_google_play_services_sign_in_failed_title).create();
    case 42:
        return builder.setTitle(R.common_android_wear_update_title).create();
    default:
        Log.e("GooglePlayServicesUtil", "Unexpected error code " + i);
        return builder.create();
    }
}

From source file:info.papdt.blacklight.support.Utility.java

public static void initDarkTabHost(Activity activity, TabHost tabhost) {
    if (isDarkMode(activity)) {
        int textColor = 0;

        try {/*ww  w  .j  av a 2s  . com*/
            TypedArray array = activity.getTheme().obtainStyledAttributes(R.styleable.BlackLight);
            textColor = array.getColor(R.styleable.BlackLight_CardForeground, 0);
            array.recycle();
        } catch (NotFoundException e) {
            return;
        }

        for (int i = 0; i < tabhost.getTabWidget().getChildCount(); i++) {
            TextView tv = (TextView) tabhost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
            tv.setTextColor(textColor);
        }
    }
}

From source file:com.irccloud.android.DrawerArrowDrawable.java

/**
 * @param context used to get the configuration for the drawable from
 *//*ww  w  . j a va  2 s. c  o  m*/
public DrawerArrowDrawable(Activity context) {
    final TypedArray typedArray = context.getTheme().obtainStyledAttributes(null, R.styleable.DrawerArrowToggle,
            R.attr.drawerArrowStyle, R.style.Base_Widget_AppCompat_DrawerArrowToggle);
    mContext = context;
    mPaint.setAntiAlias(true);
    mPaint.setColor(typedArray.getColor(R.styleable.DrawerArrowToggle_color, 0));
    mSize = typedArray.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0);
    mBarSize = typedArray.getDimension(R.styleable.DrawerArrowToggle_barSize, 0);
    mTopBottomArrowSize = typedArray.getDimension(R.styleable.DrawerArrowToggle_topBottomBarArrowSize, 0);
    mBarThickness = typedArray.getDimension(R.styleable.DrawerArrowToggle_thickness, 0);
    mBarGap = typedArray.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0);
    mSpin = typedArray.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true);
    mMiddleArrowSize = typedArray.getDimension(R.styleable.DrawerArrowToggle_middleBarArrowSize, 0);
    typedArray.recycle();

    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.SQUARE);
    mPaint.setStrokeWidth(mBarThickness);
}

From source file:com.camnter.newlife.widget.decorator.DividerItemDecoration.java

public DividerItemDecoration(Activity activity, int orientation, int drawableId) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        this.mDivider = activity.getTheme().getDrawable(drawableId);
    } else {//from  w  w w. j a va2  s.  co m
        this.mDivider = activity.getResources().getDrawable(drawableId);
    }
    this.setOrientation(orientation);
}

From source file:com.android.projectz.teamrocket.thebusapp.adapters.CustomListSettingMain.java

/**
 * costruttore con i parametri necessari
 *
 * @param context//w  w  w  .  j  a  v  a 2  s .  co m
 * @param web
 * @param imageId
 */
public CustomListSettingMain(Activity context, String[] web, Drawable[] imageId) {
    super(context, R.layout.list_main, web);
    this.context = context;
    this.text = web;
    this.imageId = imageId;
    theme = context.getTheme();
}

From source file:com.camnter.easyrecyclerview.widget.decorator.EasyDividerItemDecoration.java

/**
 * set divider color/*from   w ww  .ja v a2  s. c  o m*/
 *
 * @param activity activity
 * @param drawableId drawableId
 */
private void setDivider(Activity activity, int drawableId) {
    try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            this.mDivider = activity.getTheme().getDrawable(drawableId);
        } else {
            this.mDivider = activity.getResources().getDrawable(drawableId);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    /**
     * set default divider color
     */
    if (this.mDivider == null)
        this.setDefaultDivider(activity);
}

From source file:mobi.cangol.mobile.navigation.DrawerMenuLayout.java

public void attachToActivity(Activity activity, boolean isFloatActionBarEnabled) {
    // get the window background
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
    int background = a.getResourceId(0, 0);
    a.recycle();//from   ww w  . j  a v a 2  s  .  c  o  m

    this.isFloatActionBarEnabled = isFloatActionBarEnabled;

    if (isFloatActionBarEnabled) {
        ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
        ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
        if (decorChild.getBackground() != null) {
            this.setBackgroundDrawable(decorChild.getBackground());
            decorChild.setBackgroundDrawable(null);
        } else {
            if (this.getBackground() == null)
                this.setBackgroundResource(background);
        }
        decor.removeView(decorChild);
        decor.addView(this, 0);
        getContentView().addView(decorChild);
    } else {
        ViewGroup contentParent = (ViewGroup) activity.findViewById(android.R.id.content);
        ViewGroup content = (ViewGroup) contentParent.getChildAt(0);
        contentParent.removeView(content);
        contentParent.addView(this, 0);
        getContentView().addView(content);
    }
}

From source file:mobi.cangol.mobile.navigation.SlidingMenuLayout.java

public void attachToActivity(Activity activity, boolean isFloatActionBarEnabled) {
    // get the window background
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
    int background = a.getResourceId(0, 0);
    a.recycle();/*ww w  .j  av a2s.c o m*/

    this.isFloatActionBarEnabled = isFloatActionBarEnabled;

    if (isFloatActionBarEnabled) {
        ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
        ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
        if (decorChild.getBackground() != null) {
            this.setBackgroundDrawable(decorChild.getBackground());
            decorChild.setBackgroundDrawable(null);
        } else {
            if (this.getBackground() == null)
                this.setBackgroundResource(background);
        }
        decor.removeView(decorChild);
        decor.addView(this.getRootView(), 0);
        getContentView().addView(decorChild);
    } else {
        ViewGroup contentParent = (ViewGroup) activity.findViewById(android.R.id.content);
        ViewGroup content = (ViewGroup) contentParent.getChildAt(0);
        contentParent.removeView(content);
        contentParent.addView(this, 0);
        getContentView().addView(content);
    }
}