Advertisement
parabola949

Untitled

Oct 25th, 2011
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. /**
  2.      * Return a drawable object associated with a particular resource ID.
  3.      * Various types of objects will be returned depending on the underlying
  4.      * resource -- for example, a solid color, PNG image, scalable image, etc.
  5.      * The Drawable API hides these implementation details.
  6.      *
  7.      * mtwebster: This version also applies a Porter Duff color mask onto the object before
  8.      * returning the object. Put in Resources to give reusability, I plan on
  9.      * applying this to other parts of the gui
  10.      *
  11.      * @param id The desired resource identifier, as generated by the aapt tool.
  12.      *            This integer encodes the package, type, and resource entry.
  13.      *            The value 0 is an invalid identifier.
  14.      * @param mask The color mask to use (alpha-r-g-b)
  15.      * @param masktype The Porter Duff filter mode
  16.      * @throws NotFoundException Throws NotFoundException if the given ID does
  17.      *             not exist.
  18.      * @return Drawable An object that can be used to draw this resource.
  19.      * @hide
  20.      */
  21.     public Drawable getDrawable(int id, int mask, Mode maskType) throws NotFoundException {
  22.         synchronized (mTmpValue) {
  23.             TypedValue value = mTmpValue;
  24.             getValue(id, value, true);
  25.             Drawable tmpDrawable = loadDrawable(value, id);
  26.             tmpDrawable.setColorFilter(mask, maskType);
  27.             return tmpDrawable;
  28.         }
  29.     }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement