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.fjn.magazinereturncandidate.fragments.InputJanCodeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    //Init custom product detail layout
    View rootView = inflater.inflate(R.layout.fragment_input_jan, container, false);
    if (getDialog().getWindow() != null) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    }/*  www .j  av a  2  s  .  c  o  m*/

    //Get flag setting OCR
    if (getArguments() != null) {
        flagSwitchOCR = getArguments().getString(Constants.FLAG_SWITCH_OCR);
    }

    //Get Id textView Product detail
    txv_jan_cd = (TextView) rootView.findViewById(R.id.txv_jan_cd_input);
    txv_inventory_number = (TextView) rootView.findViewById(R.id.txv_inventory_number_input);
    Button btn_submit_edit = (Button) rootView.findViewById(R.id.btn_submit_edit_input);
    // Set adapter for combo box with array
    ArrayAdapter<String> adapter1 = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, arr);
    // Set item selected
    adapter1.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
    // Set button click
    btn_submit_edit.setOnClickListener(this);

    //Set default end text
    txv_jan_cd.setText("");
    txv_jan_cd.append(Constants.PREFIX_JAN_CODE_MAGAZINE); //focus end text
    //Show keyboard
    txv_jan_cd.requestFocus();
    getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

    checkDataCommon = new CheckDataCommon();
    registerLicenseCommon = new RegisterLicenseCommon();
    formatCommon = new FormatCommon();
    hsmDecoder = HSMDecoder.getInstance(getActivity());
    return rootView;
}

From source file:com.alibaba.weex.extend.module.WXTitleBar.java

@JSMethod
public void setStyle(JSONObject object) {
    String bgColor = object.getString("backgroundColor");
    String color = object.getString("foregroundColor");
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        if (bgColor != null) {
            int c = WXResourceUtils.getColor(bgColor);
            actionBar.setBackgroundDrawable(new ColorDrawable(c));
        }/*from   www.ja va  2 s .  com*/

        if (color != null) {
            int c = WXResourceUtils.getColor(color);

            Toolbar toolbar = (Toolbar) ((Activity) mWXSDKInstance.getContext()).findViewById(R.id.toolbar);
            if (toolbar != null) {
                toolbar.setTitleTextColor(c);
                toolbar.setSubtitleTextColor(c);

                Drawable upNavigation = toolbar.getNavigationIcon();
                if (null != upNavigation) {
                    upNavigation = DrawableCompat.wrap(upNavigation);
                    upNavigation = upNavigation.mutate();
                    DrawableCompat.setTint(upNavigation, c);
                    toolbar.setNavigationIcon(upNavigation);
                }

                Drawable overflowIcon = toolbar.getOverflowIcon();
                if (null != overflowIcon) {
                    overflowIcon = DrawableCompat.wrap(overflowIcon);
                    overflowIcon = overflowIcon.mutate();
                    DrawableCompat.setTint(overflowIcon, c);
                    toolbar.setOverflowIcon(overflowIcon);
                }

                Menu menu = toolbar.getMenu();
                if (menu != null && menu.size() > 0) {
                    for (int i = 0; i < menu.size(); i++) {
                        MenuItem item = menu.getItem(i);
                        if (item != null && item.getIcon() != null) {
                            Drawable drawable = item.getIcon();
                            if (null != drawable) {
                                drawable = DrawableCompat.wrap(drawable);
                                drawable = drawable.mutate();
                                DrawableCompat.setTint(drawable, c);
                                item.setIcon(drawable);
                            }
                        }
                    }
                    ((Activity) mWXSDKInstance.getContext()).invalidateOptionsMenu();
                }
            }
        }
    }
}

