Search in sources :

Example 1 with Drawable

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);
        }
    });
}
Also used : Target(com.squareup.picasso.Target) Bitmap(android.graphics.Bitmap) Picasso(com.squareup.picasso.Picasso) Drawable(android.graphics.drawable.Drawable)

Example 2 with Drawable

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;
}
Also used : Bitmap(android.graphics.Bitmap) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) View(android.view.View)

Example 3 with Drawable

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;
}
Also used : Drawable(android.graphics.drawable.Drawable) TypedValue(android.util.TypedValue)

Example 4 with Drawable

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;
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) SpannableString(android.text.SpannableString) Resources(android.content.res.Resources) Uri(android.net.Uri)

Example 5 with Drawable

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;
}
Also used : Drawable(android.graphics.drawable.Drawable) SpannableStringBuilder(android.text.SpannableStringBuilder) ImageSpan(android.text.style.ImageSpan)

Aggregations

Drawable (android.graphics.drawable.Drawable)4503 BitmapDrawable (android.graphics.drawable.BitmapDrawable)793 View (android.view.View)577 Bitmap (android.graphics.Bitmap)474 ColorDrawable (android.graphics.drawable.ColorDrawable)472 ImageView (android.widget.ImageView)470 TextView (android.widget.TextView)436 Paint (android.graphics.Paint)321 LayerDrawable (android.graphics.drawable.LayerDrawable)314 Test (org.junit.Test)275 Context (android.content.Context)267 Resources (android.content.res.Resources)252 Rect (android.graphics.Rect)242 PackageManager (android.content.pm.PackageManager)233 StateListDrawable (android.graphics.drawable.StateListDrawable)212 TypedArray (android.content.res.TypedArray)204 Intent (android.content.Intent)153 ViewGroup (android.view.ViewGroup)148 AnimationDrawable (android.graphics.drawable.AnimationDrawable)147 SuppressLint (android.annotation.SuppressLint)137