Created
April 12, 2015 10:49
-
-
Save searover/20facc48a097191c8301 to your computer and use it in GitHub Desktop.
TypedArray Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Container for an array of values that were retrieved with | |
* {@link Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)} | |
* or {@link Resources#obtainAttributes}. Be | |
* sure to call {@link #recycle} when done with them. | |
* | |
* The indices used to retrieve values from this structure correspond to | |
* the positions of the attributes given to obtainStyledAttributes. | |
*/ | |
public class TypedArray { | |
static TypedArray obtain(Resources res, int len) { | |
final TypedArray attrs = res.mTypedArrayPool.acquire(); | |
if (attrs != null) { | |
attrs.mLength = len; | |
attrs.mRecycled = false; | |
final int fullLen = len * AssetManager.STYLE_NUM_ENTRIES; | |
if (attrs.mData.length >= fullLen) { | |
return attrs; | |
} | |
attrs.mData = new int[fullLen]; | |
attrs.mIndices = new int[1 + len]; | |
return attrs; | |
} | |
return new TypedArray(res, | |
new int[len*AssetManager.STYLE_NUM_ENTRIES], | |
new int[1+len], len); | |
} | |
// Other members ...... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment