Example usage for android.graphics Color argb

List of usage examples for android.graphics Color argb

Introduction

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

Prototype

@ColorInt
public static int argb(float alpha, float red, float green, float blue) 

Source Link

Document

Return a color-int from alpha, red, green, blue float components in the range \([0..1]\).

Usage

From source file:com.cosmicsubspace.nerdyaudio.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    final Thread.UncaughtExceptionHandler orig = Thread.getDefaultUncaughtExceptionHandler();
    final Context c = getApplicationContext();
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        @Override//w  w w.  j  ava 2  s  .c o  m
        public void uncaughtException(Thread thread, Throwable e) {
            Log2.log(0, this, "UncaughtException logged:", Log2.logToString(e));
            //Toast.makeText(c, ErrorLogger.logToString(e), Toast.LENGTH_SHORT).show();
            FileWriter f;
            try {
                f = new FileWriter(new File(Environment.getExternalStorageDirectory() + "/AFN_exceptions.txt"),
                        true);
                f.write("\n\n\n" + DateFormat.getDateTimeInstance().format(new Date()) + "\n");
                f.write(Log2.logToString(e));
                f.flush();
                f.close();
            } catch (IOException e1) {
                Log2.log(e1);
            } //Double exception?

            Log2.dumpLogsAsync();

            orig.uncaughtException(thread, e);
        }
    });

    requestPermission();

    Log2.log(1, this, "MainActivity Created!");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    sf = getPreferences(Context.MODE_PRIVATE);

    String[] files = fileList();
    for (String i : files) {
        Log2.log(1, this, "File: " + i);
    }

    qm = QueueManager.getInstance();
    ap = AudioPlayer.getInstance();
    vb = VisualizationBuffer.getInstance();
    fm = FileManager.getInstance();
    wf = Waveform.getInstance();
    sbs = SidebarSettings.instantiate(getApplicationContext());
    vm = VisualizationManager.getInstance();

    volCtrl = new VolumeControls(getApplicationContext(), qm);

    //ap.setBufferFeedListener(vb);

    qm.passContext(getApplicationContext());
    fm.loadFromFile(this);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.addTab(tabLayout.newTab().setText("Library"));
    tabLayout.addTab(tabLayout.newTab().setText("Queue"));
    tabLayout.addTab(tabLayout.newTab().setText("Filters"));
    tabLayout.addTab(tabLayout.newTab().setText("Now Playing"));
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

    tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            int pos = tab.getPosition();
            if (pos == 0)
                ft.replace(R.id.tab_area, new LibraryFragment());
            else if (pos == 1)
                ft.replace(R.id.tab_area, new QueueFragment());
            else if (pos == 2)
                ft.replace(R.id.tab_area, new FiltersFragment());
            else if (pos == 3)
                ft.replace(R.id.tab_area, new NowPlayingFragment());

            ft.commit();
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    });
    getSupportFragmentManager().beginTransaction().replace(R.id.tab_area, new LibraryFragment()).commit();

    wfv = (PlayControlsView) findViewById(R.id.waveform);
    wfv.setSpacing(0);
    wfv.setTimestampVisibility(true);
    wfv.setTimestampSize(16);
    wfv.setTimestampColor(Color.WHITE);

    wfv.setTimestampOffset(30, 10);
    wfv.setTimestampBackgroundColor(Color.argb(128, 0, 0, 0));

    wfv.setWaveform(wf);
    qm.addQueueListener(wfv);
    qm.addProgressStringListener(wfv);

    vv = (VisualizationView) findViewById(R.id.visualization);

    dl = (DrawerLayout) findViewById(R.id.drawer_layout);

    dl.setDrawerListener(this);

    settingBtn = (RelativeLayout) findViewById(R.id.settings_btn);
    settingBtn.setOnClickListener(this);

    //statusText=(TextView)findViewById(R.id.status);

    sideContainer = (ScrollView) findViewById(R.id.drawer_scroll);
    sideContainer.addView(sbs.getView(getLayoutInflater(), sideContainer, null));

}

From source file:org.adw.library.widgets.discreteseekbar.internal.drawable.MarkerDrawable.java

