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.slensky.focussis.fragments.AboutFragment.java

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

    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_about, container, false);

    //        ImageView logo = (ImageView) view.findViewById(R.id.image_logo);
    //        ConstraintLayout.LayoutParams lp = (ConstraintLayout.LayoutParams) logo.getLayoutParams();
    //        lp.setMargins(lp.leftMargin, ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight() / 10, lp.rightMargin, lp.bottomMargin);
    //        logo.setLayoutParams(lp);

    TextView version = (TextView) view.findViewById(R.id.text_version);
    version.setText("Version " + this.version);
    //TextView copyright = (TextView) view.findViewById(R.id.text_copyright);
    //copyright.setText(String.format(getString(R.string.copyright), Calendar.getInstance().get(Calendar.YEAR)));
    //TextView license = (TextView) view.findViewById(R.id.text_license);

    ImageView mailIcon = (ImageView) view.findViewById(R.id.email_icon);
    mailIcon.setColorFilter(Color.argb(132, 0, 0, 0), PorterDuff.Mode.MULTIPLY);
    ImageView githubIcon = (ImageView) view.findViewById(R.id.github_icon);
    githubIcon.setColorFilter(Color.argb(132, 0, 0, 0), PorterDuff.Mode.MULTIPLY);
    ImageView licenseIcon = (ImageView) view.findViewById(R.id.version_icon);
    licenseIcon.setColorFilter(Color.argb(132, 0, 0, 0), PorterDuff.Mode.MULTIPLY);

    /*license.setOnClickListener(new View.OnClickListener() {
    @Override/*from  w w w.ja  v a 2s .com*/
    public void onClick(View v) {
        Uri uri = Uri.parseRequirements(getString(R.string.about_license_link));
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    }
    });*/

    RelativeLayout emailLayout = (RelativeLayout) view.findViewById(R.id.email_layout);
    emailLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", getString(R.string.about_email), null));
            startActivity(Intent.createChooser(intent, "Send Email"));
        }
    });

    RelativeLayout githubLayout = (RelativeLayout) view.findViewById(R.id.github_layout);
    githubLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri uri = Uri.parse(getString(R.string.about_github_link));
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });

    return view;
}

From source file:com.hookedonplay.decoviewsample.SamplePeopleFragment.java

@Override
protected void createTracks() {
    setDemoFinished(false);/*  w  w w.  ja  v  a  2  s  .c o  m*/
    final DecoView decoView = getDecoView();
    final View view = getView();
    if (decoView == null || view == null) {
        return;
    }

    view.setBackgroundColor(Color.argb(255, 128, 218, 128));

    decoView.executeReset();
    decoView.deleteAll();

    float circleInset = getDimension(23) - (getDimension(46) * 0.3f);
    SeriesItem seriesBack1Item = new SeriesItem.Builder(COLOR_BACK).setRange(0, mSeriesMax, mSeriesMax)
            .setChartStyle(SeriesItem.ChartStyle.STYLE_PIE).setInset(new PointF(circleInset, circleInset))
            .build();

    mBack1Index = decoView.addSeries(seriesBack1Item);

    SeriesItem series1Item = new SeriesItem.Builder(COLOR_BLUE).setRange(0, mSeriesMax, 0)
            .setInitialVisibility(false).setLineWidth(getDimension(46))
            .setSeriesLabel(new SeriesLabel.Builder("Men").build()).setCapRounded(false)
            .addEdgeDetail(new EdgeDetail(EdgeDetail.EdgeType.EDGE_INNER, COLOR_EDGE, 0.3f))
            .setShowPointWhenEmpty(false).build();

    mSeries1Index = decoView.addSeries(series1Item);

    SeriesItem series2Item = new SeriesItem.Builder(COLOR_PINK).setRange(0, mSeriesMax, 0)
            .setInitialVisibility(false).setLineWidth(getDimension(46))
            .setSeriesLabel(new SeriesLabel.Builder("Women").build()).setCapRounded(false)
            //.setChartStyle(SeriesItem.ChartStyle.STYLE_PIE)
            .addEdgeDetail(new EdgeDetail(EdgeDetail.EdgeType.EDGE_INNER, COLOR_EDGE, 0.3f))
            .setShowPointWhenEmpty(false).build();

    mSeries2Index = decoView.addSeries(series2Item);

    SeriesItem series3Item = new SeriesItem.Builder(COLOR_YELLOW).setRange(0, mSeriesMax, 0)
            .setInitialVisibility(false).setLineWidth(getDimension(46))
            .setSeriesLabel(new SeriesLabel.Builder("Children").build()).setCapRounded(false)
            //.setChartStyle(SeriesItem.ChartStyle.STYLE_PIE)
            .addEdgeDetail(new EdgeDetail(EdgeDetail.EdgeType.EDGE_INNER, COLOR_EDGE, 0.3f))
            .setShowPointWhenEmpty(false).build();

    mSeries3Index = decoView.addSeries(series3Item);

}

From source file:Main.java

