File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
lib/src/nativescript-ngx-shadow/common Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,20 @@ if (isAndroid) {
2121 PlainShadow = android . graphics . drawable . GradientDrawable . extend ( { } ) ;
2222}
2323
24+ const classCache : { [ id : string ] : { class : any , fieldCache : { [ id : string ] : any } } } = { } ;
2425// https://github.com/NativeScript/android-runtime/issues/1330
2526function getAndroidR ( rtype : string , field : string ) : number {
26- return + java . lang . Class . forName ( "android.R$" + rtype ) . getField ( field ) . get ( null ) ;
27+ const className = "android.R$" + rtype ;
28+ if ( ! classCache . hasOwnProperty ( className ) ) {
29+ classCache [ className ] = {
30+ class : java . lang . Class . forName ( className ) ,
31+ fieldCache : { }
32+ } ;
33+ }
34+ if ( ! classCache [ className ] . fieldCache . hasOwnProperty ( field ) ) {
35+ classCache [ className ] . fieldCache [ field ] = classCache [ className ] . class . getField ( field ) ;
36+ }
37+ return + classCache [ className ] . fieldCache [ field ] . get ( null ) ;
2738}
2839
2940export class Shadow {
@@ -202,7 +213,7 @@ export class Shadow {
202213 nativeView . layer . shouldRasterize = data . rasterize ;
203214 nativeView . layer . rasterizationScale = screen . mainScreen . scale ;
204215 let shadowPath = null ;
205- if ( data . useShadowPath ) {
216+ if ( data . useShadowPath ) {
206217 shadowPath = UIBezierPath . bezierPathWithRoundedRectCornerRadius ( nativeView . bounds , nativeView . layer . shadowRadius ) . cgPath ;
207218 }
208219 nativeView . layer . shadowPath = shadowPath ;
You can’t perform that action at this time.
0 commit comments