private static int blendColors(int color1, int color2, float factor) {
    final float inverseFactor = 1f - factor;
    float a = (Color.alpha(color1) * factor) + (Color.alpha(color2) * inverseFactor);
    float r = (Color.red(color1) * factor) + (Color.red(color2) * inverseFactor);
    float g = (Color.green(color1) * factor) + (Color.green(color2) * inverseFactor);
    float b = (Color.blue(color1) * factor) + (Color.blue(color2) * inverseFactor);
    return Color.argb((int) a, (int) r, (int) g, (int) b);
}

From source file:com.aosijia.dragonbutler.ui.widget.ActionSheet.java

private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(ActionSheet.BG_VIEW_ID);/*from w w  w. j a v a 2  s.  c om*/
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    mPanel.setLayoutParams(params);
    mPanel.setOrientation(LinearLayout.VERTICAL);
    if (checkDeviceHasNavigationBar(getActivity())) {
        parent.setPadding(0, 0, 0, getNavBarHeight(getActivity()));
    } else {
        parent.setPadding(0, 0, 0, 0);
    }

    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:com.shenzhen.elson.selectordialoglib.SelectorDialog.java

private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(SelectorDialog.BG_VIEW_ID);
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;/*w ww  .  j a  va 2  s  .  c  o  m*/
    mPanel.setLayoutParams(params);
    mPanel.setOrientation(LinearLayout.VERTICAL);
    parent.setPadding(0, 0, 0, getNavBarHeight(getActivity()));
    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:com.cyrilmottier.android.polaris2demo.CircleDemoActivity.java

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (seekBar == mColorBar) {
        mFillColor = Color.HSVToColor(Color.alpha(mFillColor), new float[] { progress, 1, 1 });
    } else if (seekBar == mAlphaBar) {
        mFillColor = Color.argb(progress, Color.red(mFillColor), Color.green(mFillColor),
                Color.blue(mFillColor));
    }//from www.j av  a2 s.co m

    for (DraggableCircle draggableCircle : mCircles) {
        draggableCircle.onStyleChange();
    }
}

From source file:com.rbsoftware.pfm.personalfinancemanager.utils.Utils.java

/**
 * Gets color by data type key//from  w w w  .  ja v  a2  s  .com
 *
 * @param key data type key
 * @return color
 */
public static int getColorPalette(Context mContext, String key) {
    if (isNumber(key)) {
        switch (Integer.valueOf(key)) {
        case -2:
            return ContextCompat.getColor(mContext, R.color.balance);
        case -1:
            return ContextCompat.getColor(mContext, R.color.income);
        case 0:
            return ContextCompat.getColor(mContext, R.color.expense);
        case 1:
            return ContextCompat.getColor(mContext, R.color.salary);
        case 2:
            return ContextCompat.getColor(mContext, R.color.rental_income);
        case 3:
            return ContextCompat.getColor(mContext, R.color.interest);
        case 4:
            return ContextCompat.getColor(mContext, R.color.gifts);
        case 5:
            return ContextCompat.getColor(mContext, R.color.other_income);
        case 6:
            return ContextCompat.getColor(mContext, R.color.taxes);
        case 7:
            return ContextCompat.getColor(mContext, R.color.mortgage);
        case 8:
            return ContextCompat.getColor(mContext, R.color.credit_card);
        case 9:
            return ContextCompat.getColor(mContext, R.color.utilities);
        case 10:
            return ContextCompat.getColor(mContext, R.color.food);
        case 11:
            return ContextCompat.getColor(mContext, R.color.car_payment);
        case 12:
            return ContextCompat.getColor(mContext, R.color.personal);
        case 13:
            return ContextCompat.getColor(mContext, R.color.activities);
        case 14:
            return ContextCompat.getColor(mContext, R.color.other_expense);

        }
    }
    Random rnd = new Random();
    return Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));

}

From source file:com.ferdi2005.secondgram.AndroidUtilities.java

