Example usage for android.graphics.drawable ColorDrawable ColorDrawable

List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable ColorDrawable ColorDrawable.

Prototype

public ColorDrawable(@ColorInt int color) 

Source Link

Document

Creates a new ColorDrawable with the specified color.

Usage

From source file:com.bilibili.boxing_impl.ui.BoxingViewFragment.java

public void setTitleTxt(TextView titleTxt) {
    mTitleTxt = titleTxt;/*from w  w w .ja v  a2s .  c  o m*/
    mTitleTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mAlbumPopWindow == null) {
                int height = WindowManagerHelper.getScreenHeight(v.getContext())
                        - (WindowManagerHelper.getToolbarHeight(v.getContext())
                                + WindowManagerHelper.getStatusBarHeight(v.getContext()));
                View windowView = createWindowView();
                mAlbumPopWindow = new PopupWindow(windowView, ViewGroup.LayoutParams.MATCH_PARENT, height,
                        true);
                mAlbumPopWindow.setAnimationStyle(R.style.PopupAnimation);
                mAlbumPopWindow.setOutsideTouchable(true);
                mAlbumPopWindow.setBackgroundDrawable(
                        new ColorDrawable(ContextCompat.getColor(v.getContext(), R.color.colorPrimaryAlpha)));
                mAlbumPopWindow.setContentView(windowView);
            }
            mAlbumPopWindow.showAsDropDown(v, 0, 0);
        }

        @NonNull
        private View createWindowView() {
            View view = LayoutInflater.from(getActivity()).inflate(R.layout.layout_album, null);
            RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.album_recycleview);
            recyclerView.setLayoutManager(
                    new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false));
            recyclerView.addItemDecoration(new SpacesItemDecoration(2, 1));

            View albumShadowLayout = view.findViewById(R.id.album_shadow);
            albumShadowLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismissAlbumWindow();
                }
            });
            mAlbumWindowAdapter.setAlbumOnClickListener(new OnAlbumItemOnClickListener());
            recyclerView.setAdapter(mAlbumWindowAdapter);
            return view;
        }
    });
}

From source file:com.gokuai.yunkuandroidsdk.imageutils.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.//from   w w w  . j  av  a 2  s. c  o  m
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent),
                        isRoundDrawable
                                ? new BitmapDrawable(mResources,
                                        Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false))
                                : drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(isRoundDrawable
                ? new BitmapDrawable(mResources,
                        Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false))
                : new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        if (isRoundDrawable) {

            imageView.setImageBitmap(Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false));
        } else {

            imageView.setImageDrawable(drawable);
        }
    }
}

From source file:com.gmall.gmallmanager.widget.videoimage.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.//from  w  w  w.  j  av a2s.com
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.amaze.filemanager.fragments.Main.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setHasOptionsMenu(false);/*from   ww w .ja v  a 2  s  .com*/
    //MAIN_ACTIVITY = (MainActivity) getActivity();
    initNoFileLayout();
    utils = new Futils();
    String x = PreferenceUtils.getSelectionColor(skin);
    skinselection = Color.parseColor(x);
    color = PreferenceUtils.calculatevalues(x);
    ColorMatrix colorMatrix = new ColorMatrix(PreferenceUtils.calculatefilter(color));
    colorMatrixColorFilter = new ColorMatrixColorFilter(colorMatrix);
    ROOT_MODE = Sp.getBoolean("rootmode", false);
    SHOW_HIDDEN = Sp.getBoolean("showHidden", false);
    COLORISE_ICONS = Sp.getBoolean("coloriseIcons", true);
    folder = res.getDrawable(R.drawable.ic_grid_folder_new);
    getSortModes();
    DARK_IMAGE = res.getDrawable(R.drawable.ic_doc_image_dark);
    DARK_VIDEO = res.getDrawable(R.drawable.ic_doc_video_dark);
    this.setRetainInstance(false);
    f = new HFile(HFile.UNKNOWN, CURRENT_PATH);
    f.generateMode(getActivity());
    MAIN_ACTIVITY.initiatebbar();
    IS_LIST = savedInstanceState != null ? savedInstanceState.getBoolean("IS_LIST", IS_LIST) : IS_LIST;
    ic = new IconHolder(getActivity(), SHOW_THUMBS, !IS_LIST);
    if (theme1 == 1) {

        listView.setBackgroundDrawable(
                new ColorDrawable(getResources().getColor(R.color.holo_dark_background)));
    } else {

        if (IS_LIST)
            listView.setBackgroundDrawable(
                    new ColorDrawable(getResources().getColor(android.R.color.background_light)));

    }
    listView.setHasFixedSize(true);
    columns = Integer.parseInt(Sp.getString("columns", "-1"));
    if (IS_LIST) {
        mLayoutManager = new LinearLayoutManager(getActivity());
        listView.setLayoutManager(mLayoutManager);
    } else {
        if (columns == -1 || columns == 0)
            mLayoutManagerGrid = new GridLayoutManager(getActivity(), 3);
        else
            mLayoutManagerGrid = new GridLayoutManager(getActivity(), columns);
        listView.setLayoutManager(mLayoutManagerGrid);
    }
    // use a linear layout manager
    footerView = getActivity().getLayoutInflater().inflate(R.layout.divider, null);
    dividerItemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST, false,
            SHOW_DIVIDERS);
    listView.addItemDecoration(dividerItemDecoration);
    mSwipeRefreshLayout.setColorSchemeColors(Color.parseColor(fabSkin));
    DefaultItemAnimator animator = new DefaultItemAnimator();
    listView.setItemAnimator(animator);
    mToolbarContainer.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    if ((columns == 0 || columns == -1)) {
                        int screen_width = listView.getWidth();
                        int dptopx = dpToPx(115);
                        columns = screen_width / dptopx;
                        if (columns == 0 || columns == -1)
                            columns = 3;
                        if (!IS_LIST)
                            mLayoutManagerGrid.setSpanCount(columns);
                    }
                    if (savedInstanceState != null && !IS_LIST)
                        retrieveFromSavedInstance(savedInstanceState);
                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
                        mToolbarContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    } else {
                        mToolbarContainer.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    }
                }

            });
    if (savedInstanceState == null) {
        loadlist(CURRENT_PATH, false, openMode);

    } else {
        if (IS_LIST)
            retrieveFromSavedInstance(savedInstanceState);
    }
}

