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.socialize.share.utils.selector.PopFullScreenSharePlatformSelector.java

private void createShareWindowIfNeed() {
    if (mShareWindow != null)
        return;//from   w  w  w  .  jav  a2s .  c  o  m

    Context context = getContext();

    grid = createShareGridView(context, getItemClickListener());
    RelativeLayout.LayoutParams gridParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    gridParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    grid.setLayoutParams(gridParams);

    mContainerView = new RelativeLayout(getContext());
    mContainerView.setBackgroundColor(getContext().getResources().getColor(R.color.bili_socialize_black_trans));
    RelativeLayout.LayoutParams containerParams = new RelativeLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    mContainerView.setLayoutParams(containerParams);
    mContainerView.addView(grid);
    mContainerView.setOnClickListener(this);

    mShareWindow = new PopupWindow(mContainerView, WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT, true);
    grid.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    mShareWindow.setOutsideTouchable(true);
    mShareWindow.setAnimationStyle(-1);
    mShareWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            if (getDismissListener() != null)
                getDismissListener().onDismiss();
        }
    });
}

From source file:com.aujur.ebookreader.reading.options.ReadingOptionsFragment.java

private void changeColor(int newColor) {

    // tabs.setIndicatorColor(newColor);
    tabs.setIndicatorColor(getResources().getColor(R.color.green_tab_indicator));
    // tabs.setIndicatorColor(2131034133);

    // 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 {
                getActivity().getActionBar().setBackgroundDrawable(ld);
            }//  w w  w.  ja v a2  s  .  co  m

        } 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 {
                getActivity().getActionBar().setBackgroundDrawable(td);
            }

            td.startTransition(200);

        }

        oldBackground = ld;

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

    }

    currentColor = newColor;

}

From source file:com.google.samples.apps.iosched.explore.SessionsAdapter.java

private SessionsAdapter(@NonNull Activity activity, @NonNull final List<SessionData> sessions, boolean compact,
        int columns) {
    mHost = activity;/* w  ww  . ja  v a 2 s .c  o m*/
    mInflater = LayoutInflater.from(activity);
    mCompactMode = compact;
    mColumns = columns;

    // Load the background colors
    int[] colors = mHost.getResources().getIntArray(R.array.session_tile_backgrounds);
    mBackgroundColors = new ColorDrawable[colors.length];
    for (int i = 0; i < colors.length; i++) {
        mBackgroundColors[i] = new ColorDrawable(colors[i]);
    }
    mItems = processData(sessions);
}

From source file:com.google.samples.apps.iosched.videolibrary.VideoTrackAdapter.java

private VideoTrackAdapter(@NonNull Activity activity, @NonNull List<Video> videos,
        @NonNull ImageLoader imageLoader, @NonNull List<UpdatableView.UserActionListener> listeners,
        boolean compactMode, int columns) {
    mHost = activity;//from w  w w.j av a  2s.c  o m
    mInflater = LayoutInflater.from(activity);
    mImageLoader = imageLoader;
    mListeners = listeners;
    mCompactMode = compactMode;
    mColumns = columns;
    // load the background colors
    final int[] colors = mHost.getResources().getIntArray(R.array.session_tile_backgrounds);
    mBackgroundColors = new ColorDrawable[colors.length];
    for (int i = 0; i < colors.length; i++) {
        mBackgroundColors[i] = new ColorDrawable(colors[i]);
    }
    mItems = processData(videos);
}

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

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

    Sp = PreferenceManager.getDefaultSharedPreferences(this);
    theme = Integer.parseInt(Sp.getString("theme", "0"));

    theme1 = theme == 2 ? PreferenceUtils.hourOfDay() : theme;

    if (theme1 == 1) {
        setTheme(R.style.appCompatDark);
        getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.holo_dark_background));
    }/*from   w ww .  j  av  a  2 s. c o m*/
    setContentView(R.layout.activity_db_viewer);
    toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    skin = PreferenceUtils.getPrimaryColorString(Sp);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
    skinStatusBar = PreferenceUtils.getStatusColor(skin);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    rootMode = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("rootmode", false);
    int sdk = Build.VERSION.SDK_INT;
    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor((PreferenceUtils.getStatusColor(skin)));
        if (colourednavigation)
            window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin)));

    }

    path = getIntent().getStringExtra("path");
    pathFile = new File(path);
    listView = (ListView) findViewById(R.id.listView);

    load(pathFile);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
            DbViewerFragment fragment = new DbViewerFragment();
            Bundle bundle = new Bundle();
            bundle.putString("table", arrayList.get(position));
            fragment.setArguments(bundle);
            fragmentTransaction.add(R.id.content_frame, fragment);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }
    });

}

