Example usage for android.graphics Color parseColor

List of usage examples for android.graphics Color parseColor

Introduction

In this page you can find the example usage for android.graphics Color parseColor.

Prototype

@ColorInt
public static int parseColor(@Size(min = 1) String colorString) 

Source Link

Document

Parse the color string, and return the corresponding color-int.

Usage

From source file:mp.paschalis.App.java

public static void setStyleErrorDirectionColor(TextView pTextView) {
    pTextView.setTextColor(Color.parseColor("#C2022C"));

}

From source file:com.bitants.wally.fragments.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_search, container, false);
    if (rootView != null) {
        super.onCreateView(rootView);
        quickReturnBackground = rootView.findViewById(R.id.quick_return_protective_background);
        quickReturnView = rootView.findViewById(R.id.quick_return_view);
        quickReturnEditTextClearButton = (ImageButton) rootView.findViewById(R.id.quick_return_edittext_clear);
        quickReturnEditTextClearButton.setOnClickListener(new View.OnClickListener() {
            @Override/* w  ww. jav  a 2s  . c o  m*/
            public void onClick(View v) {
                if (quickReturnEditText != null) {
                    query = "";
                    quickReturnEditText.setText("");
                    quickReturnEditText.performClick();
                    showKeyboard(quickReturnEditText);
                }
            }
        });
        quickReturnEditText = (EditText) rootView.findViewById(R.id.quick_return_edittext);
        quickReturnEditText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                quickReturnEditText.setCursorVisible(true);
                restoreQuickReturnView();
            }
        });
        quickReturnEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                    return search();
                }
                return false;
            }

        });
        quickReturnEditText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (!TextUtils.isEmpty(s)) {
                    quickReturnEditTextClearButton.setVisibility(View.VISIBLE);
                } else {
                    quickReturnEditTextClearButton.setVisibility(View.GONE);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        gridView.setOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);

                float currentTranslationY = quickReturnView.getTranslationY();
                float maxTranslationY = quickReturnHeight;
                float newTranslationY = currentTranslationY + -dy;

                if (newTranslationY > 0) {
                    newTranslationY = 0;
                } else if (newTranslationY < -maxTranslationY) {
                    newTranslationY = -maxTranslationY;
                }
                quickReturnView.setTranslationY(newTranslationY);

                float percent = (-maxTranslationY) / 100.0f;
                float currentPercent = 100 - (newTranslationY / percent);

                quickReturnBackground.setAlpha(currentPercent / 100);
                quickReturnBackground.setTranslationY(newTranslationY);

            }
        });

        colorPickerButton = rootView.findViewById(R.id.quick_return_color_picker);
        colorPickerButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showColorPickerDialog();

            }
        });

        colorTagCard = rootView.findViewById(R.id.search_color_card);
        colorTagTextView = (TextView) rootView.findViewById(R.id.search_color_textview);
        colorTagTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showColorPickerDialog();
            }
        });
        colorTagClearButton = (ImageButton) rootView.findViewById(R.id.search_color_button_clear);
        colorTagClearButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                colorTagCard.setVisibility(View.GONE);
                colorPickerButton.setVisibility(View.VISIBLE);
                currentColor = null;
                query = quickReturnEditText.getText().toString();
                gridView.setAdapter(null);
                showLoader();
                getImages(1, query);
            }
        });

        setupAutoSizeGridView();
        if (savedInstanceState != null && savedInstanceState.containsKey(STATE_IMAGES)) {
            query = savedInstanceState.getString(STATE_QUERY, "");
            Message msgObj = uiHandler.obtainMessage();
            msgObj.what = MSG_IMAGES_REQUEST_CREATE;
            msgObj.arg1 = 1;
            msgObj.obj = savedInstanceState.getParcelableArrayList(STATE_IMAGES);
            uiHandler.sendMessage(msgObj);
            currentColor = savedInstanceState.getString(STATE_COLOR);
            if (currentColor != null) {
                int backgroundColor = Color.parseColor("#" + currentColor);
                int textColor = savedInstanceState.getInt(STATE_COLOR_TEXT);
                colorizeColorTag(backgroundColor, textColor, textColor, currentColor);
                colorTagCard.setVisibility(View.VISIBLE);
                colorPickerButton.setVisibility(View.GONE);
            }
            currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE);
        }
        ((MainActivity) getActivity()).addOnFileChangedListener(this);
        ((MainActivity) getActivity()).addOnFiltersChangedListener(this);
    }
    return rootView;
}

From source file:com.cypress.cysmart.BLEServiceFragments.RGBFragment.java

private void UIupdation() {
    String hexColor = String.format("#%02x%02x%02x%02x", intensity, r, g, b);
    mColorindicator.setBackgroundColor(Color.parseColor(hexColor));
    mTextalpha.setText(String.format("0x%02x", intensity));
    hexRed = String.format("0x%02x", r);
    hexGreen = String.format("0x%02x", g);
    hexBlue = String.format("0x%02x", b);
    mTextred.setText(hexRed);//from   w  w  w. j  a  va 2s  .c  o m
    mTextblue.setText(hexBlue);
    mTextgreen.setText(hexGreen);
    mTextalpha.setText(String.format("0x%02x", intensity));
    try {
        Logger.i("Writing value-->" + r + " " + g + " " + b + " " + intensity);
        BluetoothLeService.writeCharacteristicRGB(mReadCharacteristic, r, g, b, intensity);
    } catch (Exception e) {

    }

}

