mirror of
https://github.com/fumiama/copymanga.git
synced 2026-06-23 19:10:23 +08:00
v2.0.beta23
新增 1. 我的下载长按漫画删除/进入详情页 修复 1. 阅读漫画时隐藏底部时间栏失效 2. 竖向阅读时恢复阅读进度错位 3. 关闭动画时下载/初次观看章节第一页黑屏
This commit is contained in:
@@ -8,8 +8,8 @@ android {
|
|||||||
applicationId 'top.fumiama.copymanga'
|
applicationId 'top.fumiama.copymanga'
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 33
|
targetSdkVersion 33
|
||||||
versionCode 34
|
versionCode 35
|
||||||
versionName '2.0.beta22'
|
versionName '2.0.beta23'
|
||||||
resConfigs 'zh', 'zh-rCN'
|
resConfigs 'zh', 'zh-rCN'
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
|
|||||||
import top.fumiama.copymanga.ui.vm.ViewMangaActivity
|
import top.fumiama.copymanga.ui.vm.ViewMangaActivity
|
||||||
|
|
||||||
object Reader {
|
object Reader {
|
||||||
fun viewMangaAt(name: String, pos: Int, from_first_page: Boolean = false) {
|
fun viewMangaAt(name: String, pos: Int, fromFirstPage: Boolean = false) {
|
||||||
Log.d("MyR", "viewMangaAt name $name, pos $pos")
|
Log.d("MyR", "viewMangaAt name $name, pos $pos")
|
||||||
mainWeakReference?.get()?.apply {
|
mainWeakReference?.get()?.apply {
|
||||||
getPreferences(Context.MODE_PRIVATE)?.edit {
|
getPreferences(Context.MODE_PRIVATE)?.edit {
|
||||||
@@ -21,7 +21,7 @@ object Reader {
|
|||||||
ViewMangaActivity.comicName = name
|
ViewMangaActivity.comicName = name
|
||||||
val zipf = ViewMangaActivity.fileArray[pos]
|
val zipf = ViewMangaActivity.fileArray[pos]
|
||||||
val intent = Intent(this, ViewMangaActivity::class.java)
|
val intent = Intent(this, ViewMangaActivity::class.java)
|
||||||
if(!from_first_page) {
|
if(!fromFirstPage) {
|
||||||
intent.putExtra("function", "log")
|
intent.putExtra("function", "log")
|
||||||
ViewMangaActivity.pn = -2
|
ViewMangaActivity.pn = -2
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ open class AutoDownloadHandler(private val url: String, private val jsonClass: C
|
|||||||
fun destroy() {
|
fun destroy() {
|
||||||
exit = true
|
exit = true
|
||||||
}
|
}
|
||||||
private fun download(){
|
private fun download() {
|
||||||
Thread{ dlThread() }.start()
|
Thread{ dlThread() }.start()
|
||||||
checkTimes = 0
|
checkTimes = 0
|
||||||
timeThread = TimeThread(this, callCheckMsg)
|
timeThread = TimeThread(this, callCheckMsg)
|
||||||
@@ -91,7 +91,7 @@ open class AutoDownloadHandler(private val url: String, private val jsonClass: C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun check(){
|
private fun check() {
|
||||||
val g = getGsonItem()
|
val g = getGsonItem()
|
||||||
if(g != null) {
|
if(g != null) {
|
||||||
timeThread?.canDo = false
|
timeThread?.canDo = false
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package top.fumiama.copymanga.tools.file
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
object FileUtils {
|
||||||
|
fun recursiveRemove(f: File) {
|
||||||
|
if (f.isDirectory) f.listFiles()?.let {
|
||||||
|
for (i in it)
|
||||||
|
if (i.isDirectory) recursiveRemove(i)
|
||||||
|
else i.delete()
|
||||||
|
}
|
||||||
|
f.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,17 +2,21 @@ package top.fumiama.copymanga.ui.book
|
|||||||
|
|
||||||
import android.content.Context.MODE_PRIVATE
|
import android.content.Context.MODE_PRIVATE
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import com.google.gson.Gson
|
||||||
import kotlinx.android.synthetic.main.line_booktandb.*
|
import kotlinx.android.synthetic.main.line_booktandb.*
|
||||||
import top.fumiama.copymanga.MainActivity
|
import top.fumiama.copymanga.MainActivity
|
||||||
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
|
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
|
||||||
|
import top.fumiama.copymanga.json.VolumeStructure
|
||||||
import top.fumiama.copymanga.manga.Reader
|
import top.fumiama.copymanga.manga.Reader
|
||||||
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
|
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
|
||||||
import top.fumiama.copymanga.tools.api.Navigate
|
import top.fumiama.copymanga.tools.api.Navigate
|
||||||
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment
|
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment
|
||||||
import top.fumiama.dmzj.copymanga.R
|
import top.fumiama.dmzj.copymanga.R
|
||||||
|
import java.io.File
|
||||||
import java.lang.Thread.sleep
|
import java.lang.Thread.sleep
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
|
|
||||||
@@ -26,8 +30,33 @@ class BookFragment: NoBackRefreshFragment(R.layout.fragment_book) {
|
|||||||
ComicDlFragment.exit = false
|
ComicDlFragment.exit = false
|
||||||
|
|
||||||
if(isFirstInflate) {
|
if(isFirstInflate) {
|
||||||
bookHandler = BookHandler(WeakReference(this), arguments?.getString("path")?:"null")
|
var path = ""
|
||||||
Thread{
|
arguments?.apply {
|
||||||
|
if (getBoolean("loadJson")) {
|
||||||
|
getString("name")?.let { name ->
|
||||||
|
mainWeakReference?.get()?.getExternalFilesDir("")?.let {
|
||||||
|
Gson().fromJson(File(File(it, name), "info.json").readText(), Array<VolumeStructure>::class.java)
|
||||||
|
}?.apply {
|
||||||
|
if (isEmpty() || get(0).results.list.isEmpty()) {
|
||||||
|
findNavController().popBackStack()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
path = get(0).results.list[0].comic_path_word
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else getString("path").let {
|
||||||
|
if (it != null) path = it
|
||||||
|
else {
|
||||||
|
findNavController().popBackStack()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bookHandler = BookHandler(WeakReference(this), path)
|
||||||
|
Log.d("MyBF", "read path: $path")
|
||||||
|
Thread {
|
||||||
sleep(600)
|
sleep(600)
|
||||||
bookHandler?.startLoad()
|
bookHandler?.startLoad()
|
||||||
}.start()
|
}.start()
|
||||||
@@ -54,8 +83,8 @@ class BookFragment: NoBackRefreshFragment(R.layout.fragment_book) {
|
|||||||
|
|
||||||
fun setStartRead() {
|
fun setStartRead() {
|
||||||
if(bookHandler?.chapterNames?.isNotEmpty() == true) mainWeakReference?.get()?.apply {
|
if(bookHandler?.chapterNames?.isNotEmpty() == true) mainWeakReference?.get()?.apply {
|
||||||
bookHandler?.book?.results?.comic?.name?.let { name ->
|
bookHandler?.book?.results?.comic?.let { comic ->
|
||||||
getPreferences(MODE_PRIVATE).getInt(name, -1).let { p ->
|
getPreferences(MODE_PRIVATE).getInt(comic.name, -1).let { p ->
|
||||||
this@BookFragment.lbbstart.apply {
|
this@BookFragment.lbbstart.apply {
|
||||||
var i = 0
|
var i = 0
|
||||||
if(p >= 0) {
|
if(p >= 0) {
|
||||||
@@ -63,7 +92,7 @@ class BookFragment: NoBackRefreshFragment(R.layout.fragment_book) {
|
|||||||
i = p
|
i = p
|
||||||
}
|
}
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
Reader.viewMangaAt(name, i)
|
Reader.viewMangaAt(comic.name, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ class BookHandler(private val th: WeakReference<BookFragment>, private val path:
|
|||||||
if(exit) return@runOnUiThread
|
if(exit) return@runOnUiThread
|
||||||
ViewMangaActivity.fileArray = arrayOf()
|
ViewMangaActivity.fileArray = arrayOf()
|
||||||
ViewMangaActivity.urlArray = arrayOf()
|
ViewMangaActivity.urlArray = arrayOf()
|
||||||
|
ViewMangaActivity.uuidArray = arrayOf()
|
||||||
var i = 0
|
var i = 0
|
||||||
vols?.forEachIndexed { iv, v ->
|
vols?.forEachIndexed { iv, v ->
|
||||||
if(exit) return@runOnUiThread
|
if(exit) return@runOnUiThread
|
||||||
@@ -260,13 +261,14 @@ class BookHandler(private val th: WeakReference<BookFragment>, private val path:
|
|||||||
)?:""
|
)?:""
|
||||||
ViewMangaActivity.fileArray += CMApi.getZipFile(context?.getExternalFilesDir(""), comic.name, keys[iv], it.name)
|
ViewMangaActivity.fileArray += CMApi.getZipFile(context?.getExternalFilesDir(""), comic.name, keys[iv], it.name)
|
||||||
chapterNames += it.name
|
chapterNames += it.name
|
||||||
|
ViewMangaActivity.uuidArray += it.uuid
|
||||||
if(line == null) {
|
if(line == null) {
|
||||||
if(i == last) {
|
if(i == last) {
|
||||||
line = layoutInflater.inflate(R.layout.line_chapter, that!!.fbl, false)
|
line = layoutInflater.inflate(R.layout.line_chapter, that!!.fbl, false)
|
||||||
line?.lcc?.apply {
|
line?.lcc?.apply {
|
||||||
lct.text = it.name
|
lct.text = it.name
|
||||||
val index = i
|
val index = i
|
||||||
setOnClickListener { Reader.viewMangaAt(book!!.results.comic.name, index) }
|
setOnClickListener { Reader.viewMangaAt(comic.name, index) }
|
||||||
}
|
}
|
||||||
fbl?.addView(line)
|
fbl?.addView(line)
|
||||||
} else {
|
} else {
|
||||||
@@ -274,13 +276,13 @@ class BookHandler(private val th: WeakReference<BookFragment>, private val path:
|
|||||||
line?.l2cl?.apply {
|
line?.l2cl?.apply {
|
||||||
lct.text = it.name
|
lct.text = it.name
|
||||||
val index = i
|
val index = i
|
||||||
setOnClickListener { Reader.viewMangaAt(book!!.results.comic.name, index) }
|
setOnClickListener { Reader.viewMangaAt(comic.name, index) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else line?.l2cr?.apply {
|
} else line?.l2cr?.apply {
|
||||||
lct.text = it.name
|
lct.text = it.name
|
||||||
val index = i
|
val index = i
|
||||||
setOnClickListener { Reader.viewMangaAt(book!!.results.comic.name, index) }
|
setOnClickListener { Reader.viewMangaAt(comic.name, index) }
|
||||||
fbl?.addView(line)
|
fbl?.addView(line)
|
||||||
line = null
|
line = null
|
||||||
}
|
}
|
||||||
@@ -375,18 +377,22 @@ class BookHandler(private val th: WeakReference<BookFragment>, private val path:
|
|||||||
File(mangaFolder, "info.json").writeText(json!!)
|
File(mangaFolder, "info.json").writeText(json!!)
|
||||||
File(mangaFolder, "grps.json").writeText(Gson().toJson(keys))
|
File(mangaFolder, "grps.json").writeText(Gson().toJson(keys))
|
||||||
that?.apply {
|
that?.apply {
|
||||||
File(mangaFolder, "head.jpg").let { head ->
|
Thread {
|
||||||
val fo = head.outputStream()
|
sleep(1000)
|
||||||
try {
|
if (exit) return@Thread
|
||||||
imic.drawable.toBitmap().compress(Bitmap.CompressFormat.JPEG, 90, fo)
|
File(mangaFolder, "head.jpg").let { head ->
|
||||||
} catch (e: Exception) {
|
val fo = head.outputStream()
|
||||||
e.printStackTrace()
|
try {
|
||||||
mainWeakReference?.get()?.apply {
|
imic.drawable.toBitmap().compress(Bitmap.CompressFormat.JPEG, 90, fo)
|
||||||
Toast.makeText(this, R.string.download_cover_error, Toast.LENGTH_SHORT).show()
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
mainWeakReference?.get()?.apply {
|
||||||
|
Toast.makeText(this, R.string.download_cover_error, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fo.close()
|
||||||
}
|
}
|
||||||
fo.close()
|
}.start()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ class ComicDlHandler(looper: Looper, private val th: WeakReference<ComicDlFragme
|
|||||||
else Thread{
|
else Thread{
|
||||||
ViewMangaActivity.urlArray = arrayOf()
|
ViewMangaActivity.urlArray = arrayOf()
|
||||||
ViewMangaActivity.fileArray = arrayOf()
|
ViewMangaActivity.fileArray = arrayOf()
|
||||||
|
ViewMangaActivity.uuidArray = arrayOf()
|
||||||
vols.forEachIndexed { i, vol ->
|
vols.forEachIndexed { i, vol ->
|
||||||
val caption = groupNames?.get(i)?:vol.results.list[0].group_path_word
|
val caption = groupNames?.get(i)?:vol.results.list[0].group_path_word
|
||||||
Log.d("MyCDH", "caption: $caption, group name: ${groupNames?.get(i)}")
|
Log.d("MyCDH", "caption: $caption, group name: ${groupNames?.get(i)}")
|
||||||
@@ -324,6 +325,7 @@ class ComicDlHandler(looper: Looper, private val th: WeakReference<ComicDlFragme
|
|||||||
tbtncnt++
|
tbtncnt++
|
||||||
|
|
||||||
tbv.tbtn.uuid = uuid
|
tbv.tbtn.uuid = uuid
|
||||||
|
ViewMangaActivity.uuidArray += uuid
|
||||||
tbv.tbtn.chapterName = title
|
tbv.tbtn.chapterName = title
|
||||||
tbv.tbtn.url = url
|
tbv.tbtn.url = url
|
||||||
//tbv.tbtn.hint = caption
|
//tbv.tbtn.hint = caption
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import kotlinx.android.synthetic.main.fragment_download.*
|
|||||||
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
|
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
|
||||||
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
|
import top.fumiama.copymanga.template.general.NoBackRefreshFragment
|
||||||
import top.fumiama.copymanga.tools.api.Navigate
|
import top.fumiama.copymanga.tools.api.Navigate
|
||||||
|
import top.fumiama.copymanga.tools.file.FileUtils
|
||||||
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment
|
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment
|
||||||
import top.fumiama.copymanga.ui.vm.ViewMangaActivity
|
import top.fumiama.copymanga.ui.vm.ViewMangaActivity
|
||||||
import top.fumiama.dmzj.copymanga.R
|
import top.fumiama.dmzj.copymanga.R
|
||||||
@@ -68,7 +69,7 @@ class DownloadFragment: NoBackRefreshFragment(R.layout.fragment_download) {
|
|||||||
AlertDialog.Builder(context)
|
AlertDialog.Builder(context)
|
||||||
.setIcon(R.drawable.ic_launcher_foreground).setMessage("删除?")
|
.setIcon(R.drawable.ic_launcher_foreground).setMessage("删除?")
|
||||||
.setTitle("提示").setPositiveButton(android.R.string.ok) { _, _ ->
|
.setTitle("提示").setPositiveButton(android.R.string.ok) { _, _ ->
|
||||||
if (chosenFile.exists()) recursiveRemove(chosenFile)
|
if (chosenFile.exists()) FileUtils.recursiveRemove(chosenFile)
|
||||||
scanFile(cd)
|
scanFile(cd)
|
||||||
}.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
}.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
||||||
.show()
|
.show()
|
||||||
@@ -79,16 +80,6 @@ class DownloadFragment: NoBackRefreshFragment(R.layout.fragment_download) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun recursiveRemove(f: File) {
|
|
||||||
if (f.isDirectory) f.listFiles()?.let {
|
|
||||||
for (i in it)
|
|
||||||
if (i.isDirectory) recursiveRemove(i)
|
|
||||||
else i.delete()
|
|
||||||
}
|
|
||||||
f.delete()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun callDownloadFragment(jsonFile: File, isNew: Boolean = false){
|
private fun callDownloadFragment(jsonFile: File, isNew: Boolean = false){
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
Log.d("MyDF", "Call dl and is new: $isNew")
|
Log.d("MyDF", "Call dl and is new: $isNew")
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
package top.fumiama.copymanga.ui.download
|
package top.fumiama.copymanga.ui.download
|
||||||
|
|
||||||
|
import android.app.AlertDialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import com.google.gson.Gson
|
||||||
import kotlinx.android.synthetic.main.line_lazybooklines.*
|
import kotlinx.android.synthetic.main.line_lazybooklines.*
|
||||||
import top.fumiama.copymanga.MainActivity
|
import top.fumiama.copymanga.MainActivity
|
||||||
import top.fumiama.copymanga.template.general.MangaPagesFragmentTemplate
|
import top.fumiama.copymanga.template.general.MangaPagesFragmentTemplate
|
||||||
import top.fumiama.copymanga.template.ui.CardList
|
import top.fumiama.copymanga.template.ui.CardList
|
||||||
import top.fumiama.copymanga.tools.api.Navigate
|
import top.fumiama.copymanga.tools.api.Navigate
|
||||||
|
import top.fumiama.copymanga.tools.file.FileUtils
|
||||||
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment
|
import top.fumiama.copymanga.ui.comicdl.ComicDlFragment
|
||||||
import top.fumiama.dmzj.copymanga.R
|
import top.fumiama.dmzj.copymanga.R
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -64,6 +67,42 @@ class NewDownloadFragment: MangaPagesFragmentTemplate(R.layout.fragment_newdownl
|
|||||||
}
|
}
|
||||||
callDownloadFragment(name)
|
callDownloadFragment(name)
|
||||||
}
|
}
|
||||||
|
v.setOnLongClickListener {
|
||||||
|
if (name == oldDlCardName && path == oldDlCardName) {
|
||||||
|
return@setOnLongClickListener false
|
||||||
|
}
|
||||||
|
val chosenFile = File(extDir, name)
|
||||||
|
AlertDialog.Builder(context)
|
||||||
|
.setIcon(R.drawable.ic_launcher_foreground)
|
||||||
|
.setTitle(R.string.new_download_card_option_hint)
|
||||||
|
.setItems(arrayOf("删除", "前往")) { d, p ->
|
||||||
|
d.cancel()
|
||||||
|
when (p) {
|
||||||
|
0 -> {
|
||||||
|
AlertDialog.Builder(context)
|
||||||
|
.setIcon(R.drawable.ic_launcher_foreground).setMessage("删除下载的此漫画吗?")
|
||||||
|
.setTitle("提示").setPositiveButton(android.R.string.ok) { _, _ ->
|
||||||
|
if (chosenFile.exists()) Thread {
|
||||||
|
FileUtils.recursiveRemove(chosenFile)
|
||||||
|
MainActivity.mainWeakReference?.get()?.runOnUiThread {
|
||||||
|
it.visibility = View.INVISIBLE
|
||||||
|
}
|
||||||
|
}.start()
|
||||||
|
}.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
1 -> {
|
||||||
|
val bundle = Bundle()
|
||||||
|
bundle.putBoolean("loadJson", true)
|
||||||
|
bundle.putString("name", name)
|
||||||
|
Navigate.safeNavigateTo(findNavController(), R.id.action_nav_new_download_to_nav_book, bundle)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,9 +197,9 @@ class HomeFragment : NoBackRefreshFragment(R.layout.fragment_home) {
|
|||||||
Glide.with(it).load(GlideUrl(CMApi.proxy?.wrap(cover)?:cover, CMApi.myGlideHeaders)).into(holder.itemView.imic)
|
Glide.with(it).load(GlideUrl(CMApi.proxy?.wrap(cover)?:cover, CMApi.myGlideHeaders)).into(holder.itemView.imic)
|
||||||
}
|
}
|
||||||
holder.itemView.lwc.setOnClickListener {
|
holder.itemView.lwc.setOnClickListener {
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
bundle.putString("path", path_word)
|
bundle.putString("path", path_word)
|
||||||
Navigate.safeNavigateTo(findNavController(), R.id.action_nav_home_to_nav_book, bundle)
|
Navigate.safeNavigateTo(findNavController(), R.id.action_nav_home_to_nav_book, bundle)
|
||||||
}
|
}
|
||||||
holder.itemView.lwc.layoutParams.height = fhs.width / 4
|
holder.itemView.lwc.layoutParams.height = fhs.width / 4
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class PagesManager(w: WeakReference<ViewMangaActivity>) {
|
|||||||
val chapterPosition = position + if(goNext) 1 else -1
|
val chapterPosition = position + if(goNext) 1 else -1
|
||||||
urlArray.let {
|
urlArray.let {
|
||||||
if(chapterPosition >= 0 && chapterPosition < it.size) it[chapterPosition].let {
|
if(chapterPosition >= 0 && chapterPosition < it.size) it[chapterPosition].let {
|
||||||
if (if(goNext)isEndR else isEndL) {
|
if (if(goNext) isEndR else isEndL) {
|
||||||
//if(v.zipFirst) intent.putExtra("callFrom", "zipFirst")
|
//if(v.zipFirst) intent.putExtra("callFrom", "zipFirst")
|
||||||
v.tt.canDo = false
|
v.tt.canDo = false
|
||||||
//ViewMangaActivity.dlhandler = null
|
//ViewMangaActivity.dlhandler = null
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import top.fumiama.copymanga.json.ComicStructure
|
|||||||
import top.fumiama.copymanga.template.http.AutoDownloadHandler
|
import top.fumiama.copymanga.template.http.AutoDownloadHandler
|
||||||
import top.fumiama.copymanga.ui.vm.ViewMangaActivity.Companion.comicName
|
import top.fumiama.copymanga.ui.vm.ViewMangaActivity.Companion.comicName
|
||||||
import top.fumiama.copymanga.ui.vm.ViewMangaActivity.Companion.pn
|
import top.fumiama.copymanga.ui.vm.ViewMangaActivity.Companion.pn
|
||||||
|
import top.fumiama.copymanga.ui.vm.ViewMangaActivity.Companion.position
|
||||||
|
import top.fumiama.copymanga.ui.vm.ViewMangaActivity.Companion.uuidArray
|
||||||
import top.fumiama.copymanga.views.ScaleImageView
|
import top.fumiama.copymanga.views.ScaleImageView
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
@@ -33,7 +35,7 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
|
|||||||
private val wv = WeakReference(activity)
|
private val wv = WeakReference(activity)
|
||||||
private val infcard = wv.get()?.infcard
|
private val infcard = wv.get()?.infcard
|
||||||
private var infcShowed = false
|
private var infcShowed = false
|
||||||
val dl = wv.get()?.let {
|
private val dl = wv.get()?.let {
|
||||||
val re = Dialog(it)
|
val re = Dialog(it)
|
||||||
re.setContentView(R.layout.dialog_unzipping)
|
re.setContentView(R.layout.dialog_unzipping)
|
||||||
re
|
re
|
||||||
@@ -151,6 +153,7 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
|
|||||||
it.results.comic.name = file.parentFile?.name
|
it.results.comic.name = file.parentFile?.name
|
||||||
it.results.chapter = ChapterWithContent()
|
it.results.chapter = ChapterWithContent()
|
||||||
it.results.chapter.name = file.nameWithoutExtension
|
it.results.chapter.name = file.nameWithoutExtension
|
||||||
|
it.results.chapter.uuid = uuidArray[position]
|
||||||
wv.get()?.countZipEntries { c ->
|
wv.get()?.countZipEntries { c ->
|
||||||
it.results.chapter.size = c
|
it.results.chapter.size = c
|
||||||
prepareManga()
|
prepareManga()
|
||||||
|
|||||||
@@ -77,12 +77,15 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
get() = getPageNumber()
|
get() = getPageNumber()
|
||||||
set(value) = setPageNumber(value)
|
set(value) = setPageNumber(value)
|
||||||
//var pn = 0
|
//var pn = 0
|
||||||
private val isPnValid: Boolean get(){
|
private val isPnValid: Boolean get() {
|
||||||
if(pn == -2) {
|
val re = if(pn == -2) {
|
||||||
pn = 0
|
pn = 0
|
||||||
return true
|
true
|
||||||
|
} else {
|
||||||
|
intent.getStringExtra("function") == "log" && pn > 0
|
||||||
}
|
}
|
||||||
return intent.getStringExtra("function") == "log" && pn > 0
|
Log.d("MyVM", "isPnValid: $re")
|
||||||
|
return re
|
||||||
}
|
}
|
||||||
private var tasks: Array<FutureTask<ByteArray?>?>? = null
|
private var tasks: Array<FutureTask<ByteArray?>?>? = null
|
||||||
private var destroy = false
|
private var destroy = false
|
||||||
@@ -240,9 +243,14 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
fun initManga(){
|
fun initManga() {
|
||||||
handler.manga?.results?.chapter?.uuid?.let {
|
val uuid = handler.manga?.results?.chapter?.uuid
|
||||||
pn = getPreferences(MODE_PRIVATE).getInt(it, pn)
|
Log.d("MyVM", "initManga, chapter uuid: $uuid")
|
||||||
|
if (uuid != null && uuid != "") {
|
||||||
|
pn = getPreferences(MODE_PRIVATE).getInt(uuid, -4)
|
||||||
|
Log.d("MyVM", "load pn from uuid: $pn")
|
||||||
|
} else {
|
||||||
|
pn = -4
|
||||||
}
|
}
|
||||||
if (zipFile?.exists() != true) doPrepareWebImg()
|
if (zipFile?.exists() != true) doPrepareWebImg()
|
||||||
else prepareItems()
|
else prepareItems()
|
||||||
@@ -289,6 +297,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setPageNumber(num: Int) {
|
private fun setPageNumber(num: Int) {
|
||||||
|
Log.d("MyVM", "setPageNumber($num)")
|
||||||
if (r2l && !notUseVP) vp.currentItem = realCount - num
|
if (r2l && !notUseVP) vp.currentItem = realCount - num
|
||||||
else if (notUseVP) {
|
else if (notUseVP) {
|
||||||
if(isVertical){
|
if(isVertical){
|
||||||
@@ -349,13 +358,13 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
|
|
||||||
private fun cutBitmap(bitmap: Bitmap, isEnd: Boolean) = Bitmap.createBitmap(bitmap, if(!isEnd) 0 else (bitmap.width/2), 0, bitmap.width/2, bitmap.height)
|
private fun cutBitmap(bitmap: Bitmap, isEnd: Boolean) = Bitmap.createBitmap(bitmap, if(!isEnd) 0 else (bitmap.width/2), 0, bitmap.width/2, bitmap.height)
|
||||||
|
|
||||||
private fun loadImg(imgView: ScaleImageView, bitmap: Bitmap, isLast: Int = 0, useCut: Boolean, isLeft: Boolean){
|
private fun loadImg(imgView: ScaleImageView, bitmap: Bitmap, isLast: Int = 0, useCut: Boolean, isLeft: Boolean, isPlaceholder: Boolean = true){
|
||||||
val bitmap2load = if(useCut) cutBitmap(bitmap, isLeft) else bitmap
|
val bitmap2load = if(useCut) cutBitmap(bitmap, isLeft) else bitmap
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
imgView.setImageBitmap(bitmap2load)
|
imgView.setImageBitmap(bitmap2load)
|
||||||
if(isVertical){
|
if(isVertical){
|
||||||
imgView.setHeight2FitImgWidth()
|
imgView.setHeight2FitImgWidth()
|
||||||
if (isLast == 1) handler.sendEmptyMessage(8)
|
if (!isPlaceholder && isLast == 1) handler.sendEmptyMessage(8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -363,7 +372,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
private fun loadImgUrlInto(imgView: ScaleImageView, url: String, isLast: Int = 0, useCut: Boolean, isLeft: Boolean){
|
private fun loadImgUrlInto(imgView: ScaleImageView, url: String, isLast: Int = 0, useCut: Boolean, isLeft: Boolean){
|
||||||
Log.d("MyVM", "Load from adt: $url")
|
Log.d("MyVM", "Load from adt: $url")
|
||||||
AutoDownloadThread(CMApi.proxy?.wrap(url)?:url) {
|
AutoDownloadThread(CMApi.proxy?.wrap(url)?:url) {
|
||||||
it?.let { loadImg(imgView, BitmapFactory.decodeByteArray(it, 0, it.size), isLast, useCut, isLeft) }
|
it?.let { loadImg(imgView, BitmapFactory.decodeByteArray(it, 0, it.size), isLast, useCut, isLeft, false) }
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,17 +395,17 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
val index2load = if(cut) Math.abs(indexMap[position]) -1 else position
|
val index2load = if(cut) Math.abs(indexMap[position]) -1 else position
|
||||||
val useCut = cut && isCut[index2load]
|
val useCut = cut && isCut[index2load]
|
||||||
val isLeft = cut && indexMap[position] > 0
|
val isLeft = cut && indexMap[position] > 0
|
||||||
loadImg(imgView, getLoadingBitmap(position), isLast, useCut, isLeft)
|
|
||||||
if (zipFile?.exists() == true) getImgBitmap(index2load)?.let {
|
if (zipFile?.exists() == true) getImgBitmap(index2load)?.let {
|
||||||
loadImg(imgView, it, isLast, useCut, isLeft)
|
loadImg(imgView, it, isLast, useCut, isLeft, false)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
loadImg(imgView, getLoadingBitmap(position), isLast, useCut, isLeft, true)
|
||||||
val re = tasks?.get(index2load)
|
val re = tasks?.get(index2load)
|
||||||
if (re != null) Thread{
|
if (re != null) Thread{
|
||||||
val data = re.get()
|
val data = re.get()
|
||||||
if(data != null && data.isNotEmpty()) {
|
if(data != null && data.isNotEmpty()) {
|
||||||
BitmapFactory.decodeByteArray(data, 0, data.size)?.let {
|
BitmapFactory.decodeByteArray(data, 0, data.size)?.let {
|
||||||
loadImg(imgView, it, isLast, useCut, isLeft)
|
loadImg(imgView, it, isLast, useCut, isLeft, false)
|
||||||
Log.d("MyVM", "Load from task")
|
Log.d("MyVM", "Load from task")
|
||||||
}?:Log.d("MyVM", "null bitmap")
|
}?:Log.d("MyVM", "null bitmap")
|
||||||
}
|
}
|
||||||
@@ -422,7 +431,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
|
|
||||||
fun prepareLastPage(loadCount: Int, maxCount: Int){
|
fun prepareLastPage(loadCount: Int, maxCount: Int){
|
||||||
for (i in loadCount until maxCount) handler.obtainMessage(5, scrollImages[i]).sendToTarget()
|
for (i in loadCount until maxCount) handler.obtainMessage(5, scrollImages[i]).sendToTarget()
|
||||||
handler.dl?.hide()
|
// handler.dl?.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getImgBitmap(position: Int): Bitmap? =
|
private fun getImgBitmap(position: Int): Bitmap? =
|
||||||
@@ -464,14 +473,13 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
private fun prepareItems() {
|
private fun prepareItems() {
|
||||||
try {
|
try {
|
||||||
prepareVP()
|
prepareVP()
|
||||||
//if (!isVertical) restorePN()
|
|
||||||
prepareInfoBar()
|
prepareInfoBar()
|
||||||
if (notUseVP && !isVertical && !isPnValid) loadOneImg()
|
|
||||||
prepareIdBtVH()
|
prepareIdBtVH()
|
||||||
toolsBox.dp2px(67)?.let { setIdPosition(it) }
|
toolsBox.dp2px(if(fullyHideInfo) 100 else 67)?.let { setIdPosition(it) }
|
||||||
prepareIdBtCut()
|
prepareIdBtCut()
|
||||||
prepareIdBtVP()
|
prepareIdBtVP()
|
||||||
prepareIdBtLR()
|
prepareIdBtLR()
|
||||||
|
if (notUseVP && !isVertical && !isPnValid) loadOneImg()
|
||||||
/*progressLog?.let {
|
/*progressLog?.let {
|
||||||
it["chapterId"] = hm.chapterId.toString()
|
it["chapterId"] = hm.chapterId.toString()
|
||||||
it["name"] = inftitle.ttitle.text
|
it["name"] = inftitle.ttitle.text
|
||||||
@@ -718,6 +726,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
var comicName: String? = null
|
var comicName: String? = null
|
||||||
|
var uuidArray = arrayOf<String>()
|
||||||
var urlArray = arrayOf<String>()
|
var urlArray = arrayOf<String>()
|
||||||
var fileArray = arrayOf<File>()
|
var fileArray = arrayOf<File>()
|
||||||
var position = 0
|
var position = 0
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/swiperefresh"
|
android:id="@+id/swiperefresh"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="64dp">
|
android:layout_marginTop="64dp">
|
||||||
|
|
||||||
<top.fumiama.copymanga.views.ScrollRefreshView
|
<top.fumiama.copymanga.views.ScrollRefreshView
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/fhl"
|
android:id="@+id/fhl"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingBottom="@dimen/global_content_padding_bottom">
|
android:paddingBottom="@dimen/global_content_padding_bottom">
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,13 @@
|
|||||||
app:exitAnim="@anim/slide_out_left"
|
app:exitAnim="@anim/slide_out_left"
|
||||||
app:popEnterAnim="@anim/slide_out_left_exit"
|
app:popEnterAnim="@anim/slide_out_left_exit"
|
||||||
app:popExitAnim="@anim/slide_in_right_exit"/>
|
app:popExitAnim="@anim/slide_in_right_exit"/>
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_nav_new_download_to_nav_book"
|
||||||
|
app:destination="@id/nav_book"
|
||||||
|
app:enterAnim="@anim/slide_in_right"
|
||||||
|
app:exitAnim="@anim/slide_out_left"
|
||||||
|
app:popEnterAnim="@anim/slide_out_left_exit"
|
||||||
|
app:popExitAnim="@anim/slide_in_right_exit"/>
|
||||||
</fragment>
|
</fragment>
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
|
|||||||
@@ -139,4 +139,5 @@
|
|||||||
<string name="login_restart_to_apply">重启应用以彻底退出登录</string>
|
<string name="login_restart_to_apply">重启应用以彻底退出登录</string>
|
||||||
|
|
||||||
<string name="old_download_card_name">前往旧版下载</string>
|
<string name="old_download_card_name">前往旧版下载</string>
|
||||||
|
<string name="new_download_card_option_hint">选择您的操作</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user