use of android.graphics.drawable.Drawable in project kickmaterial by byoutline.
the class RewardsListActivity method loadProjectData.
private void loadProjectData() {
selectCategoryTv.setText(R.string.select_pledge);
selectCategoryTv.setBackgroundColor(Color.TRANSPARENT);
categoryCircleIv.setVisibility(View.GONE);
Picasso.with(getApplicationContext()).load(project.getPhotoUrl()).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
selectedCategoryIv.setImageBitmap(bitmap);
LUtils.toGrayscale(selectedCategoryIv);
selectedCategoryIv.getDrawable().setColorFilter(ContextCompat.getColor(RewardsListActivity.this, R.color.green_dark), PorterDuff.Mode.MULTIPLY);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
selectedCategoryIv.setImageResource(0);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
selectedCategoryIv.setImageResource(0);
}
});
}
use of android.graphics.drawable.Drawable in project kickmaterial by byoutline.
the class CircleTransition method getStartView.
private View getStartView(ViewGroup sceneRoot, TransitionValues startValues, int[] sceneRootLoc, int[] startLoc) {
Bitmap startImage = (Bitmap) startValues.values.get(PROPERTY_IMAGE);
Drawable startBackground = new BitmapDrawable(startImage);
final View startView = addViewToOverlay(sceneRoot, startImage.getWidth(), startImage.getHeight(), startBackground);
int startTranslationX = startLoc[0] - sceneRootLoc[0];
int startTranslationY = startLoc[1] - sceneRootLoc[1];
startView.setTranslationX(startTranslationX);
startView.setTranslationY(startTranslationY);
return startView;
}
use of android.graphics.drawable.Drawable in project cw-omnibus by commonsguy.
the class ShareActionProvider method onCreateActionView.
/**
* {@inheritDoc}
*/
@Override
public View onCreateActionView() {
// Create the view and set its data model.
ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
ActivityChooserView activityChooserView = new ActivityChooserView(mContext);
activityChooserView.setActivityChooserModel(dataModel);
// Lookup and set the expand action icon.
TypedValue outTypedValue = new TypedValue();
mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true);
Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId);
activityChooserView.setExpandActivityOverflowButtonDrawable(drawable);
activityChooserView.setProvider(this);
// Set content description.
activityChooserView.setDefaultActionButtonContentDescription(R.string.abs__shareactionprovider_share_with_application);
activityChooserView.setExpandActivityOverflowButtonContentDescription(R.string.abs__shareactionprovider_share_with);
return activityChooserView;
}
use of android.graphics.drawable.Drawable in project cw-omnibus by commonsguy.
the class SuggestionsAdapter method getDrawableFromResourceValue.
/**
* Gets a drawable given a value provided by a suggestion provider.
*
* This value could be just the string value of a resource id
* (e.g., "2130837524"), in which case we will try to retrieve a drawable from
* the provider's resources. If the value is not an integer, it is
* treated as a Uri and opened with
* {@link ContentResolver#openOutputStream(android.net.Uri, String)}.
*
* All resources and URIs are read using the suggestion provider's context.
*
* If the string is not formatted as expected, or no drawable can be found for
* the provided value, this method returns null.
*
* @param drawableId a string like "2130837524",
* "android.resource://com.android.alarmclock/2130837524",
* or "content://contacts/photos/253".
* @return a Drawable, or null if none found
*/
private Drawable getDrawableFromResourceValue(String drawableId) {
if (drawableId == null || drawableId.length() == 0 || "0".equals(drawableId)) {
return null;
}
try {
// First, see if it's just an integer
int resourceId = Integer.parseInt(drawableId);
// It's an int, look for it in the cache
String drawableUri = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + mProviderContext.getPackageName() + "/" + resourceId;
// Must use URI as cache key, since ints are app-specific
Drawable drawable = checkIconCache(drawableUri);
if (drawable != null) {
return drawable;
}
// Not cached, find it by resource ID
drawable = mProviderContext.getResources().getDrawable(resourceId);
// Stick it in the cache, using the URI as key
storeInIconCache(drawableUri, drawable);
return drawable;
} catch (NumberFormatException nfe) {
// It's not an integer, use it as a URI
Drawable drawable = checkIconCache(drawableId);
if (drawable != null) {
return drawable;
}
Uri uri = Uri.parse(drawableId);
drawable = getDrawable(uri);
storeInIconCache(drawableId, drawable);
return drawable;
} catch (Resources.NotFoundException nfe) {
// It was an integer, but it couldn't be found, bail out
Log.w(LOG_TAG, "Icon resource not found: " + drawableId);
return null;
}
}
use of android.graphics.drawable.Drawable in project cw-omnibus by commonsguy.
the class SearchView method getDecoratedHint.
private CharSequence getDecoratedHint(CharSequence hintText) {
// If the field is always expanded, then don't add the search icon to the hint
if (!mIconifiedByDefault)
return hintText;
// for the icon
SpannableStringBuilder ssb = new SpannableStringBuilder(" ");
ssb.append(hintText);
Drawable searchIcon = getContext().getResources().getDrawable(getSearchIconId());
int textSize = (int) (mQueryTextView.getTextSize() * 1.25);
searchIcon.setBounds(0, 0, textSize, textSize);
ssb.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return ssb;
}
Aggregations