List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTint
public static void setTint(Drawable drawable, int i)
From source file:org.gateshipone.malp.application.listviewitems.FileListItem.java
/** * Extracts the information from a MPDPlaylist * @param playlist Playlist to show the view for. * @param context Context used for image extraction *///w w w . ja v a2s .c o m public void setPlaylist(MPDPlaylist playlist, Context context) { mTitleView.setText(playlist.getSectionTitle()); mAdditionalInfoView.setText(playlist.getLastModified()); if (mShowIcon) { Drawable icon = context.getDrawable(R.drawable.ic_queue_music_black_48dp); if (icon != null) { // get tint color int tintColor = ThemeUtils.getThemeColor(context, android.R.attr.textColor); // tint the icon DrawableCompat.setTint(icon, tintColor); } mItemIcon.setImageDrawable(icon); } }
From source file:com.l4digital.fastscroll.FastScroller.java
private void setHandleSelected(boolean selected) { mHandleView.setSelected(selected); DrawableCompat.setTint(mHandleImage, selected ? mBubbleColor : mHandleColor); }
From source file:com.birdeye.MainActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!Prefs.usernames.isSet()) { Prefs.usernames.set(Twitter.getSessionManager().getActiveSession().getUserName()); }//from w w w.j a v a2s .co m setContentView(R.layout.main); ButterKnife.bind(this); // hideSystemUI(this); Chartboost.startWithAppId(MainActivity.this, "57552756f6cd4526e365b9d1", "239b2e3aa657ccdcdf0b9674c8750f077b5e0aed"); Chartboost.setLoggingLevel(CBLogging.Level.ALL); Chartboost.setDelegate(delegate); Chartboost.onCreate(this); tv_cancel = (TextView) findViewById(R.id.tv_cancel); tvSetTimer = (Button) findViewById(R.id.tvSetTimer); if (!BillingProcessor.isIabServiceAvailable(MainActivity.this)) { // showToast("In-app billing service is unavailable, please upgrade Android Market/Play to version >= 3.9.16"); onBackPressed(); } bp = new BillingProcessor(this, LICENSE_KEY, MERCHANT_ID, new BillingProcessor.IBillingHandler() { @Override public void onProductPurchased(String productId, TransactionDetails details) { showToast("onProductPurchased: " + productId); // updateTextViews(); } @Override public void onBillingError(int errorCode, Throwable error) { showToast("onBillingError: " + Integer.toString(errorCode)); } @Override public void onBillingInitialized() { showToast("onBillingInitialized"); readyToPurchase = true; //updateTextViews(); } @Override public void onPurchaseHistoryRestored() { showToast("onPurchaseHistoryRestored"); for (String sku : bp.listOwnedProducts()) Log.d(LOG_TAG, "Owned Managed Product: " + sku); for (String sku : bp.listOwnedSubscriptions()) Log.d(LOG_TAG, "Owned Subscription: " + sku); //updateTextViews(); Log.i(LOG_TAG, String.format("%s is%s subscribed", SUBSCRIPTION_ID, bp.isSubscribed(SUBSCRIPTION_ID) ? "" : " not")); } }); subs = bp.getSubscriptionListingDetails(SUBSCRIPTION_ID); // showToast(subs != null ? subs.toString() : "Failed to load subscription details"); if (subs == null) { // showToast(subs != null ? subs.toString() : "Failed to load subscription details"); Globals.hasPaid = false; } else { Globals.hasPaid = true; } if (Globals.hasPaid) { tvSetTimer.setVisibility(View.VISIBLE); message4.setVisibility(View.VISIBLE); message5.setVisibility(View.VISIBLE); message6.setVisibility(View.VISIBLE); message7.setVisibility(View.VISIBLE); message8.setVisibility(View.VISIBLE); message9.setVisibility(View.VISIBLE); message10.setVisibility(View.VISIBLE); message11.setVisibility(View.VISIBLE); message12.setVisibility(View.VISIBLE); message13.setVisibility(View.VISIBLE); message14.setVisibility(View.VISIBLE); message15.setVisibility(View.VISIBLE); message16.setVisibility(View.VISIBLE); message17.setVisibility(View.VISIBLE); message18.setVisibility(View.VISIBLE); message19.setVisibility(View.VISIBLE); message20.setVisibility(View.VISIBLE); message21.setVisibility(View.VISIBLE); message22.setVisibility(View.VISIBLE); message23.setVisibility(View.VISIBLE); message24.setVisibility(View.VISIBLE); message25.setVisibility(View.VISIBLE); ets = Arrays.asList(usernames, hashtags, message1, message2, message3, message4, message5, message6, message7, message8, message9, message10, message11, message12, message13, message14, message15, message16, message17, message18, message19, message20, message21, message22, message23, message24, message25); } else { tvSetTimer.setVisibility(View.GONE); message4.setVisibility(View.GONE); message5.setVisibility(View.GONE); message6.setVisibility(View.GONE); message7.setVisibility(View.GONE); message8.setVisibility(View.GONE); message9.setVisibility(View.GONE); message10.setVisibility(View.GONE); message11.setVisibility(View.GONE); message12.setVisibility(View.GONE); message13.setVisibility(View.GONE); message14.setVisibility(View.GONE); message15.setVisibility(View.GONE); message16.setVisibility(View.GONE); message17.setVisibility(View.GONE); message18.setVisibility(View.GONE); message19.setVisibility(View.GONE); message20.setVisibility(View.GONE); message21.setVisibility(View.GONE); message22.setVisibility(View.GONE); message23.setVisibility(View.GONE); message24.setVisibility(View.GONE); message25.setVisibility(View.GONE); ets = Arrays.asList(usernames, hashtags, message1, message2, message3); } tvSetTimer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(MainActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setContentView(R.layout.input_time); dialog.setCancelable(true); Button bt_set = (Button) dialog.findViewById(R.id.bt_set); final EditText et_time = (EditText) dialog.findViewById(R.id.et_time); bt_set.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (et_time.getText().toString().equalsIgnoreCase("")) { Toast.makeText(MainActivity.this, "Please enter time to auto shut down", Toast.LENGTH_SHORT).show(); } else { int valueTimer = Integer.parseInt(et_time.getText().toString()) * 1000; initateCounter(valueTimer); tv_cancel.setText("Auto ShutDown started"); tvSetTimer.setVisibility(View.GONE); tv_cancel.setVisibility(View.VISIBLE); dialog.dismiss(); } } }); dialog.show(); } }); cameras.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, Facing.values())); //noinspection ConstantConditions cameras.setSelection(Prefs.facing.get().ordinal()); cameras.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Prefs.facing.set(Facing.values()[position]); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); for (TextInputEditText et : ets) { DrawableCompat.setTint(et.getBackground(), ContextCompat.getColor(this, R.color.colorAccent)); final TextInputLayout til = textLayout(et); til.setError(null); til.setErrorEnabled(false); } TextViews.setText(usernames, Prefs.usernames.get()); TextViews.setText(hashtags, Prefs.hashtags.get()); TextViews.setText(message1, Prefs.message1.get()); TextViews.setText(message2, Prefs.message2.get()); TextViews.setText(message3, Prefs.message3.get()); TextViews.setText(message4, Prefs.message4.get()); TextViews.setText(message5, Prefs.message5.get()); TextViews.setText(message6, Prefs.message6.get()); TextViews.setText(message7, Prefs.message7.get()); TextViews.setText(message8, Prefs.message8.get()); TextViews.setText(message9, Prefs.message9.get()); TextViews.setText(message10, Prefs.message10.get()); TextViews.setText(message11, Prefs.message11.get()); TextViews.setText(message12, Prefs.message12.get()); TextViews.setText(message13, Prefs.message13.get()); TextViews.setText(message14, Prefs.message14.get()); TextViews.setText(message15, Prefs.message15.get()); TextViews.setText(message16, Prefs.message16.get()); TextViews.setText(message17, Prefs.message17.get()); TextViews.setText(message18, Prefs.message18.get()); TextViews.setText(message19, Prefs.message19.get()); TextViews.setText(message20, Prefs.message20.get()); TextViews.setText(message21, Prefs.message21.get()); TextViews.setText(message22, Prefs.message22.get()); TextViews.setText(message23, Prefs.message23.get()); TextViews.setText(message24, Prefs.message24.get()); TextViews.setText(message25, Prefs.message25.get()); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); getWindow().setBackgroundDrawableResource(R.color.bg); mAdView = (AdView) findViewById(R.id.adView); mInterstitialAd = new InterstitialAd(this); // set the ad unit ID mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen)); adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // Check the LogCat to get your test device ID .addTestDevice("EB02375D2DA62FFA0F6F145AD2302B3D").build(); // adRequest = new AdRequest.Builder().build(); mAdView.setAdListener(new AdListener() { @Override public void onAdLoaded() { } @Override public void onAdClosed() { // Toast.makeText(getApplicationContext(), "Ad is closed!", Toast.LENGTH_SHORT).show(); } @Override public void onAdFailedToLoad(int errorCode) { // Toast.makeText(getApplicationContext(), "Ad failed to load! error code: " + errorCode, Toast.LENGTH_SHORT).show(); } @Override public void onAdLeftApplication() { // Toast.makeText(getApplicationContext(), "Ad left application!", Toast.LENGTH_SHORT).show(); } @Override public void onAdOpened() { super.onAdOpened(); } }); mAdView.loadAd(adRequest); mInterstitialAd.loadAd(adRequest); mInterstitialAd.setAdListener(new AdListener() { public void onAdLoaded() { showInterstitial(); } @Override public void onAdClosed() { Toast.makeText(getApplicationContext(), "Ad is closed!", Toast.LENGTH_SHORT).show(); } @Override public void onAdFailedToLoad(int errorCode) { Toast.makeText(getApplicationContext(), "Ad failed to load! error code: " + errorCode, Toast.LENGTH_SHORT).show(); } @Override public void onAdLeftApplication() { Toast.makeText(getApplicationContext(), "Ad left application!", Toast.LENGTH_SHORT).show(); } @Override public void onAdOpened() { Toast.makeText(getApplicationContext(), "Ad is opened!", Toast.LENGTH_SHORT).show(); } }); if (Globals.hasPaid) { tv_cancel.setVisibility(View.GONE); mAdView.setVisibility(View.GONE); } else { // initateCounter(120000); startRepeatingTask(); mAdView.setVisibility(View.VISIBLE); } }
From source file:com.guerinet.formgenerator.TextViewFormItem.java
/** * Builds the view and adds it to the container * * @return The {@link TextViewFormItem} instance *//* w w w. j a v a 2 s . c o m*/ @CallSuper public TextViewFormItem build() { Drawable[] drawables = new Drawable[4]; // Get all of the icons drawables[0] = getDrawable(icons[0]); drawables[1] = getDrawable(icons[1]); drawables[2] = getDrawable(icons[2]); drawables[3] = getDrawable(icons[3]); // Set the compound drawable padding if (fg.builder.defaultDrawablePaddingSize != -1) { textView.setCompoundDrawablePadding(fg.builder.defaultDrawablePaddingSize); } // Set the correct tinting and alpha for (int i = 0; i < 4; i++) { Icon icon = icons[i]; Drawable drawable = drawables[i]; if (drawable != null) { // Wrap it in the design support library drawable = DrawableCompat.wrap(drawable.mutate()); if (!icon.visible) { drawable.setAlpha(0); } else if (icon.color != -1) { DrawableCompat.setTint(drawable, icon.color); } } } // Set the drawables on the view textView.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], drawables[2], drawables[3]); // Add the view to the container fg.container.addView(view); return this; }
From source file:org.androidwhite.icons.ui.MainActivity.java
private void addTab(@DrawableRes int icon) { assert mTabs != null; TabLayout.Tab tab = mTabs.newTab().setIcon(icon); if (tab.getIcon() != null) { Drawable tintedIcon = DrawableCompat.wrap(tab.getIcon()); DrawableCompat.setTint(tintedIcon, DialogUtils.resolveColor(this, R.attr.tab_icon_color)); tab.setIcon(tintedIcon);/*from w w w .j ava2 s .c o m*/ } mTabs.addTab(tab); }
From source file:io.github.hidroh.materialistic.ItemActivity.java
@Synthetic void onVoted(Boolean successful) { if (successful == null) { Toast.makeText(this, R.string.vote_failed, Toast.LENGTH_SHORT).show(); } else if (successful) { Drawable drawable = DrawableCompat.wrap(mVoteButton.getDrawable()); DrawableCompat.setTint(drawable, ContextCompat.getColor(this, R.color.greenA700)); Toast.makeText(this, R.string.voted, Toast.LENGTH_SHORT).show(); } else {/*from w w w . ja va2 s .c o m*/ AppUtils.showLogin(this, mAlertDialogBuilder); } }
From source file:com.afollestad.polar.ui.MainActivity.java
private void addTab(@DrawableRes int icon) { assert mTabs != null; TabLayout.Tab tab = mTabs.newTab().setIcon(VC.get(icon)); if (tab.getIcon() != null) { Drawable tintedIcon = DrawableCompat.wrap(tab.getIcon()); DrawableCompat.setTint(tintedIcon, DialogUtils.resolveColor(this, R.attr.tab_icon_color)); tab.setIcon(tintedIcon);// ww w .j ava 2 s . c o m } mTabs.addTab(tab); }
From source file:uk.ac.horizon.artcodes.scanner.ScannerActivity.java
private Drawable getTintedDrawable(@DrawableRes int drawable, @ColorInt int color) { final Drawable original = ContextCompat.getDrawable(this, drawable); if (original != null) { final Drawable wrapDrawable = DrawableCompat.wrap(original); DrawableCompat.setTint(wrapDrawable, color); return wrapDrawable; }/*from w ww. j a va 2 s .c o m*/ return null; }
From source file:com.coinblesk.client.utils.UIUtils.java
public static Drawable tintIcon(Drawable drawable, @ColorInt int tint) { drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, tint); return drawable; }
From source file:net.gsantner.opoc.util.ContextUtils.java
/** * Tint a {@link Drawable} with given {@code color} *///from ww w. j a v a 2 s. co m public Drawable tintDrawable(@Nullable Drawable drawable, @ColorInt int color) { if (drawable != null) { drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable.mutate(), color); } return drawable; }