List of usage examples for android.graphics Color parseColor
@ColorInt public static int parseColor(@Size(min = 1) String colorString)
From source file:com.esri.android.ecologicalmarineunitexplorer.watercolumn.WaterColumnFragment.java
private StateListDrawable buildStateList(int emuName) { StateListDrawable stateListDrawable = new StateListDrawable(); GradientDrawable defaultShape = new GradientDrawable(); int color = Color.parseColor(EmuHelper.getColorForEMUCluster(getContext(), emuName)); defaultShape.setColor(color);// ww w. j a v a 2 s .c o m GradientDrawable selectedPressShape = new GradientDrawable(); selectedPressShape.setColor(color); selectedPressShape.setStroke(5, Color.parseColor("#f4f442")); stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, selectedPressShape); stateListDrawable.addState(new int[] { android.R.attr.state_selected }, selectedPressShape); stateListDrawable.addState(new int[] { android.R.attr.state_enabled }, defaultShape); return stateListDrawable; }
From source file:android.support.v7.graphics.drawable.VectorDrawableCompat.java
private void inflateInternal(Resources res, XmlPullParser parser, AttributeSet attrs) { // TODO: Add more details in the parsing to reconstruct the // VectorDrawable data structure. int eventType; try {/*from w w w . j av a2s . c o m*/ eventType = parser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_DOCUMENT) { if (DBG_VECTOR_DRAWABLE) { Log.v(LOG_TAG, "Start document"); } } else if (eventType == XmlPullParser.START_TAG) { if (DBG_VECTOR_DRAWABLE) { Log.v(LOG_TAG, "Parsing Attributes for [" + parser.getName() + "]"); } Map<String, String> attributes = getAttributes(parser); if (attributes != null) { final String tagName = parser.getName(); if (SHAPE_PATH.equals(tagName)) { String pathString = attributes.get("android:pathData"); if (DBG_VECTOR_DRAWABLE) { Log.v(LOG_TAG, "pathData is " + pathString); } Path path = PathParser.createPathFromPathData(pathString); String colorString = attributes.get("android:fillColor"); mPaths.add(new Pair(path, Color.parseColor(colorString))); } } } else if (eventType == XmlPullParser.END_TAG) { if (DBG_VECTOR_DRAWABLE) { Log.v(LOG_TAG, "End tag " + parser.getName()); } } else if (eventType == XmlPullParser.TEXT) { if (DBG_VECTOR_DRAWABLE) { Log.v(LOG_TAG, "Text " + parser.getText()); } } eventType = parser.next(); } } catch (XmlPullParserException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if (DBG_VECTOR_DRAWABLE) { Log.v(LOG_TAG, "End document"); } }
From source file:com.example.grayapps.contextaware.BarGraphFragment.java
/** * * Chart 1// ww w . j a v a 2s .c o m * */ public void produceOne(ChartView chart, Runnable action) { BarChartView barChart = (BarChartView) chart; barChart.setOnEntryClickListener(new OnEntryClickListener() { @Override public void onClick(int setIndex, int entryIndex, Rect rect) { System.out.println("OnClick " + rect.left); } }); // Tooltip tooltip = new Tooltip(getActivity(), R.layout.barchart_one_tooltip); //if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // tooltip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1)); // tooltip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0)); // } // barChart.setTooltips(tooltip); //mValuesOne[0][1] = Float.valueOf(String.valueOf(10 * Math.random())); //mValuesOne[0][2] = Float.valueOf(String.valueOf(10 * Math.random())); BarSet barSet = new BarSet(mLabelsOne, mValuesOne[0]); barSet.setColor(Color.parseColor(mStressColor)); barChart.addData(barSet); barChart.setBarSpacing(Tools.fromDpToPx(35)); barSet.getEntry(0).setColor(Color.parseColor(getResources().getString(R.color.colorNeutral))); barSet.getEntry(1).setColor(Color.parseColor(getResources().getString(R.color.colorStress))); barSet.getEntry(2).setColor(Color.parseColor(getResources().getString(R.color.colorNoise))); barSet.getEntry(3).setColor(Color.parseColor(getResources().getString(R.color.colorAnxious))); Paint gridColor = new Paint(); gridColor.setColor(Color.parseColor(getResources().getString(R.color.textAccent))); barChart.setBorderSpacing(5).setAxisBorderValues(0, 100, 20).setYAxis(true) .setXLabels(XController.LabelPosition.OUTSIDE).setYLabels(YController.LabelPosition.OUTSIDE) .setGrid(ChartView.GridType.HORIZONTAL, 10, 1, gridColor) .setLabelsColor(Color.parseColor(getResources().getString(R.color.textPrimary))).setFontSize(24) .setAxisColor(Color.parseColor(getResources().getString(R.color.textAccent))); int[] order = { 3, 1, 0, 2 };//, 0, 4}; final Runnable auxAction = action; Runnable chartOneAction = new Runnable() { @Override public void run() { //showTooltipOne(); auxAction.run(); } }; barChart.show(new Animation().setOverlap(.5f, order).setEndAction(chartOneAction)) //.show() ; }
From source file:com.moki.touch.fragments.views.WebContent.java
@Override public View getView() { View emptyView = super.getView(); if (emptyView != null) { return emptyView; }// w ww . j a v a 2 s . c o m LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); rootView = (LinearLayout) inflater.inflate(R.layout.webcontentlayout, null); webView = (WebView) rootView.findViewById(R.id.webcontentview); configureWebView(context); browserBar = (RelativeLayout) rootView.findViewById(R.id.barlayout); // this is added so no swipe actions are detected on the browser bar browserBar.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); progressBar = (ProgressBar) rootView.findViewById(R.id.web_progress_bar); progressBar.setVisibility(View.GONE); rootView.findViewById(R.id.barlayout).setBackgroundColor(Color.parseColor(styleColor)); configureNavigationBar(); if (!isHomeMode) { // this listener is being added to ensure that touch events bubble up to the correct receivers. disableWebView(); } if (!showBrowserBar) { browserBar.setVisibility(View.GONE); } boolean listenForLogo = setLogo(); if (listenForLogo) { registerForLogoDownload(); } return rootView; }
From source file:com.odoo.addons.customers.CustomerDetails.java
private void setupActionBar() { if (extras == null) { setMode(mEditMode);//w ww. j a v a 2s. c om userImage.setColorFilter(Color.parseColor("#ffffff")); mForm.setEditable(mEditMode); mForm.initForm(null); } else { int rowId = extras.getInt(OColumn.ROW_ID); record = resPartner.browse(rowId); record.put("full_address", resPartner.getAddress(record)); checkControls(); setMode(mEditMode); mForm.setEditable(mEditMode); mForm.initForm(record); mTitleView.setText(record.getString("name")); setCustomerImage(); if (record.getInt("id") != 0 && record.getString("large_image").equals("false")) { BigImageLoader bigImageLoader = new BigImageLoader(); bigImageLoader.execute(record.getInt("id")); } } }
From source file:com.github.michaelins.lightstatusbar.LightStatusBar.java
private void setStatusBarBackgroundColor(final String colorPref) { if (colorPref != null && !colorPref.isEmpty()) { final Window window = cordova.getActivity().getWindow(); // Method and constants not available on all SDKs but we want to // be able to compile this code with any SDK window.clearFlags(0x04000000); // SDK 19: // WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(0x80000000); // SDK 21: // WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); try {//from w ww .ja v a 2s.co m // Using reflection makes sure any 5.0+ device will work // without having to compile with SDK level 21 window.getClass().getDeclaredMethod("setStatusBarColor", int.class).invoke(window, Color.parseColor(colorPref)); } catch (IllegalArgumentException ignore) { LOG.e(TAG, "Invalid hexString argument, use f.i. '#999999'"); } catch (Exception ignore) { // this should not happen, only in case Android removes this // method in a version > 21 LOG.w(TAG, "Method window.setStatusBarColor not found for SDK level " + Build.VERSION.SDK_INT); } } }
From source file:com.amaze.filemanager.utils.Futils.java
public MaterialDialog showBasicDialog(final Activity m, String fabskin, int theme1, String[] texts) { MaterialDialog.Builder a = new MaterialDialog.Builder(m); a.content(texts[0]);/*from w w w .java2s .co m*/ a.widgetColor(Color.parseColor(fabskin)); if (theme1 == 1) a.theme(Theme.DARK); a.title(texts[1]); a.positiveText(texts[2]); a.positiveColor(Color.parseColor(fabskin)); a.negativeText(texts[3]); a.negativeColor(Color.parseColor(fabskin)); if (texts[4] != (null)) { a.neutralText(texts[4]); a.neutralColor(Color.parseColor(fabskin)); } MaterialDialog dialog = a.build(); return dialog; }
From source file:com.bonsai.btcreceive.TransactionsFragment.java
private void addTransactionRow(String hash, TableLayout table, String datestr, String timestr, String confstr, String btcstr, String btcbalstr, String fiatstr, String fiatbalstr, boolean tintrow) { TableRow row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.transaction_table_row, table, false);/* ww w .j ava 2 s. c om*/ row.setTag(hash); row.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { // Dispatch to the transaction viewer. String hash = (String) view.getTag(); Intent intent = new Intent(getActivity(), ViewTransactionActivity.class); intent.putExtra("hash", hash); startActivity(intent); } }); { TextView tv = (TextView) row.findViewById(R.id.row_date); tv.setText(datestr); } { TextView tv = (TextView) row.findViewById(R.id.row_time); tv.setText(timestr); } { TextView tv = (TextView) row.findViewById(R.id.row_confidence); tv.setText(confstr); } { TextView tv = (TextView) row.findViewById(R.id.row_btc_balance); tv.setText(btcbalstr); } { TextView tv = (TextView) row.findViewById(R.id.row_btc); tv.setText(btcstr); } { TextView tv = (TextView) row.findViewById(R.id.row_fiat_balance); tv.setText(fiatbalstr); } { TextView tv = (TextView) row.findViewById(R.id.row_fiat); tv.setText(fiatstr); } if (tintrow) row.setBackgroundColor(Color.parseColor("#ccffcc")); table.addView(row); }
From source file:com.freshdigitable.udonroad.UserInfoView.java
@ColorInt private static int parseColor(String colorString) { return Color.parseColor("#" + colorString); }
From source file:com.filemanager.free.adapters.DrawerAdapter.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { if (values.get(position).isSection()) { ImageView view = new ImageView(context); if (m.theme1 == 0) view.setImageResource(R.color.divider); else//from w w w .j a v a 2 s.c o m view.setImageResource(R.color.divider_dark); view.setClickable(false); view.setFocusable(false); if (m.theme1 == 0) view.setBackgroundColor(Color.WHITE); else view.setBackgroundResource(R.color.background_material_dark); view.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, m.dpToPx(17))); view.setPadding(0, m.dpToPx(8), 0, m.dpToPx(8)); return view; } else { View view = inflater.inflate(R.layout.drawerrow, parent, false); final TextView txtTitle = (TextView) view.findViewById(R.id.firstline); final ImageView imageView = (ImageView) view.findViewById(R.id.icon); if (m.theme1 == 0) { view.setBackgroundResource(R.drawable.safr_ripple_white); } else { view.setBackgroundResource(R.drawable.safr_ripple_black); } view.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { m.selectItem(position); } // TODO: Implement this method }); view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (!getItem(position).isSection()) // not to remove the first bookmark (storage) and permanent bookmarks if (position > m.storage_count && position < values.size() - 7) { EntryItem item = (EntryItem) getItem(position); String path = (item).getPath(); if (DataUtils.containsBooks(new String[] { item.getTitle(), path }) != -1) { m.renameBookmark((item).getTitle(), path); } else if (path.startsWith("smb:/")) { m.showSMBDialog(item.getTitle(), path, true); } } else if (position < m.storage_count) { String path = ((EntryItem) getItem(position)).getPath(); if (!path.equals("/")) new Futils().showProps(RootHelper.generateBaseFile(new File(path), true), m, m.theme1); } // return true to denote no further processing return true; } }); txtTitle.setText(((EntryItem) (values.get(position))).getTitle()); imageView.setImageDrawable(getDrawable(position)); imageView.clearColorFilter(); if (myChecked.get(position)) { if (m.theme1 == 0) view.setBackgroundColor(Color.parseColor("#ffeeeeee")); else view.setBackgroundColor(Color.parseColor("#ff424242")); imageView.setColorFilter(fabskin); txtTitle.setTextColor(Color.parseColor(m.fabskin)); } else { if (m.theme1 == 0) { imageView.setColorFilter(Color.parseColor("#666666")); txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.black)); } else { imageView.setColorFilter(Color.WHITE); txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.white)); } } return view; } }