private static int applyTransformation(int[] tintComponents, int alpha, float[] transformation) {
    return Color.argb(alpha, (int) applyTransformation(tintComponents[0], transformation),
            (int) applyTransformation(tintComponents[1], transformation),
            (int) applyTransformation(tintComponents[2], transformation));
}

From source file:edu.htl3r.schoolplanner.gui.timetable.ViewPagerIndicator.java

public void setUnfocusedTextColor(int[] col) {
    System.arraycopy(col, 0, mUnfocusedTextColor, 0, 3);
    mNext.setTextColor(Color.argb(255, col[0], col[1], col[2]));
    mPrevious.setTextColor(Color.argb(255, col[0], col[1], col[2]));
    updateColor(0);//from   w  ww  . java 2 s  .co  m
}

From source file:net.bither.util.ChartsUtil.java

public static synchronized void initMarketDepth(MarketDepthChart marketDepthChart, Depth depth,
        boolean isRefresh) {

    List<LineEntity<DateValueEntity>> lines = new ArrayList<LineEntity<DateValueEntity>>();
    LineEntity<DateValueEntity> MALineData = new LineEntity<DateValueEntity>();
    MALineData.setLineData(depth.getDateValueEntities());
    lines.add(MALineData);//from   w w w.  j  a v  a2  s .  com
    MarketDepthEntity marketDepthEntity = new MarketDepthEntity(lines, depth.getSplitIndex());
    marketDepthChart.setMareketDepthEntity(marketDepthEntity);

    int lineColor = Color.argb(30, 255, 255, 255);

    marketDepthChart.setLongitudeFontSize(14);
    marketDepthChart.setLatitudeFontSize(14);
    marketDepthChart.setLongitudeFontColor(Color.WHITE);
    marketDepthChart.setLatitudeColor(lineColor);
    marketDepthChart.setLatitudeFontColor(Color.WHITE);
    marketDepthChart.setLongitudeColor(lineColor);
    marketDepthChart.setMaxValue((int) depth.getMaxVolume());
    marketDepthChart.setMinValue(0);
    // marketDepthChart.setDisplayFrom(0);
    marketDepthChart.setDisplayNumber(depth.getDateValueEntities().size() - 1);
    marketDepthChart.setMinDisplayNumber(depth.getDateValueEntities().size() - 1);
    marketDepthChart.setZoomBaseLine(0);
    marketDepthChart.setDisplayLongitudeTitle(true);
    marketDepthChart.setDisplayLatitudeTitle(true);
    marketDepthChart.setDisplayLatitude(true);
    marketDepthChart.setDisplayLongitude(true);
    marketDepthChart.setDisplayBorder(false);
    marketDepthChart.setDataQuadrantPaddingTop(5);
    marketDepthChart.setDataQuadrantPaddingBottom(5);
    marketDepthChart.setDataQuadrantPaddingLeft(5);
    marketDepthChart.setDataQuadrantPaddingRight(5);
    marketDepthChart.setAxisYTitleQuadrantWidth(50);
    marketDepthChart.setAxisXTitleQuadrantHeight(20);
    marketDepthChart.setAxisXPosition(GridChart.AXIS_X_POSITION_BOTTOM);
    marketDepthChart.setAxisYPosition(GridChart.AXIS_Y_POSITION_RIGHT);
    if (isRefresh) {
        marketDepthChart.invalidate();
    }
}

From source file:com.uprayzner.mediator.adapters.PlanStandsListAdapter.java

@Override
public void onBindViewHolder(final StandViewHolder holder, final int position) {
    final IPlanStandCard card = getItem(position);

    GradientDrawable drawable = (GradientDrawable) holder.header.getBackground();
    drawable.setColor(card.getColor());/*from  ww  w  . j  a  v  a  2 s  . co  m*/

    holder.title.setText(card.getTitle());
    setProgressColor(card.getColor(), holder.progressBar);
    holder.logo.setBackgroundColor(Color.argb(25, Color.red(card.getColor()), Color.green(card.getColor()),
            Color.blue(card.getColor())));

    Glide.with(holder.logo.getContext()).load(card.getImageUrl()).crossFade().fitCenter().override(200, 300)
            .listener(new RequestListener<String, GlideDrawable>() {
                @Override
                public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                        boolean isFirstResource) {
                    holder.progressBar.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            holder.progressBar.setVisibility(View.VISIBLE);
                        }
                    }, 50);
                    return false;
                }

                @Override
                public boolean onResourceReady(GlideDrawable resource, String model,
                        Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                    holder.progressBar.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            holder.progressBar.setVisibility(View.GONE);
                        }
                    }, 50);
                    return false;
                }
            }).into(holder.logo);

    holder.container.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            listener.onListItemClick(position, card);
        }
    });
}

From source file:com.pranavpandey.smallapp.theme.DynamicTheme.java