From source file:com.flowzr.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    activity = this;
    setContentView(R.layout.main);//from  w w  w . j  a  v a 2s  .  com

    actionBar = getSupportActionBar();

    //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line, 
    //only way found to remove on various devices 2.3x, 3.0, ...
    actionBar.setBackgroundDrawable(new ColorDrawable(R.color.f_dark));

    setupDrawer();

    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // create new tabs and and set up the titles of the tabs
    mAccountTab = setupAccountsTab(actionBar);
    mBlotterTab = setupBlotterTab(actionBar);
    mBudgetsTab = setupBudgetsTab(actionBar);

    Intent intent = getIntent();

    mAdapter = new MyAdapter(getSupportFragmentManager(), intent);
    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setPageTransformer(true, new ZoomOutPageTransformer());
    viewPager.setAdapter(mAdapter);
    viewPager.setOnPageChangeListener(this);

    mAccountTab.setTabListener(this);
    mBlotterTab.setTabListener(this);
    mBudgetsTab.setTabListener(this);

    addMyTabs();

    if (intent.hasExtra(REQUEST_BLOTTER)) {
        blotterFragment = new BlotterFragment();
        if (intent.hasExtra(EntityListActivity.REQUEST_NEW_TRANSACTION_FROM_TEMPLATE)) {
            Bundle bundle = new Bundle();
            bundle.putInt(BlotterFragment.EXTRA_REQUEST_TYPE,
                    BlotterFragment.NEW_TRANSACTION_FROM_TEMPLATE_REQUEST);
            blotterFragment.setArguments(bundle);
        }
        loadTabFragment(blotterFragment, R.layout.blotter, intent.getExtras(), TAB_BLOTTER);

    } else if (intent.hasExtra(REQUEST_SPLIT_BLOTTER)) {
        loadTabFragment(new SplitsBlotterActivity(), R.layout.blotter, intent.getExtras(), TAB_BLOTTER);
    } else if (intent.hasExtra(REQUEST_BUDGET_BLOTTER)) {
        loadTabFragment(new BudgetBlotterFragment(), R.layout.blotter, intent.getExtras(), TAB_BLOTTER);
    } else {
        StartupScreen startupScreen = MyPreferences.getStartupScreen(this);
        viewPager.setCurrentItem(startupScreen.ordinal());
    }

    if (WebViewDialog.checkVersionAndShowWhatsNewIfNeeded(this)) {
        if (mDrawerLayout != null) {
            mDrawerLayout.openDrawer(Gravity.LEFT);
        }
    }

    initialLoad();

    FlowzrSyncEngine.setUpdatable(this);
}

From source file:com.hengtan.nanodegreeapp.stocount.ProductDetailGridPagerAdapter.java

public ProductDetailGridPagerAdapter(Context ctx, FragmentManager fm, CustomFragment cf, int id, String name,
        String additionalInfo, Integer prodCountId, double count, Bitmap image) {
    super(fm);// ww w . j a  v  a 2s .co  m
    mContext = ctx;
    mProductId = id;
    mProductName = name;
    mAdditionalInfo = additionalInfo;
    mProductCountId = prodCountId;
    mCurrentCount = count;
    mThumbnail = image;
    mRows = new ArrayList<Row>();

    customeFrag = cf;

    Bundle bundle = new Bundle();
    bundle.putInt("productId", mProductId);
    bundle.putInt("productCountId", mProductCountId);

    customeFrag.setArguments(bundle);

    CreateCardFragment(mProductName, GetCardFragmentDescription());

    row = new Row(cardFragment, customeFrag);
    mRows.add(row);

    /*
    mRows.add(new Row(cardFragment(R.string.welcome_title, R.string.welcome_text)));
    mRows.add(new Row(cardFragment(R.string.about_title, R.string.about_text)));
    mRows.add(new Row(
        cardFragment(R.string.cards_title, R.string.cards_text),
        cardFragment(R.string.expansion_title, R.string.expansion_text)));
    mRows.add(new Row(
        cardFragment(R.string.backgrounds_title, R.string.backgrounds_text),
        cardFragment(R.string.columns_title, R.string.columns_text)));
    mRows.add(new Row(new CustomFragment()));
    mRows.add(new Row(cardFragment(R.string.dismiss_title, R.string.dismiss_text)));
    */

    mDefaultBg = new ColorDrawable(mContext.getResources().getColor(android.R.color.darker_gray));
    mClearBg = new ColorDrawable(mContext.getResources().getColor(android.R.color.transparent));
}

