Skip to content

Commit 8b108d8

Browse files
committed
chore: refactor
1 parent a82f1b4 commit 8b108d8

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/ui-canvas/index.android.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { FontStyleType, FontWeightType } from '@nativescript/core/ui/styling/fon
99
declare global {
1010
const __runtimeVersion: string;
1111
}
12-
const sdkVersion = lazy(() => parseInt(Device.sdkVersion, 10));
12+
const sdkVersion = parseInt(Device.sdkVersion, 10);
1313

1414
export * from './index.common';
1515
export {
@@ -34,13 +34,6 @@ export {
3434
PorterDuffXfermode
3535
};
3636

37-
let SDK_INT = -1;
38-
function getSDK() {
39-
if (SDK_INT === -1) {
40-
SDK_INT = android.os.Build.VERSION.SDK_INT;
41-
}
42-
return SDK_INT;
43-
}
4437

4538
export function parseDashEffect(value: string) {
4639
const array = value.split(' ').map(parseFloat);
@@ -234,9 +227,9 @@ export class Paint extends ProxyClass<android.graphics.Paint> {
234227
}
235228
this.mNeedsFontUpdate = true;
236229
return this.mFontInternal;
237-
} else if (methodName === 'setLetterSpacing' && sdkVersion() < 21) {
230+
} else if (methodName === 'setLetterSpacing' && sdkVersion < 21) {
238231
return true;
239-
} else if (methodName === 'getLetterSpacing' && sdkVersion() < 21) {
232+
} else if (methodName === 'getLetterSpacing' && sdkVersion < 21) {
240233
return 0;
241234
}
242235
}
@@ -546,15 +539,15 @@ class CanvasView extends CanvasBase {
546539
nativeViewProtected: com.akylas.canvas.CanvasView;
547540
createNativeView() {
548541
const view = new com.akylas.canvas.CanvasView(this._context);
549-
if (getSDK() >= 28) {
542+
if (sdkVersion >= 28) {
550543
view.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
551544
} else {
552545
view.setLayerType(android.view.View.LAYER_TYPE_SOFTWARE, null);
553546
}
554547
return view;
555548
}
556549
[hardwareAcceleratedProperty.getDefault](value) {
557-
return getSDK() >= 28;
550+
return sdkVersion >= 28;
558551
}
559552

560553
[hardwareAcceleratedProperty.setNative](value) {

0 commit comments

Comments
 (0)