From 3a30d76c351ffedaaf31622d2719b88cf26cf0f5 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Tue, 25 Jun 2024 17:58:08 +0200 Subject: [PATCH] Added Callback Interface --- PrintWrapper/build.gradle | 4 ++-- .../printwrapper/GetPrinterStatusTask.java | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/PrintWrapper/build.gradle b/PrintWrapper/build.gradle index 8bc6bdd..804c1ee 100644 --- a/PrintWrapper/build.gradle +++ b/PrintWrapper/build.gradle @@ -17,8 +17,8 @@ android { defaultConfig { minSdkVersion 25 targetSdkVersion 33 - versionCode 7 - versionName "1.6" + versionCode 9 + versionName "1.8" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" diff --git a/PrintWrapper/src/main/java/com/zebra/printwrapper/GetPrinterStatusTask.java b/PrintWrapper/src/main/java/com/zebra/printwrapper/GetPrinterStatusTask.java index d3aca42..e2a484e 100644 --- a/PrintWrapper/src/main/java/com/zebra/printwrapper/GetPrinterStatusTask.java +++ b/PrintWrapper/src/main/java/com/zebra/printwrapper/GetPrinterStatusTask.java @@ -9,7 +9,13 @@ import com.zebra.sdk.printer.discovery.DiscoveredPrinter; public class GetPrinterStatusTask extends ExecutorTask{ - public PrinterStatus printerStatus = null; + + public interface GetPrinterStatusTaskCallback + { + void onPrinterStatus(PrinterStatus status); + } + + GetPrinterStatusTaskCallback getPrinterStatusTaskCallback = null; @Override protected PrinterStatus doInBackground(DiscoveredPrinter... printerParams) { @@ -47,7 +53,15 @@ protected PrinterStatus doInBackground(DiscoveredPrinter... printerParams) { @Override protected void onPostExecute(PrinterStatus printerStatus) { + if(getPrinterStatusTaskCallback != null) + { + getPrinterStatusTaskCallback.onPrinterStatus(printerStatus); + } super.onPostExecute(printerStatus); - this.printerStatus = printerStatus; + } + + public void setGetPrinterStatusTaskCallback(GetPrinterStatusTaskCallback getPrinterStatusTaskCallback) + { + this.getPrinterStatusTaskCallback = getPrinterStatusTaskCallback; } }