feat: adult only media option

This commit is contained in:
aayush262 2024-03-30 15:44:29 +05:30
parent c0bccc027f
commit 99b3bbaaad
13 changed files with 137 additions and 135 deletions

View file

@ -278,7 +278,6 @@ class AnimeFragment : Fragment() {
}
model.loaded = true
model.loadTrending(1)
model.loadUpdated()
model.loadAll()
model.loadPopular(
"ANIME", sort = Anilist.sortBy[1], onList = PrefManager.getVal(

View file

@ -195,70 +195,61 @@ class AnimePageAdapter : RecyclerView.Adapter<AnimePageAdapter.AnimePageViewHold
}
fun updateRecent(adaptor: MediaAdaptor) {
binding.animeUpdatedProgressBar.visibility = View.GONE
binding.animeUpdatedRecyclerView.adapter = adaptor
binding.animeUpdatedRecyclerView.layoutManager =
LinearLayoutManager(
binding.animeUpdatedRecyclerView.context,
LinearLayoutManager.HORIZONTAL,
false
binding.apply{
init(
adaptor,
animeUpdatedRecyclerView,
animeUpdatedProgressBar,
animeRecently
)
binding.animeUpdatedRecyclerView.visibility = View.VISIBLE
binding.animeRecently.visibility = View.VISIBLE
binding.animeRecently.startAnimation(setSlideUp())
binding.animeUpdatedRecyclerView.layoutAnimation =
LayoutAnimationController(setSlideIn(), 0.25f)
binding.animePopular.visibility = View.VISIBLE
binding.animePopular.startAnimation(setSlideUp())
animePopular.visibility = View.VISIBLE
binding.animePopular.startAnimation(setSlideUp())
}
}
fun updateMovies(adaptor: MediaAdaptor) {
binding.animeMoviesProgressBar.visibility = View.GONE
binding.animeMoviesRecyclerView.adapter = adaptor
binding.animeMoviesRecyclerView.layoutManager =
LinearLayoutManager(
binding.animeMoviesRecyclerView.context,
LinearLayoutManager.HORIZONTAL,
false
binding.apply{
init(
adaptor,
animeMoviesRecyclerView,
animeMoviesProgressBar,
animeMovies
)
binding.animeMoviesRecyclerView.visibility = View.VISIBLE
binding.animeMovies.visibility = View.VISIBLE
binding.animeMovies.startAnimation(setSlideUp())
binding.animeMoviesRecyclerView.layoutAnimation =
LayoutAnimationController(setSlideIn(), 0.25f)
}
}
fun updateTopRated(adaptor: MediaAdaptor) {
binding.animeTopRatedProgressBar.visibility = View.GONE
binding.animeTopRatedRecyclerView.adapter = adaptor
binding.animeTopRatedRecyclerView.layoutManager =
LinearLayoutManager(
binding.animeTopRatedRecyclerView.context,
LinearLayoutManager.HORIZONTAL,
false
binding.apply{
init(
adaptor,
animeTopRatedRecyclerView,
animeTopRatedProgressBar,
animeTopRated
)
binding.animeTopRatedRecyclerView.visibility = View.VISIBLE
binding.animeTopRated.visibility = View.VISIBLE
binding.animeTopRated.startAnimation(setSlideUp())
binding.animeTopRatedRecyclerView.layoutAnimation =
LayoutAnimationController(setSlideIn(), 0.25f)
}
}
fun updateMostFav(adaptor: MediaAdaptor) {
binding.animeMostFavProgressBar.visibility = View.GONE
binding.animeMostFavRecyclerView.adapter = adaptor
binding.animeMostFavRecyclerView.layoutManager =
binding.apply{
init(
adaptor,
animeMostFavRecyclerView,
animeMostFavProgressBar,
animeMostFav
)
}
}
fun init(adaptor: MediaAdaptor,recyclerView: RecyclerView, progress: View, title: View){
progress.visibility = View.GONE
recyclerView.adapter = adaptor
recyclerView.layoutManager =
LinearLayoutManager(
binding.animeMostFavRecyclerView.context,
recyclerView.context,
LinearLayoutManager.HORIZONTAL,
false
)
binding.animeMostFavRecyclerView.visibility = View.VISIBLE
binding.animeMostFav.visibility = View.VISIBLE
binding.animeMostFav.startAnimation(setSlideUp())
binding.animeMostFavRecyclerView.layoutAnimation =
recyclerView.visibility = View.VISIBLE
title.visibility = View.VISIBLE
title.startAnimation(setSlideUp())
recyclerView.layoutAnimation =
LayoutAnimationController(setSlideIn(), 0.25f)
}
fun updateAvatar() {

View file

@ -160,7 +160,7 @@ class MangaFragment : Fragment() {
})
mangaPageAdapter.ready.observe(viewLifecycleOwner) { i ->
if (i == true) {
model.getTrendingNovel().observe(viewLifecycleOwner) {
model.getPopularNovel().observe(viewLifecycleOwner) {
if (it != null) {
mangaPageAdapter.updateNovel(MediaAdaptor(0, it, requireActivity()))
}
@ -257,7 +257,6 @@ class MangaFragment : Fragment() {
}
model.loaded = true
model.loadTrending()
model.loadTrendingNovel()
model.loadAll()
model.loadPopular(
"MANGA", sort = Anilist.sortBy[1], onList = PrefManager.getVal(

View file

@ -182,86 +182,72 @@ class MangaPageAdapter : RecyclerView.Adapter<MangaPageAdapter.MangaPageViewHold
}
fun updateTrendingManga(adaptor: MediaAdaptor) {
binding.mangaTrendingMangaProgressBar.visibility = View.GONE
binding.mangaTrendingMangaRecyclerView.adapter = adaptor
binding.mangaTrendingMangaRecyclerView.layoutManager =
LinearLayoutManager(
binding.mangaTrendingMangaRecyclerView.context,
LinearLayoutManager.HORIZONTAL,
false
binding.apply {
init(
adaptor,
mangaTrendingMangaRecyclerView,
mangaTrendingMangaProgressBar,
mangaTrendingManga
)
binding.mangaTrendingMangaRecyclerView.visibility = View.VISIBLE
binding.mangaTrendingManga.visibility = View.VISIBLE
binding.mangaTrendingManga.startAnimation(setSlideUp())
binding.mangaTrendingMangaRecyclerView.layoutAnimation =
LayoutAnimationController(setSlideIn(), 0.25f)
}
}
fun updateTrendingManhwa(adaptor: MediaAdaptor) {
binding.mangaTrendingManhwaProgressBar.visibility = View.GONE
binding.mangaTrendingManhwaRecyclerView.adapter = adaptor
binding.mangaTrendingManhwaRecyclerView.layoutManager =
LinearLayoutManager(
binding.mangaNovelRecyclerView.context,
LinearLayoutManager.HORIZONTAL,
false
binding.apply {
init(
adaptor,
mangaTrendingManhwaRecyclerView,
mangaTrendingManhwaProgressBar,
mangaTrendingManhwa
)
binding.mangaTrendingManhwaRecyclerView.visibility = View.VISIBLE
binding.mangaTrendingManhwa.visibility = View.VISIBLE
binding.mangaTrendingManhwa.startAnimation(setSlideUp())
binding.mangaTrendingManhwaRecyclerView.layoutAnimation =
LayoutAnimationController(setSlideIn(), 0.25f)
}
fun updateTopRated(adaptor: MediaAdaptor) {
binding.mangaTopRatedProgressBar.visibility = View.GONE
binding.mangaTopRatedRecyclerView.adapter = adaptor
binding.mangaTopRatedRecyclerView.layoutManager =
LinearLayoutManager(
binding.mangaTopRatedRecyclerView.context,
LinearLayoutManager.HORIZONTAL,
false
)
binding.mangaTopRatedRecyclerView.visibility = View.VISIBLE
binding.mangaTopRated.visibility = View.VISIBLE
binding.mangaTopRated.startAnimation(setSlideUp())
binding.mangaTopRatedRecyclerView.layoutAnimation =
LayoutAnimationController(setSlideIn(), 0.25f)
}
fun updateMostFav(adaptor: MediaAdaptor) {
binding.mangaMostFavProgressBar.visibility = View.GONE
binding.mangaMostFavRecyclerView.adapter = adaptor
binding.mangaMostFavRecyclerView.layoutManager =
LinearLayoutManager(
binding.mangaMostFavRecyclerView.context,
LinearLayoutManager.HORIZONTAL,
false
)
binding.mangaMostFavRecyclerView.visibility = View.VISIBLE
binding.mangaMostFav.visibility = View.VISIBLE
binding.mangaMostFav.startAnimation(setSlideUp())
binding.mangaMostFavRecyclerView.layoutAnimation =
LayoutAnimationController(setSlideIn(), 0.25f)
}
}
fun updateNovel(adaptor: MediaAdaptor) {
binding.mangaNovelProgressBar.visibility = View.GONE
binding.mangaNovelRecyclerView.adapter = adaptor
binding.mangaNovelRecyclerView.layoutManager =
binding.apply {
init(
adaptor,
mangaNovelRecyclerView,
mangaNovelProgressBar,
mangaNovel
)
}
}
fun updateTopRated(adaptor: MediaAdaptor) {
binding.apply {
init(
adaptor,
mangaTopRatedRecyclerView,
mangaTopRatedProgressBar,
mangaTopRated
)
}
}
fun updateMostFav(adaptor: MediaAdaptor) {
binding.apply {
init(
adaptor,
mangaMostFavRecyclerView,
mangaMostFavProgressBar,
mangaMostFav
)
mangaPopular.visibility = View.VISIBLE
mangaPopular.startAnimation(setSlideUp())
}
}
fun init(adaptor: MediaAdaptor,recyclerView: RecyclerView, progress: View, title: View){
progress.visibility = View.GONE
recyclerView.adapter = adaptor
recyclerView.layoutManager =
LinearLayoutManager(
binding.mangaNovelRecyclerView.context,
recyclerView.context,
LinearLayoutManager.HORIZONTAL,
false
)
binding.mangaNovelRecyclerView.visibility = View.VISIBLE
binding.mangaNovel.visibility = View.VISIBLE
binding.mangaNovel.startAnimation(setSlideUp())
binding.mangaNovelRecyclerView.layoutAnimation =
recyclerView.visibility = View.VISIBLE
title.visibility = View.VISIBLE
title.startAnimation(setSlideUp())
recyclerView.layoutAnimation =
LayoutAnimationController(setSlideIn(), 0.25f)
binding.mangaPopular.visibility = View.VISIBLE
binding.mangaPopular.startAnimation(setSlideUp())
}
fun updateAvatar() {

View file

@ -30,7 +30,7 @@ class OtherDetailsViewModel : ViewModel() {
fun getCalendar(): LiveData<Map<String, MutableList<Media>>> = calendar
suspend fun loadCalendar() {
val curr = System.currentTimeMillis() / 1000
val res = Anilist.query.recentlyUpdated(false, curr - 86400, curr + (86400 * 6))
val res = Anilist.query.recentlyUpdated(curr - 86400, curr + (86400 * 6))
val df = DateFormat.getDateInstance(DateFormat.FULL)
val map = mutableMapOf<String, MutableList<Media>>()
val idMap = mutableMapOf<String, MutableList<Int>>()

View file

@ -457,7 +457,9 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
settingsIncludeAnimeList.isChecked = PrefManager.getVal(PrefName.IncludeAnimeList)
settingsIncludeAnimeList.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.IncludeAnimeList, isChecked)
restartApp(binding.root)
}
var previousEp: View = when (PrefManager.getVal<Int>(PrefName.AnimeDefaultView)) {
0 -> settingsEpList
1 -> settingsEpGrid
@ -548,6 +550,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
settingsIncludeMangaList.isChecked = PrefManager.getVal(PrefName.IncludeMangaList)
settingsIncludeMangaList.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.IncludeMangaList, isChecked)
restartApp(binding.root)
}
}
@ -721,7 +724,11 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
settingsRecentlyListOnly.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.RecentlyListOnly, isChecked)
}
settingsAdultAnimeOnly.isChecked = PrefManager.getVal(PrefName.AdultOnly)
settingsAdultAnimeOnly.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.AdultOnly, isChecked)
restartApp(binding.root)
}
var previousStart: View = when (PrefManager.getVal<Int>(PrefName.DefaultStartUpTab)) {
0 -> uiSettingsAnime
1 -> uiSettingsHome

View file

@ -40,6 +40,9 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
LastAnilistNotificationId(Pref(Location.General, Int::class, 0)),
AnilistFilteredTypes(Pref(Location.General, Set::class, setOf<String>())),
UseAlarmManager(Pref(Location.General, Boolean::class, false)),
IncludeAnimeList(Pref(Location.General, Boolean::class, true)),
IncludeMangaList(Pref(Location.General, Boolean::class, true)),
AdultOnly(Pref(Location.General, Boolean::class, false)),
//User Interface
UseOLED(Pref(Location.UI, Boolean::class, false)),
@ -77,8 +80,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
MangaListSortOrder(Pref(Location.UI, String::class, "score")),
CommentSortOrder(Pref(Location.UI, String::class, "newest")),
FollowerLayout(Pref(Location.UI, Int::class, 0)),
IncludeAnimeList(Pref(Location.UI, Boolean::class, true)),
IncludeMangaList(Pref(Location.UI, Boolean::class, true)),
//Player
DefaultSpeed(Pref(Location.Player, Int::class, 5)),