From source file:com.flowzr.activity.BackupListActivity.java

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

    //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line, 
    //only way found to remove on various devices 2.3x, 3.0, ...
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#121212")));

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    ListView listview = (ListView) findViewById(R.id.listview);
    listview.setAdapter(new BackupListAdapter(this, backups));
    listview.setOnItemClickListener(new OnItemClickListener() {
        @Override/*from  www.jav  a 2s .c om*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                doBackup();
                break;
            case 1:
                doImport();
                break;
            case 2:
                doBackupOnGoogleDrive();
                break;
            case 3:
                doRestoreFromGoogleDrive();
                break;
            case 4:
                doBackupOnDropbox();
                break;
            case 5:
                doRestoreFromDropbox();
                break;
            case 6:
                doQifExport();
                break;
            case 7:
                doQifImport();
                break;
            case 8:
                doCsvExport();
                break;
            case 9:
                doCsvImport();
                break;
            }
        }
    });
}

From source file:fr.bde_eseo.eseomega.lacommande.OrderDetailsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_order_detail);
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    toolbar.setPadding(0, Utilities.getStatusBarHeight(this), 0, 0);
    setSupportActionBar(toolbar);/*from   w w  w .j  a v  a2s. co m*/
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00263238")));
    getSupportActionBar().setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#550000ff")));

    // Android setup
    context = OrderDetailsActivity.this;

    // Intent recuperation
    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            Toast.makeText(context, "Erreur de l'application (c'est pas normal)", Toast.LENGTH_SHORT).show();
            finish();
        } else {
            idcmd = extras.getInt(Constants.KEY_ORDER_ID);
        }
    }

    // Layout
    tvOrderDate = (TextView) findViewById(R.id.tvCommandDate);
    tvOrderPrice = (TextView) findViewById(R.id.tvCommandPrice);
    tvOrderDetails = (TextView) findViewById(R.id.tvOrderDetail);
    tvOrderNumero = (TextView) findViewById(R.id.tvCommandNumero);
    tvInstruction = (TextView) findViewById(R.id.tvOrderInstructions);
    tvInstrHeader = (TextView) findViewById(R.id.tvHeaderInstructions);
    progressBar = (ProgressBar) findViewById(R.id.progressDetails);
    tvDesc = (TextView) findViewById(R.id.textView3);
    imgCategory = (ImageView) findViewById(R.id.imgOrder);
    rl1 = (RelativeLayout) findViewById(R.id.relativeLayout3);
    rl2 = (RelativeLayout) findViewById(R.id.relativeLayout5);

    progressBar.setVisibility(View.VISIBLE);
    tvOrderDate.setVisibility(View.INVISIBLE);
    tvOrderPrice.setVisibility(View.INVISIBLE);
    tvOrderDetails.setVisibility(View.INVISIBLE);
    tvOrderNumero.setVisibility(View.INVISIBLE);
    tvDesc.setVisibility(View.INVISIBLE);
    imgCategory.setVisibility(View.INVISIBLE);
    rl1.setVisibility(View.INVISIBLE);
    rl2.setVisibility(View.INVISIBLE);

    // profile
    profile = new UserProfile();
    profile.readProfilePromPrefs(context);

    // Save old brightness level and set it now to 100%
    WindowManager.LayoutParams layout = getWindow().getAttributes();
    oldScreenBrightness = layout.screenBrightness;
    layout.screenBrightness = 1F;
    getWindow().setAttributes(layout);

    // Couleurs
    circle_preparing = context.getResources().getColor(R.color.circle_preparing);
    blue_light = context.getResources().getColor(R.color.blue_light);
    circle_done = context.getResources().getColor(R.color.circle_done);
    gray_light = context.getResources().getColor(R.color.gray_light);
    circle_ready = context.getResources().getColor(R.color.circle_ready);
    green_light = context.getResources().getColor(R.color.green_light);
    circle_error = context.getResources().getColor(R.color.circle_error);
    orange_light = context.getResources().getColor(R.color.orange_light);
}

From source file:com.sck.maininterface.PaymentInfo.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_payment_info);
    actionBar = getActionBar();/*  w ww.j a v a  2 s  . c  o m*/
    actionBar.setTitle("Payment Info");
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#80b5e1")));

    rgSelect = (RadioGroup) findViewById(R.id.rgOption);
    rgSelect.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            // TODO Auto-generated method stub
            selectedId = rgSelect.indexOfChild(findViewById(checkedId));
            // Toast.makeText(getBaseContext(),
            // "Method 1 ID = "+String.valueOf(selectedId),
            // Toast.LENGTH_SHORT).show();
        }
    });

    final String phoneNo = read(file2);
    final String expiryDate = read(file3);

    printPhoneNo = (TextView) findViewById(R.id.textPhoneNo);
    printExpDate = (TextView) findViewById(R.id.textExpDate);

    printPhoneNo.setText("+" + phoneNo);
    printExpDate.setText(expiryDate);

    year = expiryDate.substring(0, 4);
    monthDate = expiryDate.substring(4, 10);

    Intent intent = new Intent(this, PayPalService.class);
    intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
    startService(intent);

    new updateExpiryDate().execute();

}