Skip to content

Add new functions #5

@ickaim

Description

@ickaim

Thank you so much for your plugin. Please, can you add these new function asap? This plugin really needs function for cut paper.

In SunmiPlugin.java:
@PluginMethod(returnType = PluginMethod.RETURN_NONE)
public void cutPaper(PluginCall call) throws RemoteException {
if (mPrinterService != null) {
mPrinterService.cutPaper(new InnerResultCallback() {
@OverRide
public void onRunResult(boolean isSuccess) {
Log.d(TAG, String.format("InnerResultCallback#onRunResult() %b", isSuccess));
}

            @Override
            public void onReturnString(String result) {
                Log.d(TAG, String.format("InnerResultCallback#onReturnString() %s", result));
            }

            @Override
            public void onRaiseException(int code, String msg) {
                Log.e(TAG, String.format("InnerResultCallback#onRaiseException() %s, %d", msg, code));

                call.reject(msg, String.valueOf(code));
            }

            @Override
            public void onPrintResult(int code, String msg) {
                if (code == 0) {
                    Log.d(TAG, String.format("InnerResultCallback#onPrintResult() %s, %d", msg, code));

                    call.resolve();
                } else {
                    Log.e(TAG, String.format("InnerResultCallback#onPrintResult() %s, %d", msg, code));

                    call.reject(msg, String.valueOf(code));
                }
            }
        });
    }
}

@PluginMethod(returnType = PluginMethod.RETURN_NONE)
public void printBarcode(PluginCall call) throws RemoteException {
    if (mPrinterService != null) {
        String data = call.getString("data");
        int size = call.getInt("size");
        int errorlevel = call.getInt("errorlevel");
        mPrinterService.printQRCode(data, size, errorlevel, null);
    }
}

In definitions.ts :
cutPaper(): void
printBarcode(options: {
data: string;
size: 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16;
errorlevel: 0 | 1 | 2 | 3;
}): void;

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions