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.kncwallet.wallet.ui.WalletActivity.java

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

    application = getWalletApplication();
    wallet = application.getWallet();//  www.java 2s. c o  m
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    application.registerBackgroundCallback(this);

    setContentView(R.layout.wallet_activity);

    if (savedInstanceState == null)
        checkAlerts();

    touchLastUsed();

    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowTitleEnabled(false);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            int currentIndex = actionBar.getSelectedNavigationIndex();

            boolean newPosition = currentIndex != position;

            actionBar.setSelectedNavigationItem(position);

            if (newPosition) {
                clearActionMode();
                mSectionsPagerAdapter.notifyIsShowing(position);
            }
        }
    });

    //keep all 3 tabs in memory - this might be a bad idea, but only 1 more than default
    mViewPager.setOffscreenPageLimit(3);
    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    actionBar.setSelectedNavigationItem(1);
    actionBar.setBackgroundDrawable(
            new ColorDrawable(getResources().getColor(R.color.knc_action_bar_background)));
    actionBar.setStackedBackgroundDrawable(
            new ColorDrawable(getResources().getColor(R.color.knc_background_lighter)));
    actionBar.setIcon(R.drawable.ic_knclogo);

    prefs.registerOnSharedPreferenceChangeListener(prefsListener);

    handleIntent(getIntent());

    Pin.setPinAuthorized(this, false);

}

From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java

protected void makeActionBarTransparent() {
    getActionBar().setBackgroundDrawable(new ColorDrawable(Color.argb(128, 0, 0, 0)));
    getActionBar().setSplitBackgroundDrawable(new ColorDrawable(Color.argb(128, 0, 0, 0)));
}

From source file:com.ifeng.util.imagecache.ImageWorker.java

/**
 * /*from   w  w  w. j  a  va  2 s. c  o m*/
 * 
 * @param imageView
 * @param drawable
 */
public static void setFadeInDrawable(ImageView imageView, Drawable drawable) {
    // Bug fix by XuWei 2013-09-09
    // Drawable?bug?ViewDrawable??Drawable
    Drawable copyDrawable = new BitmapDrawable(imageView.getContext().getResources(),
            ((BitmapDrawable) drawable).getBitmap());

    // Transition drawable with a transparent drawable and the final
    // drawable
    final TransitionDrawable td = new TransitionDrawable(
            new Drawable[] { new ColorDrawable(android.R.color.transparent), copyDrawable });

    imageView.setImageDrawable(td);
    td.startTransition(FADE_IN_TIME);
}

From source file:com.ibm.mil.readyapps.physio.activities.LandingActivity.java

private void deleteGoogleFitData() {
    String title = getString(R.string.delete_title);
    String message = getString(R.string.delete_message);
    ColorDrawable color = new ColorDrawable(getResources().getColor(R.color.ready_red));

    final PhysioAlertDialog alertDialog = new PhysioAlertDialog(this);
    alertDialog.setPrimaryText(title);//from   w ww . ja v a 2s  . c  om
    alertDialog.setSecondaryText(message);
    alertDialog.setButtonDrawable(color);
    alertDialog.setPositiveText(getString(android.R.string.ok));
    alertDialog.setPositiveClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            alertDialog.dismiss();

            final Dialog progressDialog = AndroidUtils.circularProgressDialog(LandingActivity.this);
            progressDialog.show();

            new HealthDataInjector(LandingActivity.this, mClient, new DataNotifier() {
                @Override
                public void dataIsAvailable() {
                    progressDialog.dismiss();
                    mClient.disconnect();
                    alertDialog.cancel();
                }
            }).delete();
        }
    });
    alertDialog.setNegativeText(getString(android.R.string.no));
    alertDialog.setNegativeClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            alertDialog.cancel();
        }
    });
    alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            logout();
        }
    });
    alertDialog.show();
}

From source file:com.bottomsheetbehavior.ReactNestedScrollView.java

public void setEndFillColor(int color) {
    if (color != mEndFillColor) {
        mEndFillColor = color;//from  w ww  .j a  v  a  2  s. c o  m
        mEndBackground = new ColorDrawable(mEndFillColor);
    }
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

private void init(AttributeSet attrs) {

    mHostActivity = getHostActivity();/*from   w  w  w.java  2 s.c o m*/

    LayoutInflater layoutInflater = (LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    inflate(getContext(), R.layout.floating_search_layout, this);

    mBackgroundDrawable = new ColorDrawable(Color.BLACK);

    mQuerySection = findViewById(R.id.search_query_section);
    mVoiceInputOrClearButton = (ImageView) findViewById(R.id.search_bar_mic_or_ex);
    mSearchInput = (EditText) findViewById(R.id.search_bar_text);
    mSearchBarTitle = (TextView) findViewById(R.id.search_bar_title);
    mMenuSearchOrExitButton = (ImageView) findViewById(R.id.search_bar_exit);
    mSearchProgress = (ProgressBar) findViewById(R.id.search_bar_search_progress);
    mShowMenuAction = true;
    mOverflowMenu = (ImageView) findViewById(R.id.search_bar_overflow_menu);
    mMenuBuilder = new MenuBuilder(getContext());
    mMenuPopupHelper = new MenuPopupHelper(getContext(), mMenuBuilder, mOverflowMenu);
    initDrawables();
    mVoiceInputOrClearButton.setImageDrawable(mIconMic);
    mOverflowMenu.setImageDrawable(mIconOverflowMenu);

    mDivider = findViewById(R.id.divider);

    mSuggestionsSection = (RelativeLayout) findViewById(R.id.search_suggestions_section);
    mSuggestionListContainer = findViewById(R.id.suggestions_list_container);
    mSuggestionsList = (RecyclerView) findViewById(R.id.suggestions_list);

    setupViews(attrs);
}

From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java

private void setupViews() {
    searchContainer.setLayoutTransition(getDefaultLayoutTransition());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
        searchContainer.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);

    ViewUtils.setBackground(searchContainer, searchBackground);
    searchContainer.setMinimumHeight((int) searchBackground.getMinHeight());
    searchContainer.setMinimumWidth((int) searchBackground.getMinWidth());

    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.addItemDecoration(cardDecorator);
    recyclerView.setHasFixedSize(true);/*from   w w w.  j a  v a2s  . co  m*/
    recyclerView.setVisibility(View.INVISIBLE);

    backgroundDrawable = getBackground();

    if (backgroundDrawable != null) {
        backgroundDrawable = backgroundDrawable.mutate();
    } else {
        backgroundDrawable = new ColorDrawable(DEFAULT_BACKGROUND_COLOR);
    }

    ViewUtils.setBackground(this, backgroundDrawable);
    backgroundDrawable.setAlpha(0);

    navButtonView.setOnClickListener(v -> {
        if (navigationClickListener != null)
            navigationClickListener.onNavigationClick();
    });

    setOnTouchListener((v, event) -> {
        if (!isActivated())
            return false;
        setActivated(false);
        return onContainerTouchClickListener == null || onContainerTouchClickListener.onTouch(v, event);
    });

    searchInput.setOnFocusChangeListener((v, hasFocus) -> {
        if (hasFocus != isActivated())
            setActivated(hasFocus);
    });

    searchInput.setOnKeyListener((view, keyCode, keyEvent) -> {
        if (keyCode != KeyEvent.KEYCODE_ENTER)
            return false;
        setActivated(false);
        return true;
    });
}

From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java

private static Drawable createOverflowButtonBgBC(int pressedStateColor) {
    StateListDrawable sld = new StateListDrawable();
    sld.addState(new int[] { android.R.attr.state_pressed },
            createBgDrawable(pressedStateColor, 0, CORNER_RADIUS, 0, 0));
    sld.addState(new int[] {}, new ColorDrawable(Color.TRANSPARENT));
    return sld;//  w  w w.  java  2  s  .  c om
}

From source file:com.daiv.android.twitter.ui.compose.Compose.java

public void setUpWindow() {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,
            WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    // Params for the window.
    // You can easily set the alpha and the dim behind the window from here
    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.alpha = 1.0f; // lower than one makes it more transparent
    params.dimAmount = .6f; // set it higher if you want to dim behind the window
    getWindow().setAttributes(params);/* w w  w  .  j  a  v  a 2s .c  o m*/
    getWindow().setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));

    // Gets the display size so that you can set the window to a percent of that
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    // You could also easily used an integer value from the shared preferences to set the percent
    if (height > width) {
        getWindow().setLayout((int) (width * .9), (int) (height * .9));
    } else {
        getWindow().setLayout((int) (width * .7), (int) (height * .8));
    }
}

