You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am triying to extend a native android class but I am facing some difficulties. I try to extend the nativescript-drawingpad plugin based on android-signaturepad native plugin to avoid some memory leaks.
My goal is to overwrite some methods in the native class "com.github.gcacace.signaturepad.views.SignaturePad".
my first step is to extend the nativescript plugin like this to use a CustomSignaturePad object intead of the com.github.gcacace.signaturepad.views.SignaturePad:
import { DrawingPad as DrawingPadVendor } from "nativescript-drawingpad";
export class DrawingPad extends DrawingPadVendor {
public createNativeView() {
const signaturePad = new CustomSignaturePad(this._context, null);
if (this.penColor) {
signaturePad.setPenColor(this.penColor.android);
}
if (this.penWidth) {
signaturePad.setMinWidth(this.penWidth);
}
return signaturePad;
}
}
next step is to create the new CustomSignaturePad class:
here it the first typescript issue: super(context, attrs); cause a "call target does not contain any signatures" error. This error can be fixed with a little workaround described here microsoft/TypeScript#17032 . declartion is now: class CustomSignaturePad extends (com.github.gcacace.signaturepad.views.SignaturePad as { new(context, attrs):any; }) { }
This code works (no error), but there is still 2 issues:
clear() function, called from nativescript plugin is executed but clearView() function, called in the native clear() method is not used (if I log something it doesn't display anything). -> Is it possible to overwrite a method that is called in native androd class?
I can't have access to android class private properties, I tried this.property and this.super.property but it doesn't works -> is it possible to access this properties?
Hey @Serge-SDL, NativeScript does not officially support extending of extended native classes in TypeScript - which appears to be the case with DrawingPad extending DrawingPadVendor.
This code works (no error), but there is still 2 issues:
From @Serge-SDL on November 1, 2017 18:21
Hi!
I am triying to extend a native android class but I am facing some difficulties. I try to extend the nativescript-drawingpad plugin based on android-signaturepad native plugin to avoid some memory leaks.
My goal is to overwrite some methods in the native class "com.github.gcacace.signaturepad.views.SignaturePad".
my first step is to extend the nativescript plugin like this to use a CustomSignaturePad object intead of the com.github.gcacace.signaturepad.views.SignaturePad:
next step is to create the new CustomSignaturePad class:
here it the first typescript issue:
super(context, attrs);
cause a "call target does not contain any signatures" error. This error can be fixed with a little workaround described here microsoft/TypeScript#17032 . declartion is now:class CustomSignaturePad extends (com.github.gcacace.signaturepad.views.SignaturePad as { new(context, attrs):any; }) { }
This code works (no error), but there is still 2 issues:
Thank you for your help!
serge
Copied from original issue: NativeScript/NativeScript#5022
The text was updated successfully, but these errors were encountered: