diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt index 44b3e6a1ef..3d4e6d8e66 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt @@ -1,10 +1,12 @@ package ani.dantotsu.media.manga +import android.app.AlertDialog import android.util.TypedValue import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.animation.LinearInterpolator +import android.widget.NumberPicker import androidx.lifecycle.coroutineScope import androidx.recyclerview.widget.RecyclerView import ani.dantotsu.R @@ -138,6 +140,25 @@ class MangaChapterAdapter( } } + fun downloadNChaptersFrom(position: Int, n: Int) { + //download next n chapters + for (i in 0..() @@ -224,6 +245,24 @@ class MangaChapterAdapter( } } } + binding.itemDownload.setOnLongClickListener { + //Alert dialog asking for the number of chapters to download + val alertDialog = AlertDialog.Builder(currContext(), R.style.MyPopup) + alertDialog.setTitle("Multi Chapter Downloader") + alertDialog.setMessage("Enter the number of chapters to download") + val input = NumberPicker(currContext()) + input.minValue = 1 + input.maxValue = itemCount - bindingAdapterPosition + input.value = 1 + alertDialog.setView(input) + alertDialog.setPositiveButton("OK") { dialog, which -> + downloadNChaptersFrom(bindingAdapterPosition, input.value) + } + alertDialog.setNegativeButton("Cancel") { dialog, _ -> dialog.cancel() } + val dialog = alertDialog.show() + dialog.window?.setDimAmount(0.8f) + true + } } }