Skip to content

Commit 60d386a

Browse files
committed
cache the (static) value instead of field
1 parent 40ad66d commit 60d386a

File tree

1 file changed

+3
-3
lines changed
  • lib/src/nativescript-ngx-shadow/common

1 file changed

+3
-3
lines changed

lib/src/nativescript-ngx-shadow/common/shadow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if (isAndroid) {
2121
PlainShadow = android.graphics.drawable.GradientDrawable.extend({});
2222
}
2323

24-
const classCache: { [id: string]: { class: any, fieldCache: { [id: string]: any } } } = {};
24+
const classCache: { [id: string]: { class: any, fieldCache: { [id: string]: number } } } = {};
2525
// https://github.com/NativeScript/android-runtime/issues/1330
2626
function getAndroidR(rtype: string, field: string): number {
2727
const className = "android.R$" + rtype;
@@ -32,9 +32,9 @@ function getAndroidR(rtype: string, field: string): number {
3232
};
3333
}
3434
if(!classCache[className].fieldCache.hasOwnProperty(field)) {
35-
classCache[className].fieldCache[field] = classCache[className].class.getField(field);
35+
classCache[className].fieldCache[field] = +classCache[className].class.getField(field).get(null);
3636
}
37-
return +classCache[className].fieldCache[field].get(null);
37+
return classCache[className].fieldCache[field];
3838
}
3939

4040
export class Shadow {

0 commit comments

Comments
 (0)