From source file:by.android.dailystatus.SettingsActivity.java

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

    setContentView(R.layout.settings);/*from   w  w  w  .  ja  v a2  s  .c  o m*/

    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#ffffffff")));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (!OSUtil.IsNetworkAvailable(getApplicationContext())) {
        AlertMessageBox.Show(SettingsActivity.this, "Internet connection",
                "A valid internet connection can't be established", AlertMessageBox.AlertMessageBoxIcon.Info);
        return;
    }

    radioGroup = (RadioGroup) findViewById(R.id.rad_group);
    int index = PreferenceUtils.getCurrentRadioNotification(getApplicationContext());
    int id = R.id.radbtn_do_not_notify;
    switch (index) {
    case 0:
        id = R.id.radbtn_six_hours;
        break;
    case 2:
        id = R.id.radbtn_three_hours;
        break;

    default:
        break;
    }
    radioGroup.check(id);
    radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            View radioButton = radioGroup.findViewById(checkedId);
            int idx = radioGroup.indexOfChild(radioButton);
            PreferenceUtils.setCurrentRadioNotification(getApplicationContext(), idx);
            switch (idx) {
            case 0:
            case 2:
                AlarmActivity.CancelAlarm(getApplicationContext());
                AlarmActivity.setRepeatingAlarm(getApplicationContext(), idx);
                break;
            case 4:
                AlarmActivity.CancelAlarm(getApplicationContext());
                break;
            default:
                break;
            }
        }
    });

    PackageInfo pInfo;
    String vers = "";
    try {
        pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        vers = pInfo.versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    faceUserName = (TextView) findViewById(R.id.txt_face_user_name);
    facebookDescription = (TextView) findViewById(R.id.txt_facebook_descroption);

    findViewById(R.id.lay_rate).setOnClickListener(this);
    findViewById(R.id.lay_connect_with_developer).setOnClickListener(this);
    findViewById(R.id.lay_facebook).setOnClickListener(this);
    findViewById(R.id.lay_version).setOnClickListener(this);
    findViewById(R.id.lay_license).setOnClickListener(this);

    Session.openActiveSession(this, false, new Session.StatusCallback() {

        // callback when session changes state
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            if (session.isOpened()) {
                Request.newMeRequest(session, new Request.GraphUserCallback() {

                    @Override
                    public void onCompleted(GraphUser user, Response response) {

                        if (user != null) {
                            faceUserName.setText(user.getFirstName() + " " + user.getLastName());
                            facebookDescription.setText("?  ");
                            faceLogin = true;
                        }
                    }
                }).executeAsync();
            }

        }
    });
}

From source file:com.burntout.burntout.SendReportActivity.java

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

    ActionBar bar = getActionBar();/*  www  . j  ava  2s.c o m*/
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#1E5791")));
    bar.setTitle("Burnt Out");
    bar.setSubtitle("Report Burnout");
    bar.setDisplayHomeAsUpEnabled(true);

    context = this;
    SharedPreferences sharedPref = context.getSharedPreferences(getString(R.string.pref), Context.MODE_PRIVATE);

    email = sharedPref.getString("email", null);

    Log.d("email", email);

    frontText = (TextView) findViewById(R.id.frontText);
    backText = (TextView) findViewById(R.id.backText);
    reportedLightsCheck = (TextView) findViewById(R.id.reported_lights_text);
    reportPlateNumber = (EditText) findViewById(R.id.report_plate_number);
    message = (EditText) findViewById(R.id.extra_message);
    submitBtn = (Button) findViewById(R.id.report_button);
    pageMarkers = (PageMarkers) findViewById(R.id.pageMarkersReport);
    pageMarkers.setTotalPages(4);
    pageMarkers.makeView(0);

    statePicker = (StatePicker) findViewById(R.id.statepicker_view1);

    reportables = (TappablesHSV) findViewById(R.id.tappablesHSV1);
    reportables.setCommunicator(this);
    reportables.initItems(this);
    reportables.setFeatureItems();
    reportables.addManagers(this);

    reportPlateNumber.clearFocus();
    message.clearFocus();

    addListenerOnSubmit();

}

From source file:com.agenmate.lollipop.util.ViewUtils.java

public static RippleDrawable createRipple(@ColorInt int color, @FloatRange(from = 0f, to = 1f) float alpha,
        boolean bounded) {
    color = ColorUtils.modifyAlpha(color, alpha);
    return new RippleDrawable(ColorStateList.valueOf(color), null,
            bounded ? new ColorDrawable(Color.WHITE) : null);
}

From source file:com.linkedin.android.eventsapp.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    pager = new ViewPager(this);
    pager.setId(R.id.pager);//from w w  w. j  a  v  a2  s. c o  m
    pager.setOffscreenPageLimit(5);
    setContentView(pager);

    final ActionBar bar = getActionBar();
    View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null);

    TextView textviewTitle = (TextView) viewActionBar.findViewById(R.id.actionbar_textview);
    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
    textviewTitle.setText("UPCOMING EVENTS");
    bar.setCustomView(viewActionBar, params);
    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setIcon(new ColorDrawable(Color.TRANSPARENT));
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153")));

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mEventTabsAdapter = new com.linkedin.android.eventsapp.EventTabsAdapter(this, pager);
    SimpleDateFormat ft = new SimpleDateFormat("E dd MMM");
    ArrayList<Event> events = EventsManager.getInstance(this).getEvents();
    for (Event event : events) {
        String eventDay = ft.format(new Date(event.getEventDate()));
        mEventTabsAdapter.addTab(bar.newTab().setText(eventDay), EventFragment.class, event);
    }
}

