mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-20 18:43:55 +00:00
feat: status filter fully functional
This commit is contained in:
@@ -45,6 +45,14 @@ object Anilist {
|
||||
"SCORE"
|
||||
)
|
||||
|
||||
val status = listOf(
|
||||
"FINISHED",
|
||||
"RELEASING",
|
||||
"NOT_YET_RELEASED",
|
||||
"HIATUS",
|
||||
"CANCELLED"
|
||||
)
|
||||
|
||||
val seasons = listOf(
|
||||
"WINTER", "SPRING", "SUMMER", "FALL"
|
||||
)
|
||||
|
||||
@@ -881,6 +881,7 @@ class AnilistQueries {
|
||||
sort: String? = null,
|
||||
genres: MutableList<String>? = null,
|
||||
tags: MutableList<String>? = null,
|
||||
status: String? = null,
|
||||
format: String? = null,
|
||||
isAdult: Boolean = false,
|
||||
onList: Boolean? = null,
|
||||
@@ -944,6 +945,7 @@ query (${"$"}page: Int = 1, ${"$"}id: Int, ${"$"}type: MediaType, ${"$"}isAdult:
|
||||
${if (season != null) ""","season":"$season"""" else ""}
|
||||
${if (search != null) ""","search":"$search"""" else ""}
|
||||
${if (sort != null) ""","sort":"$sort"""" else ""}
|
||||
${if (status != null) ""","status":"$status"""" else ""}
|
||||
${if (format != null) ""","format":"${format.replace(" ", "_")}"""" else ""}
|
||||
${if (genres?.isNotEmpty() == true) ""","genres":[${genres.joinToString { "\"$it\"" }}]""" else ""}
|
||||
${
|
||||
@@ -1008,6 +1010,7 @@ query (${"$"}page: Int = 1, ${"$"}id: Int, ${"$"}type: MediaType, ${"$"}isAdult:
|
||||
excludedGenres = excludedGenres,
|
||||
tags = tags,
|
||||
excludedTags = excludedTags,
|
||||
status = status,
|
||||
format = format,
|
||||
seasonYear = seasonYear,
|
||||
season = season,
|
||||
|
||||
@@ -185,6 +185,7 @@ class AnilistAnimeViewModel : ViewModel() {
|
||||
r.sort,
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.format,
|
||||
r.isAdult,
|
||||
r.onList
|
||||
@@ -257,6 +258,7 @@ class AnilistMangaViewModel : ViewModel() {
|
||||
r.sort,
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.format,
|
||||
r.isAdult,
|
||||
r.onList,
|
||||
@@ -286,6 +288,7 @@ class AnilistSearch : ViewModel() {
|
||||
r.sort,
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.format,
|
||||
r.isAdult,
|
||||
r.onList,
|
||||
@@ -305,6 +308,7 @@ class AnilistSearch : ViewModel() {
|
||||
r.sort,
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.format,
|
||||
r.isAdult,
|
||||
r.onList,
|
||||
|
||||
@@ -16,6 +16,7 @@ data class SearchResults(
|
||||
var excludedGenres: MutableList<String>? = null,
|
||||
var tags: MutableList<String>? = null,
|
||||
var excludedTags: MutableList<String>? = null,
|
||||
var status: String? = null,
|
||||
var format: String? = null,
|
||||
var seasonYear: Int? = null,
|
||||
var season: String? = null,
|
||||
@@ -37,6 +38,9 @@ data class SearchResults(
|
||||
)
|
||||
)
|
||||
}
|
||||
status?.let {
|
||||
list.add(SearchChip("STATUS", currContext()!!.getString(R.string.filter_status, it)))
|
||||
}
|
||||
format?.let {
|
||||
list.add(SearchChip("FORMAT", currContext()!!.getString(R.string.filter_format, it)))
|
||||
}
|
||||
@@ -74,6 +78,7 @@ data class SearchResults(
|
||||
fun removeChip(chip: SearchChip) {
|
||||
when (chip.type) {
|
||||
"SORT" -> sort = null
|
||||
"STATUS" -> status = null
|
||||
"FORMAT" -> format = null
|
||||
"SEASON" -> season = null
|
||||
"SEASON_YEAR" -> seasonYear = null
|
||||
|
||||
@@ -67,6 +67,7 @@ class SearchActivity : AppCompatActivity() {
|
||||
genres = intent.getStringExtra("genre")?.let { mutableListOf(it) },
|
||||
tags = intent.getStringExtra("tag")?.let { mutableListOf(it) },
|
||||
sort = intent.getStringExtra("sortBy"),
|
||||
status = intent.getStringExtra("status"),
|
||||
season = intent.getStringExtra("season"),
|
||||
seasonYear = intent.getStringExtra("seasonYear")?.toIntOrNull(),
|
||||
results = mutableListOf(),
|
||||
@@ -128,6 +129,7 @@ class SearchActivity : AppCompatActivity() {
|
||||
tags = it.tags
|
||||
season = it.season
|
||||
seasonYear = it.seasonYear
|
||||
status = it.status
|
||||
format = it.format
|
||||
page = it.page
|
||||
hasNextPage = it.hasNextPage
|
||||
@@ -182,7 +184,7 @@ class SearchActivity : AppCompatActivity() {
|
||||
override fun run() {
|
||||
scope.launch(Dispatchers.IO) {
|
||||
loading = true
|
||||
model.loadSearch(result)
|
||||
model.loadSearch(result.copy(status = result.status))
|
||||
loading = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ class SearchFilterBottomDialog : BottomSheetDialogFragment() {
|
||||
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
activity.result.apply {
|
||||
status = binding.searchStatus.text.toString().ifBlank { null }
|
||||
format = binding.searchFormat.text.toString().ifBlank { null }
|
||||
season = binding.searchSeason.text.toString().ifBlank { null }
|
||||
seasonYear = binding.searchYear.text.toString().toIntOrNull()
|
||||
@@ -220,6 +221,7 @@ class SearchFilterBottomDialog : BottomSheetDialogFragment() {
|
||||
|
||||
binding.searchFilterApply.setOnClickListener {
|
||||
activity.result.apply {
|
||||
status = binding.searchStatus.text.toString().ifBlank { null }
|
||||
format = binding.searchFormat.text.toString().ifBlank { null }
|
||||
season = binding.searchSeason.text.toString().ifBlank { null }
|
||||
seasonYear = binding.searchYear.text.toString().toIntOrNull()
|
||||
@@ -237,6 +239,15 @@ class SearchFilterBottomDialog : BottomSheetDialogFragment() {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
binding.searchStatus.setText(activity.result.status)
|
||||
binding.searchStatus.setAdapter(
|
||||
ArrayAdapter(
|
||||
binding.root.context,
|
||||
R.layout.item_dropdown,
|
||||
Anilist.status.toTypedArray()
|
||||
)
|
||||
)
|
||||
|
||||
binding.searchFormat.setText(activity.result.format)
|
||||
binding.searchFormat.setAdapter(
|
||||
ArrayAdapter(
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_weight="1"
|
||||
android:hint="Status"
|
||||
android:hint="@string/status_title"
|
||||
app:boxCornerRadiusBottomEnd="16dp"
|
||||
app:boxCornerRadiusBottomStart="16dp"
|
||||
app:boxCornerRadiusTopEnd="16dp"
|
||||
|
||||
@@ -613,6 +613,7 @@
|
||||
<string name="chapter_singular">Chapter</string>
|
||||
<string name="chapter_plural">Chapters</string>
|
||||
|
||||
<string name="filter_status">"Status : %1$s"</string>
|
||||
<string name="filter_format">"Format : %1$s"</string>
|
||||
<string name="filter_sort">"Sort : %1$s"</string>
|
||||
<string name="filter_exclude">"Not %1$s"</string>
|
||||
|
||||
Reference in New Issue
Block a user