Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
[shared_preferences] Replace lambda expression for compatibility with…
Browse files Browse the repository at this point in the history
… older Java versions
  • Loading branch information
axel-op committed Nov 27, 2019
1 parent 7e9f147 commit 99505a9
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ class MethodCallHandlerImpl implements MethodChannel.MethodCallHandler {
* @return An instance of {@link SharedPreferences}.
*/
private SharedPreferences getPreferences(String filename) {
return instances.computeIfAbsent(
filename,
k ->
context.getSharedPreferences(
Optional.ofNullable(k).orElse(SHARED_PREFERENCES_DEFAULT_NAME),
Context.MODE_PRIVATE));
SharedPreferences instance = instances.get(filename);
if (instance == null) {
instance =
context.getSharedPreferences(
Optional.ofNullable(filename).orElse(SHARED_PREFERENCES_DEFAULT_NAME),
Context.MODE_PRIVATE);
}
return instance;
}

@Override
Expand Down

0 comments on commit 99505a9

Please sign in to comment.