Skip to content

Al-Hussein-96/RxZebraScanner

Repository files navigation

RxZebraScanner

Integrate EMDK zebra scanner with reactive programming (RxJava).

see project on GitHub.

Download

First add kotlin to your project, in build.gradle project level:

allprojects {
    repositories {
        mavenCentral()
        ...
    }
}

Then add this line to build.gradle app module level:

dependencies {
	implementation 'io.github.Al-Hussein-96:RxZebraScanner:1.0'
}

For maven

<dependency>
    <groupId>io.github.Al-Hussein-96</groupId>
    <artifactId>RxZebraScanner</artifactId>
    <version>1.0</version>
</dependency>

How to use it without Hilt:

  • How to initialize:
val rxZebraScanner = RxZebraScanner(applicationContext)
  • Use rxZebraScanner with RxJava
rxZebraScanner.getScannerAsObserve().subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread()).subscribe() {
        Toast.makeText(applicationContext, it, Toast.LENGTH_SHORT).show()
    }

How to use it with Hilt:

  • note: if you want full example change branch from master to hilt

after adding the hilt library...

  • Create class which extends from RxZebraScanner and Inject it by hilt:
@Singleton
class ZebraClient @Inject constructor(@ApplicationContext  context: Context) : RxZebraScanner(context)
  • Use ZebraClient with RxJava
zebraClient.getScannerAsObserve().throttleFirst(2000, TimeUnit.MILLISECONDS).subscribe {
    Timber.i("BASE_SCANNER: %s", it)

    /**
     * Handle scanned qr code here
     */

}

TODO

  • Complete working on it

LICENSE


Copyright 2022 Mohammad AlHussain

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Integrate EMDK zebra scanner with reactive programming (RxJava).

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages