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.gdgdevfest.android.apps.devfestbcn.ui.PlusStreamRowViewBinder.java

public static ImageLoader getPlusStreamImageLoader(FragmentActivity activity, Resources resources) {
    DisplayMetrics metrics = resources.getDisplayMetrics();
    int largestWidth = metrics.widthPixels > metrics.heightPixels ? metrics.widthPixels : metrics.heightPixels;

    // Create list of placeholder drawables (this ImageLoader requires two different
    // placeholder images).
    ArrayList<Drawable> placeHolderDrawables = new ArrayList<Drawable>(2);
    placeHolderDrawables.add(PLACEHOLDER_USER_IMAGE, resources.getDrawable(drawable.person_image_empty));
    placeHolderDrawables.add(PLACEHOLDER_MEDIA_IMAGE,
            new ColorDrawable(resources.getColor(R.color.plus_empty_image_background_color)));

    // Create ImageLoader instance
    return new ImageLoader(activity, placeHolderDrawables).setMaxImageSize(largestWidth);
}

From source file:com.bilibili.socialize.share.utils.selector.PopWrapSharePlatformSelector.java

protected void createShareWindowIfNeed() {
    if (mShareWindow != null)
        return;//www .  j av a 2 s .c  o  m

    Context context = getContext();
    GridView grid = createShareGridView(context, getItemClickListener());
    mShareWindow = new PopupWindow(grid, WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT, true);
    mShareWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    mShareWindow.setOutsideTouchable(true);
    mShareWindow.setAnimationStyle(R.style.socialize_shareboard_animation);
    mShareWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            if (getDismissListener() != null)
                getDismissListener().onDismiss();
        }
    });
}

From source file:appocorrencias.com.appocorrencias.Activitys.DelayedProgressDialog.java

@Override
public void onStart() {
    super.onStart();
    mProgressBar = (ProgressBar) getDialog().findViewById(R.id.progress);

    if (getDialog().getWindow() != null) {
        int px = (int) (PROGRESS_CONTENT_SIZE_DP * getResources().getDisplayMetrics().density);
        getDialog().getWindow().setLayout(px, px);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    }/*from  w  ww.  java  2  s.  c om*/
}

From source file:com.adithya321.sharesanalysis.fragments.SharePurchaseMainFragment.java

private void setColors() {
    if (title.equals("Share Purchase")) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            window.setStatusBarColor(getResources().getColor(R.color.red_700));
        actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.red_500)));
        tabLayout.setBackgroundColor(getResources().getColor(R.color.red_500));
    } else {//  w  ww .j  a v a 2  s  .  c  om
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
        actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));
        tabLayout.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
    }
}

From source file:com.facebook.litho.reference.ColorDrawableReference.java

@Override
protected Drawable onAcquire(ComponentContext context, Reference reference) {
    ColorDrawable drawable = null;//from  w w  w . ja v a  2  s  .c om

    if (CAN_RECYCLE) {
        drawable = sPool.acquire();
    }

    if (drawable == null) {
        drawable = new ColorDrawable(((State) reference).mColor);
    } else {
        drawable.setColor(((State) reference).mColor);
    }

    drawable.setAlpha(((State) reference).mAlpha);

    return drawable;
}

From source file:com.amaze.filemanager.activities.TextReader.java

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

    setContentView(R.layout.search);/*from  w  w  w.  java 2 s . c o m*/
    ma = (EditText) findViewById(R.id.fname);
    p = (ProgressBar) findViewById(R.id.pbar);
    ma.setVisibility(View.GONE);
    String skin = PreferenceManager.getDefaultSharedPreferences(this).getString("skin_color", "#5677fc");
    getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    if (Build.VERSION.SDK_INT >= 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));
        FrameLayout a = (FrameLayout) ma.getParent();
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) a.getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getPixelInsetTop(true), 0, 0);
    }
    path = this.getIntent().getStringExtra("path");
    if (path != null) {
        Toast.makeText(this, "" + path, Toast.LENGTH_SHORT).show();
        new LoadText().execute(path);
    } else {
        Toast.makeText(this, utils.getString(this, R.string.cant_read_file), Toast.LENGTH_LONG).show();
        finish();
    }
    getActionBar().setTitle(new File(path).getName());
    getActionBar().setSubtitle(path);
}

From source file:com.androidarchitecture.widgets.RecyclerViewSwipeToDeleteImpl.java

/**
 * This is the standard support library way of implementing "swipe to delete" feature. You can do custom drawing in onChildDraw method
 * but whatever you draw will disappear once the swipe is over, and while the items are animating to their new position the recycler view
 * background will be visible. That is rarely an desired effect.
 *//*  w w  w . ja  v a2s  . c  o m*/
