Skip to content

Commit

Permalink
fixed broken transition in offline anime page
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush2622 committed Jan 23, 2024
1 parent 4218d81 commit e5f0b71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener {
ActivityOptionsCompat.makeSceneTransitionAnimation(
requireActivity(),
Pair.create(
requireActivity().findViewById<ImageView>(R.id.itemCompactImage),
gridView.getChildAt(position).findViewById<ImageView>(R.id.itemCompactImage),
ViewCompat.getTransitionName(requireActivity().findViewById(R.id.itemCompactImage))
),
).toBundle()
Expand Down Expand Up @@ -252,41 +252,7 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

var height = statusBarHeight
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val displayCutout = activity?.window?.decorView?.rootWindowInsets?.displayCutout
if (displayCutout != null) {
if (displayCutout.boundingRects.size > 0) {
height = max(
statusBarHeight,
min(
displayCutout.boundingRects[0].width(),
displayCutout.boundingRects[0].height()
)
)
}
}
}
val scrollTop = view.findViewById<CardView>(R.id.mangaPageScrollTop)
scrollTop.translationY =
-(navBarHeight + bottomBar.height + bottomBar.marginBottom).toFloat()
val visible = false

fun animate() {
val start = if (visible) 0f else 1f
val end = if (!visible) 0f else 1f
ObjectAnimator.ofFloat(scrollTop, "scaleX", start, end).apply {
duration = 300
interpolator = OvershootInterpolator(2f)
start()
}
ObjectAnimator.ofFloat(scrollTop, "scaleY", start, end).apply {
duration = 300
interpolator = OvershootInterpolator(2f)
start()
}
}

scrollTop.setOnClickListener {
gridView.smoothScrollToPositionFromTop(0, 0)
}
Expand All @@ -306,7 +272,9 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener {
totalItemCount: Int
) {
val first = view.getChildAt(0)
val visibility = first != null && first.top < -height
val visibility = first != null && first.top < 0
scrollTop.translationY =
-(navBarHeight + bottomBar.height + bottomBar.marginBottom).toFloat()
scrollTop.visibility = if (visibility) View.VISIBLE else View.GONE
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,41 +236,8 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initActivity(requireActivity())
var height = statusBarHeight
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val displayCutout = activity?.window?.decorView?.rootWindowInsets?.displayCutout
if (displayCutout != null) {
if (displayCutout.boundingRects.size > 0) {
height = max(
statusBarHeight,
min(
displayCutout.boundingRects[0].width(),
displayCutout.boundingRects[0].height()
)
)
}
}
}
val scrollTop = view.findViewById<CardView>(R.id.mangaPageScrollTop)
scrollTop.translationY =
-(navBarHeight + bottomBar.height + bottomBar.marginBottom).toFloat()
val visible = false

fun animate() {
val start = if (visible) 0f else 1f
val end = if (!visible) 0f else 1f
ObjectAnimator.ofFloat(scrollTop, "scaleX", start, end).apply {
duration = 300
interpolator = OvershootInterpolator(2f)
start()
}
ObjectAnimator.ofFloat(scrollTop, "scaleY", start, end).apply {
duration = 300
interpolator = OvershootInterpolator(2f)
start()
}
}

val scrollTop = view.findViewById<CardView>(R.id.mangaPageScrollTop)
scrollTop.setOnClickListener {
gridView.smoothScrollToPositionFromTop(0, 0)
}
Expand All @@ -290,8 +257,10 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {
totalItemCount: Int
) {
val first = view.getChildAt(0)
val visibility = first != null && first.top < -height
val visibility = first != null && first.top < 0
scrollTop.visibility = if (visibility) View.VISIBLE else View.GONE
scrollTop.translationY =
-(navBarHeight + bottomBar.height + bottomBar.marginBottom).toFloat()
}
})

Expand Down

0 comments on commit e5f0b71

Please sign in to comment.