mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-20 12:23:55 +00:00
feat: hide media from home screen
This commit is contained in:
@@ -11,7 +11,6 @@ import ani.dantotsu.connections.anilist.api.FuzzyDate
|
||||
import ani.dantotsu.connections.anilist.api.NotificationResponse
|
||||
import ani.dantotsu.connections.anilist.api.Page
|
||||
import ani.dantotsu.connections.anilist.api.Query
|
||||
import ani.dantotsu.connections.anilist.api.Social
|
||||
import ani.dantotsu.connections.anilist.api.ToggleLike
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.isOnline
|
||||
@@ -413,6 +412,7 @@ class AnilistQueries {
|
||||
}
|
||||
|
||||
suspend fun initHomePage(): Map<String, ArrayList<*>> {
|
||||
val removeList = PrefManager.getCustomVal("removeList", setOf<Int>())
|
||||
val toShow: List<Boolean> =
|
||||
PrefManager.getVal(PrefName.HomeLayout) // anime continue, anime fav, anime planned, manga continue, manga fav, manga planned, recommendations
|
||||
var query = """{"""
|
||||
@@ -462,15 +462,20 @@ class AnilistQueries {
|
||||
current?.lists?.forEach { li ->
|
||||
li.entries?.reversed()?.forEach {
|
||||
val m = Media(it)
|
||||
m.cameFromContinue = true
|
||||
subMap[m.id] = m
|
||||
if (m.id !in removeList) {
|
||||
m.cameFromContinue = true
|
||||
subMap[m.id] = m
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repeating?.lists?.forEach { li ->
|
||||
li.entries?.reversed()?.forEach {
|
||||
val m = Media(it)
|
||||
m.cameFromContinue = true
|
||||
subMap[m.id] = m
|
||||
if (m.id !in removeList) {
|
||||
m.cameFromContinue = true
|
||||
subMap[m.id] = m
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type != "Anime") {
|
||||
@@ -504,8 +509,10 @@ class AnilistQueries {
|
||||
current?.lists?.forEach { li ->
|
||||
li.entries?.reversed()?.forEach {
|
||||
val m = Media(it)
|
||||
m.cameFromContinue = true
|
||||
subMap[m.id] = m
|
||||
if (m.id !in removeList) {
|
||||
m.cameFromContinue = true
|
||||
subMap[m.id] = m
|
||||
}
|
||||
}
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@@ -532,7 +539,10 @@ class AnilistQueries {
|
||||
val returnArray = arrayListOf<Media>()
|
||||
apiMediaList?.edges?.forEach {
|
||||
it.node?.let { i ->
|
||||
returnArray.add(Media(i).apply { isFav = true })
|
||||
val m = Media(i).apply { isFav = true }
|
||||
if (m.id !in removeList) {
|
||||
returnArray.add(m)
|
||||
}
|
||||
}
|
||||
}
|
||||
returnMap["favorite$type"] = returnArray
|
||||
|
||||
@@ -20,6 +20,7 @@ import ani.dantotsu.connections.anilist.api.FuzzyDate
|
||||
import ani.dantotsu.connections.mal.MAL
|
||||
import ani.dantotsu.databinding.BottomSheetMediaListBinding
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.tryWith
|
||||
import com.google.android.material.materialswitch.MaterialSwitch
|
||||
@@ -187,7 +188,15 @@ class MediaListDialogFragment : BottomSheetDialogFragment() {
|
||||
binding.mediaListPrivate.setOnCheckedChangeListener { _, checked ->
|
||||
media?.isListPrivate = checked
|
||||
}
|
||||
|
||||
val removeList = PrefManager.getCustomVal("removeList", setOf<Int>())
|
||||
binding.mediaListShow.isChecked = media?.id in removeList
|
||||
binding.mediaListShow.setOnCheckedChangeListener { _, checked ->
|
||||
if (checked) {
|
||||
PrefManager.setCustomVal("removeList", removeList.plus(media?.id))
|
||||
} else {
|
||||
PrefManager.setCustomVal("removeList", removeList.minus(media?.id))
|
||||
}
|
||||
}
|
||||
media?.userRepeat?.apply {
|
||||
binding.mediaListRewatch.setText(this.toString())
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import ani.dantotsu.connections.mal.MAL
|
||||
import ani.dantotsu.databinding.BottomSheetMediaListSmallBinding
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.snackString
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -170,7 +171,15 @@ class MediaListDialogSmallFragment : BottomSheetDialogFragment() {
|
||||
binding.mediaListPrivate.setOnCheckedChangeListener { _, checked ->
|
||||
media.isListPrivate = checked
|
||||
}
|
||||
|
||||
val removeList = PrefManager.getCustomVal("removeList", setOf<Int>())
|
||||
binding.mediaListShow.isChecked = media?.id in removeList
|
||||
binding.mediaListShow.setOnCheckedChangeListener { _, checked ->
|
||||
if (checked) {
|
||||
PrefManager.setCustomVal("removeList", removeList.plus(media.id))
|
||||
} else {
|
||||
PrefManager.setCustomVal("removeList", removeList.minus(media.id))
|
||||
}
|
||||
}
|
||||
binding.mediaListSave.setOnClickListener {
|
||||
scope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
|
||||
Reference in New Issue
Block a user