private void setUpItemTouchHelper() {

    ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0,
            ItemTouchHelper.LEFT) {

        // we want to cache these and not allocate anything repeatedly in the onChildDraw method
        Drawable background;
        Drawable xMark;
        int xMarkMargin;
        boolean initiated;

        private void init() {
            background = new ColorDrawable(ContextCompat.getColor(mContext, R.color.colorPrimary));
            xMark = ContextCompat.getDrawable(mContext, R.drawable.ic_cancel_black_24dp);
            xMark.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
            xMarkMargin = (int) mContext.getResources().getDimension(R.dimen.activity_margin);
            initiated = true;
        }

        // not important, we don't want drag & drop
        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            return super.getSwipeDirs(recyclerView, viewHolder);
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
            int swipedPosition = viewHolder.getAdapterPosition();
            mListener.removeItem(swipedPosition);
        }

        @Override
        public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                float dX, float dY, int actionState, boolean isCurrentlyActive) {
            View itemView = viewHolder.itemView;

            // not sure why, but this method get's called for viewHolder that are already swiped away
            if (viewHolder.getAdapterPosition() == -1) {
                // not interested in those
                return;
            }

            if (!initiated) {
                init();
            }

            // draw red background
            background.setBounds(itemView.getRight() + (int) dX, itemView.getTop(), itemView.getRight(),
                    itemView.getBottom());
            background.draw(c);

            // draw x mark
            int itemHeight = itemView.getBottom() - itemView.getTop();
            int intrinsicWidth = xMark.getIntrinsicWidth();
            int intrinsicHeight = xMark.getIntrinsicWidth();

            int xMarkLeft = itemView.getRight() - xMarkMargin - intrinsicWidth;
            int xMarkRight = itemView.getRight() - xMarkMargin;
            int xMarkTop = itemView.getTop() + (itemHeight - intrinsicHeight) / 2;
            int xMarkBottom = xMarkTop + intrinsicHeight;
            xMark.setBounds(xMarkLeft, xMarkTop, xMarkRight, xMarkBottom);

            xMark.draw(c);

            super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
        }

    };
    ItemTouchHelper mItemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
    mItemTouchHelper.attachToRecyclerView(mRecyclerView);
}

From source file:am.roadpolice.roadpolice.ViolationInfoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_violation_info);

    DialogRateUs.showRateUs(getApplicationContext(), getSupportFragmentManager());

    // Customize Action Bar
    ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(0xFF1A237E));
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(Html.fromHtml("<small>" + getString(R.string.title_activity_info) + "</small>"));

    final Intent intent = getIntent();
    // Get Data which is sent from MainActivity.
    mAutoLogin = intent.getBooleanExtra(EXTRA_AUTO_LOGIN, false);
    ArrayList<ViolationInfo> violationList = intent.getParcelableArrayListExtra(EXTRA_VIOLATION_INFO_LIST);

    ViolationInfoAdapter adapter = new ViolationInfoAdapter(getApplicationContext(), violationList);

    ListView listView = (ListView) findViewById(R.id.listViewViolationInfo);
    listView.setOnItemClickListener(this);
    listView.setEmptyView(findViewById(R.id.textViewEmpty));
    listView.setAdapter(adapter);/*from   www.  j ava2s . co  m*/
}

From source file:com.levibostian.pantrypirate.activity.MainActivity.java

private void setActionBar() {
    getSupportActionBar().setTitle(mTitle);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(R.color.actionbar_color));
}

From source file:com.carinsurance.pagerslidingtabstrip.pagerslidingtabstripMainActivity.java

private void changeColor(int newColor) {

    tabs.setIndicatorColor(newColor);//  www  .j  a  v a 2 s .  c  o  m

    // change ActionBar color just if an ActionBar is available
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {

        Drawable colorDrawable = new ColorDrawable(newColor);
        Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom);
        LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable });

        if (oldBackground == null) {

            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
                ld.setCallback(drawableCallback);
            } else {
                //               Log.v("aaa","getActionBar=="+getActionBar());
                getActionBar().setBackgroundDrawable(ld);
            }

        } else {

            TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld });

            // workaround for broken ActionBarContainer drawable handling on
            // pre-API 17 builds
            // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
                td.setCallback(drawableCallback);
            } else {
                getActionBar().setBackgroundDrawable(td);
            }

            td.startTransition(200);

        }

        oldBackground = ld;

        // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler
        getActionBar().setDisplayShowTitleEnabled(false);
        getActionBar().setDisplayShowTitleEnabled(true);

    }

    currentColor = newColor;

}