From source file:com.davis.kangpinhui.views.viewpagerindicator.ScrollPageIndicator.java

public ScrollPageIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    setHorizontalScrollBarEnabled(false);
    mTabLayout = new LinearLayout(context, attrs);
    ColorDrawable colorDrawable = new ColorDrawable(Color.WHITE);
    mTabLayout.setDividerDrawable(colorDrawable);
    addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT));
    density = context.getResources().getDisplayMetrics().density;
}

From source file:com.flowzr.widget.CalculatorInput.java

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

    setContentView(R.layout.calculator);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#121212")));

    vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);

    for (int id : buttons) {
        Button b = (Button) findViewById(id);
        b.setOnClickListener(this);
    }// w ww  .  j  a va  2 s  .com

    tvResult = (TextView) findViewById(R.id.result);
    tvOp = (TextView) findViewById(R.id.op);

    Intent intent = getIntent();
    if (intent != null) {
        String amount = intent.getStringExtra(AmountInput.EXTRA_AMOUNT);
        if (amount != null) {
            setDisplay(amount);
        }
    }

}

From source file:com.example.swipeuiforupclose.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.profile_main);

    // Create the adapter that will return a fragment for each of the three
    // primary sections
    // of the app.

    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is
    // no hierarchical
    // parent./* www.  j  ava 2s . c om*/
    actionBar.setHomeButtonEnabled(false);
    actionBar.setBackgroundDrawable(new ColorDrawable(0xFF46304e));
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(0xFF573d5d));
    actionBar.setTitle("My Profile");

    // Specify that we will be displaying tabs in the action bar.
    //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // Set up the ViewPager, attaching the adapter and setting up a listener
    // for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select
            // the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if
            // we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.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
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.fjn.magazinereturncandidate.fragments.ProductDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    formatCommon = new FormatCommon();
    registerLicenseCommon = new RegisterLicenseCommon();
    checkDataCommon = new CheckDataCommon();

    //Init custom product detail layout
    View rootView = inflater.inflate(R.layout.fragment_product_detail, container, false);
    if (getDialog().getWindow() != null) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    }/*w  ww.  java2 s. c  o m*/

    //Get Id textview Product detail
    TextView txv_jan_cd = (TextView) rootView.findViewById(R.id.txv_jan_cd);
    TextView txv_group1_name = (TextView) rootView.findViewById(R.id.txv_group1_name);
    TextView txv_group2_name = (TextView) rootView.findViewById(R.id.txv_group2_name);
    TextView txv_product_name = (TextView) rootView.findViewById(R.id.txv_product_name);
    TextView txv_writer_name = (TextView) rootView.findViewById(R.id.txv_writer_name);
    TextView txv_publisher_name = (TextView) rootView.findViewById(R.id.txv_publisher_name);
    TextView txv_publish_date = (TextView) rootView.findViewById(R.id.txv_publish_date);
    TextView txv_price = (TextView) rootView.findViewById(R.id.txv_price);
    txv_inventory_number = (TextView) rootView.findViewById(R.id.txv_inventory_number);
    TextView txv_first_supply_date = (TextView) rootView.findViewById(R.id.txv_first_supply_date);
    TextView txv_last_supply_date = (TextView) rootView.findViewById(R.id.txv_last_supply_date);
    TextView txv_last_sales_date = (TextView) rootView.findViewById(R.id.txv_last_sales_date);
    TextView txv_last_order_date = (TextView) rootView.findViewById(R.id.txv_last_order_date);
    TextView txv_year_rank = (TextView) rootView.findViewById(R.id.txv_year_rank);
    //TextView txv_joubi = (TextView) rootView.findViewById(R.id.txv_joubi);
    TextView txv_total_sales = (TextView) rootView.findViewById(R.id.txv_total_sales);
    TextView txv_total_supply = (TextView) rootView.findViewById(R.id.txv_total_supply);
    TextView txv_total_return = (TextView) rootView.findViewById(R.id.txv_total_return);
    TextView txv_location_id = (TextView) rootView.findViewById(R.id.txv_location_id);
    Button btn_submit_edit = (Button) rootView.findViewById(R.id.btn_submit_edit);

    Bundle bundle = getArguments();
    if (bundle != null) {

        //Show year_rank
        String valueYearRank = bundle.getString(Constants.COLUMN_YEAR_RANK);
        String showYearRank;
        if (Constants.VALUE_MAX_YEAR_RANK.equals(valueYearRank)) {
            showYearRank = Constants.SHOW_MAX_YEAR_RANK;
        } else {
            showYearRank = String.format("%s?/%s", formatCommon.formatMoney(valueYearRank),
                    formatCommon.formatMoney(String.valueOf(bundle.getInt(Constants.COLUMN_MAX_YEAR_RANK))));
        }

        //Get bundle janCode
        String janCode = bundle.getString(Constants.COLUMN_JAN_CD);
        int lenJanCode = 0;
        String janCodeResult = "";
        if (janCode != null) {
            lenJanCode = janCode.length();
            janCodeResult = janCode.substring(0, lenJanCode - 5);
        }
        if (lenJanCode != Constants.JAN_18_CHAR) {
            janCodeResult = janCode;
        }
        txv_jan_cd.setText(janCodeResult);
        txv_group1_name.setText(bundle.getString(Constants.COLUMN_MEDIA_GROUP1_NAME));
        txv_group2_name.setText(bundle.getString(Constants.COLUMN_MEDIA_GROUP2_NAME));
        txv_product_name.setText(bundle.getString(Constants.COLUMN_GOODS_NAME));
        txv_writer_name.setText(bundle.getString(Constants.COLUMN_WRITER_NAME));
        txv_publisher_name.setText(bundle.getString(Constants.COLUMN_PUBLISHER_NAME));
        txv_publish_date.setText(
                formatCommon.formatDate(bundle.getString(Constants.COLUMN_SALES_DATE, Constants.BLANK)));
        if (Constants.BLANK.equals(bundle.getString(Constants.COLUMN_PRICE))) {
            txv_price.setText(Constants.BLANK);
        } else {
            txv_price.setText(String.format("%s%s", Constants.SYMBOL,
                    formatCommon.formatMoney((bundle.getString(Constants.COLUMN_PRICE)))));
        }
        if (bundle.getString(Constants.COLUMN_STOCK_COUNT) == null) {
            txv_inventory_number.setText("");
            txv_inventory_number.append(Constants.BLANK); //focus end text
        } else {
            txv_inventory_number.setText("");
            txv_inventory_number
                    .append(formatCommon.formatMoney(bundle.getString(Constants.COLUMN_STOCK_COUNT)));//focus end text
        }
        txv_first_supply_date.setText(
                formatCommon.formatDate(bundle.getString(Constants.COLUMN_FIRST_SUPPLY_DATE, Constants.BLANK)));
        txv_last_supply_date.setText(
                formatCommon.formatDate(bundle.getString(Constants.COLUMN_LAST_SUPPLY_DATE, Constants.BLANK)));
        txv_last_sales_date.setText(
                formatCommon.formatDate(bundle.getString(Constants.COLUMN_LAST_SALES_DATE, Constants.BLANK)));
        txv_last_order_date.setText(
                formatCommon.formatDate(bundle.getString(Constants.COLUMN_LAST_ORDER_DATE, Constants.BLANK)));
        txv_year_rank.setText(showYearRank);
        //txv_joubi.setText(formatJoubi(bundle.getString(Constants.COLUMN_JOUBI)));
        txv_total_sales.setText(formatCommon.formatMoney(bundle.getString(Constants.COLUMN_TOTAL_SALES)));
        txv_total_supply.setText(formatCommon.formatMoney(bundle.getString(Constants.COLUMN_TOTAL_SUPPLY)));
        txv_total_return.setText(formatCommon.formatMoney(bundle.getString(Constants.COLUMN_TOTAL_RETURN)));
        txv_location_id.setText(bundle.getString(Constants.COLUMN_LOCATION_ID));

        //get position
        positionEdit = bundle.getInt(Constants.POSITION_EDIT_PRODUCT);

        //get flag OCR
        flagSwitchOCR = getArguments().getString(Constants.FLAG_SWITCH_OCR);
    }

    loadItems();

    // Set adapter for combo box with array
    ArrayAdapter<String> adapter1 = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, arr);

    // Set item selected
    adapter1.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);

    // Set button click
    btn_submit_edit.setOnClickListener(this);

    hsmDecoder = HSMDecoder.getInstance(getActivity());
    return rootView;
}