aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-03-20 19:56:55 -0700
committerScott Jackson <daneren2005@gmail.com>2015-03-20 19:56:55 -0700
commite2d272e905c0350af19a773c80a29270cde3e5d4 (patch)
tree7ec2ef4355f9fe94eef6941d867471e052cfcfb4
parent9736e06e4a3edef265241500a6ce31444327edf0 (diff)
downloaddsub-e2d272e905c0350af19a773c80a29270cde3e5d4.tar.gz
dsub-e2d272e905c0350af19a773c80a29270cde3e5d4.tar.bz2
dsub-e2d272e905c0350af19a773c80a29270cde3e5d4.zip
Add try/catch blocks to create options menu in case called before context is valid
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java6
-rw-r--r--src/github/daneren2005/dsub/fragments/MainFragment.java8
2 files changed, 11 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index e3094546..d5821dac 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -348,7 +348,11 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
if(drawerOpen) {
menuInflater.inflate(R.menu.drawer_menu, menu);
} else if(currentFragment != null) {
- currentFragment.onCreateOptionsMenu(menu, menuInflater);
+ try {
+ currentFragment.onCreateOptionsMenu(menu, menuInflater);
+ } catch(Exception e) {
+ Log.w(TAG, "Error on creating options menu", e);
+ }
}
return true;
}
diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java
index 7225f551..fb36c9e3 100644
--- a/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -78,8 +78,12 @@ public class MainFragment extends SubsonicFragment {
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
menuInflater.inflate(R.menu.main, menu);
- if(!ServerInfo.isMadsonic(context) || !UserUtil.isCurrentAdmin()) {
- menu.setGroupVisible(R.id.madsonic, false);
+ try {
+ if (!ServerInfo.isMadsonic(context) || !UserUtil.isCurrentAdmin()) {
+ menu.setGroupVisible(R.id.madsonic, false);
+ }
+ } catch(Exception e) {
+ Log.w(TAG, "Error on setting madsonic invisible", e);
}
}