Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush2622 committed Jun 16, 2024
2 parents 0052eba + eda213a commit 124f4eb
Show file tree
Hide file tree
Showing 18 changed files with 310 additions and 278 deletions.
184 changes: 98 additions & 86 deletions app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import ani.dantotsu.FileUrl
import ani.dantotsu.R
import ani.dantotsu.addons.download.DownloadAddonManager
import ani.dantotsu.connections.anilist.api.MediaStreamingEpisode
import ani.dantotsu.databinding.FragmentAnimeWatchBinding
import ani.dantotsu.databinding.FragmentMediaSourceBinding
import ani.dantotsu.download.DownloadedType
import ani.dantotsu.download.DownloadsManager
import ani.dantotsu.download.DownloadsManager.Companion.compareName
Expand Down Expand Up @@ -81,7 +81,7 @@ import kotlin.math.max
import kotlin.math.roundToInt

class AnimeWatchFragment : Fragment() {
private var _binding: FragmentAnimeWatchBinding? = null
private var _binding: FragmentMediaSourceBinding? = null
private val binding get() = _binding!!
private val model: MediaDetailsViewModel by activityViewModels()

Expand All @@ -108,7 +108,7 @@ class AnimeWatchFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentAnimeWatchBinding.inflate(inflater, container, false)
_binding = FragmentMediaSourceBinding.inflate(inflater, container, false)
return _binding?.root
}

Expand All @@ -129,7 +129,7 @@ class AnimeWatchFragment : Fragment() {
)


binding.animeSourceRecycler.updatePadding(bottom = binding.animeSourceRecycler.paddingBottom + navBarHeight)
binding.mediaSourceRecycler.updatePadding(bottom = binding.mediaSourceRecycler.paddingBottom + navBarHeight)
screenWidth = resources.displayMetrics.widthPixels.dp

var maxGridSize = (screenWidth / 100f).roundToInt()
Expand All @@ -153,13 +153,13 @@ class AnimeWatchFragment : Fragment() {
}
}

binding.animeSourceRecycler.layoutManager = gridLayoutManager
binding.mediaSourceRecycler.layoutManager = gridLayoutManager

binding.ScrollTop.setOnClickListener {
binding.animeSourceRecycler.scrollToPosition(10)
binding.animeSourceRecycler.smoothScrollToPosition(0)
binding.mediaSourceRecycler.scrollToPosition(10)
binding.mediaSourceRecycler.smoothScrollToPosition(0)
}
binding.animeSourceRecycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
binding.mediaSourceRecycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)

Expand All @@ -173,7 +173,7 @@ class AnimeWatchFragment : Fragment() {
}
})
model.scrolledToTop.observe(viewLifecycleOwner) {
if (it) binding.animeSourceRecycler.scrollToPosition(0)
if (it) binding.mediaSourceRecycler.scrollToPosition(0)
}

continueEp = model.continueMedia ?: false
Expand Down Expand Up @@ -206,7 +206,7 @@ class AnimeWatchFragment : Fragment() {
offlineMode = offlineMode
)

binding.animeSourceRecycler.adapter =
binding.mediaSourceRecycler.adapter =
ConcatAdapter(headerAdapter, episodeAdapter)

lifecycleScope.launch(Dispatchers.IO) {
Expand Down Expand Up @@ -267,7 +267,7 @@ class AnimeWatchFragment : Fragment() {
}
media.anime?.episodes = episodes

//CHIP GROUP
// CHIP GROUP
val total = episodes.size
val divisions = total.toDouble() / 10
start = 0
Expand Down Expand Up @@ -635,7 +635,7 @@ class AnimeWatchFragment : Fragment() {
private fun reload() {
val selected = model.loadSelected(media)

//Find latest episode for subscription
// Find latest episode for subscription
selected.latest =
media.anime?.episodes?.values?.maxOfOrNull { it.number.toFloatOrNull() ?: 0f } ?: 0f
selected.latest =
Expand Down Expand Up @@ -679,14 +679,14 @@ class AnimeWatchFragment : Fragment() {
override fun onResume() {
super.onResume()
binding.mediaInfoProgressBar.visibility = progress
binding.animeSourceRecycler.layoutManager?.onRestoreInstanceState(state)
binding.mediaSourceRecycler.layoutManager?.onRestoreInstanceState(state)

requireActivity().setNavigationTheme()
}

override fun onPause() {
super.onPause()
state = binding.animeSourceRecycler.layoutManager?.onSaveInstanceState()
state = binding.mediaSourceRecycler.layoutManager?.onSaveInstanceState()
}

companion object {
Expand Down
26 changes: 13 additions & 13 deletions app/src/main/java/ani/dantotsu/media/anime/EpisodeAdapters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class EpisodeAdapter(

val thumb =
ep.thumb?.let { if (it.url.isNotEmpty()) GlideUrl(it.url) { it.headers } else null }
Glide.with(binding.itemEpisodeImage).load(thumb ?: media.cover).override(400, 0)
.into(binding.itemEpisodeImage)
Glide.with(binding.itemMediaImage).load(thumb ?: media.cover).override(400, 0)
.into(binding.itemMediaImage)
binding.itemEpisodeNumber.text = ep.number
binding.itemEpisodeTitle.text = if (ep.number == title) "Episode $title" else title

Expand Down Expand Up @@ -141,9 +141,9 @@ class EpisodeAdapter(
}

handleProgress(
binding.itemEpisodeProgressCont,
binding.itemEpisodeProgress,
binding.itemEpisodeProgressEmpty,
binding.itemMediaProgressCont,
binding.itemMediaProgress,
binding.itemMediaProgressEmpty,
media.id,
ep.number
)
Expand All @@ -155,8 +155,8 @@ class EpisodeAdapter(

val thumb =
ep.thumb?.let { if (it.url.isNotEmpty()) GlideUrl(it.url) { it.headers } else null }
Glide.with(binding.itemEpisodeImage).load(thumb ?: media.cover).override(400, 0)
.into(binding.itemEpisodeImage)
Glide.with(binding.itemMediaImage).load(thumb ?: media.cover).override(400, 0)
.into(binding.itemMediaImage)

binding.itemEpisodeNumber.text = ep.number
binding.itemEpisodeTitle.text = title
Expand Down Expand Up @@ -184,9 +184,9 @@ class EpisodeAdapter(
binding.itemEpisodeViewed.visibility = View.GONE
}
handleProgress(
binding.itemEpisodeProgressCont,
binding.itemEpisodeProgress,
binding.itemEpisodeProgressEmpty,
binding.itemMediaProgressCont,
binding.itemMediaProgress,
binding.itemMediaProgressEmpty,
media.id,
ep.number
)
Expand All @@ -209,9 +209,9 @@ class EpisodeAdapter(
}
}
handleProgress(
binding.itemEpisodeProgressCont,
binding.itemEpisodeProgress,
binding.itemEpisodeProgressEmpty,
binding.itemMediaProgressCont,
binding.itemMediaProgress,
binding.itemMediaProgressEmpty,
media.id,
ep.number
)
Expand Down
Loading

0 comments on commit 124f4eb

Please sign in to comment.