public bool RemoveVideoFromSharedPreferences(string videoKey, SharedPreferenceType type) { if (videoKey == null) return false; var sharedPref = GetSharedPreferernceByType (type); var key = sharedPref.GetString (videoKey, string.Empty); if (key != string.Empty) { // Video is in favorites, remove it sharedPref.Edit ().Remove (key).Apply (); return true; } return false; }
public bool AddVideoToSharedPreferences(string videoKey, SharedPreferenceType type) { if (videoKey == null) return false; var sharedPref = GetSharedPreferernceByType (type); var key = sharedPref.GetString (videoKey, string.Empty); if (key == string.Empty) { // Not in favorites, add it sharedPref.Edit ().PutString (videoKey, videoKey).Apply (); return true; } return false; }
private ISharedPreferences GetSharedPreferernceByType(SharedPreferenceType type) { switch (type) { case SharedPreferenceType.Favorites: return _favPrefs; case SharedPreferenceType.Liked: return _likedVidsPrefs; case SharedPreferenceType.Disliked: return _dislikedVidsPrefs; case SharedPreferenceType.Watchlist: return _watchListPrefs; case SharedPreferenceType.Watched: return _watchedVidsPrefs; } return _favPrefs; }
public int GetCount(SharedPreferenceType type) { var sharedPref = GetSharedPreferernceByType (type); return sharedPref.All.Keys.Count; }
public List<string> GetAllVideos(SharedPreferenceType type) { var sharedPref = GetSharedPreferernceByType (type); return sharedPref.All.Keys.ToList(); }