From source file:mp.paschalis.App.java

public static void setStyleSuccessDirectionColor(TextView pTextView) {
    pTextView.setTextColor(Color.parseColor("#ff33b5e5"));
}

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 . c o m*/
    //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.filemanager.free.fragments.Main.java

@SuppressLint("InflateParams")
@Override/*from ww  w  .  ja  v  a2  s  .  c  o  m*/
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setHasOptionsMenu(false);
    //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 = ContextCompat.getDrawable(getContext(), R.drawable.ic_grid_folder_new);
    getSortModes();
    DARK_IMAGE = ContextCompat.getDrawable(getContext(), R.drawable.ic_doc_image_dark);
    DARK_VIDEO = ContextCompat.getDrawable(getContext(), 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.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.holo_dark_background));
    } else {
        if (IS_LIST)
            listView.setBackgroundColor(ContextCompat.getColor(getContext(), 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.samsung.richnotification.RichNotificationHelper.java

public static SrnSecondaryTemplate createSecondaryTemplate(Context mContext, RichNotificationOptions options)
        throws JSONException {
    SrnSecondaryTemplate secondaryTemplate = null;
    //In case of Seconday Type None
    if (options.secondaryType.equalsIgnoreCase(RichNotificationHelper.SECONDARY_TYPE_NONE)) {
        return null;
    } //In case of Seconday Type Standard
    else if (options.secondaryType.equalsIgnoreCase(RichNotificationHelper.SECONDARY_TYPE_STD)) {
        SrnStandardSecondaryTemplate stdSecondary = new SrnStandardSecondaryTemplate();
        stdSecondary.setSubHeader(options.secondarySubHeader);

        if (options.secondaryContent != null) {
            JSONObject content = options.secondaryContent.optJSONObject(0);
            if (content != null) {
                stdSecondary.setTitle(content.optString("title"));
                stdSecondary.setBody(content.optString("body"));
            }//from  w w w . j  ava  2  s  . c om
        }

        // Set SmallIcons
        Bitmap icon1 = null;
        if (!options.secondaryIcon1Path.equals("")) {
            icon1 = getIconBitmap(mContext, "file://" + options.secondaryIcon1Path);
        }
        SrnImageAsset smallIcon1 = new SrnImageAsset(mContext, "smallIcon1", icon1);
        stdSecondary.setSmallIcon1(smallIcon1, options.secondaryIcon1Text);

        Bitmap icon2 = null;
        if (!options.secondaryIcon2Path.equals("")) {
            icon2 = getIconBitmap(mContext, "file://" + options.secondaryIcon2Path);
        }
        SrnImageAsset smallIcon2 = new SrnImageAsset(mContext, "smallIcon2", icon2);
        stdSecondary.setSmallIcon2(smallIcon2, options.secondaryIcon2Text);

        // Set Image
        if (!options.secondaryImage.equals("")) {
            Bitmap secBgBit = getIconBitmap(mContext, "file://" + options.secondaryImage);
            SrnImageAsset secBgAsst = new SrnImageAsset(mContext, "SecondaryBG", secBgBit);
            stdSecondary.setImage(secBgAsst);
        }

        secondaryTemplate = stdSecondary;

    } //In case of Seconday Type QR
    else if (options.secondaryType.equalsIgnoreCase(RichNotificationHelper.SECONDARY_TYPE_QR)) {
        SrnQRSecondaryTemplate qrSecondary = new SrnQRSecondaryTemplate();

        if (options.secondaryContent != null) {
            for (int i = 0; i < options.secondaryContent.length(); i++) {
                JSONObject content = options.secondaryContent.optJSONObject(i);
                if (content == null)
                    continue;
                qrSecondary.addListItem(content.optString("title"), content.optString("body"));
            }
        }

        // Set SmallIcons
        Bitmap icon1 = null;
        if (!options.secondaryIcon1Path.equals("")) {
            icon1 = getIconBitmap(mContext, "file://" + options.secondaryIcon1Path);
        }
        SrnImageAsset smallIcon1 = new SrnImageAsset(mContext, "smallIcon1", icon1);
        qrSecondary.setSmallIcon1(smallIcon1, options.secondaryIcon1Text);

        Bitmap icon2 = null;
        if (!options.secondaryIcon2Path.equals("")) {
            icon2 = getIconBitmap(mContext, "file://" + options.secondaryIcon2Path);
        }
        SrnImageAsset smallIcon2 = new SrnImageAsset(mContext, "smallIcon2", icon2);
        qrSecondary.setSmallIcon2(smallIcon2, options.secondaryIcon2Text);

        // Set Image
        if (!options.secondaryImage.equals("")) {
            Bitmap secBgBit = getIconBitmap(mContext, "file://" + options.secondaryImage);
            SrnImageAsset secBgAsst = new SrnImageAsset(mContext, "SecondaryBG", secBgBit);
            qrSecondary.setImage(secBgAsst);
        }

        secondaryTemplate = qrSecondary;
    } else {
        return null;
    }

    // Set the background color of the secondary template
    if (!options.secondaryBackgroundColor.isEmpty()) {
        try {
            int color = Color.parseColor(options.secondaryBackgroundColor);
            secondaryTemplate.setBackgroundColor(color);
        } catch (IllegalArgumentException illArgEx) {
            Log.e(TAG, "Invalid color string for Secondary Background");
        }
    } else {
        Log.e(TAG, "Empty string for Secondary Background");
    }

    return secondaryTemplate;
}

From source file:adventure_fragments.Swimming.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    ((MainActivityTrekkly) activity).onSectionAttached(8);
    MainActivityTrekkly mA = ((MainActivityTrekkly) getActivity());
    mA.restoreActionBar(Color.parseColor("#007FFF"));
}

From source file:com.byteshaft.medicosperuanos.utils.Helper.EmojiconsPopup.java

private View createCustomView() {
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.emojicons, null, false);
    emojisPager = (ViewPager) view.findViewById(R.id.emojis_pager);
    LinearLayout tabs = (LinearLayout) view.findViewById(R.id.emojis_tab);

    emojisPager.setOnPageChangeListener(this);
    EmojiconRecents recents = this;
    mEmojisAdapter = new EmojisPagerAdapter(
            Arrays.asList(new EmojiconRecentsGridView(mContext, null, null, this, mUseSystemDefault),
                    new EmojiconGridView(mContext, People.DATA, recents, this, mUseSystemDefault),
                    new EmojiconGridView(mContext, Nature.DATA, recents, this, mUseSystemDefault),
                    new EmojiconGridView(mContext, Food.DATA, recents, this, mUseSystemDefault),
                    new EmojiconGridView(mContext, Sport.DATA, recents, this, mUseSystemDefault),
                    new EmojiconGridView(mContext, Cars.DATA, recents, this, mUseSystemDefault),
                    new EmojiconGridView(mContext, Electr.DATA, recents, this, mUseSystemDefault),
                    new EmojiconGridView(mContext, Symbols.DATA, recents, this, mUseSystemDefault)

            ));/*w ww  .j a  v  a2s.c  o m*/
    emojisPager.setAdapter(mEmojisAdapter);
    mEmojiTabs = new View[8];

    mEmojiTabs[0] = view.findViewById(R.id.emojis_tab_0_recents);
    mEmojiTabs[1] = view.findViewById(R.id.emojis_tab_1_people);
    mEmojiTabs[2] = view.findViewById(R.id.emojis_tab_2_nature);
    mEmojiTabs[3] = view.findViewById(R.id.emojis_tab_3_food);
    mEmojiTabs[4] = view.findViewById(R.id.emojis_tab_4_sport);
    mEmojiTabs[5] = view.findViewById(R.id.emojis_tab_5_cars);
    mEmojiTabs[6] = view.findViewById(R.id.emojis_tab_6_elec);
    mEmojiTabs[7] = view.findViewById(R.id.emojis_tab_7_sym);
    for (int i = 0; i < mEmojiTabs.length; i++) {
        final int position = i;
        mEmojiTabs[i].setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                emojisPager.setCurrentItem(position);
            }
        });
    }

    emojisPager.setBackgroundColor(Color.parseColor(backgroundColor));
    tabs.setBackgroundColor(Color.parseColor(tabsColor));
    for (int x = 0; x < mEmojiTabs.length; x++) {
        ImageButton btn = (ImageButton) mEmojiTabs[x];
        btn.setColorFilter(Color.parseColor(iconPressedColor));
    }

    ImageButton imgBtn = (ImageButton) view.findViewById(R.id.emojis_backspace);
    imgBtn.setColorFilter(Color.parseColor(iconPressedColor));
    imgBtn.setBackgroundColor(Color.parseColor(backgroundColor));

    view.findViewById(R.id.emojis_backspace)
            .setOnTouchListener(new RepeatListener(500, 50, new OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (onEmojiconBackspaceClickedListener != null)
                        onEmojiconBackspaceClickedListener.onEmojiconBackspaceClicked(v);
                }
            }));

    // get last selected page
    mRecentsManager = EmojiconRecentsManager.getInstance(view.getContext());
    int page = mRecentsManager.getRecentPage();
    // last page was recents, check if there are recents to use
    // if none was found, go to page 1
    if (page == 0 && mRecentsManager.size() == 0) {
        page = 1;
    }

    if (page == 0) {
        onPageSelected(page);
    } else {
        emojisPager.setCurrentItem(page, false);
    }
    return view;
}

From source file:com.android.tabletcustomui.views.LeftCircleContainer.java

public void setTextColor(String color) {
    if (circleTitleView != null) {
        circleTitleView.setTextColor(Color.parseColor("#" + color));
        circleTitleView.invalidate();/*from  ww  w.  j a  va 2s . c o  m*/
    }
}