From 4567c97e526154394874b971a29f66c9ca22e6f2 Mon Sep 17 00:00:00 2001 From: Sean Leonard Date: Tue, 5 Feb 2013 10:35:36 -0700 Subject: Move Dashboard view building code into a function so it does not run when we have no config (createed NullPointerExceptions) --- src/se/leap/leapclient/Dashboard.java | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src/se') diff --git a/src/se/leap/leapclient/Dashboard.java b/src/se/leap/leapclient/Dashboard.java index 7bb71c1e..a7e84eef 100644 --- a/src/se/leap/leapclient/Dashboard.java +++ b/src/se/leap/leapclient/Dashboard.java @@ -36,21 +36,12 @@ public class Dashboard extends Activity { preferences = getPreferences(MODE_PRIVATE); - // FIXME We need to StartActivityForResult and move the rest to buildDashboard (called in "else" and onActivityResult) - if ( !preferences.contains("provider") ) + // Check if we have preferences, run configuration wizard if not + // TODO We should do a better check for config that this! + if (!preferences.contains("provider") ) startActivity(new Intent(this, ProviderListActivity.class)); - - // Get our provider - provider = Provider.getInstance(preferences); - - // Set provider name in textview - providerNameTV = (TextView) findViewById(R.id.providerName); - providerNameTV.setText(provider.getName()); - providerNameTV.setTextSize(28); // TODO maybe to some calculating, or a marquee? - - // TODO Inflate layout fragments for provider's services - if ( provider.hasEIP() ) - serviceItemEIP(); + else + buildDashboard(); } // FIXME!! We don't want you around here once we have something /real/ going on @@ -99,6 +90,20 @@ public class Dashboard extends Activity { fakes.putString("eip", eipjson); fakes.commit(); } + + private void buildDashboard() { + // Get our provider + provider = Provider.getInstance(preferences); + + // Set provider name in textview + providerNameTV = (TextView) findViewById(R.id.providerName); + providerNameTV.setText(provider.getName()); + providerNameTV.setTextSize(28); // TODO maybe to some calculating, or a marquee? + + // TODO Inflate layout fragments for provider's services + if ( provider.hasEIP() ) + serviceItemEIP(); + } private void serviceItemEIP() { // FIXME Provider service (eip/openvpn) -- cgit v1.2.3