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.particles.nova.vo.NovaVO.java

protected static ArrayList<GLColor> getListColor(final JSONObject json, final String field)
        throws JSONException {
    // field check
    if (!json.has(field)) {
        return null;
    }//from ww  w .  j ava  2s  . c  om

    final ArrayList<GLColor> result = new ArrayList<GLColor>();
    try {
        final JSONArray array = json.getJSONArray(field);
        if (array != null) {
            final int size = array.length();
            for (int i = 0; i < size; i++) {
                if (array.get(i) instanceof String) {
                    result.add(new GLColor(Color.parseColor(array.getString(i))));
                } else {
                    result.add(new GLColor(array.getInt(i)));
                }
            }
        }
    } catch (JSONException e) {
        // single value
        if (json.get(field) instanceof String) {
            result.add(new GLColor(Color.parseColor(json.getString(field))));
        } else {
            result.add(new GLColor(json.getInt(field)));
        }
    }

    return result;
}

From source file:com.spydiko.rotationmanager.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    myapp = (AppSpecificOrientation) getApplication();
    setContentView(R.layout.activity_main);
    myapp.chechForUpdate(this);
    if (AppSpecificOrientation.appflood) {
        AppFlood.initialize(this, "4oxXbIyVm6xNiizl", "TbcZgeJj2facL52e003c9", AppFlood.AD_ALL);
        //      AppFlood.showBanner(this,AppFlood.BANNER_POSITION_BOTTOM,AppFlood.BANNER_SMALL);
        AppFlood.preload(AppFlood.AD_ALL, new AFRequestDelegate() {
            @Override/*from  w  w  w. j a va 2  s  .  c om*/
            public void onFinish(JSONObject arg0) {
                runOnUiThread(new Runnable() {
                    public void run() {
                        //                  Toast.makeText(MainActivity.this, "preload finish", Toast.LENGTH_SHORT).show();
                        AFBannerView afBannerView = (AFBannerView) findViewById(R.id.banner);
                        try {
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        afBannerView.setVisibility(View.VISIBLE);
                    }
                });
            }
        });
    }
    // Initialize everything
    /* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      ActionBar actionBar = getActionBar();
    ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#00FEBB31"));
    actionBar.setBackgroundDrawable(colorDrawable);
    }*/

    //      AppFlood.initialize(this, "1lfdyfOzKDcLPRPu", "th4j61EB18bdL522870c8", AppFlood.AD_ALL);
    names = new ArrayList<String>();
    //      if (myapp.loadDonate("appflood2")) AppFlood.showFullScreen(this);
    myapp.configureAdColony(this);
    menu = new SlidingMenu(this);
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    menu.setShadowWidthRes(R.dimen.shadow_width);
    menu.setShadowDrawable(R.drawable.shadow);
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setFadeDegree(0.35f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
    menu.setMenu(R.layout.slidingmenu);
    buttonClearAll = (Button) findViewById(R.id.button2);
    vibe = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
    orientationButton = (ImageView) findViewById(R.id.orientationButton);
    globalOrientation = (LinearLayout) findViewById(R.id.globalOrientation);
    autoRotate = (TextView) findViewById(R.id.orientationText);
    activities = new ArrayList<Model>();
    lv = (ListView) findViewById(R.id.appList);
    final ArrayList<Model> data = (ArrayList<Model>) getLastNonConfigurationInstance();
    // Set Listeners
    orientationButton.setOnClickListener(this);
    buttonClearAll.setOnClickListener(this);
    if (AppSpecificOrientation.getCheck_button() == 0 || AppSpecificOrientation.getCheck_button() == 1) {
        if (Settings.System.getInt(getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) == 1) {
            orientationButton.setImageDrawable(getResources().getDrawable(R.drawable.auto_rotate_on));
            autoRotate.setTextColor(Color.GREEN);
            autoRotate.setText(getResources().getText(R.string.orientationOn));
            AppSpecificOrientation.setCheck_button(0);
        } else {
            orientationButton.setImageDrawable(getResources().getDrawable(R.drawable.auto_rotate_off));
            autoRotate.setTextColor(Color.RED);
            autoRotate.setText(getResources().getText(R.string.orientationOff));
            AppSpecificOrientation.setCheck_button(1);
        }
    } else {
        if (AppSpecificOrientation.getCheck_button() == 2) {
            orientationButton.setImageDrawable(getResources().getDrawable(R.drawable.forced_portrait));
            autoRotate.setTextColor(Color.CYAN);
            autoRotate.setText(getResources().getText(R.string.forced_portrait));
        } else if (AppSpecificOrientation.getCheck_button() == 3) {
            orientationButton.setImageDrawable(getResources().getDrawable(R.drawable.forced_landscape));
            autoRotate.setTextColor(Color.CYAN);
            autoRotate.setText(getResources().getText(R.string.forced_landscape));
        } else if (AppSpecificOrientation.getCheck_button() == 4) {
            orientationButton.setImageDrawable(getResources().getDrawable(R.drawable.forced_auto));
            autoRotate.setTextColor(Color.parseColor("#FFFFFF"));
            autoRotate.setText(getResources().getText(R.string.forced_auto));
        }
    }
    // Register Content Observer
    getContentResolver().registerContentObserver(
            Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), true, rotationObserver);
    // Fill the list
    if (data == null) { // List not stored
        if (AppSpecificOrientation.LOG)
            Log.d(TAG, "null");
        packageManager = getPackageManager();
        this.adapter = new InteractiveArrayAdapter(this, activities, (AppSpecificOrientation) getApplication());
        lv.setAdapter(adapter);
        UpdateData updateData = new UpdateData();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            updateData.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
        else
            updateData.execute((Void[]) null);
    } else { // List stored
        if (AppSpecificOrientation.LOG)
            Log.d(TAG, "ok");
        activities = data;
        buttonsLayout = (LinearLayout) findViewById(R.id.twoButtons);
        progBar = (LinearLayout) findViewById(R.id.channelsProgress);
        this.adapter = new InteractiveArrayAdapter(this, activities, (AppSpecificOrientation) getApplication());
        lv.setAdapter(adapter);
        adapter.notifyDataSetChanged();
        for (Model mdl : activities) {
            names.add(mdl.getPackageName());
        }
        progBar.setVisibility(View.GONE);
        lv.setVisibility(View.VISIBLE);
        buttonsLayout.setVisibility(View.VISIBLE);
        globalOrientation.setVisibility(View.VISIBLE);
    }
}

From source file:com.ak.qmyd.view.TabPageIndicator.java

@Override
public void setCurrentItem(int item) {
    if (mViewPager == null) {
        //throw new IllegalStateException("ViewPager has not been bound.");
        return;/* w w  w .  j  ava 2  s  . c om*/
    }
    mSelectedTabIndex = item;
    mViewPager.setCurrentItem(item);

    final int tabCount = mTabLayout.getChildCount();
    for (int i = 0; i < tabCount; i++) {
        final View child = mTabLayout.getChildAt(i);
        final boolean isSelected = (i == item);
        child.setSelected(isSelected);
        if (isSelected) {
            animateToTab(item);
            ((TabView) child).setTextColor(Color.parseColor("#FF8200"));
            ((TabView) child).setTextSize(17);
        } else {
            ((TabView) child).setTextColor(Color.parseColor("#333333"));
            ((TabView) child).setTextSize(15);
        }
    }

}

From source file:com.android.andryyu.lifehelper.widget.RippleView.java

private void doRippleWork(Canvas canvas, int offect) {
    canvas.save();/*from w  w w  . j a  v  a  2  s.  com*/
    if (rippleDuration <= timer * frameRate) {
        // There is problem on Android M where canvas.restore() seems to be called automatically
        // For now, don't call canvas.restore() manually on Android M (API 23)
        canvas.drawCircle(x, y, (radiusMax * (((float) timer * frameRate) / rippleDuration)), paint);

        if (onCompletionListener != null && rippleStatus != RIPPLE_ACTION_MOVE
                && rippleStatus != RIPPLE_LONG_PRESS) {
            onCompletionListener.onComplete(this);
        }
        if (rippleStatus != RIPPLE_LONG_PRESS) {
            animationRunning = false;
            rippleStatus = RIPPLE_NORMAL;
            timer = 0;
            durationEmpty = -1;
            timerEmpty = 0;
            if (Build.VERSION.SDK_INT != 23) {
                canvas.restore();
            }
        }
        invalidate();
        return;
    } else
        canvasHandler.postDelayed(runnable, frameRate);

    if (timer == 0)
        canvas.save();

    canvas.drawCircle(x, y, (radiusMax * (((float) timer * frameRate) / rippleDuration)), paint);

    paint.setColor(Color.parseColor("#ffff4444"));

    if (rippleType == 1 && originBitmap != null && (((float) timer * frameRate) / rippleDuration) > 0.4f) {
        if (durationEmpty == -1)
            durationEmpty = rippleDuration - timer * frameRate;

        timerEmpty++;
        final Bitmap tmpBitmap = getCircleBitmap(
                (int) ((radiusMax) * (((float) timerEmpty * frameRate) / (durationEmpty))));
        canvas.drawBitmap(tmpBitmap, 0, 0, paint);
        tmpBitmap.recycle();
    }

    paint.setColor(rippleColor);
    if (!isListMode) {
        if (rippleType == 1) {
            if ((((float) timer * frameRate) / rippleDuration) > 0.6f)
                paint.setAlpha((int) (rippleAlpha
                        - ((rippleAlpha) * (((float) timerEmpty * frameRate) / (durationEmpty)))));
            else
                paint.setAlpha(rippleAlpha);
        } else
            paint.setAlpha(
                    (int) (rippleAlpha - ((rippleAlpha) * (((float) timer * frameRate) / rippleDuration))));
    }
    timer += offect;
}

