mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-28 03:51:02 +00:00
feat: add delete to smaller media bottom sheet
This commit is contained in:
@@ -58,6 +58,32 @@ class MediaListDialogSmallFragment : BottomSheetDialogFragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
binding.mediaListContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> { bottomMargin += navBarHeight }
|
binding.mediaListContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> { bottomMargin += navBarHeight }
|
||||||
val scope = viewLifecycleOwner.lifecycleScope
|
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.mediaListProgressBar.visibility = View.GONE
|
||||||
binding.mediaListLayout.visibility = View.VISIBLE
|
binding.mediaListLayout.visibility = View.VISIBLE
|
||||||
|
|||||||
@@ -178,22 +178,43 @@
|
|||||||
android:fontFamily="@font/poppins_bold"
|
android:fontFamily="@font/poppins_bold"
|
||||||
android:text="@string/list_private" />
|
android:text="@string/list_private" />
|
||||||
|
|
||||||
<Button
|
<LinearLayout
|
||||||
android:id="@+id/mediaListSave"
|
|
||||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="56dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="16dp"
|
||||||
android:fontFamily="@font/poppins_bold"
|
android:orientation="horizontal">
|
||||||
android:insetTop="0dp"
|
|
||||||
android:insetBottom="0dp"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:text="@string/save"
|
|
||||||
android:textSize="16sp"
|
|
||||||
app:cornerRadius="16dp"
|
|
||||||
app:strokeColor="?attr/colorPrimaryContainer" />
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/mediaListDelete"
|
||||||
|
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||||
|
android:layout_width="128dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetBottom="0dp"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:text="@string/delete"
|
||||||
|
android:textSize="16sp"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:strokeColor="?attr/colorPrimaryContainer" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/mediaListSave"
|
||||||
|
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetBottom="0dp"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:text="@string/save"
|
||||||
|
android:textSize="16sp"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:strokeColor="?attr/colorPrimaryContainer" />
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
|
|||||||
Reference in New Issue
Block a user