1111import android .content .pm .PackageManager ;
1212import android .os .SystemClock ;
1313import android .os .Vibrator ;
14+ import android .support .annotation .StringRes ;
1415import android .support .design .widget .CoordinatorLayout ;
15- import android .support .design .widget .Snackbar ;
1616import android .support .v4 .app .ActivityCompat ;
1717import android .support .v7 .app .AlertDialog ;
1818import android .text .InputType ;
1919import android .util .AttributeSet ;
2020import android .view .KeyEvent ;
21- import android .view .LayoutInflater ;
2221import android .view .View ;
2322import android .widget .EditText ;
2423import android .widget .LinearLayout ;
3736import io .snabble .sdk .ui .SnabbleUICallback ;
3837import io .snabble .sdk .ui .telemetry .Telemetry ;
3938import io .snabble .sdk .ui .utils .DelayedProgressDialog ;
40- import io .snabble .sdk .ui .utils .OneShotClickListener ;
4139import io .snabble .sdk .ui .utils .UIUtils ;
4240import io .snabble .sdk .utils .SimpleActivityLifecycleCallbacks ;
4341import io .snabble .sdk .utils .Utils ;
@@ -160,20 +158,17 @@ public void onShow(DialogInterface dialog) {
160158 public void lookupAndShowProduct (final ScannableCode scannedCode ) {
161159 productDialog .dismiss ();
162160 ignoreNextDialog = false ;
161+ pauseBarcodeScanner ();
163162
164163 if (scannedCode .hasEmbeddedData () && !scannedCode .isEmbeddedDataOk ()){
165164 delayNextScan ();
166165
167166 Telemetry .event (Telemetry .Event .ScannedUnknownCode , scannedCode .getCode ());
168- UIUtils .snackbar (SelfScanningView .this ,
169- R .string .Snabble_Scanner_unknownBarcode ,
170- UIUtils .SNACKBAR_LENGTH_VERY_LONG )
171- .show ();
167+ showInfo (R .string .Snabble_Scanner_unknownBarcode );
172168 return ;
173169 }
174170
175171 progressDialog .showAfterDelay (300 );
176- pauseBarcodeScanner ();
177172
178173 if (scannedCode .hasEmbeddedData ()){
179174 productDatabase .findByWeighItemIdOnline (scannedCode .getLookupCode (), new OnProductAvailableListener () {
@@ -240,13 +235,10 @@ private void handleProductAvailable(Product product, boolean wasOnlineProduct, S
240235 showBundleDialog (product );
241236 } else {
242237 if (product .getType () == Product .Type .PreWeighed && !scannedCode .hasEmbeddedData ()) {
243- UIUtils .snackbar (SelfScanningView .this ,
244- R .string .Snabble_Scanner_scannedShelfCode ,
245- UIUtils .SNACKBAR_LENGTH_VERY_LONG )
246- .show ();
238+
239+ showInfo (R .string .Snabble_Scanner_scannedShelfCode );
247240
248241 progressDialog .dismiss ();
249- resumeBarcodeScanner ();
250242 delayNextScan ();
251243 } else {
252244 showProduct (product , scannedCode );
@@ -262,25 +254,27 @@ private void handleProductAvailable(Product product, boolean wasOnlineProduct, S
262254
263255 private void handleProductNotFound (ScannableCode scannedCode ) {
264256 progressDialog .dismiss ();
265- resumeBarcodeScanner ();
266257 delayNextScan ();
267258
268259 Telemetry .event (Telemetry .Event .ScannedUnknownCode , scannedCode .getCode ());
269- UIUtils .snackbar (SelfScanningView .this ,
270- R .string .Snabble_Scanner_unknownBarcode ,
271- UIUtils .SNACKBAR_LENGTH_VERY_LONG )
272- .show ();
260+
261+ showInfo (R .string .Snabble_Scanner_unknownBarcode );
273262 }
274263
275264 private void handleProductError () {
276265 progressDialog .dismiss ();
277- resumeBarcodeScanner ();
278266 delayNextScan ();
279267
280- UIUtils .snackbar (SelfScanningView .this ,
281- R .string .Snabble_Scanner_networkError ,
282- UIUtils .SNACKBAR_LENGTH_VERY_LONG )
283- .show ();
268+ showInfo (R .string .Snabble_Scanner_networkError );
269+ }
270+
271+ private void showInfo (@ StringRes int resId ) {
272+ UIUtils .info (getContext (), resId , new DialogInterface .OnDismissListener () {
273+ @ Override
274+ public void onDismiss (DialogInterface dialog ) {
275+ resumeBarcodeScanner ();
276+ }
277+ });
284278 }
285279
286280 private void onClickEnterBarcode () {
0 commit comments