Example usage for android.graphics.drawable Drawable getMinimumWidth

List of usage examples for android.graphics.drawable Drawable getMinimumWidth

Introduction

In this page you can find the example usage for android.graphics.drawable Drawable getMinimumWidth.

Prototype

public int getMinimumWidth() 

Source Link

Document

Returns the minimum width suggested by this Drawable.

Usage

From source file:com.novel.lightnovel.Utils.DrawableManager.java

public Drawable fetchDrawable(String urlString) {
    if (drawableMap.containsKey(urlString)) {
        return drawableMap.get(urlString);
    }/*from ww w  .  j  a v  a2s  . c  om*/
    Log.d(this.getClass().getSimpleName(), "image url:" + urlString);
    try {
        InputStream is = fetch(urlString);
        Drawable drawable = Drawable.createFromStream(is, "src");
        if (drawable != null) {
            drawableMap.put(urlString, drawable);
            Log.d(this.getClass().getSimpleName(),
                    "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight()
                            + "," + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + ","
                            + drawable.getMinimumWidth());
        } else {
            Log.w(this.getClass().getSimpleName(), "could not get thumbnail");
        }
        return drawable;
    } catch (MalformedURLException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    } catch (IOException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    }
}

From source file:com.kaku.weac.activities.MainActivity.java

/**
 * Tab//from   www.  j  a v a2  s .  c o m
 *
 * @param iconId   Tab
 * @param textView Tab
 * @param color    Tab
 */
private void setTextView(int iconId, TextView textView, int color) {
    @SuppressWarnings("deprecation")
    Drawable drawable = getResources().getDrawable(iconId);
    if (drawable != null) {
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        // 
        textView.setCompoundDrawables(null, drawable, null, null);
    }
    // 
    textView.setTextColor(color);
}

From source file:com.aldogomez.bluebird.DrawableManager.java

public Drawable fetchDrawable(String urlString) {
    if (drawableMap.containsKey(urlString)) {
        return drawableMap.get(urlString);
    }//  ww w.j av  a 2 s .com

    Log.d(this.getClass().getSimpleName(), "image url:" + urlString);
    try {
        InputStream is = fetch(urlString);
        Drawable drawable = Drawable.createFromStream(is, "src");

        if (drawable != null) {
            drawableMap.put(urlString, drawable);
            Log.d(this.getClass().getSimpleName(),
                    "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight()
                            + "," + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + ","
                            + drawable.getMinimumWidth());
        } else {
            Log.w(this.getClass().getSimpleName(), "could not get thumbnail");
        }

        return drawable;
    } catch (MalformedURLException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    } catch (IOException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    }
}

From source file:me.piebridge.prevent.ui.UserGuideActivity.java

private Drawable cropDrawable(Drawable icon) {
    int width = getPixel(0x20);
    if (icon.getMinimumWidth() > width && icon instanceof BitmapDrawable) {
        Bitmap bitmap = Bitmap.createScaledBitmap(((BitmapDrawable) icon).getBitmap(), width, width, false);
        return new BitmapDrawable(getResources(), bitmap);
    }/*from w  w w .  j  a  va2 s . co m*/
    return icon;
}

From source file:net.sarangnamu.android.DrawableManager.java

public Drawable fetchDrawable(String urlString) {
    if (drawableMap.containsKey(urlString)) {
        return drawableMap.get(urlString);
    }//w  w w.j a v a  2  s  .c o  m

    Log.d(this.getClass().getSimpleName(), "image url:" + urlString);
    try {
        InputStream is = fetch(urlString);
        Drawable drawable = null;

        drawable = Drawable.createFromStream(is, "src");

        if (drawable != null) {
            drawableMap.put(urlString, drawable);
            Log.d(this.getClass().getSimpleName(),
                    "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight()
                            + "," + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + ","
                            + drawable.getMinimumWidth());
        }
        return drawable;
    } catch (MalformedURLException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    } catch (IOException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    }
}

From source file:com.lepin.activity.MyLoveCarActivity.java

/**
 * ???/*from   ww  w .  j ava2  s . c om*/
 */
public void setVisible(boolean b) {
    if (b == true) {
        mlTitleEdit.setVisibility(View.GONE);
        Drawable drawable = getResources().getDrawable(R.drawable.arrow);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        mlType.setCompoundDrawables(null, null, drawable, null);
        mlSave.setVisibility(View.VISIBLE);
        mlEditShow.setVisibility(View.VISIBLE);
        mlSafeLayout.setVisibility(View.GONE);
    } else {
        mlTitleEdit.setVisibility(View.VISIBLE);
        mlType.setCompoundDrawables(null, null, null, null);
        mlSave.setVisibility(View.INVISIBLE);
        mlEditShow.setVisibility(View.GONE);
        mlSafeLayout.setVisibility(View.VISIBLE);
    }
}