From source file:com.example.sam14240619331555.food_app.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();
    title.clear();/*from w w w  . j  a  va2s.  c  o  m*/
    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);

        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        textColor = tabTitleView.getTextColors();
        if (i == 2) {
            tabTitleView.setTextColor(Color.parseColor("#f5f5f5"));
        }
        title.add(tabTitleView);
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}

From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java

public void loginStart(View view) {
    boolean hasError = false;
    final String rollNo = rollNoEditText.getText().toString().trim();
    String password = passwordEditText.getText().toString().trim();
    if (StringUtils.isEmpty(rollNo)) {
        hasError = true;/*from   w w  w .  j  a  va 2 s  .  c  om*/
        rollNoEditText.setError("Your Roll Number is required");
    }

    if (StringUtils.isEmpty(password)) {
        hasError = true;
        passwordEditText.setError("Your GPMS password is required");
    }

    if (!hasError) {
        hideSoftKeyboard();
        SharedPreferences.Editor editor = preferences.edit();
        editor.putString("roll_no", rollNoEditText.getText().toString());
        editor.putString("password",
                Security.encrypt(passwordEditText.getText().toString(), MainApplication.key));
        editor.apply();
        dialog.show();

        gpms.logout();
        gpms.login(rollNo, password, new InfoResponse() {

            @Override
            public void onSuccess() {
                showError();
            }

            @Override
            public void onFailedAuthentication() {
                showIncorrectError();
            }

            @SuppressWarnings("ConstantConditions")
            @Override
            public void onSuccess(String regNo, String name, String hostel, String roomNo, String mobile,
                    String email, String photoUrl, String numPasses) {
                setupLayout(R.layout.activity_gpms_profile, Color.parseColor("#009688"));
                ((TextView) findViewById(R.id.name)).setText(name);
                ((TextView) findViewById(R.id.roll_no)).setText(regNo);
                ((TextView) findViewById(R.id.mobile)).setText(mobile);
                ((TextView) findViewById(R.id.hostel)).setText(hostel + " - " + roomNo);
                getSupportActionBar().setSubtitle("Logged in as " + name);
                studentName = name;
                ImageView profilePic = (ImageView) findViewById(R.id.profile_pic);
                Picasso picasso = getUnsecuredPicassoDownloader();
                picasso.load(photoUrl).error(R.drawable.user).into(profilePic);
                hideProgress();
                loggedIn = true;

                Bundle bundle = new Bundle();
                bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "GPMS");
                bundle.putString(FirebaseAnalytics.Param.CHARACTER, name + " - " + regNo);
                tracker.logEvent(FirebaseAnalytics.Event.LOGIN, bundle);

            }

            @Override
            public void onFailure(Throwable throwable) {
                Ln.e(throwable);
                showError();
            }
        });
    }
}

