fix: download button orientation

This commit is contained in:
rebelonion 2024-02-08 00:56:14 -06:00
parent b093b5f979
commit 0758241e06
4 changed files with 12 additions and 10 deletions

View file

@ -372,18 +372,18 @@ class EpisodeAdapter(
if (activeDownloads.contains(episodeNumber)) { if (activeDownloads.contains(episodeNumber)) {
// Show spinner // Show spinner
binding.itemDownload.setImageResource(R.drawable.ic_sync) binding.itemDownload.setImageResource(R.drawable.ic_sync)
startOrContinueRotation(episodeNumber) startOrContinueRotation(episodeNumber) {
binding.itemDownload.rotation = 0f
}
binding.itemEpisodeDesc.visibility = View.GONE binding.itemEpisodeDesc.visibility = View.GONE
} else if (downloadedEpisodes.contains(episodeNumber)) { } else if (downloadedEpisodes.contains(episodeNumber)) {
binding.itemEpisodeDesc.visibility = View.GONE binding.itemEpisodeDesc.visibility = View.GONE
binding.itemDownloadStatus.visibility = View.VISIBLE binding.itemDownloadStatus.visibility = View.VISIBLE
// Show checkmark // Show checkmark
binding.itemDownload.setImageResource(R.drawable.ic_circle_check) binding.itemDownload.setImageResource(R.drawable.ic_circle_check)
//binding.itemDownload.setColorFilter(typedValue2.data) //TODO: colors go to wrong places
binding.itemDownload.postDelayed({ binding.itemDownload.postDelayed({
binding.itemDownload.setImageResource(R.drawable.ic_round_delete_24) binding.itemDownload.setImageResource(R.drawable.ic_round_delete_24)
binding.itemDownload.rotation = 0f binding.itemDownload.rotation = 0f
//binding.itemDownload.setColorFilter(typedValue2.data)
}, 1000) }, 1000)
} else { } else {
binding.itemDownloadStatus.visibility = View.GONE binding.itemDownloadStatus.visibility = View.GONE
@ -396,7 +396,7 @@ class EpisodeAdapter(
} }
private fun startOrContinueRotation(episodeNumber: String) { private fun startOrContinueRotation(episodeNumber: String, resetRotation: () -> Unit) {
if (!isRotationCoroutineRunningFor(episodeNumber)) { if (!isRotationCoroutineRunningFor(episodeNumber)) {
val scope = fragment.lifecycle.coroutineScope val scope = fragment.lifecycle.coroutineScope
scope.launch { scope.launch {
@ -411,6 +411,7 @@ class EpisodeAdapter(
} }
// Remove chapter number from active coroutines set // Remove chapter number from active coroutines set
activeCoroutines.remove(episodeNumber) activeCoroutines.remove(episodeNumber)
resetRotation()
} }
} }
} }

View file

@ -154,15 +154,15 @@ class MangaChapterAdapter(
if (activeDownloads.contains(chapterNumber)) { if (activeDownloads.contains(chapterNumber)) {
// Show spinner // Show spinner
binding.itemDownload.setImageResource(R.drawable.ic_sync) binding.itemDownload.setImageResource(R.drawable.ic_sync)
startOrContinueRotation(chapterNumber) startOrContinueRotation(chapterNumber) {
binding.itemDownload.rotation = 0f
}
} else if (downloadedChapters.contains(chapterNumber)) { } else if (downloadedChapters.contains(chapterNumber)) {
// Show checkmark // Show checkmark
binding.itemDownload.setImageResource(R.drawable.ic_circle_check) binding.itemDownload.setImageResource(R.drawable.ic_circle_check)
//binding.itemDownload.setColorFilter(typedValue2.data) //TODO: colors go to wrong places
binding.itemDownload.postDelayed({ binding.itemDownload.postDelayed({
binding.itemDownload.setImageResource(R.drawable.ic_round_delete_24) binding.itemDownload.setImageResource(R.drawable.ic_round_delete_24)
binding.itemDownload.rotation = 0f binding.itemDownload.rotation = 0f
//binding.itemDownload.setColorFilter(typedValue2.data)
}, 1000) }, 1000)
} else { } else {
// Show download icon // Show download icon
@ -172,7 +172,7 @@ class MangaChapterAdapter(
} }
private fun startOrContinueRotation(chapterNumber: String) { private fun startOrContinueRotation(chapterNumber: String, resetRotation: () -> Unit) {
if (!isRotationCoroutineRunningFor(chapterNumber)) { if (!isRotationCoroutineRunningFor(chapterNumber)) {
val scope = fragment.lifecycle.coroutineScope val scope = fragment.lifecycle.coroutineScope
scope.launch { scope.launch {
@ -187,6 +187,7 @@ class MangaChapterAdapter(
} }
// Remove chapter number from active coroutines set // Remove chapter number from active coroutines set
activeCoroutines.remove(chapterNumber) activeCoroutines.remove(chapterNumber)
resetRotation()
} }
} }
} }

View file

@ -48,7 +48,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:background="?android:attr/selectableItemBackground" android:background="@android:color/transparent"
app:srcCompat="@drawable/ic_download_24" app:srcCompat="@drawable/ic_download_24"
app:tint="?attr/colorOnBackground" /> app:tint="?attr/colorOnBackground" />

View file

@ -150,7 +150,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:background="?android:attr/selectableItemBackground" android:background="@android:color/transparent"
app:srcCompat="@drawable/ic_download_24" app:srcCompat="@drawable/ic_download_24"
app:tint="?attr/colorOnBackground" app:tint="?attr/colorOnBackground"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />