List of usage examples for android.graphics Color argb
@ColorInt public static int argb(float alpha, float red, float green, float blue)
From source file:com.astuetz.viewpager.extensions.IndicatorLineView.java
protected synchronized void onDraw(Canvas canvas) { super.onDraw(canvas); final Paint linePaint = mLinePaint; final int color = Color.argb(mAlpha, Color.red(mLineColor), Color.green(mLineColor), Color.blue(mLineColor)); linePaint.setColor(color);/*from w ww. j ava 2s . c om*/ // draw the line canvas.drawRect(mLineLeft, 0, mLineLeft + mLineWidth, getMeasuredHeight(), linePaint); }
From source file:dev.vision.shopping.center.Splash.java
void Init() { overrideFonts(this, findViewById(android.R.id.content)); final ImageView im = null;//(ImageView) findViewById(R.id.ImageView01); td = (TransitionDrawable) im.getDrawable(); td.setCrossFadeEnabled(true);//www . j a v a 2s.co m td.startTransition(3000); final Random rnd = new Random(); new Handler().postDelayed(new Runnable() { @SuppressLint("NewApi") @Override public void run() { int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)); td = new TransitionDrawable(new Drawable[] { td.getDrawable(1), new ColorDrawable(color) }); im.setImageDrawable(td); td.setCrossFadeEnabled(true); td.startTransition(3000); new Handler().postDelayed(this, 3000); } }, 3000); }
From source file:arun.com.chromer.browsing.article.util.ArticleUtil.java
/** * Changes the text selection handle colors. *//*from w ww. j a v a 2 s.com*/ public static void changeTextSelectionHandleColors(TextView textView, int color) { textView.setHighlightColor(Color.argb(40, Color.red(color), Color.green(color), Color.blue(color))); try { Field editorField = TextView.class.getDeclaredField("mEditor"); if (!editorField.isAccessible()) { editorField.setAccessible(true); } Object editor = editorField.get(textView); Class<?> editorClass = editor.getClass(); String[] handleNames = { "mSelectHandleLeft", "mSelectHandleRight", "mSelectHandleCenter" }; String[] resNames = { "mTextSelectHandleLeftRes", "mTextSelectHandleRightRes", "mTextSelectHandleRes" }; for (int i = 0; i < handleNames.length; i++) { Field handleField = editorClass.getDeclaredField(handleNames[i]); if (!handleField.isAccessible()) { handleField.setAccessible(true); } Drawable handleDrawable = (Drawable) handleField.get(editor); if (handleDrawable == null) { Field resField = TextView.class.getDeclaredField(resNames[i]); if (!resField.isAccessible()) { resField.setAccessible(true); } int resId = resField.getInt(textView); handleDrawable = ContextCompat.getDrawable(textView.getContext(), resId); } if (handleDrawable != null) { Drawable drawable = handleDrawable.mutate(); drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN); handleField.set(editor, drawable); } } } catch (Exception ignored) { } }
From source file:com.ibm.iot.android.iotstarter.utils.MessageConductor.java
/** * Steer incoming MQTT messages to the proper activities based on their content. * * @param payload The log of the MQTT message. * @param topic The topic the MQTT message was received on. * @throws JSONException If the message contains invalid JSON. *//*w w w .j a v a2 s . c om*/ public void steerMessage(String payload, String topic) throws JSONException { Log.d(TAG, ".steerMessage() entered"); JSONObject top = new JSONObject(payload); JSONObject d = top.getJSONObject("d"); if (topic.contains(Constants.COLOR_EVENT)) { Log.d(TAG, "Color Event"); int r = d.getInt("r"); int g = d.getInt("g"); int b = d.getInt("b"); // alpha value received is 0.0 < a < 1.0 but Color.argb expects 0 < a < 255 int alpha = (int) (d.getDouble("alpha") * 255.0); if ((r > 255 || r < 0) || (g > 255 || g < 0) || (b > 255 || b < 0) || (alpha > 255 || alpha < 0)) { return; } app.setColor(Color.argb(alpha, r, g, b)); Intent actionIntent = new Intent(Constants.APP_ID + Constants.INTENT_IOT); actionIntent.putExtra(Constants.INTENT_DATA, Constants.COLOR_EVENT); context.sendBroadcast(actionIntent); } else if (topic.contains(Constants.FRE_EVENT)) { JSONObject topp = new JSONObject(payload); JSONObject dd = topp.getJSONObject("d"); int frequency = dd.getInt("f"); Log.d("MMM", "" + frequency); app.setFfe(frequency); } else if (topic.contains(Constants.LIGHT_EVENT)) { app.handleLightMessage(); } else if (topic.contains(Constants.TEXT_EVENT)) { int unreadCount = app.getUnreadCount(); String messageText = d.getString("text"); app.setUnreadCount(++unreadCount); // Log message with the following format: // [yyyy-mm-dd hh:mm:ss.S] Received text: // <message text> Date date = new Date(); String logMessage = "[" + new Timestamp(date.getTime()) + "] Received Text:\n"; app.getMessageLog().add(logMessage + messageText); // Send intent to LOG fragment to mark list data invalidated String runningActivity = app.getCurrentRunningActivity(); //if (runningActivity != null && runningActivity.equals(LogPagerFragment.class.getName())) { Intent actionIntent = new Intent(Constants.APP_ID + Constants.INTENT_LOG); actionIntent.putExtra(Constants.INTENT_DATA, Constants.TEXT_EVENT); context.sendBroadcast(actionIntent); //} // Send intent to current active fragment / activity to update Unread message count // Skip sending intent if active tab is LOG // TODO: 'current activity' code needs fixing. Intent unreadIntent; if (runningActivity.equals(LogPagerFragment.class.getName())) { unreadIntent = new Intent(Constants.APP_ID + Constants.INTENT_LOG); } else if (runningActivity.equals(LoginPagerFragment.class.getName())) { unreadIntent = new Intent(Constants.APP_ID + Constants.INTENT_LOGIN); } else if (runningActivity.equals(IoTPagerFragment.class.getName())) { unreadIntent = new Intent(Constants.APP_ID + Constants.INTENT_IOT); } else if (runningActivity.equals(ProfilesActivity.class.getName())) { unreadIntent = new Intent(Constants.APP_ID + Constants.INTENT_PROFILES); } else { return; } if (messageText != null) { unreadIntent.putExtra(Constants.INTENT_DATA, Constants.UNREAD_EVENT); context.sendBroadcast(unreadIntent); } } else if (topic.contains(Constants.ALERT_EVENT)) { // save payload in an arrayList int unreadCount = app.getUnreadCount(); String messageText = d.getString("text"); app.setUnreadCount(++unreadCount); // Log message with the following format: // [yyyy-mm-dd hh:mm:ss.S] Received alert: // <message text> Date date = new Date(); String logMessage = "[" + new Timestamp(date.getTime()) + "] Received Alert:\n"; app.getMessageLog().add(logMessage + messageText); String runningActivity = app.getCurrentRunningActivity(); if (runningActivity != null) { //if (runningActivity.equals(LogPagerFragment.class.getName())) { Intent actionIntent = new Intent(Constants.APP_ID + Constants.INTENT_LOG); actionIntent.putExtra(Constants.INTENT_DATA, Constants.TEXT_EVENT); context.sendBroadcast(actionIntent); //} // Send alert intent with message payload to current active activity / fragment. // TODO: update for current activity changes. Intent alertIntent; if (runningActivity.equals(LogPagerFragment.class.getName())) { alertIntent = new Intent(Constants.APP_ID + Constants.INTENT_LOG); } else if (runningActivity.equals(LoginPagerFragment.class.getName())) { alertIntent = new Intent(Constants.APP_ID + Constants.INTENT_LOGIN); } else if (runningActivity.equals(IoTPagerFragment.class.getName())) { alertIntent = new Intent(Constants.APP_ID + Constants.INTENT_IOT); } else if (runningActivity.equals(ProfilesActivity.class.getName())) { alertIntent = new Intent(Constants.APP_ID + Constants.INTENT_PROFILES); } else { return; } if (messageText != null) { alertIntent.putExtra(Constants.INTENT_DATA, Constants.ALERT_EVENT); alertIntent.putExtra(Constants.INTENT_DATA_MESSAGE, d.getString("text")); context.sendBroadcast(alertIntent); } } } }
From source file:cn.edu.nuc.seeworld.YOUJIActivity.java
private void createViewPagerFragments() { mViewPagerFragments = new ArrayList<>(); int startColor = getResources().getColor(R.color.emerald); int startR = Color.red(startColor); int startG = Color.green(startColor); int startB = Color.blue(startColor); int endColor = getResources().getColor(R.color.wisteria); int endR = Color.red(endColor); int endG = Color.green(endColor); int endB = Color.blue(endColor); ValueInterpolator interpolatorR = new ValueInterpolator(0, NUMBER_OF_FRAGMENTS - 1, endR, startR); ValueInterpolator interpolatorG = new ValueInterpolator(0, NUMBER_OF_FRAGMENTS - 1, endG, startG); ValueInterpolator interpolatorB = new ValueInterpolator(0, NUMBER_OF_FRAGMENTS - 1, endB, startB); for (int i = 0; i < NUMBER_OF_FRAGMENTS; ++i) { mViewPagerFragments.add(ColorFragment.newInstance(Color.argb(255, (int) interpolatorR.map(i), (int) interpolatorG.map(i), (int) interpolatorB.map(i)))); }/* w ww . ja v a 2 s .c o m*/ }
From source file:com.grarak.kerneladiutor.views.XYGraph.java
public XYGraph(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mPaintLine = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintEdge = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintGraph = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintGraphStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPathGraph = new Path(); mPaintEdge.setStyle(Paint.Style.STROKE); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.XYGraph, defStyleAttr, 0); int accentColor = ContextCompat.getColor(context, R.color.colorAccent); mPaintLine.setColor(a.getColor(R.styleable.XYGraph_linecolor, accentColor)); mPaintEdge.setColor(a.getColor(R.styleable.XYGraph_edgecolor, accentColor)); mPaintEdge.setStrokeWidth(a.getDimension(R.styleable.XYGraph_edgestrokewidth, getResources().getDimension(R.dimen.xygraph_edge_stroke_width))); int graphColor = a.getColor(R.styleable.XYGraph_graphcolor, accentColor); mPaintGraphStroke.setColor(graphColor); mPaintGraphStroke.setStyle(Paint.Style.STROKE); mPaintGraphStroke.setStrokeWidth(a.getDimension(R.styleable.XYGraph_graphstrokewidth, getResources().getDimension(R.dimen.xygraph_graph_stroke_width))); graphColor = Color.argb(120, Color.red(graphColor), Color.green(graphColor), Color.blue(graphColor)); mPaintGraph.setColor(graphColor);/*from w w w . j av a 2 s . c o m*/ mPaintGraph.setStyle(Paint.Style.FILL); mPathGraph.setFillType(Path.FillType.EVEN_ODD); mEdgeVisible = a.getBoolean(R.styleable.XYGraph_edgevisibile, true); a.recycle(); }
From source file:com.example.mymodule.foldingsample.sample.FoldingListActivity.java
@SuppressLint("NewApi") public View createFoldingView() { final FoldingItemViewGroup itemGroup = new FoldingItemViewGroup(mFoldingContainer.getContext()); final FoldingLayout foldingLayout = (FoldingLayout) View.inflate(getApplicationContext(), R.layout.fragment_folding, null); foldingLayout.setBackgroundColor(Color.argb(255, 0, 0, 255)); foldingLayout.setNumberOfFolds(2);/*from w w w. j a va 2s . c om*/ foldingLayout.setAnchorFactor(0); foldingLayout.setOrientation(FoldingLayout.Orientation.VERTICAL); itemGroup.addView(foldingLayout); //mFoldingContainer.addView(itemGroup, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,itemHeight)); return itemGroup; }
From source file:com.sakisds.icymonitor.fragments.graph.GraphFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mRootView = inflater.inflate(R.layout.fragment_graph, container, false); mSettings = getActivity().getSharedPreferences(MainViewActivity.SHAREDPREFS_FILE, 0); if (savedInstanceState != null) { onRestoreInstanceState(savedInstanceState); } else {/*w w w .jav a 2s . co m*/ mRenderer = new XYMultipleSeriesRenderer(); mDataset = new XYMultipleSeriesDataset(); mRenderer.setXTitle(""); mRenderer.setYTitle(""); mRenderer.setXAxisMin(-5); mRenderer.setXAxisMax(80); mRenderer.setMargins(new int[] { 0, 25, 0, 0 }); mRenderer.setApplyBackgroundColor(true); mRenderer.setMarginsColor(Color.argb(0x00, 0x01, 0x01, 0x01)); mRenderer.setBackgroundColor(Color.TRANSPARENT); mRenderer.setShowGridX(mSettings.getBoolean(getString(R.string.key_grid_x), false)); mRenderer.setShowGridY(mSettings.getBoolean(getString(R.string.key_grid_y), false)); mRenderer.setYLabels(5); mRenderer.setYLabelsAlign(Paint.Align.CENTER); mRenderer.setYLabelsPadding(15.0f); mRenderer.setYLabelsColor(0, getResources().getColor(android.R.color.secondary_text_light)); mRenderer.setGridColor(getResources().getColor(android.R.color.darker_gray)); mRenderer.setShowLegend(false); mRenderer.setZoomEnabled(false, false); mRenderer.setPanEnabled(false, false); mLineWidth = Float.valueOf(mSettings.getString(getString(R.string.key_line_width), "2")); } return mRootView; }
From source file:com.koushikdutta.superuser.helper.Theme.java
public static void handleTheme(Activity context, String theme, int textToolbarDefault, DrawerLayout drawer, AppBarLayout appBar, Toolbar toolbar, TabLayout tabLayout) { if (!theme.equals(PREF_BLACK_THEME)) { ATH.setStatusbarColor(context, context.getResources().getInteger(R.integer.statusbar_tint)); if (drawer != null) drawer.setStatusBarBackgroundColor(ThemeStore.statusBarColor(context)); else/*from w w w. j ava 2 s . c om*/ ((CoordinatorLayout) context.findViewById(R.id.coordinator)) .setStatusBarBackgroundColor(ThemeStore.statusBarColor(context)); if (appBar != null) appBar.setBackgroundColor(ThemeStore.primaryColor(context)); else toolbar.setBackgroundColor(ThemeStore.primaryColor(context)); ToolbarContentTintHelper.setToolbarContentColor(context, toolbar, null, textToolbarDefault, textToolbarDefault, textToolbarDefault, 0xff424242); int tabTextColor = PreferenceManager.getDefaultSharedPreferences(context).getInt("tab_text_selected", textToolbarDefault); if (tabLayout != null) tabLayout.setTabTextColors( //ColorUtil.isColorLight(tabTextColor) ? ColorUtil.shiftColor(tabTextColor, 0.9f) : ColorUtil.shiftColor(tabTextColor, 1.5f), Color.argb(180, Color.red(tabTextColor), Color.green(tabTextColor), Color.blue(tabTextColor)), tabTextColor); } else { ToolbarContentTintHelper.setToolbarContentColor(context, toolbar, null, 0xffeaeaea, 0xffeaeaea, 0xffeaeaea, 0xff424242); if (tabLayout != null) tabLayout.setTabTextColors(ColorUtil.shiftColor(0xffeaeaea, 1.5f), 0xffeaeaea); } }
From source file:com.uws.campus_app.core.maps.BaseCustomMap.java
@Override public void onUserMoved(Double lat, Double lng) { if (userMarker != null && userArea != null) { userMarker.remove();/* w ww.j a v a 2s. co m*/ userArea.remove(); } GoogleMap googleMap = getMap(); userMarker = googleMap.addMarker(new MarkerOptions().position(new LatLng(lat, lng)).title("Your Location")); userArea = googleMap.addCircle(new CircleOptions().center(new LatLng(lat, lng)) .strokeColor(Color.argb(180, 7, 205, 227)).fillColor(Color.argb(100, 7, 205, 227)).radius(30.0)); }