From source file:com.amaze.filemanager.utils.Futils.java

public void setTint(CheckBox box, int color) {
    if (Build.VERSION.SDK_INT >= 21)
        return;//from www .j a  v  a 2s. co  m
    ColorStateList sl = new ColorStateList(
            new int[][] { new int[] { -android.R.attr.state_checked },
                    new int[] { android.R.attr.state_checked } },
            new int[] { Color.parseColor("#666666"), color });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        box.setButtonTintList(sl);
    } else {
        Drawable drawable = DrawableCompat
                .wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material));
        DrawableCompat.setTintList(drawable, sl);
        box.setButtonDrawable(drawable);
    }
}

From source file:com.andybotting.tubechaser.activity.StationDetail.java

/**
 * Display station/*  w ww.  j a va 2 s .co  m*/
 */
private void displayStation() {

    setContentView(R.layout.activity_station_detail);

    // Home button
    findViewById(R.id.btn_title_home).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            UIUtils.goHome(StationDetail.this);
        }
    });

    // Refresh button
    findViewById(R.id.btn_title_refresh).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            new GetDepartures().execute();
        }
    });

    // Map button
    findViewById(R.id.btn_title_map).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            final Intent intent = new Intent(StationDetail.this, StationMap.class);
            intent.putExtra(StationMap.EXTRA_STATION, mStation.getUri());
            startActivityForResult(intent, 1);
        }
    });

    // Set up our list
    mListAdapter = new DepartureListAdapter();

    mListView = getExpandableListView();
    Display display = getWindowManager().getDefaultDisplay();
    mListView.setIndicatorBounds(display.getWidth() - 50, display.getWidth() - 10);

    // Get our line, if we haven't already
    if (mLine == null)
        mLine = mProvider.getLine(mContext, mLineUri);

    // Set the title bar text
    ((TextView) findViewById(R.id.title_text)).setText(mLine.getLineName());

    // Set the title bar colour
    String lineColour = mLine.getColour();
    int colour = Color.parseColor("#" + lineColour);
    UIUtils.setTitleBarColor(findViewById(R.id.title_container), colour);

    // Set the station text
    ((TextView) findViewById(R.id.station_name)).setText(mStation.getName());
    ((TextView) findViewById(R.id.station_lines)).setText(mLine.getLineName());

    // Get Favourite
    mStarred = mPreferenceHelper.isStarred(mStation.getId(), mLine.getId());

    // Star button
    mStarredButton = (CompoundButton) findViewById(R.id.star_button);
    mStarredButton.setChecked(mStarred);

    // Star button OnClick
    mStarredButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            toggleStarred();
        }
    });

    new GetDepartures().execute();
}

From source file:com.bobomee.android.common.util.ScreenUtil.java

/**
 * http://blog.csdn.net/lyy1104/article/details/40048329
 *//*from   ww w .ja v  a  2s .c  om*/
public static Bitmap shotScrollView(ScrollView scrollView) {
    int h = 0;
    Bitmap bitmap = null;
    for (int i = 0; i < scrollView.getChildCount(); i++) {
        h += scrollView.getChildAt(i).getHeight();
        scrollView.getChildAt(i).setBackgroundColor(Color.parseColor("#ffffff"));
    }
    bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Bitmap.Config.RGB_565);
    final Canvas canvas = new Canvas(bitmap);
    scrollView.draw(canvas);
    return bitmap;
}

From source file:com.android.emergencyapp.ui.widget.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;//  ww w  .  j a  va 2s  .c  om
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        /*if (mDistributeEvenly) {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
        lp.width = 0;
        lp.weight = 1;
        }*/

        tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
        if (i == mViewPager.getCurrentItem()) {
            tabView.setSelected(true);
        }

        tabTitleView.setTextColor(Color.parseColor("#FFFFFF"));
    }
}