From source file:com.android.simpleimageloader.image.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be set on the ImageView.
 * /*  w ww .j  a v  a 2 s  . c  o m*/
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable, DisplayOptions options) {
    if (options.mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, options.mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.linhnv.apps.funnybox.utils.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView//from w w w . j ava2 s.c  o  m
 * @param bitmap
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drwabale and the final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });
        // Set background to loading bitmap
        imageView.setImageDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
        imageView.setBackgroundColor(Color.BLACK);
    }
}

From source file:com.grarak.kerneladiutor.fragments.RecyclerViewFragment.java

private void setAppBarLayoutAlpha(int alpha) {
    if (isForeground())
        return;//from  w w  w. j a  v  a 2 s  .  c o m
    Activity activity;
    if ((activity = getActivity()) != null && mAppBarLayout != null && mToolBar != null) {
        int colorPrimary = ViewUtils.getColorPrimaryColor(activity);
        mAppBarLayout.setBackgroundDrawable(new ColorDrawable(Color.argb(alpha, Color.red(colorPrimary),
                Color.green(colorPrimary), Color.blue(colorPrimary))));
        mToolBar.setTitleTextColor(Color.argb(alpha, 255, 255, 255));
    }
}

From source file:com.appeaser.sublimenavigationviewlibrary.SublimeThemer.java

private void setDefaultItemBackground() {
    TypedValue value = new TypedValue();
    int colorControlHighlight = 0;
    if (mContext.getTheme().resolveAttribute(R.attr.colorControlHighlight, value, true)) {
        colorControlHighlight = value.data;
    } else {/*ww  w.java  2s .  c o m*/
        colorControlHighlight = mDefaultTheme == DefaultTheme.LIGHT
                ? mContext.getResources().getColor(R.color.snv_ripple_material_light)
                : mContext.getResources().getColor(R.color.snv_ripple_material_dark);
    }

    StateListDrawable drawable = new StateListDrawable();
    LayerDrawable checked = new LayerDrawable(
            new Drawable[] { new ColorDrawable(colorControlHighlight), obtainSelectableItemBackground() });
    drawable.addState(CHECKED_STATE_SET, checked);
    drawable.addState(EMPTY_STATE_SET, obtainSelectableItemBackground());
    mItemBackground = drawable;
}

From source file:com.codingPower.framework.worker.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView/*from www.  j  av  a 2s  .  c o m*/
 * @param bitmap
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drwabale and the final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });
        // Set background to loading bitmap
        //imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.crearo.gpslogger.GpsMainActivity.java

