add "Others" category

This commit is contained in:
C10udburst 2022-08-14 13:49:14 +02:00
parent 9e157a8a12
commit 017020fb03
11 changed files with 40 additions and 5 deletions

View File

@ -555,6 +555,7 @@ enum class TvType {
Documentary,
AsianDrama,
Live,
Others
}
// IN CASE OF FUTURE ANIME MOVIE OR SMTH

View File

@ -252,6 +252,7 @@ class HomeFragment : Fragment() {
movies: MaterialButton?,
asian: MaterialButton?,
livestream: MaterialButton?,
others: MaterialButton?,
): List<Pair<MaterialButton?, List<TvType>>> {
return listOf(
Pair(anime, listOf(TvType.Anime, TvType.OVA, TvType.AnimeMovie)),
@ -261,6 +262,7 @@ class HomeFragment : Fragment() {
Pair(movies, listOf(TvType.Movie, TvType.Torrent)),
Pair(asian, listOf(TvType.AsianDrama)),
Pair(livestream, listOf(TvType.Live)),
Pair(others, listOf(TvType.Others)),
)
}
@ -295,10 +297,11 @@ class HomeFragment : Fragment() {
val movies = dialog.findViewById<MaterialButton>(R.id.home_select_movies)
val asian = dialog.findViewById<MaterialButton>(R.id.home_select_asian)
val livestream = dialog.findViewById<MaterialButton>(R.id.home_select_livestreams)
val others = dialog.findViewById<MaterialButton>(R.id.home_select_others)
val cancelBtt = dialog.findViewById<MaterialButton>(R.id.cancel_btt)
val applyBtt = dialog.findViewById<MaterialButton>(R.id.apply_btt)
val pairList = getPairList(anime, cartoons, tvs, docs, movies, asian, livestream)
val pairList = getPairList(anime, cartoons, tvs, docs, movies, asian, livestream, others)
cancelBtt?.setOnClickListener {
dialog.dismissSafe()

View File

@ -197,6 +197,7 @@ fun LoadResponse.toResultData(repo: APIRepository): ResultData {
TvType.Torrent -> R.string.torrent_singular
TvType.AsianDrama -> R.string.asian_drama_singular
TvType.Live -> R.string.live_singular
TvType.Others -> R.string.other_singular
}
),
yearText = txt(year?.toString()),
@ -549,6 +550,7 @@ class ResultViewModel2 : ViewModel() {
TvType.Documentary -> "Documentaries"
TvType.AsianDrama -> "AsianDrama"
TvType.Live -> "LiveStreams"
TvType.Others -> "Others"
}
}

View File

@ -169,6 +169,7 @@ class SearchFragment : Fragment() {
val asian = dialog.findViewById<MaterialButton>(R.id.home_select_asian)
val livestream =
dialog.findViewById<MaterialButton>(R.id.home_select_livestreams)
val other = dialog.findViewById<MaterialButton>(R.id.home_select_others)
val cancelBtt = dialog.findViewById<MaterialButton>(R.id.cancel_btt)
val applyBtt = dialog.findViewById<MaterialButton>(R.id.apply_btt)
@ -180,7 +181,8 @@ class SearchFragment : Fragment() {
docs,
movies,
asian,
livestream
livestream,
other
)
cancelBtt?.setOnClickListener {
@ -297,7 +299,8 @@ class SearchFragment : Fragment() {
search_select_documentaries,
search_select_movies,
search_select_asian,
search_select_livestreams
search_select_livestreams,
search_select_others
)
val settingsManager = context?.let { PreferenceManager.getDefaultSharedPreferences(it) }

View File

@ -112,7 +112,8 @@ class PluginsFragment : Fragment() {
home_select_documentaries,
home_select_movies,
home_select_asian,
home_select_livestreams
home_select_livestreams,
home_select_others
)
// Copy pasted code

View File

@ -175,7 +175,10 @@ class PluginsViewModel : ViewModel() {
// Perhaps can be optimized?
private fun List<PluginViewData>.filterTvTypes(): List<PluginViewData> {
if (tvTypes.isEmpty()) return this
return this.filter { it.plugin.second.tvTypes?.any { type -> tvTypes.contains(type) } == true }
return this.filter {
(it.plugin.second.tvTypes?.any { type -> tvTypes.contains(type) } == true) ||
(tvTypes.contains("Others") && (it.plugin.second.tvTypes ?: emptyList()).isEmpty())
}
}
private fun List<PluginViewData>.sortByQuery(query: String?): List<PluginViewData> {

View File

@ -110,6 +110,12 @@
android:nextFocusLeft="@id/home_select_documentaries"
android:text="@string/livestreams" />
<com.google.android.material.button.MaterialButton
android:id="@+id/home_select_others"
style="@style/RoundedSelectableButton"
android:nextFocusLeft="@id/home_select_livestreams"
android:text="@string/others" />
</LinearLayout>
</HorizontalScrollView>
</com.google.android.material.appbar.AppBarLayout>

View File

@ -146,6 +146,12 @@
style="@style/RoundedSelectableButton"
android:nextFocusLeft="@id/search_select_documentaries"
android:text="@string/livestreams" />
<com.google.android.material.button.MaterialButton
android:id="@+id/search_select_others"
style="@style/RoundedSelectableButton"
android:nextFocusLeft="@id/search_select_livestreams"
android:text="@string/others" />
</LinearLayout>
</HorizontalScrollView>

View File

@ -104,6 +104,12 @@
android:nextFocusLeft="@id/home_select_documentaries"
android:text="@string/livestreams" />
<com.google.android.material.button.MaterialButton
android:id="@+id/home_select_others"
style="@style/RoundedSelectableButton"
android:nextFocusLeft="@id/home_select_livestreams"
android:text="@string/others" />
</LinearLayout>
</HorizontalScrollView>

View File

@ -427,4 +427,6 @@
<string name="blank_repo_message">Dodaj repozytorium aby zainstalować rozszerzenia</string>
<string name="sync_score">Ocenione</string>
<string name="sync_score_format">%d na 10</string>
<string name="others">Inne</string>
<string name="other_singular">Wideo</string>
</resources>

View File

@ -333,6 +333,7 @@
<string name="ova">OVA</string>
<string name="asian_drama">Asian Dramas</string>
<string name="livestreams">Livestreams</string>
<string name="others">Others</string>
<!--singular-->
<string name="movies_singular">Movie</string>
@ -344,6 +345,7 @@
<string name="documentaries_singular">Documentary</string>
<string name="asian_drama_singular">Asian Drama</string>
<string name="live_singular">Livestream</string>
<string name="other_singular">Video</string>
<string name="source_error">Source error</string>
<string name="remote_error">Remote error</string>