From 1fe78d00244f52f903435c970c0ebf0071a08f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 14 Jan 2014 19:44:10 +0100 Subject: No sharedprefs methods in ConfigHelper. This means we obtain the SharedPreferences object each time we want to use it. This yields to longer code lines while reading and writing to them. --- src/se/leap/bitmaskclient/EIP.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/se/leap/bitmaskclient/EIP.java') diff --git a/src/se/leap/bitmaskclient/EIP.java b/src/se/leap/bitmaskclient/EIP.java index 2b7fd39f..25ea88f7 100644 --- a/src/se/leap/bitmaskclient/EIP.java +++ b/src/se/leap/bitmaskclient/EIP.java @@ -96,13 +96,7 @@ public final class EIP extends IntentService { context = getApplicationContext(); - try { - eipDefinition = ConfigHelper.getJsonFromSharedPref(KEY); - parsedEipSerial = ConfigHelper.getIntFromSharedPref(PARSED_SERIAL); - } catch (JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + updateEIPService(); this.retreiveVpnService(); } @@ -250,8 +244,8 @@ public final class EIP extends IntentService { */ private void updateEIPService() { try { - eipDefinition = ConfigHelper.getJsonFromSharedPref(EIP.KEY); - parsedEipSerial = ConfigHelper.getIntFromSharedPref(PARSED_SERIAL); + eipDefinition = new JSONObject(getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).getString(KEY, "")); + parsedEipSerial = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).getInt(PARSED_SERIAL, 0); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -315,8 +309,7 @@ public final class EIP extends IntentService { e.printStackTrace(); } } - - ConfigHelper.saveSharedPref(PARSED_SERIAL, eipDefinition.optInt(Provider.API_RETURN_SERIAL)); + getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putInt(PARSED_SERIAL, eipDefinition.optInt(Provider.API_RETURN_SERIAL)).commit(); } /** -- cgit v1.2.3