Update ActivityItem.kt

This commit is contained in:
UmbrellaalAcademy
2024-06-09 21:25:33 +05:30
committed by GitHub
parent 6f685a4388
commit c06c7da0de

View File

@@ -192,6 +192,27 @@ class ActivityItem(
}
}
}
binding.activityDelete.setOnClickListener {
val builder = androidx.appcompat.app.AlertDialog.Builder(
fragActivity,
R.style.MyPopup
)
builder.setTitle(R.string.activity_delete)
builder.setPositiveButton(R.string.yes) { _, _ ->
CoroutineScope(Dispatchers.IO).launch {
Anilist.mutation.deleteActivity(activity.id)
withContext(Dispatchers.Main) {
fragActivity.recreate()
}
}
}
builder.setNegativeButton(R.string.no) { _, _ ->
// Do nothing
}
val dialog = builder.show()
dialog.window?.setDimAmount(0.8f)
}
binding.activityDelete.isVisible = activity.userId == Anilist.userid
}
override fun getLayout(): Int {
@@ -201,4 +222,4 @@ class ActivityItem(
override fun initializeViewBinding(view: View): ItemActivityBinding {
return ItemActivityBinding.bind(view)
}
}
}