I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit a057e4a5 authored by str4d's avatar str4d
Browse files

Show dialog if graphs are not ready

parent 7a096700
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,8 @@
<string name="action_reload">Reload</string>
<string name="hint_search_addressbook">Search addressbook</string>
<string name="graphs_not_ready">Graphs are not ready, or the router is not running. Try again later.</string>
<string name="menu_settings">Settings</string>
<string name="settings_enable">Enable</string>
<string name="settings_desc_subscriptions">Subscription URLs</string>
......
......@@ -9,7 +9,11 @@ import net.i2p.android.router.fragment.GraphFragment;
import net.i2p.android.router.service.StatSummarizer;
import net.i2p.android.router.service.SummaryListener;
import net.i2p.stat.Rate;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.ActionBar;
import android.widget.ArrayAdapter;
import android.widget.SpinnerAdapter;
......@@ -21,13 +25,14 @@ public class GraphActivity extends I2PActivityBase {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up action bar for drop-down list
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
mDrawerToggle.setDrawerIndicatorEnabled(false);
if (StatSummarizer.instance() != null) {
// Set up action bar for drop-down list
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
// Get the rates currently being graphed
List<SummaryListener> listeners = StatSummarizer.instance().getListeners();
TreeSet<SummaryListener> ordered = new TreeSet<SummaryListener>(new AlphaComparator());
ordered.addAll(listeners);
......@@ -64,6 +69,22 @@ public class GraphActivity extends I2PActivityBase {
int selected = savedInstanceState.getInt(SELECTED_RATE);
actionBar.setSelectedNavigationItem(selected);
}
} else {
DialogFragment df = new DialogFragment() {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(R.string.graphs_not_ready)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
});
return builder.create();
}
};
df.show(getSupportFragmentManager(), "nographs");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment