List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable
public ColorDrawable(@ColorInt int color)
From source file:com.github.shareme.gwsmaterialdrawer.library.DrawerView.java
private void init(Context context) { Log.d(TAG, "init()"); inflate(context, R.layout.md_drawer_view, this); findViews();/*w w w . j a va 2s . c o m*/ setClipToPadding(false); setInsetForeground(new ColorDrawable(getResources().getColor(R.color.md_inset_foreground))); setOnInsetsCallback(this); mProfileAdapter = new DrawerProfileAdapter(context, new ArrayList<DrawerProfile>()); linearListViewProfileList.setAdapter(mProfileAdapter); linearListViewProfileList.setOnItemClickListener(new LinearListView.OnItemClickListener() { @Override public void onItemClick(LinearListView parent, View view, int position, long id) { if (position != 0) { selectProfile(mProfileAdapter.getItem(position)); } } }); mAdapter = new DrawerAdapter(context, new ArrayList<DrawerItem>()); linearListView.setAdapter(mAdapter); linearListView.setOnItemClickListener(new LinearListView.OnItemClickListener() { @Override public void onItemClick(LinearListView parent, View view, int position, long id) { DrawerItem item = mAdapter.getItem(position); if (!item.isHeader()) { if (item.hasOnItemClickListener()) { item.getOnItemClickListener().onClick(item, item.getId(), position); } else { if (hasOnItemClickListener()) { mOnItemClickListener.onClick(item, item.getId(), position); } } } } }); mAdapterFixed = new DrawerAdapter(context, new ArrayList<DrawerItem>()); linearListViewFixed.setAdapter(mAdapterFixed); linearListViewFixed.setOnItemClickListener(new LinearListView.OnItemClickListener() { @Override public void onItemClick(LinearListView parent, View view, int position, long id) { DrawerItem item = mAdapterFixed.getItem(position); if (!item.isHeader()) { if (item.hasOnItemClickListener()) { item.getOnItemClickListener().onClick(item, item.getId(), position); } else { if (hasOnFixedItemClickListener()) { mOnFixedItemClickListener.onClick(item, item.getId(), position); } } } } }); resetDrawerTheme(); imageViewOpenProfileListIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { toggleProfileList(); } }); frameLayoutProfile.setVisibility(GONE); layout.setPadding(0, statusBarHeight, 0, 0); updateListVisibility(); }
From source file:ccv.checkhelzio.nuevaagendacucsh.transitions.FabTransition.java
@Override public Animator createAnimator(final ViewGroup sceneRoot, final TransitionValues startValues, final TransitionValues endValues) { if (startValues == null || endValues == null) return null; final Rect startBounds = (Rect) startValues.values.get(PROP_BOUNDS); final Rect endBounds = (Rect) endValues.values.get(PROP_BOUNDS); final boolean fromFab = endBounds.width() > startBounds.width(); final View view = endValues.view; final Rect dialogBounds = fromFab ? endBounds : startBounds; final Rect fabBounds = fromFab ? startBounds : endBounds; final Interpolator fastOutSlowInInterpolator = AnimUtils .getFastOutSlowInInterpolator(sceneRoot.getContext()); final long duration = getDuration(); final long halfDuration = duration / 2; final long twoThirdsDuration = duration * 2 / 3; if (!fromFab) { // Force measure / layout the dialog back to it's original bounds view.measure(makeMeasureSpec(startBounds.width(), View.MeasureSpec.EXACTLY), makeMeasureSpec(startBounds.height(), View.MeasureSpec.EXACTLY)); view.layout(startBounds.left, startBounds.top, startBounds.right, startBounds.bottom); }//from ww w . java2 s . c o m final int translationX = startBounds.centerX() - endBounds.centerX(); final int translationY = startBounds.centerY() - endBounds.centerY(); if (fromFab) { view.setTranslationX(translationX); view.setTranslationY(translationY); } // Add a color overlay to fake appearance of the FAB final ColorDrawable fabColor = new ColorDrawable(color); fabColor.setBounds(0, 0, dialogBounds.width(), dialogBounds.height()); if (!fromFab) fabColor.setAlpha(0); view.getOverlay().add(fabColor); // Add an icon overlay again to fake the appearance of the FAB final Drawable fabIcon = ContextCompat.getDrawable(sceneRoot.getContext(), icon).mutate(); final int iconLeft = (dialogBounds.width() - fabIcon.getIntrinsicWidth()) / 2; final int iconTop = (dialogBounds.height() - fabIcon.getIntrinsicHeight()) / 2; fabIcon.setBounds(iconLeft, iconTop, iconLeft + fabIcon.getIntrinsicWidth(), iconTop + fabIcon.getIntrinsicHeight()); if (!fromFab) fabIcon.setAlpha(0); view.getOverlay().add(fabIcon); // Circular clip from/to the FAB size final Animator circularReveal; if (fromFab) { circularReveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2, view.getHeight() / 2, startBounds.width() / 2, (float) Math.hypot(endBounds.width() / 2, endBounds.height() / 2)); circularReveal.setInterpolator(AnimUtils.getFastOutLinearInInterpolator(sceneRoot.getContext())); //circularReveal.setInterpolator(new AnimationUtils().loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in)); } else { circularReveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2, view.getHeight() / 2, (float) Math.hypot(startBounds.width() / 2, startBounds.height() / 2), endBounds.width() / 2); circularReveal.setInterpolator(AnimUtils.getLinearOutSlowInInterpolator(sceneRoot.getContext())); // Persist the end clip i.e. stay at FAB size after the reveal has run circularReveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { final int left = (view.getWidth() - fabBounds.width()) / 2; final int top = (view.getHeight() - fabBounds.height()) / 2; outline.setOval(left, top, left + fabBounds.width(), top + fabBounds.height()); view.setClipToOutline(true); } }); } }); } circularReveal.setDuration(duration); // Translate to end position along an arc final Animator translate = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, View.TRANSLATION_Y, fromFab ? getPathMotion().getPath(translationX, translationY, 0, 0) : getPathMotion().getPath(0, 0, -translationX, -translationY)); translate.setDuration(duration); translate.setInterpolator(fastOutSlowInInterpolator); // Fade contents of non-FAB view in/out List<Animator> fadeContents = null; if (view instanceof ViewGroup) { final ViewGroup vg = ((ViewGroup) view); fadeContents = new ArrayList<>(vg.getChildCount()); for (int i = vg.getChildCount() - 1; i >= 0; i--) { final View child = vg.getChildAt(i); final Animator fade = ObjectAnimator.ofFloat(child, View.ALPHA, fromFab ? 1f : 0f); if (fromFab) { child.setAlpha(0f); } fade.setDuration(twoThirdsDuration); fade.setInterpolator(fastOutSlowInInterpolator); fadeContents.add(fade); } } // Fade in/out the fab color & icon overlays final Animator colorFade = ObjectAnimator.ofInt(fabColor, "alpha", fromFab ? 0 : 255); final Animator iconFade = ObjectAnimator.ofInt(fabIcon, "alpha", fromFab ? 0 : 255); if (!fromFab) { colorFade.setStartDelay(halfDuration); iconFade.setStartDelay(halfDuration); } colorFade.setDuration(halfDuration); iconFade.setDuration(halfDuration); colorFade.setInterpolator(fastOutSlowInInterpolator); iconFade.setInterpolator(fastOutSlowInInterpolator); // Work around issue with elevation shadows. At the end of the return transition the shared // element's shadow is drawn twice (by each activity) which is jarring. This workaround // still causes the shadow to snap, but it's better than seeing it double drawn. Animator elevation = null; if (!fromFab) { elevation = ObjectAnimator.ofFloat(view, View.TRANSLATION_Z, -view.getElevation()); elevation.setDuration(duration); elevation.setInterpolator(fastOutSlowInInterpolator); } // Run all animations together final AnimatorSet transition = new AnimatorSet(); transition.playTogether(circularReveal, translate, colorFade, iconFade); transition.playTogether(fadeContents); if (elevation != null) transition.play(elevation); if (fromFab) { transition.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // Clean up view.getOverlay().clear(); } }); } return new AnimUtils.NoPauseAnimator(transition); }
From source file:com.spoiledmilk.ibikecph.util.Util.java
public static void launchNoConnectionDialog(Context ctx) { final Dialog dialog = new Dialog(ctx); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_no_connection); TextView text = (TextView) dialog.findViewById(R.id.textNetworkError); text.setTypeface(IbikeApplication.getNormalFont()); text.setText(IbikeApplication.getString("network_error_text")); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.show();//from ww w .java2 s . co m final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { try { dialog.dismiss(); } catch (Exception e) { // dialog not attached to window } } }, 3000); }
From source file:com.lithiumli.fiction.NowPlayingActivity.java
public void onImageFound(BitmapDrawable bitmap) { ImageView view = (ImageView) findViewById(R.id.background_image); if (bitmap != null) { view.setImageDrawable(bitmap);//www . ja v a 2 s. co m } else { view.setImageDrawable(new ColorDrawable(0xFF000000)); } }
From source file:com.cloudkick.NodeViewActivity.java
private void redrawHeader() { // Set the a color representing the state ((TextView) findViewById(R.id.node_detail_status)) .setBackgroundDrawable(new ColorDrawable(node.getStateColor())); // Set the background ((RelativeLayout) findViewById(R.id.node_detail_header)) .setBackgroundDrawable(new ColorDrawable(node.color)); ((TextView) findViewById(R.id.node_detail_name)).setText(node.name); ((TextView) findViewById(R.id.node_detail_tags)).setText(node.getTagString()); }
From source file:au.com.wallaceit.reddinator.MainActivity.java
private void setThemeColors() { int themenum = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context) .getString(context.getString(R.string.widget_theme_pref), "1")); switch (themenum) { case 1:/*from w w w. j a va 2 s. c om*/ actionBar.getCustomView().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#CEE3F8"))); appView.setBackgroundColor(Color.WHITE); configbutton.setBackgroundColor(Color.parseColor("#CEE3F8")); refreshbutton.setBackgroundColor(Color.parseColor("#CEE3F8")); errorIcon.setBackgroundColor(Color.parseColor("#CEE3F8")); srtext.setTextColor(Color.parseColor("#000000")); break; case 3: case 5: Drawable header = getResources().getDrawable(android.R.drawable.dark_header); actionBar.getCustomView().setBackgroundDrawable(header); appView.setBackgroundColor(Color.BLACK); configbutton.setBackgroundDrawable(null); refreshbutton.setBackgroundDrawable(null); errorIcon.setBackgroundDrawable(header); srtext.setTextColor(Color.parseColor("#FFFFFF")); break; case 4: case 2: actionBar.getCustomView().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#5F99CF"))); appView.setBackgroundColor(Color.BLACK); configbutton.setBackgroundColor(Color.parseColor("#5F99CF")); refreshbutton.setBackgroundColor(Color.parseColor("#5F99CF")); errorIcon.setBackgroundColor(Color.parseColor("#5F99CF")); srtext.setTextColor(Color.parseColor("#000000")); break; } }
From source file:com.dirkgassen.wator.ui.view.RollingGraphView.java
/** * Read out the attributes from the given attribute set and initialize whatever they represent. * * @param attributeArray typed array containing the attribute values from the XML file *///from ww w . j av a2s . com private void setupAttributes(TypedArray attributeArray) { String series1Name = attributeArray.getString(R.styleable.RollingGraphView_series1name); if (series1Name == null) { seriesNames = null; } else { String series2Name = attributeArray.getString(R.styleable.RollingGraphView_series2name); if (series2Name == null) { seriesNames = new String[] { series1Name }; } else { String series3Name = attributeArray.getString(R.styleable.RollingGraphView_series3name); if (series3Name == null) { seriesNames = new String[] { series1Name, series2Name }; } else { String series4Name = attributeArray.getString(R.styleable.RollingGraphView_series4name); if (series4Name == null) { seriesNames = new String[] { series1Name, series2Name, series3Name }; } else { seriesNames = new String[] { series1Name, series2Name, series3Name, series4Name }; } } } maxValues = attributeArray.getInt(R.styleable.RollingGraphView_maxValues, -1); seriesPaints = new Paint[seriesNames.length]; seriesPaints[0] = new Paint(Paint.ANTI_ALIAS_FLAG); seriesPaints[0] .setColor(attributeArray.getColor(R.styleable.RollingGraphView_series1color, 0xFFFF0000)); seriesPaints[0].setStrokeWidth(attributeArray .getDimension(R.styleable.RollingGraphView_series1thickness, 1 /* dp */ * displayDensity)); seriesPaints[0].setTextSize( attributeArray.getDimension(R.styleable.RollingGraphView_label1textSize, 14 * displayDensity)); if (seriesPaints.length > 1) { seriesPaints[1] = new Paint(Paint.ANTI_ALIAS_FLAG); seriesPaints[1] .setColor(attributeArray.getColor(R.styleable.RollingGraphView_series2color, 0xFFFF0000)); seriesPaints[1].setStrokeWidth(attributeArray .getDimension(R.styleable.RollingGraphView_series2thickness, 1 /* dp */ * displayDensity)); seriesPaints[1].setTextSize(attributeArray.getDimension(R.styleable.RollingGraphView_label2textSize, 14 * displayDensity)); if (seriesPaints.length > 2) { seriesPaints[2] = new Paint(Paint.ANTI_ALIAS_FLAG); seriesPaints[2].setColor( attributeArray.getColor(R.styleable.RollingGraphView_series3color, 0xFFFF0000)); seriesPaints[2].setStrokeWidth(attributeArray.getDimension( R.styleable.RollingGraphView_series3thickness, 1 /* dp */ * displayDensity)); seriesPaints[2].setTextSize(attributeArray .getDimension(R.styleable.RollingGraphView_label3textSize, 14 * displayDensity)); if (seriesPaints.length > 3) { seriesPaints[3] = new Paint(Paint.ANTI_ALIAS_FLAG); seriesPaints[3].setColor( attributeArray.getColor(R.styleable.RollingGraphView_series4color, 0xFFFF0000)); seriesPaints[3].setStrokeWidth(attributeArray.getDimension( R.styleable.RollingGraphView_series4thickness, 1 /* dp */ * displayDensity)); seriesPaints[3].setTextSize(attributeArray .getDimension(R.styleable.RollingGraphView_label4textSize, 14 * displayDensity)); } } } background = getBackground(); if (background == null) { background = new ColorDrawable(ContextCompat.getColor(getContext(), android.R.color.white)); } } horizontal = attributeArray.getInt(R.styleable.RollingGraphView_android_orientation, 0) == 0; }
From source file:com.flowzr.activity.FlowzrSyncActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.flowzr_sync); //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line, //only way found to remove on various devices 2.3x, 3.0, ... getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#121212"))); renderLastTime();//from w w w .j a v a 2s .c o m CheckBox chkForce = (CheckBox) findViewById(R.id.chk_sync_from_zero); chkForce.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { resetLastTime(); renderLastTime(); } }); Button syncButton = (Button) findViewById(R.id.sync); syncButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startSync(); } }); Button textViewAbout = (Button) findViewById(R.id.buySubscription); textViewAbout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String accountName = MyPreferences.getFlowzrAccount(getApplicationContext()); if (accountName == null) { Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_choose_account, Toast.LENGTH_SHORT) .show(); return; } if (isOnline(FlowzrSyncActivity.this)) { //checkPlayServices(); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); return; } // Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_sync_auth_inprogress, Toast.LENGTH_SHORT) .show(); FlowzrBillTask ft = new FlowzrBillTask(FlowzrSyncActivity.this); ft.execute(); //visitFlowzr(accountName); } }); Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr); textViewAboutAnon.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(null); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote); textViewNotes.setMovementMethod(LinkMovementMethod.getInstance()); textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use))); if (MyPreferences.isAutoSync(this)) { if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(getApplicationContext()); if (regid.equals("")) { registerInBackground(); } Log.i(TAG, "Google Cloud Messaging registered as :" + regid); } else { Log.i(TAG, "No valid Google Play Services APK found."); } } }
From source file:com.flowzr.budget.holo.activity.FlowzrSyncActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.flowzr_sync); //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line, //only way found to remove on various devices 2.3x, 3.0, ... getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#121212"))); renderLastTime();//w w w . j a va 2 s .c o m CheckBox chkForce = (CheckBox) findViewById(R.id.chk_sync_from_zero); chkForce.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { resetLastTime(); renderLastTime(); } }); Button syncButton = (Button) findViewById(R.id.sync); syncButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startSync(); } }); Button textViewAbout = (Button) findViewById(R.id.buySubscription); textViewAbout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String accountName = MyPreferences.getFlowzrAccount(getApplicationContext()); if (accountName == null) { Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_choose_account, Toast.LENGTH_SHORT) .show(); return; } if (isOnline(FlowzrSyncActivity.this)) { //checkPlayServices(); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); return; } // Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_sync_auth_inprogress, Toast.LENGTH_SHORT) .show(); FlowzrBillTask ft = new FlowzrBillTask(FlowzrSyncActivity.this); ft.execute(); //visitFlowzr(accountName); } }); Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr); textViewAboutAnon.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(null); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote); textViewNotes.setMovementMethod(LinkMovementMethod.getInstance()); textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use))); if (MyPreferences.isAutoSync(this)) { if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(getApplicationContext()); if (regid.equals("")) { registerInBackground(); } Log.i(TAG, "Google Cloud Messaging registered as :" + regid); } else { Log.i(TAG, "No valid Google Play Services APK found."); } } }
From source file:com.musenkishi.wally.util.PaletteLoader.java
private static void applyColorToView(final PaletteTarget target, int color, boolean fromCache) { if (target.getView() instanceof TextView) { applyColorToView((TextView) target.getView(), color, fromCache); return;/*from w w w. j av a2 s . c o m*/ } if (fromCache) { if (target.getView() instanceof ImageView && target.shouldMaskDrawable()) { ((ImageView) target.getView()).getDrawable().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY); } else { target.getView().setBackgroundColor(color); } } else { if (target.getView() instanceof ImageView && target.shouldMaskDrawable()) { Integer colorFrom; ValueAnimator.AnimatorUpdateListener imageAnimatorUpdateListener = new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { ((ImageView) target.getView()).getDrawable().mutate().setColorFilter( (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY); } }; ValueAnimator.AnimatorUpdateListener animatorUpdateListener; PaletteTag paletteTag = (PaletteTag) target.getView().getTag(); animatorUpdateListener = imageAnimatorUpdateListener; colorFrom = paletteTag.getColor(); target.getView().setTag(new PaletteTag(paletteTag.getId(), color)); Integer colorTo = color; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(animatorUpdateListener); colorAnimation.setDuration(300); colorAnimation.start(); } else { Drawable preDrawable; if (target.getView().getBackground() == null) { preDrawable = new ColorDrawable(Color.TRANSPARENT); } else { preDrawable = target.getView().getBackground(); } TransitionDrawable transitionDrawable = new TransitionDrawable( new Drawable[] { preDrawable, new ColorDrawable(color) }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { target.getView().setBackground(transitionDrawable); } else { target.getView().setBackgroundDrawable(transitionDrawable); } transitionDrawable.startTransition(300); } } }