From source file:com.lemon.lime.MainActivity.java

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

    getBatteryPercentage();/*from  w ww. j  a v  a 2s  .c  o  m*/
    setContentView(R.layout.activity_main);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    mWebView = (ObservableWebView) findViewById(R.id.activity_main_webview);
    mWebView.setScrollViewCallbacks(this);
    LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View v = inflator.inflate(R.layout.bar, null);
    getSupportActionBar().setCustomView(v);

    WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());

    swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipeToRefresh);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mWebView.reload();
        }
    });
    swipeLayout.setColorSchemeResources(R.color.lili, R.color.colorPrimary, R.color.red);

    window = getWindow();
    favicon = (ImageView) findViewById(R.id.favicon);
    editurl = (EditText) findViewById(R.id.editurl);
    mWebView.setDownloadListener(new DownloadListener() {
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype,
                long contentLength) {

            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }

    });

    favicon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (lili == 5) {
                lilimode();
                lili = 0;
                lilimode = true;
            } else {
                lili = lili + 1;
            }
        }
    });

    editurl.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                if (event.getAction() == KeyEvent.ACTION_UP) {
                    if (editurl.getText().toString().contains("file:///")) {
                        filemgr();
                    } else if (editurl.getText().toString().contains("gaymode")) {
                        gaymode();
                    } else if (editurl.getText().toString().contains("exitapp")) {
                        finish();
                    } else if (editurl.getText().toString().contains("light")) {
                        flash();
                    }

                    if (isconnected()) {
                        if (editurl.getText().toString().contains("http://")
                                || editurl.getText().toString().contains("https://")) {
                            mWebView.loadUrl(editurl.getText().toString());

                        } else if (editurl.getText().toString().contains(".com")
                                || editurl.getText().toString().contains(".net")
                                || editurl.getText().toString().contains(".org")
                                || editurl.getText().toString().contains(".gov")
                                || editurl.getText().toString().contains(".hu")
                                || editurl.getText().toString().contains(".sk")
                                || editurl.getText().toString().contains(".co.uk")
                                || editurl.getText().toString().contains(".co.in")
                                || editurl.getText().toString().contains(".cn")
                                || editurl.getText().toString().contains(".it")
                                || editurl.getText().toString().contains(".de")
                                || editurl.getText().toString().contains(".aus")
                                || editurl.getText().toString().contains(".hr")
                                || editurl.getText().toString().contains(".cz")
                                || editurl.getText().toString().contains(".xyz")
                                || editurl.getText().toString().contains(".pl")
                                || editurl.getText().toString().contains(".io")) {
                            mWebView.loadUrl("http://" + editurl.getText().toString());

                            InputMethodManager imm = (InputMethodManager) getSystemService(
                                    Context.INPUT_METHOD_SERVICE);
                            imm.hideSoftInputFromWindow(editurl.getWindowToken(), 0);

                        } else {
                            mWebView.loadUrl("https://www.google.com/search?q=" + editurl.getText().toString());

                            InputMethodManager imm = (InputMethodManager) getSystemService(
                                    Context.INPUT_METHOD_SERVICE);
                            imm.hideSoftInputFromWindow(editurl.getWindowToken(), 0);
                        }
                    }
                    return true;
                }
                return false;
            }

            return true;
        }
    });
    // Enable Javascript
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setSupportMultipleWindows(true);

    if (isconnected()) {
        mWebView.loadUrl("http://google.com");
    } else {

        final View coordinatorLayoutView = findViewById(R.id.snackbarPosition);
        mWebView.loadUrl("file:///android_asset/nonet.html");
        Snackbar snackbar = Snackbar.make(coordinatorLayoutView, R.string.offline, Snackbar.LENGTH_LONG);
        snackbar.show();

    }

    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onReceivedIcon(WebView mWebView, Bitmap icon) {
            super.onReceivedIcon(mWebView, icon);
            favicon.setImageBitmap(icon);
        }

        public void onProgressChanged(WebView view, int progress) {
            activity.setProgress(progress * 100);
            int a = progress;
            if (lilimode) {
                editurl.setText("Liling: " + Integer.toString(a) + "?");
            } else
                editurl.setText("Liming: " + Integer.toString(a) + "%");
            if (progress == 100) {

                editurl.setHint(view.getTitle());
                activity.setTitle(view.getTitle());
                editurl.setText(view.getUrl());

                fav();

                //battery
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    if (level <= 20) {
                        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                        window.setNavigationBarColor(Color.RED);
                        window.setStatusBarColor(Color.RED);
                        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.RED));
                    }
                }
            }
        }
    });

    mWebView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView mWebView, String url) {
            swipeLayout.setRefreshing(false);
        }
    });

}