multi fix + etc
This commit is contained in:
parent
ad1734d640
commit
fab978dba4
7 changed files with 62 additions and 43 deletions
|
@ -92,6 +92,7 @@ class MangaChapterAdapter(
|
||||||
// Find the position of the chapter and notify only that item
|
// Find the position of the chapter and notify only that item
|
||||||
val position = arr.indexOfFirst { it.number == chapterNumber }
|
val position = arr.indexOfFirst { it.number == chapterNumber }
|
||||||
if (position != -1) {
|
if (position != -1) {
|
||||||
|
arr[position].progress = ""
|
||||||
notifyItemChanged(position)
|
notifyItemChanged(position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +103,7 @@ class MangaChapterAdapter(
|
||||||
// Find the position of the chapter and notify only that item
|
// Find the position of the chapter and notify only that item
|
||||||
val position = arr.indexOfFirst { it.number == chapterNumber }
|
val position = arr.indexOfFirst { it.number == chapterNumber }
|
||||||
if (position != -1) {
|
if (position != -1) {
|
||||||
|
arr[position].progress = ""
|
||||||
notifyItemChanged(position)
|
notifyItemChanged(position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,30 +118,6 @@ class MangaChapterAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun downloadNextNChapters(n: Int) {
|
|
||||||
//find last viewed chapter
|
|
||||||
var lastViewedChapter = arr.indexOfFirst { MangaNameAdapter.findChapterNumber(it.number)?.toInt() == media.userProgress }
|
|
||||||
if (lastViewedChapter == -1) {
|
|
||||||
lastViewedChapter = 0
|
|
||||||
}
|
|
||||||
//download next n chapters
|
|
||||||
for (i in 1..n) {
|
|
||||||
if (lastViewedChapter + i < arr.size) {
|
|
||||||
val chapterNumber = arr[lastViewedChapter + i].number
|
|
||||||
if (activeDownloads.contains(chapterNumber)) {
|
|
||||||
//do nothing
|
|
||||||
continue
|
|
||||||
} else if (downloadedChapters.contains(chapterNumber)) {
|
|
||||||
//do nothing
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
fragment.onMangaChapterDownloadClick(chapterNumber)
|
|
||||||
startDownload(chapterNumber)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun downloadNChaptersFrom(position: Int, n: Int) {
|
fun downloadNChaptersFrom(position: Int, n: Int) {
|
||||||
//download next n chapters
|
//download next n chapters
|
||||||
for (i in 0..<n) {
|
for (i in 0..<n) {
|
||||||
|
@ -179,10 +157,10 @@ class MangaChapterAdapter(
|
||||||
} 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)
|
//binding.itemDownload.setColorFilter(typedValue2.data) //TODO: colors go to wrong places
|
||||||
binding.itemDownload.postDelayed({
|
binding.itemDownload.postDelayed({
|
||||||
binding.itemDownload.setImageResource(R.drawable.ic_circle_cancel)
|
binding.itemDownload.setImageResource(R.drawable.ic_round_delete_24)
|
||||||
binding.itemDownload.setColorFilter(typedValue2.data)
|
//binding.itemDownload.setColorFilter(typedValue2.data)
|
||||||
}, 1000)
|
}, 1000)
|
||||||
} else {
|
} else {
|
||||||
// Show download icon
|
// Show download icon
|
||||||
|
|
|
@ -180,7 +180,7 @@ class MangaReadAdapter(
|
||||||
hiddenScanlators.add(checkBox.text.toString())
|
hiddenScanlators.add(checkBox.text.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
media.selected!!.scanlators = hiddenScanlators
|
fragment.onScanlatorChange(hiddenScanlators)
|
||||||
scanlatorSelectionListener?.onScanlatorsSelected()
|
scanlatorSelectionListener?.onScanlatorsSelected()
|
||||||
}
|
}
|
||||||
.setNegativeButton("Cancel", null)
|
.setNegativeButton("Cancel", null)
|
||||||
|
|
|
@ -198,7 +198,21 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun multiDownload(n: Int) {
|
fun multiDownload(n: Int) {
|
||||||
chapterAdapter.downloadNextNChapters(n)
|
//get last viewed chapter
|
||||||
|
val selected = media.userProgress
|
||||||
|
val chapters = media.manga?.chapters?.values?.toList()
|
||||||
|
//filter by selected language
|
||||||
|
val progressChapterIndex = chapters?.indexOfFirst { MangaNameAdapter.findChapterNumber(it.number)?.toInt() == selected }?:0
|
||||||
|
val chaptersToDownload = chapters?.subList(
|
||||||
|
progressChapterIndex + 1,
|
||||||
|
progressChapterIndex + n + 1
|
||||||
|
)
|
||||||
|
if (chaptersToDownload != null) {
|
||||||
|
for (chapter in chaptersToDownload) {
|
||||||
|
onMangaChapterDownloadClick(chapter.title!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateChapters() {
|
private fun updateChapters() {
|
||||||
|
@ -275,6 +289,12 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {
|
||||||
media.selected = selected
|
media.selected = selected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onScanlatorChange(list: List<String>) {
|
||||||
|
val selected = model.loadSelected(media)
|
||||||
|
selected.scanlators = list
|
||||||
|
model.saveSelected(media.id, selected, requireActivity())
|
||||||
|
media.selected = selected
|
||||||
|
}
|
||||||
|
|
||||||
fun loadChapters(i: Int, invalidate: Boolean) {
|
fun loadChapters(i: Int, invalidate: Boolean) {
|
||||||
lifecycleScope.launch(Dispatchers.IO) { model.loadMangaChapters(media, i, invalidate) }
|
lifecycleScope.launch(Dispatchers.IO) { model.loadMangaChapters(media, i, invalidate) }
|
||||||
|
|
|
@ -27,6 +27,28 @@ class LanguageMapper {
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class Language(val code: String) {
|
||||||
|
ALL("all"),
|
||||||
|
ARABIC("ar"),
|
||||||
|
GERMAN("de"),
|
||||||
|
ENGLISH("en"),
|
||||||
|
SPANISH("es"),
|
||||||
|
FRENCH("fr"),
|
||||||
|
INDONESIAN("id"),
|
||||||
|
ITALIAN("it"),
|
||||||
|
JAPANESE("ja"),
|
||||||
|
KOREAN("ko"),
|
||||||
|
POLISH("pl"),
|
||||||
|
PORTUGUESE_BRAZIL("pt-BR"),
|
||||||
|
RUSSIAN("ru"),
|
||||||
|
THAI("th"),
|
||||||
|
TURKISH("tr"),
|
||||||
|
UKRAINIAN("uk"),
|
||||||
|
VIETNAMESE("vi"),
|
||||||
|
CHINESE("zh"),
|
||||||
|
CHINESE_SIMPLIFIED("zh-Hans")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import ani.dantotsu.others.LangSet
|
||||||
import ani.dantotsu.themes.ThemeManager
|
import ani.dantotsu.themes.ThemeManager
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import com.google.android.material.tabs.TabLayoutMediator
|
import com.google.android.material.tabs.TabLayoutMediator
|
||||||
import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension
|
|
||||||
|
|
||||||
class ExtensionsActivity : AppCompatActivity() {
|
class ExtensionsActivity : AppCompatActivity() {
|
||||||
private val restartMainActivity = object : OnBackPressedCallback(false) {
|
private val restartMainActivity = object : OnBackPressedCallback(false) {
|
||||||
|
@ -120,15 +119,17 @@ class ExtensionsActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
|
||||||
initActivity(this)
|
initActivity(this)
|
||||||
|
/* TODO
|
||||||
fun bind(extension: AnimeExtension.Available) {
|
binding.languageselect.setOnClickListener {
|
||||||
binding.languageselect.setOnClickListener {
|
val popup = PopupMenu(this, it)
|
||||||
val popup = PopupMenu(this, it)
|
popup.inflate(R.menu.launguage_selector_menu)
|
||||||
|
popup.setOnMenuItemClickListener { menuItem ->
|
||||||
popup.inflate(R.menu.launguage_selector_menu)
|
true
|
||||||
popup.show()
|
|
||||||
}
|
}
|
||||||
}
|
popup.setOnDismissListener {
|
||||||
|
}
|
||||||
|
popup.show()
|
||||||
|
}*/
|
||||||
binding.settingsContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.settingsContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
topMargin = statusBarHeight
|
topMargin = statusBarHeight
|
||||||
bottomMargin = navBarHeight
|
bottomMargin = navBarHeight
|
||||||
|
|
|
@ -48,8 +48,8 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
<ImageButton
|
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
android:id="@+id/languageselect"
|
android:id="@+id/languageselect"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
android:id="@+id/listTitle"
|
android:id="@+id/listTitle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginStart="32dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="32dp"
|
|
||||||
android:fontFamily="@font/poppins_bold"
|
android:fontFamily="@font/poppins_bold"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
|
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
|
||||||
|
@ -48,7 +47,6 @@
|
||||||
android:id="@+id/random"
|
android:id="@+id/random"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:contentDescription="@string/random_selection"
|
android:contentDescription="@string/random_selection"
|
||||||
app:tint="?attr/colorOnBackground"
|
app:tint="?attr/colorOnBackground"
|
||||||
|
@ -58,7 +56,7 @@
|
||||||
android:id="@+id/listSort"
|
android:id="@+id/listSort"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:contentDescription="@string/sort_by"
|
android:contentDescription="@string/sort_by"
|
||||||
app:tint="?attr/colorOnBackground"
|
app:tint="?attr/colorOnBackground"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue