Skip to content

Commit

Permalink
Merge pull request #2 from zunix65/refactor-SynchronousMethodsNT
Browse files Browse the repository at this point in the history
Refactor synchronous methods nt
  • Loading branch information
ltrudu authored Oct 3, 2022
2 parents 3f0007b + eef7ef9 commit bdca88c
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 257 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"

//classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'

Expand Down
2 changes: 2 additions & 0 deletions datawedgeprofileintentswrapper/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.library'
//apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'org.jetbrains.kotlin.android'
group = 'com.github.ltrudu'
version = rootProject.ext.versionName

Expand Down Expand Up @@ -33,6 +34,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.zebra.datawedgeprofileintents.SynchronousMethodsNT

import android.content.Context
import android.util.Pair
import com.zebra.datawedgeprofileintents.*
import com.zebra.datawedgeprofileintents.DWSynchronousMethods.EResults

class DWSynchronousMethodsNT(private val mContext: Context) {

fun runInNewThread(methodName: String, param: Any, paramClass: Class<*>): Pair<EResults, String> {
val synchronousNTRunnable = SynchronousMethodExecutor<String>(mContext, methodName, param, paramClass, "")
synchronousNTRunnable.runInThreadAndWaitForEnd()
return synchronousNTRunnable.results
}

fun setupDWProfile(settings: DWProfileSetConfigSettings): Pair<EResults, String> {
return runInNewThread("setupDWProfile", settings, DWProfileSetConfigSettings::class.java)
}

fun enablePlugin(): Pair<EResults, String> {
return runInNewThread("enablePlugin", mContext.packageName, String::class.java)
}

fun enablePlugin(profileName: String): Pair<EResults, String> {
return runInNewThread("enablePlugin", profileName, String::class.java)
}

fun disablePlugin(): Pair<EResults, String> {
return runInNewThread("disablePlugin", mContext.packageName, String::class.java)
}

fun disablePlugin(profileName: String): Pair<EResults, String> {
return runInNewThread("disablePlugin", profileName, String::class.java)
}

fun startScan(): Pair<EResults, String> {
return runInNewThread("startScan", mContext.packageName, String::class.java)
}

fun startScan(profileName: String): Pair<EResults, String> {
return runInNewThread("startScan", profileName, String::class.java)
}

fun stopScan(): Pair<EResults, String> {
return runInNewThread("stopScan", mContext.packageName, String::class.java)
}

fun stopScan(profileName: String): Pair<EResults, String> {
return runInNewThread("stopScan", profileName, String::class.java)
}

fun profileExists(): Pair<EResults, String> {
return runInNewThread("profileExists", mContext.packageName, String::class.java)
}

fun profileExists(profileName: String): Pair<EResults, String> {
return runInNewThread("profileExists", profileName, String::class.java)
}

fun deleteProfile(): Pair<EResults, String> {
return runInNewThread("deleteProfile", mContext.packageName, String::class.java)
}

fun deleteProfile(profileName: String): Pair<EResults, String> {
return runInNewThread("deleteProfile", profileName, String::class.java)
}

fun switchBarcodeParams(settings: DWProfileSwitchBarcodeParamsSettings): Pair<EResults, String> {
return runInNewThread("switchBarcodeParams", settings, DWProfileSwitchBarcodeParamsSettings::class.java)
}

fun enumerateScanners(settings: DWEnumerateScannersSettings): Pair<EResults, List<DWEnumerateScanners.Scanner>> {
val synchronousNTRunnable = SynchronousMethodExecutor<List<DWEnumerateScanners.Scanner>>(mContext, "enumerateScanners", settings, DWEnumerateScannersSettings::class.java, emptyList())
synchronousNTRunnable.runInThreadAndWaitForEnd()
return synchronousNTRunnable.results
}
}
Loading

0 comments on commit bdca88c

Please sign in to comment.