diff --git a/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Activity_Main.java b/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Activity_Main.java index 698b5ab3..59316062 100644 --- a/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Activity_Main.java +++ b/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Activity_Main.java @@ -117,10 +117,6 @@ public void onCreate(Bundle savedInstanceState) { */ public void onLoadFinished() { preloading = false; - - // Inflate menu if not already done - if (!optionsMenuLoaded) - createOptionsMenu(); // Ask the user to rate the app AlertDialog.Builder builder = new AlertDialog.Builder(this) @@ -155,17 +151,19 @@ public void onClick(View view) { } else findViewById(R.id.setDefaultActivity).setVisibility(View.GONE); } else { - switch (muninFoo.getSettings().getString(Settings.PrefKeys.DefaultActivity)) { + switch (settings.getString(Settings.PrefKeys.DefaultActivity)) { case "grid": { mainFragment = MainFragment.GRID; findViewById(R.id.empty_layout).setVisibility(View.GONE); findViewById(R.id.fragment_container).setVisibility(View.VISIBLE); + // Prepare fragment + boolean autoLoad = settings.getBool(Settings.PrefKeys.DefaultActivity_Grid_AutoloadGraphs); fragment = new Fragment_Grid(); Bundle bundle = new Bundle(); int gridId = muninFoo.getSettings().getInt(Settings.PrefKeys.DefaultActivity_GridId); bundle.putLong(Fragment_Grid.ARG_GRIDID, gridId); - bundle.putBoolean(Fragment_Grid.ARG_AUTOLOAD, settings.getBool(Settings.PrefKeys.DefaultActivity_Grid_AutoloadGraphs)); + bundle.putBoolean(Fragment_Grid.ARG_AUTOLOAD, autoLoad); fragment.setArguments(bundle); getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, fragment).commit(); break; @@ -201,6 +199,10 @@ public void onClick(View view) { dh.reset(); if (mainFragment == MainFragment.NONE) dh.toggle(); + + // Inflate menu if not already done + if (!optionsMenuLoaded) + createOptionsMenu(); } @Override @@ -310,6 +312,11 @@ private void createOptionsMenu() { // _refresh and _changePeriod are set visible when the user hits the "Load" button menu_grid_refresh = menu.findItem(R.id.menu_grid_refresh); menu_grid_changePeriod = menu.findItem(R.id.menu_grid_period); + // If autoLoad, toggle their visibility + if (settings.getString(Settings.PrefKeys.DefaultActivity, "none").equals("grid") + && settings.getBool(Settings.PrefKeys.DefaultActivity_Grid_AutoloadGraphs)) { + onManualLoad(); + } // Alerts menu.findItem(R.id.menu_alerts_refresh).setVisible(mainFragment == MainFragment.ALERTS); diff --git a/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Fragment_Grid.java b/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Fragment_Grid.java index 8ea14a2b..e62584bc 100644 --- a/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Fragment_Grid.java +++ b/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Fragment_Grid.java @@ -115,9 +115,7 @@ public void onClick(View v) { if (autoLoad && grid.getItems().isEmpty()) edit(); - if (autoLoad) - activity.onManualLoad(); - else { + if (!autoLoad) { view.findViewById(R.id.manual_load).setVisibility(View.VISIBLE); view.findViewById(R.id.manual_load_action).setOnClickListener(new View.OnClickListener() { @Override