Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
Alistair Sykes edited this page Mar 12, 2019 · 2 revisions

Sample App

Getting Started

In order to run the sample app, you will need to config it to your Firebase account.

See Firebase documentation for help on this.

Note: The Google Services plugin and relevant Firebase SDK's have already been added to the appropriate build.gradle files.

Examples

In the sample app we have provided, we have 4 different implementations of the library.

XmlActivity In XmlActivity we have done a simple implementation, using the xml method. We have handled runtime permissions and are observing barcodes to receive multiple results.

XmlJavaActivity XmlJavaActivity is identical to XmlActivity except it is written in Java.

ProgrammaticActivity In ProgrammaticActivity we have implemented BarcodeView programmatically, including setting options.

Viewfinder Example

In ViewfinderFragment we have implemented the library in a more realistic way. We have used a Fragment with a ViewModel as many code bases use these as standard. In the layout fragment_viewfinder.xml we have added the BarcodeView, as expected, but also added an ImageView to act as a viewfinder, ProgressBar and a full screen alpha overlay as a scrim.

In the ViewModel we fake some processing of the barcode, for example sending it to an api. The ViewModel exposes this through a LiveData<Resource<Barcode>>. This allows the ViewModel to communicate state. Whilst there is loading we pause the BarcodeView to stop more results coming in. We then display a Toast to the user once we have a success and resume the BarcodeView.