-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
667 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 0 additions & 134 deletions
134
app/src/main/java/soko/ekibun/bangumi/api/bangumi/bean/gson.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
app/src/main/java/soko/ekibun/bangumi/model/SearchHistoryModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package soko.ekibun.bangumi.model | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import android.preference.PreferenceManager | ||
import com.google.gson.reflect.TypeToken | ||
import soko.ekibun.bangumi.util.JsonUtil | ||
|
||
class SearchHistoryModel(context: Context){ | ||
val sp: SharedPreferences by lazy{ PreferenceManager.getDefaultSharedPreferences(context) } | ||
|
||
fun addHistory(searchKey: String) { | ||
val newList = getHistoryList().toMutableList() | ||
newList.add(0, searchKey) | ||
sp.edit().putString(PREF_SEARCH_HISTORY, JsonUtil.toJson(newList.distinct())).apply() | ||
} | ||
|
||
fun removeHistory(searchKey: String): Boolean { | ||
val newList = getHistoryList().toMutableList() | ||
val removed = newList.remove(searchKey) | ||
sp.edit().putString(PREF_SEARCH_HISTORY, JsonUtil.toJson(newList)).apply() | ||
return removed | ||
} | ||
|
||
fun clearHistory() { | ||
sp.edit().putString(PREF_SEARCH_HISTORY, JsonUtil.toJson(ArrayList<String>())).apply() | ||
} | ||
|
||
fun getHistoryList(): List<String> { | ||
return JsonUtil.toEntity(sp.getString(PREF_SEARCH_HISTORY, JsonUtil.toJson(ArrayList<String>()))!!, object: TypeToken<List<String>>() {}.type)?:ArrayList() | ||
} | ||
|
||
companion object { | ||
const val PREF_SEARCH_HISTORY="searchHistory" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.