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:com.funzio.pure2D.ui.vo.FontVO.java

public TextOptions createTextOptions(final UIManager manager) {
    final TextOptions options = TextOptions.getDefault();

    options.id = name;//  ww  w . ja  v  a2  s. c  om
    options.inCharacters = manager.evalString(characters);
    options.inMipmaps = texture_mipmaps;

    try {
        options.inTextPaint.setTypeface(
                Typeface.createFromAsset(manager.getContext().getAssets(), manager.evalString(typeface)));
    } catch (Exception e) {
        // Log.e(TAG, "Creating Typeface Error: " + typeface, e);
        // fallback solution
        options.inTextPaint.setTypeface(Typeface.create(typeface, TextOptions.getTypefaceStyle(style)));
    }

    options.inTextPaint.setTextSize(Float.valueOf(manager.evalString(size)) * mScale);
    options.inTextPaint.setColor(Color.parseColor(color));

    options.inPaddingX = padding_x * mScale;
    options.inPaddingY = padding_y * mScale;

    // stroke
    final float ss = Float.valueOf(manager.evalString(stroke_size)) * mScale;
    if (ss > 0) {
        options.inStrokePaint = new TextPaint(options.inTextPaint);
        options.inStrokePaint.setColor(Color.parseColor(stroke_color));
        options.inStrokePaint.setTextSize(ss);
    }

    // shadow
    if (shadow_radius > 0) {
        if (options.inStrokePaint == null) {
            options.inStrokePaint = new TextPaint(options.inTextPaint);
        }
        options.inStrokePaint.setShadowLayer(shadow_radius * mScale, shadow_dx * mScale, shadow_dy * mScale,
                Color.parseColor(shadow_color));
    }

    return options;
}

From source file:com.may.ple.parking.gateway.activity.GateInActivity.java

@Override
public void onComplete(int id, Object result, Object passedParam) {
    try {/* w w  w  .  ja  v a2s  . com*/
        VehicleSaveCriteriaResp resp = (VehicleSaveCriteriaResp) result;

        if (resp.statusCode != 9999) {
            new ErrorHandler(this).handler(resp);
            return;
        }

        licenseNo = "";
        show.setText(licenseNo);
        show.setBackgroundResource(R.drawable.text_show);
        show.setTextColor(Color.parseColor("#FFFFFF"));
        Toast.makeText(this, "Sent already", Toast.LENGTH_SHORT).show();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        spinner.dismiss();
    }
}

From source file:com.dm.material.dashboard.candybar.adapters.IntentAdapter.java

@Override
public View getView(final int position, View view, ViewGroup viewGroup) {
    ViewHolder holder;//from  ww  w.  j a  va 2  s .co  m
    if (view == null) {
        view = View.inflate(mContext, R.layout.fragment_intent_chooser_item_list, null);
        holder = new ViewHolder(view);
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
        holder.divider.setVisibility(View.VISIBLE);
    }

    holder.icon.setImageDrawable(DrawableHelper.getAppIcon(mContext, mApps.get(position).getApp()));
    holder.name.setText(mApps.get(position).getApp().loadLabel(mContext.getPackageManager()).toString());

    if (position == mApps.size() - 1) {
        holder.divider.setVisibility(View.GONE);
    }

    if (mApps.get(position).getType() == IntentChooser.TYPE_SUPPORTED) {
        holder.type.setTextColor(ColorHelper.getAttributeColor(mContext, android.R.attr.textColorSecondary));
        holder.type.setText(mContext.getResources().getString(R.string.intent_email_supported));
    } else if (mApps.get(position).getType() == IntentChooser.TYPE_RECOMMENDED) {
        holder.type.setTextColor(ColorHelper.getAttributeColor(mContext, R.attr.colorAccent));
        holder.type.setText(mContext.getResources().getString(R.string.intent_email_recommended));
    } else {
        holder.type.setTextColor(Color.parseColor("#F44336"));
        holder.type.setText(mContext.getResources().getString(R.string.intent_email_not_supported));
    }

    holder.container.setOnClickListener(v -> {
        ActivityInfo app = mApps.get(position).getApp().activityInfo;
        if (mApps.get(position).getType() == IntentChooser.TYPE_RECOMMENDED
                || mApps.get(position).getType() == IntentChooser.TYPE_SUPPORTED) {
            ComponentName name = new ComponentName(app.applicationInfo.packageName, app.name);
            sendRequest(name);

            FragmentManager fm = ((AppCompatActivity) mContext).getSupportFragmentManager();
            if (fm != null) {
                DialogFragment dialog = (DialogFragment) fm.findFragmentByTag(IntentChooserFragment.TAG);
                if (dialog != null) {
                    dialog.dismiss();
                }
            }
            return;
        }

        Toast.makeText(mContext, R.string.intent_email_not_supported_message, Toast.LENGTH_LONG).show();
    });

    return view;
}

