diff --git a/app/src/main/java/com/example/nemophila/Nemophila.java b/app/src/main/java/com/example/nemophila/Nemophila.java index b48eb3c..37d9e2b 100644 --- a/app/src/main/java/com/example/nemophila/Nemophila.java +++ b/app/src/main/java/com/example/nemophila/Nemophila.java @@ -11,8 +11,6 @@ import java.util.HashSet; public class Nemophila extends Application { - private final int MAX_FILTER = 5; - //アカウントのデータ private String name; private String uid; @@ -32,6 +30,7 @@ //フィルターのデータ private HashSet selectGenres = new HashSet<>(); private HashSet selectFriends = new HashSet<>(); + private HashSet favoriteFriends = new HashSet<>(); //Account関連のGetter public String getName() { @@ -100,6 +99,13 @@ public HashSet getSelectFriends() { return selectFriends; } + public HashSet getFavoriteFriends() { + if(favoriteFriends.isEmpty()){ + SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); + favoriteFriends = (HashSet) preferences.getStringSet("favoriteFriends", new HashSet<>()); + } + return new HashSet<>(favoriteFriends); + } //Setter public void setName(String name) { @@ -161,6 +167,12 @@ public void setSelectFriends(String selectFriend) { this.selectFriends.add(selectFriend); } + public void setFavoriteFriends(String favoriteFriend) { + SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + editor.putStringSet("favoriteFriends", favoriteFriends); + this.favoriteFriends.add(favoriteFriend); + } //フィルターを取り除く public void removeSelectGenres(String selectGenre){ @@ -169,4 +181,7 @@ public void removeSelectFriends(String selectFriend) { this.selectFriends.remove(selectFriend); } + public void removeFavoriteFriends(String favoriteFriend){ + this.selectFriends.remove(favoriteFriend); + } }