public void setUpNavigationDrawer(Bundle savedInstanceState) {

    final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, getToolbar(), R.string.navigation_drawer_open,
            R.string.navigation_drawer_close) {

        public void onDrawerClosed(View view) {
            invalidateOptionsMenu();/* w  ww  .  j a  va  2 s  . co m*/
        }

        public void onDrawerOpened(View drawerView) {
            invalidateOptionsMenu();
        }
    };

    drawerHeader = new AccountHeaderBuilder().withActivity(this).withCompactStyle(true)
            .withAccountHeader(R.layout.smaller_header).withSavedInstance(savedInstanceState)
            .withProfileImagesVisible(false)
            .withHeaderBackground(new ColorDrawable(getResources().getColor(R.color.accentColor)))
            .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {

                @Override
                public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {

                    //Add new profile
                    if (profile.getIdentifier() == 101) {
                        new MaterialDialog.Builder(GpsMainActivity.this)
                                .title(getString(R.string.profile_create_new))
                                .inputType(InputType.TYPE_CLASS_TEXT).negativeText(R.string.cancel)
                                .input("", "", false, new MaterialDialog.InputCallback() {
                                    @Override
                                    public void onInput(@NonNull MaterialDialog materialDialog,
                                            CharSequence charSequence) {
                                        String profileName = charSequence.toString().trim();
                                        if (!Strings.isNullOrEmpty(profileName)) {
                                            final String[] ReservedChars = { "|", "\\", "?", "*", "<", "\"",
                                                    ":", ">", ".", "/", "'", ";" };

                                            for (String c : ReservedChars) {
                                                profileName = profileName.replace(c, "");
                                            }

                                            EventBus.getDefault()
                                                    .post(new ProfileEvents.CreateNewProfile(profileName));
                                        }
                                    }
                                }).show();
                        return true;
                    }

                    //Clicked on profile name
                    String newProfileName = profile.getName().getText();
                    EventBus.getDefault().post(new ProfileEvents.SwitchToProfile(newProfileName));

                    refreshProfileIcon(profile.getName().getText());
                    return true;
                }
            })
            .withOnAccountHeaderItemLongClickListener(new AccountHeader.OnAccountHeaderItemLongClickListener() {
                @Override
                public boolean onProfileLongClick(View view, final IProfile iProfile, boolean b) {
                    if (iProfile.getIdentifier() > 150) {

                        if (preferenceHelper.getCurrentProfileName().equals(iProfile.getName().getText())) {
                            Dialogs.alert(getString(R.string.sorry),
                                    getString(R.string.profile_switch_before_delete), GpsMainActivity.this);
                        } else {
                            new MaterialDialog.Builder(GpsMainActivity.this)
                                    .title(getString(R.string.profile_delete))
                                    .content(iProfile.getName().getText()).positiveText(R.string.ok)
                                    .negativeText(R.string.cancel)
                                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                                        @Override
                                        public void onClick(@NonNull MaterialDialog materialDialog,
                                                @NonNull DialogAction dialogAction) {
                                            EventBus.getDefault().post(new ProfileEvents.DeleteProfile(
                                                    iProfile.getName().getText()));
                                        }
                                    }).show();
                        }
                    }
                    return false;
                }
            }).build();

    populateProfilesList();

    materialDrawer = new DrawerBuilder().withActivity(this).withSavedInstance(savedInstanceState)
            .withToolbar(getToolbar()).withActionBarDrawerToggle(drawerToggle).withDrawerGravity(Gravity.LEFT)
            .withAccountHeader(drawerHeader).withSelectedItem(-1).build();

    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_general_title,
            R.string.pref_general_summary, R.drawable.settings, 1000));
    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_logging_title,
            R.string.pref_logging_summary, R.drawable.loggingsettings, 1001));
    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_performance_title,
            R.string.pref_performance_summary, R.drawable.performance, 1002));
    materialDrawer.addItem(new DividerDrawerItem());

    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_autosend_title,
            R.string.pref_autosend_summary, R.drawable.autosend, 1003));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.gdocs_setup_title, R.drawable.googledrive, 1004));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.dropbox_setup_title, R.drawable.dropbox, 1005));
    materialDrawer.addItem(GpsLoggerDrawerItem.newSecondary(R.string.autoemail_title, R.drawable.email, 1006));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.autoftp_setup_title, R.drawable.ftp, 1007));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.opengts_setup_title, R.drawable.opengts, 1008));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.osm_setup_title, R.drawable.openstreetmap, 1009));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.owncloud_setup_title, R.drawable.owncloud, 1010));
    materialDrawer.addItem(new DividerDrawerItem());

    materialDrawer
            .addStickyFooterItem(GpsLoggerDrawerItem.newSecondary(R.string.menu_faq, R.drawable.helpfaq, 1011));
    materialDrawer
            .addStickyFooterItem(GpsLoggerDrawerItem.newSecondary(R.string.menu_exit, R.drawable.exit, 1012));

    materialDrawer.setOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {

            switch (iDrawerItem.getIdentifier()) {
            case 1000:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.GENERAL);
                break;
            case 1001:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.LOGGING);
                break;
            case 1002:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.PERFORMANCE);
                break;
            case 1003:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.UPLOAD);
                break;
            case 1004:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.GDOCS);
                break;
            case 1005:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.DROPBOX);
                break;
            case 1006:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.EMAIL);
                break;
            case 1007:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.FTP);
                break;
            case 1008:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OPENGTS);
                break;
            case 1009:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OSM);
                break;
            case 1010:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OWNCLOUD);
                break;
            case 1011:
                Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
                startActivity(faqtivity);
                break;
            case 1012:
                EventBus.getDefault().post(new CommandEvents.RequestStartStop(false));
                finish();
                break;

            }
            return false;
        }
    });

    ImageButton helpButton = (ImageButton) findViewById(R.id.imgHelp);
    helpButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
            startActivity(faqtivity);
        }
    });

}