Browse Source

Prevent crash when returning empty (like a cancelled scan) from the barcode scanner. Fixes #209.

pull/222/merge
Eric Kok 10 years ago
parent
commit
cf631082d2
  1. 2
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java

2
app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java

@ -774,10 +774,12 @@ public class TorrentsActivity extends ActionBarActivity implements TorrentTasksE
@Background @Background
@OnActivityResult(BarcodeHelper.ACTIVITY_BARCODE_ADDTORRENT) @OnActivityResult(BarcodeHelper.ACTIVITY_BARCODE_ADDTORRENT)
public void onBarcodeScanned(int resultCode, Intent data) { public void onBarcodeScanned(int resultCode, Intent data) {
if (data != null) {
// We receive from the helper either a URL (as string) or a query we can start a search for // We receive from the helper either a URL (as string) or a query we can start a search for
String query = BarcodeHelper.handleScanResult(resultCode, data, navigationHelper.enableSearchUi()); String query = BarcodeHelper.handleScanResult(resultCode, data, navigationHelper.enableSearchUi());
onBarcodeScanHandled(data.getStringExtra("SCAN_RESULT"), query); onBarcodeScanHandled(data.getStringExtra("SCAN_RESULT"), query);
} }
}
@UiThread @UiThread
protected void onBarcodeScanHandled(String barcode, String result) { protected void onBarcodeScanHandled(String barcode, String result) {

Loading…
Cancel
Save