Avoid crashes when appid or repoUri are empty

This commit is contained in:
Daniel Martí 2013-09-26 20:16:08 +02:00
parent 40904ab75f
commit 78e2e1bcc4
3 changed files with 10 additions and 10 deletions

View File

@ -197,7 +197,6 @@ public class AppDetails extends ListActivity {
setContentView(R.layout.appdetails); setContentView(R.layout.appdetails);
Intent i = getIntent(); Intent i = getIntent();
appid = "";
Uri data = i.getData(); Uri data = i.getData();
if (data != null) { if (data != null) {
if (data.isHierarchical()) { if (data.isHierarchical()) {
@ -328,11 +327,13 @@ public class AppDetails extends ListActivity {
Log.d("FDroid", "Getting application details for " + appid); Log.d("FDroid", "Getting application details for " + appid);
app = null; app = null;
List<DB.App> apps = ((FDroidApp) getApplication()).getApps(); if (appid != null && appid.length() > 0) {
for (DB.App tapp : apps) { List<DB.App> apps = ((FDroidApp) getApplication()).getApps();
if (tapp.id.equals(appid)) { for (DB.App tapp : apps) {
app = tapp; if (tapp.id.equals(appid)) {
break; app = tapp;
break;
}
} }
} }
if (app == null) { if (app == null) {

View File

@ -89,14 +89,14 @@ public class FDroid extends FragmentActivity {
String appid = data.getQueryParameter("fdid"); String appid = data.getQueryParameter("fdid");
// If appid == null, we just browse all the apps. // If appid == null, we just browse all the apps.
// If appid != null, we browse the app specified. // If appid != null, we browse the app specified.
if (appid != null) { if (appid != null && appid.length() > 0) {
Intent call = new Intent(this, AppDetails.class); Intent call = new Intent(this, AppDetails.class);
call.putExtra("appid", appid); call.putExtra("appid", appid);
startActivityForResult(call, REQUEST_APPDETAILS); startActivityForResult(call, REQUEST_APPDETAILS);
} }
} else { } else {
String repoUri = data.getEncodedSchemeSpecificPart(); String repoUri = data.getEncodedSchemeSpecificPart();
if (repoUri != null) { if (repoUri != null && repoUri.length() > 0) {
Intent call = new Intent(this, ManageRepo.class); Intent call = new Intent(this, ManageRepo.class);
call.putExtra("repoUri", repoUri); call.putExtra("repoUri", repoUri);
startActivityForResult(call, REQUEST_MANAGEREPOS); startActivityForResult(call, REQUEST_MANAGEREPOS);

View File

@ -82,8 +82,7 @@ public class ManageRepo extends ListActivity {
Intent i = getIntent(); Intent i = getIntent();
if (i.hasExtra("repoUri")) { if (i.hasExtra("repoUri")) {
String repoUri = i.getStringExtra("repoUri"); addRepo(i.getStringExtra("repoUri"));
addRepo(repoUri);
finish(); finish();
} }