From source file:com.example.android.miwok.activity.FamilyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.word_list);//from w  w  w.  ja  v  a  2 s  . co  m

    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    // Create a list of words
    final ArrayList<Word> words = new ArrayList<Word>();
    words.add(new Word("father", "p", R.drawable.family_father, R.raw.family_father));
    words.add(new Word("mother", "a", R.drawable.family_mother, R.raw.family_mother));
    words.add(new Word("son", "angsi", R.drawable.family_son, R.raw.family_son));
    words.add(new Word("daughter", "tune", R.drawable.family_daughter, R.raw.family_daughter));
    words.add(new Word("older brother", "taachi", R.drawable.family_older_brother, R.raw.family_older_brother));
    words.add(new Word("younger brother", "chalitti", R.drawable.family_younger_brother,
            R.raw.family_younger_brother));
    words.add(new Word("older sister", "tee", R.drawable.family_older_sister, R.raw.family_older_sister));
    words.add(new Word("younger sister", "kolliti", R.drawable.family_younger_sister,
            R.raw.family_younger_sister));
    words.add(new Word("grandmother ", "ama", R.drawable.family_grandmother, R.raw.family_grandmother));
    words.add(new Word("grandfather", "paapa", R.drawable.family_grandfather, R.raw.family_grandfather));

    // Create an {@link WordAdapter}, whose data source is a list of {@link Word}s. The
    // adapter knows how to create list items for each item in the list.
    WordAdapter adapter = new WordAdapter(this, words);

    // Find the {@link ListView} object in the view hierarchy of the {@link Activity}.
    // There should be a {@link ListView} with the view ID called list, which is declared in the
    // word_list.xml layout file.
    ListView listView = (ListView) findViewById(R.id.list);
    listView.setBackgroundColor(Color.parseColor("#379237")); //<--this is another way to set the background color is it wasn't in colors.xml
    //listView.setBackgroundColor(R.color.category_family);

    // Make the {@link ListView} use the {@link WordAdapter} we created above, so that the
    // {@link ListView} will display list items for each {@link Word} in the list.
    listView.setAdapter(adapter);

    //plays the audio for number one when any item in the list is clicked click
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            //release current resources being used for media player if it currently exists
            //because we are about to play a different sound file.
            releaseMediaPlayer();

            //get the word located in the list that is at same position as the item clicked in the list
            Word currentWord = words.get(position);

            // Request audio focus for playback
            int result = mAudioManager.requestAudioFocus(mAudioFocusChangeListener,
                    // Use the music stream.
                    AudioManager.STREAM_MUSIC,
                    // Request temporary focus.
                    AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);

            if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {

                //create the medial player with the audio file that is stored in the list for that word.
                mMediaPlayer = MediaPlayer.create(getApplicationContext(), currentWord.getmMiwokAudio());
                //play the file
                mMediaPlayer.start();

                //listener to stop and release the media player and resources being used
                // once the sounds has finished playing
                mMediaPlayer.setOnCompletionListener(mCompletionListener);
            }
        }
    });
}

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/* w  w  w  .j  a  v  a  2 s .  c o m*/
        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:com.brodev.socialapp.view.EventDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // setTheme(SampleList.THEME); //Used for theme switching in samples
    super.onCreate(savedInstanceState);
    phraseManager = new PhraseManager(getApplicationContext());
    user = (User) getApplication().getApplicationContext();
    colorView = new ColorView(getApplicationContext());

    colorCode = colorView.getColorCode(getApplicationContext(), user);

    setContentView(R.layout.fragment_tabs_pager);
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();/* w  w w  .ja va 2 s  .  co m*/

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(2);
    mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(phraseManager.getPhrase(getApplicationContext(), "event.event"));
    Bundle extras = getIntent().getExtras();

    mTabsAdapter.addTab(
            mTabHost.newTabSpec("wall")
                    .setIndicator(phraseManager.getPhrase(getApplicationContext(), "accountapi.info")),
            EventDetailFragment.class, extras);

    mTabsAdapter.addTab(
            mTabHost.newTabSpec("info")
                    .setIndicator(phraseManager.getPhrase(getApplicationContext(), "accountapi.member")),
            EventMemberFragment.class, extras);

    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
    }

    //set color for tabhost
    for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {
        mTabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#272727"));
        tv = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
        tv.setTextColor(Color.parseColor("#ffffffff"));
    }
    mTabHost.getTabWidget().setCurrentTab(0);
    mTabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor(colorCode));
}