From source file:com.neudesic.mobile.pulse.ui.drawable.DrawableManager.java

public synchronized Drawable fetchDrawable(String urlString) {
    if (drawableMap.containsKey(urlString)) {
        Log.d(getClass().getSimpleName(), "loading image from localcache");
        return drawableMap.get(urlString);
    }/*from w w  w . j  av  a2  s .c om*/

    Log.d(this.getClass().getSimpleName(), "image url:" + urlString);
    try {
        InputStream is = fetch(urlString);

        Drawable drawable = Drawable.createFromStream(is, "src");
        if (drawableMap.size() > MAX_CACHE_SIZE) {
            drawableMap.clear();
        }
        drawableMap.put(urlString, drawable);
        Log.d(this.getClass().getSimpleName(),
                "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight() + ","
                        + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + ","
                        + drawable.getMinimumWidth());
        return drawable;
    } catch (MalformedURLException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    } catch (IOException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    }
}

From source file:com.cm.beer.util.DrawableManager.java

/**
 * //from  ww  w  .ja v a  2  s  . c  om
 * @param urlString
 * @return
 */
public Drawable fetchDrawable(String urlString) {
    if (mDrawableCache.containsKey(urlString)) {
        if (Logger.isLogEnabled())
            Logger.log("Returning Drawable from Cache:" + urlString);
        SoftReference<Drawable> softReference = mDrawableCache.get(urlString);
        if ((softReference == null) || (softReference.get() == null)) {
            mDrawableCache.remove(urlString);
            if (Logger.isLogEnabled())
                Logger.log("fetchDrawable():Soft Reference has been Garbage Collected:" + urlString);
        } else {
            return softReference.get();
        }
    }

    if (Logger.isLogEnabled())
        Logger.log("image url:" + urlString);
    try {
        // prevents multithreaded fetches for the same image
        mLockCache.put(urlString, urlString);
        if (Logger.isLogEnabled())
            Logger.log("Begin Downloading:" + urlString);
        InputStream is = fetch(urlString);
        if (Logger.isLogEnabled())
            Logger.log("End Downloading:" + urlString);
        Drawable drawable = Drawable.createFromStream(is, "src");
        mDrawableCache.put(urlString, new SoftReference<Drawable>(drawable));
        mLockCache.remove(urlString);
        if (Logger.isLogEnabled())
            Logger.log("got a thumbnail drawable: " + drawable.getBounds() + ", "
                    + drawable.getIntrinsicHeight() + "," + drawable.getIntrinsicWidth() + ", "
                    + drawable.getMinimumHeight() + "," + drawable.getMinimumWidth());
        return drawable;
    } catch (Throwable e) {
        Log.e(this.getClass().getName(), "fetchDrawable failed", e);
        return null;
    }
}

From source file:com.insthub.ecmobile.component.PagerSlidingTabStrip.java

/** add one text tab */
private void addTextTab(final int position, String title, int res) {
    TextView tab = new TextView(getContext());
    tab.setText(title);//from   w ww . j  av  a2 s .c  o m
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    Drawable drawable = getResources().getDrawable(res);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
    tab.setCompoundDrawables(drawable, null, null, null);
    addTab(position, tab);
}

From source file:com.geekandroid.sdk.base.BaseFragment.java

public void setDrawablePosition(TextView textView, int left, int top, int right, int bottom) {
    Drawable drawableTop = null;
    Drawable drawableLeft = null;/*w  ww . ja  v a  2 s  .  c o  m*/
    Drawable drawableRight = null;
    Drawable drawableBottom = null;

    if (top != 0) {
        drawableTop = getResources().getDrawable(top);
    }
    if (left != 0) {
        drawableLeft = getResources().getDrawable(left);
    }
    if (right != 0) {
        drawableRight = getResources().getDrawable(right);
    }
    if (bottom != 0) {
        drawableBottom = getResources().getDrawable(bottom);
    }
    /// ??,??.
    if (drawableTop != null) {
        drawableTop.setBounds(0, 0, drawableTop.getMinimumWidth(), drawableTop.getMinimumHeight());
    }

    if (drawableLeft != null) {
        int result = convertDp(60);
        drawableLeft.setBounds(0, 0, result, result);
        //            drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
    }
    if (drawableRight != null) {
        int result = convertDp(50);
        drawableRight.setBounds(0, 0, result, result);
        //            drawableRight.setBounds(0, 0, drawableRight.getMinimumWidth(), drawableRight.getMinimumHeight());
    }
    if (drawableBottom != null) {
        drawableBottom.setBounds(0, 0, drawableBottom.getMinimumWidth(), drawableBottom.getMinimumHeight());
    }
    int result = convertDp(10);
    textView.setCompoundDrawablePadding(result);
    textView.setCompoundDrawables(drawableLeft, drawableTop, drawableRight, drawableBottom);
}