Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Add methods for StringSet to OPFPreferences.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Savin committed Jul 21, 2015
1 parent c5421f7 commit a77c2a3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\" \"-Xmx1024m\" \"-Xms256m\" \"-XX:MaxPermSize=1024m\""
fi

# For Cygwin, switch paths to Windows format before running java
Expand Down
31 changes: 31 additions & 0 deletions opfutils/src/main/java/org/onepf/opfutils/OPFPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,27 @@
import android.support.annotation.Nullable;
import android.text.TextUtils;

import java.util.Set;

/**
* The helper class for the easier work with the {@link android.content.SharedPreferences}.
*/
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public class OPFPreferences {

private static void put(@NonNull final SharedPreferences preferences,
@NonNull final String key,
@NonNull final Set<String> value) {
preferences.edit().putStringSet(key, value).apply();
}

@NonNull
private static Set<String> getStringSet(@NonNull final SharedPreferences preferences,
@NonNull final String key,
@NonNull final Set<String> value) {
return preferences.getStringSet(key, value);
}

private static void put(@NonNull final SharedPreferences preferences,
@NonNull final String key,
@NonNull final String value) {
Expand Down Expand Up @@ -148,6 +163,22 @@ public SharedPreferences getPreferences() {
return preferences;
}

public void put(@NonNull final String key, @NonNull final Set<String> value) {
put(preferences, key, value);
}

@NonNull
public Set<String> getStringSet(@NonNull final String key,
@NonNull final Set<String> defValue) {
return getStringSet(preferences, key, defValue);
}

@SuppressWarnings("ConstantConditions")
@Nullable
public Set<String> getStringSet(@NonNull final String key) {
return getStringSet(key, null);
}

public void put(@NonNull final String key, @NonNull final String value) {
put(preferences, key, value);
}
Expand Down

0 comments on commit a77c2a3

Please sign in to comment.