diff options
author | Scott Jackson <daneren2005@gmail.com> | 2016-01-13 17:36:02 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2016-01-13 17:36:02 -0800 |
commit | 00d91d4caa811eb33eaf543813c893021955d355 (patch) | |
tree | 791767dda16139355c392c6c05f0bbc86db46eb4 /app/src/main/java | |
parent | bc2a7d3674903b8fba986135f7ca3327bac99d6b (diff) | |
download | dsub-00d91d4caa811eb33eaf543813c893021955d355.tar.gz dsub-00d91d4caa811eb33eaf543813c893021955d355.tar.bz2 dsub-00d91d4caa811eb33eaf543813c893021955d355.zip |
Fix some misc crashes
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java | 7 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java | 8 |
2 files changed, 12 insertions, 3 deletions
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<Entry> { } 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); + } } } } |