List of utility methods to do Drawable Create
Drawable | loadDrawable(final String imageUrl, final ImageView imageView, final ImageCallback imageCallback) load Drawable Log.d(TAG, "loadDrawable(), url = " + imageUrl); if (imageCache.containsKey(imageUrl)) { SoftReference<Drawable> softReference = imageCache .get(imageUrl); Drawable drawable = softReference.get(); if (drawable != null) { Log.w(TAG, "loadDrawable(), find url incache: " + imageUrl); return drawable; ... |
Drawable | getDrawableById(Context paramContext, String paramString) get Drawable By Id return paramContext.getResources().getDrawable(
getDrawableId(paramContext, paramString));
|
Drawable | getDrawableFromUrl(String url) get Drawable From Url return Drawable.createFromStream(getRequest(url), null);
|
StateListDrawable | getPressedDrawable(int color) get Pressed Drawable StateListDrawable drawable = new StateListDrawable(); drawable.addState(new int[] { R.attr.state_pressed }, new ColorDrawable(color)); return drawable; |
Bitmap | getDrawableByName(Context ctx, String name) get Drawable By Name BitmapFactory.Options options = new BitmapFactory.Options(); Bitmap bitmap = BitmapFactory.decodeResource( ctx.getResources(), ctx.getResources().getIdentifier(name, "drawable", ctx.getPackageName()), options); return bitmap; |
Drawable | getDrawable(final Context context, final String packageName, final int resourceID) get Drawable Drawable drawable = null; Context remoteContext = null; try { remoteContext = context.createPackageContext(packageName, 0); drawable = remoteContext.getResources().getDrawable(resourceID); } catch (final NameNotFoundException e) { e.printStackTrace(); return drawable; |
TransitionDrawable | drawableToTransitionDrawable( Drawable drawable) drawable To Transition Drawable TransitionDrawable mBitmapDrawable = null; try { if (drawable == null) { return null; mBitmapDrawable = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); ... |
File | createTempImageFile(Context context, Drawable drawable) create Temp Image File File cacheDir = context.getCacheDir(); File file = null; try { if (!cacheDir.isDirectory() || !cacheDir.exists()) cacheDir.mkdir(); } catch (Exception e) { Toast.makeText(context, "Create Folder Error about Cache Directory", ... |
Drawable | loadImageFromUrl(String url) load Image From Url URL m; InputStream i = null; try { m = new URL(url); i = (InputStream) m.getContent(); } catch (MalformedURLException e1) { e1.printStackTrace(); } catch (IOException e) { ... |