mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
Load BitmapDrawable with getDrawable to make use of Android internal caching
This commit is contained in:
@ -6,7 +6,11 @@ export function fromResource(name: string) {
|
|||||||
if (res) {
|
if (res) {
|
||||||
var identifier: number = res.getIdentifier(name, 'drawable', androidApp.packageName);
|
var identifier: number = res.getIdentifier(name, 'drawable', androidApp.packageName);
|
||||||
if (0 < identifier) {
|
if (0 < identifier) {
|
||||||
return android.graphics.BitmapFactory.decodeResource(res, identifier);
|
// Load BitmapDrawable with getDrawable to make use of Android internal caching
|
||||||
|
var bitmapDrawable = <android.graphics.drawable.BitmapDrawable>res.getDrawable(identifier);
|
||||||
|
if (bitmapDrawable && bitmapDrawable.getBitmap) {
|
||||||
|
return bitmapDrawable.getBitmap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user