/**
 * Calculate accent based on a given color for dynamic theme generation.
 * Still in beta so, sometimes may be inaccurate colors.
 *
 * @param color whose accent to be calculated.
 *
 * @return Accent based on given color./*  w  w w. ja va  2  s . co  m*/
 */
public static @ColorInt int getAccentColor(@ColorInt int color) {
    int finalColor;
    int a = Color.alpha(color);
    int r = Color.red(color);
    int g = Color.green(color);
    int b = Color.blue(color);
    double Y = ((r * 299) + (g * 587) + (b * 114)) / 1000;

    int rc = b ^ 0x55;
    int gc = g & 0xFA;
    int bc = r ^ 0x55;

    finalColor = Color.argb(a, rc, gc, bc);
    int r1 = Color.red(finalColor);
    int g1 = Color.green(finalColor);
    int b1 = Color.blue(finalColor);
    double YC = ((r1 * 299) + (g1 * 587) + (b1 * 114)) / 1000;

    int CD = (Math.max(r, r1) - Math.min(r, r1)) + (Math.max(g, g1) - Math.min(g, g1))
            + (Math.max(b, b1) - Math.min(b, b1));
    if ((Y - YC <= 50) && CD <= 200) {
        rc = b ^ 0xFA;
        gc = g & 0x55;
        bc = r ^ 0x55;
    }

    finalColor = Color.argb(a, rc, gc, bc);
    return finalColor;
}

From source file:jayen.library.rbgcolorpicker.ColorPickerSupportDialogFrag.java

@Override
public void update(Subject subject, int value) {
    if (subject instanceof AlphaPickerBar) {
        alphaValue = value;/*w w w.  ja  va2  s .c  o m*/
    } else if (subject instanceof RedPickerBar) {
        redValue = value;
    } else if (subject instanceof GreenPickerBar) {
        greenValue = value;
    } else if (subject instanceof BluePickerBar) {
        blueValue = value;
    }
    currentColorTV.setBackgroundColor(Color.argb(alphaValue, redValue, greenValue, blueValue));
    currentColorTV.setText("#" + Integer.toHexString(alphaValue) + Integer.toHexString(redValue)
            + Integer.toHexString(greenValue) + Integer.toHexString(blueValue));
}

From source file:com.danimahardhika.android.helpers.core.ColorHelper.java

@ColorInt
public static int setColorAlpha(@ColorInt int color, @FloatRange(from = 0.0f, to = 1.0f) float alpha) {
    int alpha2 = Math.round(Color.alpha(color) * alpha);
    int red = Color.red(color);
    int green = Color.green(color);
    int blue = Color.blue(color);
    return Color.argb(alpha2, red, green, blue);
}

From source file:com.money.manager.ex.assetallocation.full.FullAssetAllocationAdapter.java

@Override
public void onBindViewHolder(FullAssetClassViewHolder holder, int position) {
    AssetClassViewModel item = this.model.get(position);

    // color the background, depending on the level.
    switch (item.assetClass.getType()) {
    case Allocation:
        // reset bg color
        holder.listItem.setBackgroundColor(Color.TRANSPARENT);
        break;//w w  w .j  ava 2  s  .com

    case Footer:
        holder.listItem.setBackgroundColor(Color.DKGRAY);
        break;

    default:
        int colorDepth = 50 * item.level;
        holder.listItem.setBackgroundColor(Color.argb(225, 0, 100 + colorDepth, 0));
        break;
    }

    holder.assetClassTextView.setText(item.assetClass.getName());
    holder.setAllocationTextView.setText(item.assetClass.getAllocation().toString());

    // Current Allocation
    Money currentAllocation = item.assetClass.getCurrentAllocation();
    String currentAllocationString = currentAllocation == null ? "" : currentAllocation.toString();
    holder.currentAllocationTextView.setText(currentAllocationString);

    // % diff
    Money diff = item.assetClass.getDiffAsPercentOfSet();
    DecimalFormat df = new DecimalFormat("0.00");
    String diffString = df.format(diff.toDouble());
    holder.allocationDiffTextView.setText(diffString);

    // color red/green if under/over the threshold.
    if (diff.toDouble() >= this.differenceThreshold.toDouble()) {
        holder.allocationDiffTextView.setTextColor(Color.GREEN);
    }
    if (diff.toDouble() <= this.differenceThreshold.multiply(-1).toDouble()) {
        holder.allocationDiffTextView.setTextColor(Color.RED);
    }

    holder.setValueTextView.setText(mFormatter.getValueFormattedInBaseCurrency(item.assetClass.getValue()));
    holder.currentValueTextView
            .setText(mFormatter.getValueFormattedInBaseCurrency(item.assetClass.getCurrentValue()));
    holder.valueDiffTextView
            .setText(mFormatter.getValueFormattedInBaseCurrency(item.assetClass.getDifference()));

    holder.setLevel(item.level, this.context);

    //        if (position == expandedPosition) {
    //            holder.valuetPanel.setVisibility(View.VISIBLE);
    //        } else {
    //            holder.valuetPanel.setVisibility(View.GONE);
    //        }
}