List of usage examples for android.graphics Color rgb
@ColorInt public static int rgb(float red, float green, float blue)
From source file:mah.farmer.ui.ProductInfoActivity.java
/** * APPLayout,?/*w w w .j av a 2 s. c om*/ */ private void initAppBarLayout() { //???? farmerProduct = (FarmerProduct) getIntent().getSerializableExtra("products"); //ID produt_avatar = (ImageView) findViewById(R.id.productinfo_avatar); mFab = findViewById(R.id.flexible_example_fab); danjia = (TextView) findViewById(R.id.product_danjia); desc = (TextView) findViewById(R.id.productinfo_desc); xiaoliang = (TextView) findViewById(R.id.product_xiaoliang); supplier_name = (TextView) findViewById(R.id.supplier_name); supplier_location = (TextView) findViewById(R.id.supplier_location); supplier_avatar = (ImageView) findViewById(R.id.supplier_avatar); addshoppingcart = (LinearLayout) findViewById(R.id.add_shopping_cart); product_leibie = (TextView) findViewById(R.id.product_leibie); //?? danjia.setText("?" + farmerProduct.getMyprice() + "/"); desc.setText(farmerProduct.getDescription()); if (farmerProduct.getSalesNum() == null || farmerProduct.getSalesNum().equals("")) { xiaoliang.setText("???"); } else { xiaoliang.setText("?" + farmerProduct.getSalesNum() + ""); } product_leibie .setText("" + farmerProduct.getTagOne() + " ?" + farmerProduct.getTagTwo()); supplier_location.setText("?" + farmerProduct.getSupplierAddress()); supplier_name.setText(": " + farmerProduct.getSupplier()); //? if (farmerProduct.getAvata_md5() != null && !farmerProduct.getAvata_md5().equals("")) { ImageLoader.getInstance().displayImage(farmerProduct.getAvata_md5(), produt_avatar, ImageLoadOptions.getOptions()); } else { produt_avatar.setImageResource(R.drawable.default_head); } //? getSupplierAvatar(); //?? mFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //?? Uri uri = Uri.parse("tel:" + farmerProduct.getSupplierPhone()); Intent intent = new Intent(Intent.ACTION_DIAL, uri); startActivity(intent); } }); //??? addshoppingcart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //??? if (FarmerConfig.getCachedFarmerNickname(ProductInfoActivity.this) .equals(farmerProduct.getSupplier())) { new SweetAlertDialog(ProductInfoActivity.this, SweetAlertDialog.ERROR_TYPE) .setTitleText("?").setContentText("??") .show(); } else { Intent intent = new Intent(ProductInfoActivity.this, AddShoppingDeliveryActivity.class); intent.putExtra("userTrueName", FarmerConfig.getCachedFarmerPhoTruename(ProductInfoActivity.this)); intent.putExtra("userAddress", FarmerConfig.getCachedFarmerAddress(ProductInfoActivity.this)); intent.putExtra("userPhone", FarmerConfig.getCachedFarmerPhone(ProductInfoActivity.this)); intent.putExtra("product", farmerProduct); startActivity(intent); } } }); //toolbar? Toolbar toolbar = (Toolbar) findViewById(R.id.flexible_example_toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); AppBarLayout appbar = (AppBarLayout) findViewById(R.id.flexible_example_appbar); appbar.addOnOffsetChangedListener(this); /** * */ final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById( R.id.flexible_example_collapsing); collapsingToolbarLayout.setTitle(farmerProduct.getName()); collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.farmer_shop_list_back)); // transperent color = #00000000 collapsingToolbarLayout.setCollapsedTitleTextColor(Color.rgb(232, 247, 239)); }
From source file:com.zhejunzhu.ucviewpager.weight.StreamTabIndicator.java
@Override public void onPageScrolled(int index, float process, int arg2) { LLog.e("indicator onPageScrolled : " + index + " " + process + " " + arg2); TextView leftTab = (TextView) mTabLayout.getChildAt(index); TextView rightTab = (TextView) mTabLayout.getChildAt(index + 1); if (leftTab != null) { leftTab.setTextColor(Color.rgb((int) (11 + 177 * process), 188, 188)); leftTab.setScaleX(1 + (1 - process) / 8); leftTab.setScaleY(1 + (1 - process) / 8); }/*from w w w . j a va2 s . co m*/ if (rightTab != null) { rightTab.setTextColor(Color.rgb((int) (188 - process * 177), 188, 188)); rightTab.setScaleX(1 + process / 8); rightTab.setScaleY(1 + process / 8); } if (mListener != null) { mListener.onPageScrolled(index, process, arg2); } if (process == 0f) { clearTabChang(index); } }
From source file:com.personal.learn_android.EventActivity.java
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap;/*w w w . j a va2 s .c o m*/ IconGenerator generator = new IconGenerator(this); Random random = new Random(); for (Event event : listEvent) { LatLng place = new LatLng(event.getLatitude(), event.getLongitude()); generator.setColor(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255))); Bitmap icon = generator.makeIcon(event.getEventName()); mMap.addMarker(new MarkerOptions().position(place).title(event.getEventName()) .icon(BitmapDescriptorFactory.fromBitmap(icon))); } Event event = listEvent.get(0); LatLng place = new LatLng(event.getLatitude(), event.getLongitude()); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(place, 8.0f)); mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { String eventName = marker.getTitle(); int i = 0; for (Event event : listEvent) { if (event.getEventName().equalsIgnoreCase(eventName)) { mViewPager.setCurrentItem(i); break; } else { i++; } } return true; } }); }
From source file:com.todoroo.astrid.actfm.ActFmLoginActivity.java
protected SpannableString getLinkStringWithCustomInterval(String base, String linkComponent, int start, int endOffset, final OnClickListener listener) { SpannableString link = new SpannableString(String.format("%s %s", //$NON-NLS-1$ base, linkComponent));//w w w.java 2 s .co m ClickableSpan linkSpan = new ClickableSpan() { @Override public void onClick(View widget) { listener.onClick(widget); } @Override public void updateDrawState(TextPaint ds) { ds.setUnderlineText(true); ds.setColor(Color.rgb(68, 68, 68)); } }; link.setSpan(linkSpan, start, link.length() + endOffset, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return link; }
From source file:com.duy.pascal.ui.editor.highlight.CodeHighlighter.java
private void highlightOther(@NonNull Editable allText, @NonNull CharSequence textToHighlight, int start) { //high light number for (Matcher m = NUMBERS.matcher(textToHighlight); m.find();) { allText.setSpan(new ForegroundColorSpan(codeTheme.getNumberColor()), start + m.start(), start + m.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); }//ww w .j a v a 2 s. c om for (Matcher m = KEYWORDS.matcher(textToHighlight); m.find();) { allText.setSpan(new ForegroundColorSpan(codeTheme.getKeywordColor()), start + m.start(), start + m.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } for (Matcher m = BUILTIN_FUNCTIONS.matcher(textToHighlight); m.find();) { allText.setSpan(new ForegroundColorSpan(codeTheme.getKeywordColor()), start + m.start(), start + m.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } for (Matcher m = SYMBOLS.matcher(textToHighlight); m.find();) { allText.setSpan(new ForegroundColorSpan(codeTheme.getOptColor()), start + m.start(), start + m.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } for (Matcher m = RGB_FUNCTION.matcher(textToHighlight); m.find();) { try { int r = Integer.parseInt(m.group(3).trim()); int g = Integer.parseInt(m.group(5).trim()); int b = Integer.parseInt(m.group(7).trim()); int back = Color.rgb(r, g, b); int fore = Color.rgb(255 - r, 255 - g, 255 - b); allText.setSpan(new BackgroundColorSpan(back), start + m.start(1), start + m.end(1), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); allText.setSpan(new ForegroundColorSpan(fore), start + m.start(1), start + m.end(1), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } catch (Exception e) { } } for (Matcher m = ARGB_FUNCTION.matcher(textToHighlight); m.find();) { try { int r = Integer.parseInt(m.group(3).trim()); int g = Integer.parseInt(m.group(5).trim()); int b = Integer.parseInt(m.group(7).trim()); int back = Color.rgb(r, g, b); int fore = Color.rgb(255 - r, 255 - g, 255 - b); allText.setSpan(new BackgroundColorSpan(back), start + m.start(1), start + m.end(1), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); allText.setSpan(new ForegroundColorSpan(fore), start + m.start(1), start + m.end(1), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } catch (Exception e) { } } }
From source file:lollipop.iconics.IconicsDrawable.java
/** * Set the color of the drawable./*from ww w. ja v a 2s .c o m*/ * * @param color The color, usually from android.graphics.Color or 0xFF012345. * @return The current IconExtDrawable for chaining. */ public IconicsDrawable color(@ColorInt int color) { int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); mIconPaint.setColor(Color.rgb(red, green, blue)); setAlpha(Color.alpha(color)); invalidateSelf(); return this; }
From source file:de.frank_durr.ble_v_monitor.HistoryFragment.java
/** * Update the view data according to the data stored by the data model. *///from ww w .ja v a2 s. co m private void updateView() { List<Integer> historyData = null; String label = null; String timeUnitStr = null; switch (historyType) { case minutely: historyData = DataModel.theModel.getMinutelyHistory(); label = getResources().getString(R.string.minutely_history); timeUnitStr = "min"; break; case hourly: historyData = DataModel.theModel.getHourlyHistory(); label = getResources().getString(R.string.hourly_history); timeUnitStr = "h"; break; case daily: historyData = DataModel.theModel.getDailyHistory(); label = getResources().getString(R.string.daily_history); timeUnitStr = "d"; break; } if (historyData == null) { // No history data in data model return; } ArrayList<Entry> values = new ArrayList<>(); int x = 0; for (Integer value : historyData) { float v = (float) (value.floatValue() / 1000.0); Entry entry = new Entry(v, x++); values.add(entry); } LineDataSet dataSet = new LineDataSet(values, label); dataSet.setLineWidth(2.5f); dataSet.setCircleSize(4.5f); dataSet.setColor(Color.rgb(255, 0, 0)); dataSet.setCircleColor(Color.rgb(255, 0, 0)); dataSet.setHighLightColor(Color.rgb(255, 0, 0)); dataSet.setAxisDependency(YAxis.AxisDependency.LEFT); dataSet.setDrawValues(false); //dataSet.setValueTextSize(10f); ArrayList<LineDataSet> dataSets = new ArrayList<>(); dataSets.add(dataSet); int xValueCnt = historyData.size(); ArrayList<String> xVals = new ArrayList<>(); for (int i = 0; i < xValueCnt; i++) { xVals.add(Integer.toString(-xValueCnt + i + 1) + timeUnitStr); } LineData data = new LineData(xVals, dataSets); chart.setDescription(""); // Refresh chart chart.setData(data); chart.notifyDataSetChanged(); chart.invalidate(); }
From source file:com.spoiledmilk.cykelsuperstier.navigation.SMRouteNavigationActivity.java
public void onPatchContainerClick(View v) { v.setBackgroundColor(isPathSelected ? Color.rgb(255, 255, 255) : Color.rgb(236, 104, 0)); ((ImageView) findViewById(R.id.imgCheckbox1)) .setImageResource(isPathSelected ? R.drawable.check_field : R.drawable.check_in_orange); ((ImageView) findViewById(R.id.imgPath)) .setImageResource(isPathSelected ? R.drawable.bike_icon_gray : R.drawable.bike_icon_white); textPath.setTextColor(isPathSelected ? getResources().getColor(R.color.DarkGrey) : Color.WHITE); if (isPathSelected) getMapFragment().overlaysManager.removeBikeRoutes(); else//ww w . j a v a 2s .c om getMapFragment().overlaysManager.drawBikeRoutes(this); isPathSelected = !isPathSelected; }
From source file:com.progym.custom.fragments.CalloriesProgressMonthlyLineFragment.java
public void setLineData3(final Date date, final boolean isLeftIn) { final ProgressDialog ringProgressDialog = ProgressDialog.show(getActivity(), getResources().getString(R.string.please_wait), getResources().getString(R.string.populating_data), true);//from w w w.j a v a2 s .c om ringProgressDialog.setCancelable(true); new Thread(new Runnable() { @Override public void run() { try { int yMaxAxisValue = 0; try { getActivity().runOnUiThread(new Runnable() { @Override public void run() { rlRootGraphLayout.removeView(mChartView); } }); } catch (Exception edsx) { edsx.printStackTrace(); } date.setDate(1); DATE = date; // Get amount of days in a month to find out average int daysInMonth = Utils.getDaysInMonth(date.getMonth(), Integer.valueOf(Utils.formatDate(date, DataBaseUtils.DATE_PATTERN_YYYY))); // set First day of the month as first month int[] x = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; // Creating an XYSeries for Consumed water XYSeries callories = new XYSeries("Callories"); List<Ingridient> list; Date dt = date; // ** // Adding data to Income and Expense Series for (int i = 1; i <= daysInMonth; i++) { // get all water records consumed per this month list = DataBaseUtils.getAllFoodConsumedInMonth( Utils.formatDate(dt, DataBaseUtils.DATE_PATTERN_YYYY_MM_DD)); // init "average" data int totalCallories = 0; for (Ingridient ingridient : list) { totalCallories += ingridient.kkal; } callories.add(i, totalCallories); dt = DateUtils.addDays(dt, 1); yMaxAxisValue = Math.max(yMaxAxisValue, totalCallories); } // Creating a dataset to hold each series final XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); // Adding Income Series to the dataset dataset.addSeries(callories); // Creating XYSeriesRenderer to customize protein series XYSeriesRenderer calloriesRenderer = new XYSeriesRenderer(); calloriesRenderer.setColor(Color.rgb(220, 255, 110)); calloriesRenderer.setFillPoints(true); calloriesRenderer.setLineWidth(3); calloriesRenderer.setDisplayChartValues(true); // Creating a XYMultipleSeriesRenderer to customize the whole chart final XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer(); // multiRenderer.setXLabels(0); for (int i = 0; i < x.length; i++) { multiRenderer.addXTextLabel(i, String.valueOf(x[i])); } // Adding incomeRenderer and expenseRenderer to multipleRenderer // Note: The order of adding dataseries to dataset and renderers to multipleRenderer // should be same multiRenderer.setChartTitle(String.format("Callories statistic")); multiRenderer.setXTitle(Utils.getSpecificDateValue(DATE, "MMM") + " of " + Utils.formatDate(DATE, DataBaseUtils.DATE_PATTERN_YYYY)); multiRenderer.setYTitle(getActivity().getResources().getString(R.string.callories_consumption)); multiRenderer.setAxesColor(Color.WHITE); multiRenderer.setShowLegend(true); multiRenderer.addSeriesRenderer(calloriesRenderer); multiRenderer.setShowGrid(true); multiRenderer.setClickEnabled(true); multiRenderer.setXLabelsAngle(20); multiRenderer.setYAxisMax(yMaxAxisValue + 200); multiRenderer.setXLabelsColor(Color.WHITE); multiRenderer.setZoomButtonsVisible(false); // configure visible area multiRenderer.setXAxisMax(31); multiRenderer.setXAxisMin(1); multiRenderer.setAxisTitleTextSize(15); multiRenderer.setZoomEnabled(true); getActivity().runOnUiThread(new Runnable() { @Override public void run() { mChartView = ChartFactory.getLineChartView(getActivity(), dataset, multiRenderer); rlRootGraphLayout.addView(mChartView, 0); if (isLeftIn) { rightIn.setDuration(1000); mChartView.startAnimation(rightIn); } else { leftIn.setDuration(1000); mChartView.startAnimation(leftIn); } } }); } catch (Exception e) { e.printStackTrace(); } ringProgressDialog.dismiss(); } }).start(); }
From source file:com.jest.phone.PhoneActivity.java
/** Called when the activity is first created. */ @Override//w w w . j ava 2 s . c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_phone); // ////// DATABASE //////////// MDM = new MotionDatabaseManager(PhoneActivity.this); // //////////////////////////// playPause = (Button) findViewById(R.id.pause); resetButton = (Button) findViewById(R.id.resetButton); resetButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { minXY.x = xHistorySeries.getX(0).floatValue(); maxXY.x = xHistorySeries.getX(xHistorySeries.size() - 1).floatValue(); sensorHistoryPlot.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.FIXED); // pre 0.5.1 users should use postRedraw() instead. sensorHistoryPlot.redraw(); } }); saveDataButton = (Button) findViewById(R.id.save_data_unused); saveDataButton.setOnClickListener(new OnClickListener() { // The purpose of DEBUG is to grab and display data for debugging // and data analysis @Override public void onClick(View v) { // TEST: current boundaries of what we're looking at Toast.makeText(getApplicationContext(), "Min: " + minXY.x + " | Max: " + maxXY.x, Toast.LENGTH_LONG) .show(); SaveDataDialog sdd = new SaveDataDialog(); FragmentManager fm = getSupportFragmentManager(); sdd.show(fm, "SaveDataDialog"); } }); analyzeDataButton = (Button) findViewById(R.id.analyze_data); analyzeDataButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub } }); viewDataButton = (Button) findViewById(R.id.view_data); viewDataButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(PhoneActivity.this, ViewMotionDataActivity.class); startActivity(i); } }); trainMotionSet = (Button) findViewById(R.id.train_motion_set); trainMotionSet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ChooseSetDialog csd = new ChooseSetDialog(); FragmentManager fm = getSupportFragmentManager(); csd.show(fm, "ChooseSetDialog"); } }); xSeries = new SimpleXYSeries("X"); ySeries = new SimpleXYSeries("Y"); zSeries = new SimpleXYSeries("Z"); // setup the APR History plot: sensorHistoryPlot = (XYPlot) findViewById(R.id.sensorHistoryPlot); sensorHistoryPlot.setOnTouchListener(this); xHistorySeries = new SimpleXYSeries("aX"); xHistorySeries.useImplicitXVals(); yHistorySeries = new SimpleXYSeries("aY"); yHistorySeries.useImplicitXVals(); zHistorySeries = new SimpleXYSeries("aZ"); zHistorySeries.useImplicitXVals(); sensorHistoryPlot.setRangeBoundaries(-180, 359, BoundaryMode.FIXED); sensorHistoryPlot.setDomainBoundaries(0, HISTORY_SIZE, BoundaryMode.FIXED); sensorHistoryPlot.addSeries(xHistorySeries, new LineAndPointFormatter(Color.rgb(100, 100, 200), null, null, null)); sensorHistoryPlot.addSeries(yHistorySeries, new LineAndPointFormatter(Color.rgb(100, 200, 100), null, null, null)); sensorHistoryPlot.addSeries(zHistorySeries, new LineAndPointFormatter(Color.rgb(200, 100, 100), null, null, null)); sensorHistoryPlot.setDomainStepMode(XYStepMode.INCREMENT_BY_VAL); sensorHistoryPlot.setDomainStepValue(HISTORY_SIZE / 10); sensorHistoryPlot.setTicksPerRangeLabel(3); sensorHistoryPlot.setDomainLabel("Sample Index"); sensorHistoryPlot.getDomainLabelWidget().pack(); sensorHistoryPlot.setRangeLabel("Acceleration (M/s2)"); sensorHistoryPlot.getRangeLabelWidget().pack(); sensorHistoryPlot.setRangeValueFormat(new DecimalFormat("#")); sensorHistoryPlot.setDomainValueFormat(new DecimalFormat("#")); int maxValue = 360; // TODO - make this not be empirical... Based on // device's accelerometer range. int minValue = maxValue * -1; sensorHistoryPlot.setRangeBoundaries(minValue, maxValue, BoundaryMode.FIXED); sensorHistoryPlot.calculateMinMaxVals(); minXY = new PointF(sensorHistoryPlot.getCalculatedMinX().floatValue(), sensorHistoryPlot.getCalculatedMinY().floatValue()); maxXY = new PointF(sensorHistoryPlot.getCalculatedMaxX().floatValue(), sensorHistoryPlot.getCalculatedMaxY().floatValue()); redrawer = new Redrawer(Arrays.asList(new Plot[] { sensorHistoryPlot }), 100, false); // , // aprLevelsPlot playPause.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { play = !play; } }); // //////// NETWORKING // ////////////////////////////////////////////// // hostText = (EditText) findViewById(R.id.host_text); portText = (EditText) findViewById(R.id.port_text); connectButton = (Button) findViewById(R.id.connect_button); connectButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // connectButton.setClickable(false); // HOST_NAME = hostText.getText().toString(); PORT_NAME = portText.getText().toString(); if (PORT_NAME == null) { Toast.makeText(PhoneActivity.this, "Host and/or port not set!", Toast.LENGTH_LONG).show(); return; } PORT = Integer.parseInt(PORT_NAME); new initNetworkTask().execute(); } }); connectButton.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { hostText.setText("192.168.43.249"); portText.setText("4444"); return false; } }); }