public static int[] calcDrawableColor(Drawable drawable) {
    int bitmapColor = 0xff000000;
    int result[] = new int[2];
    try {//ww w. j a v a  2  s  .c om
        if (drawable instanceof BitmapDrawable) {
            Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
            if (bitmap != null) {
                Bitmap b = Bitmaps.createScaledBitmap(bitmap, 1, 1, true);
                if (b != null) {
                    bitmapColor = b.getPixel(0, 0);
                    if (bitmap != b) {
                        b.recycle();
                    }
                }
            }
        } else if (drawable instanceof ColorDrawable) {
            bitmapColor = ((ColorDrawable) drawable).getColor();
        }
    } catch (Exception e) {
        FileLog.e(e);
    }

    double[] hsv = rgbToHsv((bitmapColor >> 16) & 0xff, (bitmapColor >> 8) & 0xff, bitmapColor & 0xff);
    hsv[1] = Math.min(1.0, hsv[1] + 0.05 + 0.1 * (1.0 - hsv[1]));
    hsv[2] = Math.max(0, hsv[2] * 0.65);
    int rgb[] = hsvToRgb(hsv[0], hsv[1], hsv[2]);
    result[0] = Color.argb(0x66, rgb[0], rgb[1], rgb[2]);
    result[1] = Color.argb(0x88, rgb[0], rgb[1], rgb[2]);
    return result;
}

From source file:com.achep.acdisplay.ui.widgets.CircleView.java

@Override
protected void onDraw(Canvas canvas) {
    final float ratio = calculateRatio();

    // Draw all corners
    drawCornerIcon(canvas, mDrawableLeftTopCorner, 0, 0 /* left top */);
    drawCornerIcon(canvas, mDrawableRightTopCorner, 1, 0 /* right top */);
    drawCornerIcon(canvas, mDrawableLeftBottomCorner, 0, 1 /* left bottom */);
    drawCornerIcon(canvas, mDrawableRightBottomCorner, 1, 1 /* right bottom */);

    // Darkening background
    int alpha = (int) (mDarkening * 255);
    alpha += (int) ((255 - alpha) * ratio * 0.7f); // Change alpha dynamically
    canvas.drawColor(/*from  www.  ja  va2 s  .  co  m*/
            Color.argb(alpha, Color.red(mOuterColor), Color.green(mOuterColor), Color.blue(mOuterColor)));

    // Draw unlock circle
    mPaint.setColor(mInnerColor);
    mPaint.setAlpha((int) (255 * Math.pow(ratio, 1f / 3f)));
    canvas.drawCircle(mPoint[0], mPoint[1], mRadiusDrawn, mPaint);

    if (ratio >= 0.5f) {
        // Draw unlock icon at the center of circle
        float scale = 0.5f + 0.5f * ratio;
        canvas.save();
        canvas.translate(mPoint[0] - mDrawable.getMinimumWidth() / 2 * scale,
                mPoint[1] - mDrawable.getMinimumHeight() / 2 * scale);
        canvas.scale(scale, scale);
        mDrawable.draw(canvas);
        canvas.restore();
    }
}

From source file:com.mickledeals.views.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./* w ww .java2 s .c o  m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
            context.getResources().getDimensionPixelSize(R.dimen.sp_17));
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setTextColor(Color.argb((int) (MIN_TEXT_ALPHA * 255), 255, 255, 255));
    textView.setBackgroundResource(R.drawable.selector_bg);

    //        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    //            // If we're running on Honeycomb or newer, then we can use the Theme's
    //            // selectableItemBackground to ensure that the View has a pressed state
    //            TypedValue outValue = new TypedValue();
    //            getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
    //                    outValue, true);
    //            textView.setBackgroundResource(outValue.resourceId);
    //        }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:br.com.testmaster.view.activity.LeadDetailActivity.java

@Override
public void onMapReady(GoogleMap googleMap) {
    mMMap = googleMap;//  www . j av  a2 s  . c  o  m
    mMMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

    Geolocation local;
    if (mDetail == null) {
        return;
    } else {
        local = mDetail.get_embedded().getAddress().getGeolocation();
    }

    LatLng latLon = new LatLng(local.getLatitude(), local.getLongitude());
    mMMap.addCircle(new CircleOptions().center(latLon).radius(30).strokeColor(Color.BLUE).strokeWidth(2f)
            .fillColor(Color.argb(1, 0, 0, 255)).center(latLon));
    mMMap.moveCamera(CameraUpdateFactory.newLatLng(latLon));
    mMMap.animateCamera(CameraUpdateFactory.zoomTo(17.0f));
}