From source file:com.dw.bartinter.BarTinter.java

private void statusBar(final String colorPref) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (colorPref != null && !colorPref.isEmpty()) {
            final Window window = cordova.getActivity().getWindow();
            window.clearFlags(0x04000000);
            window.addFlags(0x80000000);
            try {
                window.getClass().getDeclaredMethod("setStatusBarColor", int.class).invoke(window,
                        Color.parseColor(colorPref));
            } catch (IllegalArgumentException ignore) {
                Log.e(PLUGIN, "Invalid hexString argument.");
            } catch (Exception ignore) {
                Log.w(PLUGIN,//from www. ja v a2s  . c om
                        "Method window.setStatusBarColor not found for SDK level " + Build.VERSION.SDK_INT);
            }
        }
    }
}

From source file:com.example.android.miwok.activity.NumbersActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.word_list);/*from  w w  w .  ja  va2 s  .c o  m*/

    //Create and setup the {@link AudioManager} to request audio focus
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    // Create a list of words
    //made the arraylist final so that it could be accessed inside the onItemClick method.
    final ArrayList<Word> words = new ArrayList<Word>();
    words.add(new Word("one", "lutti", R.drawable.number_one, R.raw.number_one));
    words.add(new Word("two", "otiiko", R.drawable.number_two, R.raw.number_two));
    words.add(new Word("three", "tolookosu", R.drawable.number_three, R.raw.number_three));
    words.add(new Word("four", "oyyisa", R.drawable.number_four, R.raw.number_four));
    words.add(new Word("five", "massokka", R.drawable.number_five, R.raw.number_five));
    words.add(new Word("six", "temmokka", R.drawable.number_six, R.raw.number_six));
    words.add(new Word("seven", "kenekaku", R.drawable.number_seven, R.raw.number_seven));
    words.add(new Word("eight", "kawinta", R.drawable.number_eight, R.raw.number_eight));
    words.add(new Word("nine", "woe", R.drawable.number_nine, R.raw.number_nine));
    words.add(new Word("ten", "naaacha", R.drawable.number_ten, R.raw.number_ten));

    // Create an {@link WordAdapter}, whose data source is a list of {@link Word}s. The
    // adapter knows how to create list items for each item in the list.
    WordAdapter adapter = new WordAdapter(this, words);

    // Find the {@link ListView} object in the view hierarchy of the {@link Activity}.
    // There should be a {@link ListView} with the view ID called list, which is declared in the
    // word_list.xml layout file.
    ListView listView = (ListView) findViewById(R.id.list);
    //listView.setBackgroundColor(R.color.category_numbers);
    listView.setBackgroundColor(Color.parseColor("#FD8E09"));
    // Make the {@link ListView} use the {@link WordAdapter} we created above, so that the
    // {@link ListView} will display list items for each {@link Word} in the list.
    listView.setAdapter(adapter);

    //plays the audio for number one when any item in the list is clicked click
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            //release current resources being used for media player if it currently exists
            //because we are about to play a different sound file.
            releaseMediaPlayer();

            //get the word located in the list that is at same position as the item clicked in the list
            Word currentWord = words.get(position);

            // Request audio focus for playback
            int result = mAudioManager.requestAudioFocus(mAudioFocusChangeListener,
                    // Use the music stream.
                    AudioManager.STREAM_MUSIC,
                    // Request temporary focus.
                    AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);

            if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {

                //create the medial player with the audio file that is stored in the list for that word.
                mMediaPlayer = MediaPlayer.create(getApplicationContext(), currentWord.getmMiwokAudio());
                //play the file
                mMediaPlayer.start();

                //listener to stop and release the media player and resources being used
                // once the sounds has finished playing
                mMediaPlayer.setOnCompletionListener(mCompletionListener);
            }

        }
    });

}

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   www . j  a va  2s  .  c om
    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  va  2 s.  c om*/
    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();

}