-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented logic to scan and retrieve barcodes
- Loading branch information
1 parent
6da3bee
commit d8a6928
Showing
7 changed files
with
119 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...pp/src/main/java/beertastic/sanag/com/flutter_beertastic/view_model/ScannerViewModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package beertastic.sanag.com.flutter_beertastic.view_model; | ||
|
||
import android.util.Log; | ||
|
||
import androidx.lifecycle.LiveData; | ||
import androidx.lifecycle.MutableLiveData; | ||
import androidx.lifecycle.ViewModel; | ||
|
||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class ScannerViewModel extends ViewModel { | ||
private MutableLiveData<String> qrData; | ||
|
||
public ScannerViewModel(){ | ||
qrData=new MutableLiveData<>(); | ||
} | ||
|
||
public LiveData<String> getQrData() { | ||
return qrData; | ||
} | ||
|
||
public void handleScanResult(Task<List<FirebaseVisionBarcode>> listener) { | ||
if (listener.isSuccessful()) { | ||
Optional.ofNullable(listener.getResult()) | ||
.ifPresent(result -> { | ||
if (result.size() > 0) qrData.postValue(result.get(0).getRawValue()); | ||
} | ||
); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...eertastic/view_model/BarcodesScanner.java → ...tic/view_model/tools/BarcodesScanner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<integer name="beertastic_camera_request_code">200</integer> | ||
<integer name="beertastic_qr_request_code">1000000001</integer> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="qr_code_data_extra">QrCode</string> | ||
</resources> |