Skip to content

Commit

Permalink
Merge pull request #334 from mogol/ensure_intitialized_bug
Browse files Browse the repository at this point in the history
bug: fix sharedPrefs not being initialized
  • Loading branch information
juliansteenbakker authored Nov 15, 2021
2 parents da497f3 + fd6b5be commit 26efe91
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ public void run() {
String key = getKeyFromCall(call);
Map<String, Object> arguments = (Map<String, Object>) call.arguments;
ensureInitialized(arguments);

String value = (String) arguments.get("value");

if (value != null) {
write(key, value, useEncryptedSharedPreferences);
result.success(null);
Expand All @@ -294,9 +296,9 @@ public void run() {
case "read": {
String key = getKeyFromCall(call);
Map<String, Object> arguments = (Map<String, Object>) call.arguments;
ensureInitialized(arguments);

if (preferences.contains(key)) {
ensureInitialized(arguments);
String value = read(key, useEncryptedSharedPreferences);
result.success(value);
} else {
Expand All @@ -314,19 +316,26 @@ public void run() {
}
case "containsKey": {
String key = getKeyFromCall(call);
Map<String, Object> arguments = (Map<String, Object>) call.arguments;
ensureInitialized(arguments);

boolean containsKey = preferences.contains(key);
result.success(containsKey);
break;
}
case "delete": {
String key = getKeyFromCall(call);
Map<String, Object> arguments = (Map<String, Object>) call.arguments;
ensureInitialized(arguments);

delete(key);
result.success(null);
break;
}
case "deleteAll": {
Map<String, Object> arguments = (Map<String, Object>) call.arguments;
ensureInitialized(arguments);

deleteAll();
result.success(null);
break;
Expand Down

0 comments on commit 26efe91

Please sign in to comment.