feat: longclicklistener for AL profile now accessible everywhere (#228)

* feat: added longclicklistener for AL profile in AnimePageAdapter and MangaPageAdapter

* feat: add delete to smaller media bottom sheet
This commit is contained in:
ibo 2024-03-09 22:02:23 +01:00 committed by GitHub
parent 7504bb9081
commit 7f36eba709
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 80 additions and 14 deletions

View file

@ -58,6 +58,32 @@ class MediaListDialogSmallFragment : BottomSheetDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
binding.mediaListContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> { bottomMargin += navBarHeight }
val scope = viewLifecycleOwner.lifecycleScope
binding.mediaListDelete.setOnClickListener {
val id = media.userListId
if (id != null) {
viewLifecycleOwner.lifecycleScope.launch {
withContext(Dispatchers.IO) {
try {
Anilist.mutation.deleteList(id)
MAL.query.deleteList(media.anime != null, media.idMAL)
} catch (e: Exception) {
withContext(Dispatchers.Main) {
snackString("Failed to delete because of... ${e.message}")
}
return@withContext
}
}
withContext(Dispatchers.Main) {
Refresh.all()
snackString(getString(R.string.deleted_from_list))
dismissAllowingStateLoss()
}
}
} else {
snackString(getString(R.string.no_list_id))
Refresh.all()
}
}
binding.mediaListProgressBar.visibility = View.GONE
binding.mediaListLayout.visibility = View.VISIBLE