Changeset View
Changeset View
Standalone View
Standalone View
app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | private final ActivityResultLauncher<BarcodeScanOptions> barcodeLauncher = registerForActivityResult(new BarcodeScanContract(), | ||||
result -> { | result -> { | ||||
if(result!=null && result.getContents()!=null) { | if(result!=null && result.getContents()!=null) { | ||||
//Toast.makeText(MyActivity.this, "Cancelled", Toast.LENGTH_LONG).show(); | //Toast.makeText(MyActivity.this, "Cancelled", Toast.LENGTH_LONG).show(); | ||||
Uri uri; | Uri uri; | ||||
try { | try { | ||||
uri = Uri.parse(result.getContents()); // this apparently prevents NullPointerException. Somehow. | uri = Uri.parse(result.getContents()); // this apparently prevents NullPointerException. Somehow. | ||||
} catch (NullPointerException e) { | } catch (NullPointerException e) { | ||||
if (getContext()!=null) | if (getContext()!=null) | ||||
Toast.makeText(getContext().getApplicationContext(), | Toast.makeText(getContext().getApplicationContext(), | ||||
R.string.no_qrcode, Toast.LENGTH_SHORT).show(); | R.string.no_qrcode, Toast.LENGTH_SHORT).show(); | ||||
return; | return; | ||||
} | } | ||||
String busStopID = getBusStopIDFromUri(uri); | String busStopID = getBusStopIDFromUri(uri); | ||||
busStopSearchByIDEditText.setText(busStopID); | busStopSearchByIDEditText.setText(busStopID); | ||||
requestArrivalsForStopID(busStopID); | requestArrivalsForStopID(busStopID); | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 735 Lines • Show Last 20 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register