From 00d91d4caa811eb33eaf543813c893021955d355 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 13 Jan 2016 17:36:02 -0800 Subject: Fix some misc crashes --- .../java/github/daneren2005/dsub/activity/SubsonicActivity.java | 7 ++++++- .../java/github/daneren2005/dsub/adapter/EntryGridAdapter.java | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java index f9c14439..793d976f 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -537,7 +537,7 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte public void onItemSelected(AdapterView parent, View view, int position, long id) { int top = spinnerAdapter.getCount() - 1; if(position < top) { - for(int i = top; i > position; i--) { + for(int i = top; i > position && i >= 0; i--) { removeCurrent(); } } @@ -751,6 +751,11 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte recreateSpinner(); } public void removeCurrent() { + // Don't try to remove current if there is no backstack to remove from + if(backStack.isEmpty()) { + return; + } + if(currentFragment != null) { currentFragment.setPrimaryFragment(false); } diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java index 5693ba56..71e78e4b 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java @@ -19,6 +19,7 @@ import android.content.Context; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; @@ -149,8 +150,11 @@ public class EntryGridAdapter extends SectionAdapter { } if(!selected.isEmpty()) { - boolean isStarred = selected.get(0).isStarred(); - menu.findItem(R.id.menu_star).setTitle(isStarred ? R.string.common_unstar : R.string.common_star); + MenuItem starItem = menu.findItem(R.id.menu_star); + if(starItem != null) { + boolean isStarred = selected.get(0).isStarred(); + starItem.setTitle(isStarred ? R.string.common_unstar : R.string.common_star); + } } } } -- cgit v1.2.3