mirror of
https://github.com/fumiama/copymanga.git
synced 2026-06-05 07:20:23 +08:00
v2.0.4
修复 1. 横向阅览漫画无法用音量键翻页(fix #35) 2. 纵向恢复阅览进度错位 3. 一个以上分卷的漫画最后一个章节为奇数时无法显示(如妖忍三重奏) 4. 下载页阅览已下载漫画加载下一章失败 5. 竖向阅览只有一页时准备中弹框不消失 优化 1. PagesManager 内存占用 2. 分类页默认显示最新更新时间 3. 主页、漫画详情页加载流畅度 4. 登录页使用协程重构(#36) by @Mrs4s
This commit is contained in:
@@ -8,8 +8,8 @@ android {
|
||||
applicationId 'top.fumiama.copymanga'
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 34
|
||||
versionCode 39
|
||||
versionName '2.0.3'
|
||||
versionCode 40
|
||||
versionName '2.0.4'
|
||||
resConfigs 'zh', 'zh-rCN'
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
@@ -74,5 +74,5 @@ dependencies {
|
||||
implementation 'com.liaoinstan.springview:library:1.7.0'
|
||||
implementation 'com.github.zawadz88.materialpopupmenu:material-popup-menu:4.0.1'
|
||||
implementation 'com.lapism:search:2.4.1@aar'
|
||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.android.synthetic.main.activity_login.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import top.fumiama.dmzj.copymanga.R
|
||||
import kotlin.random.Random
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.bumptech.glide.load.model.GlideUrl
|
||||
import kotlinx.android.synthetic.main.card_book.view.*
|
||||
import kotlinx.android.synthetic.main.line_horizonal_empty.view.*
|
||||
import kotlinx.android.synthetic.main.line_lazybooklines.*
|
||||
import top.fumiama.copymanga.MainActivity.Companion.mainWeakReference
|
||||
import top.fumiama.copymanga.tools.api.CMApi
|
||||
import top.fumiama.dmzj.copymanga.R
|
||||
import java.io.File
|
||||
@@ -76,7 +75,7 @@ class CardList(
|
||||
if (exitCardList) return
|
||||
manageRow()
|
||||
that?.apply {
|
||||
layoutInflater.inflate(R.layout.card_book, mydll.ltbtn, false)?.let {
|
||||
layoutInflater.inflate(R.layout.card_book, mydll?.ltbtn, false)?.let {
|
||||
val card = it.cic
|
||||
card.name = name
|
||||
card.append = append
|
||||
|
||||
@@ -73,9 +73,12 @@ class BookHandler(private val th: WeakReference<BookFragment>, val path: String)
|
||||
1 -> setCover()
|
||||
2 -> setTexts()
|
||||
3 -> that?.fbibinfo?.let { setInfoHeight(it) }
|
||||
4 -> setThemes()
|
||||
4 -> setAuthorsAndTags()
|
||||
5 -> setOverScale()
|
||||
6 -> if(complete) that?.navigate2dl()
|
||||
7 -> setVolumes()
|
||||
8 -> that?.apply { fbl?.addView(msg.obj as View) }
|
||||
9 -> endSetLayouts()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,14 +111,14 @@ class BookHandler(private val th: WeakReference<BookFragment>, val path: String)
|
||||
cnts += it.count
|
||||
Log.d("MyBFH", "Add caption: ${it.name} @ ${it.path_word} of ${it.count}")
|
||||
}
|
||||
for (i in 1..5) {
|
||||
sendEmptyMessageDelayed(i, (100*i).toLong())
|
||||
}
|
||||
if(vols?.isEmpty() != false) initComicData()
|
||||
Thread{ for (i in 1..5) {
|
||||
sleep(512)
|
||||
sendEmptyMessage(i)
|
||||
} }.start()
|
||||
}
|
||||
|
||||
private fun endSetLayouts(){
|
||||
private fun endSetLayouts() {
|
||||
if (exit) return
|
||||
that?.fbloading?.visibility = View.GONE
|
||||
complete = true
|
||||
that?.setStartRead()
|
||||
@@ -230,76 +233,92 @@ class BookHandler(private val th: WeakReference<BookFragment>, val path: String)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setThemes(){
|
||||
if (exit) return
|
||||
private fun setAuthorsAndTags() {
|
||||
that?.apply {
|
||||
book?.results?.comic?.apply {
|
||||
author?.let { setTheme(getString(R.string.author), it, R.id.action_nav_book_to_nav_author) }
|
||||
author?.let {
|
||||
setTheme(
|
||||
getString(R.string.author),
|
||||
it,
|
||||
R.id.action_nav_book_to_nav_author
|
||||
)
|
||||
}
|
||||
fbl.addView(layoutInflater.inflate(R.layout.div_h, fbl, false))
|
||||
theme?.let { setTheme(getString(R.string.caption), it, R.id.action_nav_book_to_nav_caption) }
|
||||
theme?.let {
|
||||
setTheme(
|
||||
getString(R.string.caption),
|
||||
it,
|
||||
R.id.action_nav_book_to_nav_caption
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Thread{
|
||||
while (vols == null && !exit) sleep(1000)
|
||||
if(exit) return@Thread
|
||||
that?.apply {
|
||||
book?.results?.apply {
|
||||
that?.activity?.runOnUiThread{
|
||||
if(exit) return@runOnUiThread
|
||||
ViewMangaActivity.fileArray = arrayOf()
|
||||
urlArray = arrayOf()
|
||||
ViewMangaActivity.uuidArray = arrayOf()
|
||||
var i = 0
|
||||
vols?.forEachIndexed { iv, v ->
|
||||
if(exit) return@runOnUiThread
|
||||
fbl.addView(layoutInflater.inflate(R.layout.div_h, fbl, false))
|
||||
val t = layoutInflater.inflate(R.layout.line_caption, fbl, false)
|
||||
t.tcptn.text = keys[iv]
|
||||
fbl.addView(t)
|
||||
fbl.addView(layoutInflater.inflate(R.layout.div_h, fbl, false))
|
||||
var line: View? = null
|
||||
val last = v.results.list.size - 1
|
||||
v.results.list.forEach {
|
||||
urlArray += CMApi.getChapterInfoApiUrl(
|
||||
comic.path_word,
|
||||
it.uuid
|
||||
)?:""
|
||||
ViewMangaActivity.fileArray += CMApi.getZipFile(context?.getExternalFilesDir(""), comic.name, keys[iv], it.name)
|
||||
chapterNames += it.name
|
||||
ViewMangaActivity.uuidArray += it.uuid
|
||||
if(line == null) {
|
||||
if(i == last) {
|
||||
line = layoutInflater.inflate(R.layout.line_chapter, that!!.fbl, false)
|
||||
line?.lcc?.apply {
|
||||
lct.text = it.name
|
||||
val index = i
|
||||
setOnClickListener { Reader.viewMangaAt(comic.name, index, urlArray) }
|
||||
}
|
||||
fbl?.addView(line)
|
||||
} else {
|
||||
line = layoutInflater.inflate(R.layout.line_2chapters, that!!.fbl, false)
|
||||
line?.l2cl?.apply {
|
||||
lct.text = it.name
|
||||
val index = i
|
||||
setOnClickListener { Reader.viewMangaAt(comic.name, index, urlArray) }
|
||||
}
|
||||
}
|
||||
} else line?.l2cr?.apply {
|
||||
}
|
||||
|
||||
private fun addVolumesView(v: View) {
|
||||
obtainMessage(8, v).sendToTarget()
|
||||
}
|
||||
|
||||
private fun setVolumes() = Thread {
|
||||
if (exit) return@Thread
|
||||
that?.apply {
|
||||
book?.results?.apply {
|
||||
ViewMangaActivity.fileArray = arrayOf()
|
||||
urlArray = arrayOf()
|
||||
ViewMangaActivity.uuidArray = arrayOf()
|
||||
var i = 0
|
||||
var last = -1
|
||||
vols?.forEachIndexed { groupIndex, v ->
|
||||
if(exit) return@Thread
|
||||
addVolumesView(layoutInflater.inflate(R.layout.div_h, fbl, false))
|
||||
val t = layoutInflater.inflate(R.layout.line_caption, fbl, false)
|
||||
t.tcptn.text = keys[groupIndex]
|
||||
addVolumesView(t)
|
||||
addVolumesView(layoutInflater.inflate(R.layout.div_h, fbl, false))
|
||||
var line: View? = null
|
||||
last += v.results.list.size
|
||||
v.results.list.forEach {
|
||||
urlArray += CMApi.getChapterInfoApiUrl(
|
||||
comic.path_word,
|
||||
it.uuid
|
||||
)?:""
|
||||
ViewMangaActivity.fileArray += CMApi.getZipFile(context?.getExternalFilesDir(""), comic.name, keys[groupIndex], it.name)
|
||||
chapterNames += it.name
|
||||
ViewMangaActivity.uuidArray += it.uuid
|
||||
Log.d("MyBH", "i = $i, last=$last, add chapter ${it.name}, line is null: ${line == null}")
|
||||
if(line == null) {
|
||||
if(i == last) {
|
||||
line = layoutInflater.inflate(R.layout.line_chapter, that!!.fbl, false)
|
||||
line?.lcc?.apply {
|
||||
lct.text = it.name
|
||||
Log.d("MyBH", "add last single chapter ${it.name}")
|
||||
val index = i
|
||||
setOnClickListener { Reader.viewMangaAt(comic.name, index, urlArray) }
|
||||
}
|
||||
line?.let { l -> addVolumesView(l) }
|
||||
|
||||
} else {
|
||||
line = layoutInflater.inflate(R.layout.line_2chapters, that!!.fbl, false)
|
||||
line?.l2cl?.apply {
|
||||
lct.text = it.name
|
||||
val index = i
|
||||
setOnClickListener { Reader.viewMangaAt(comic.name, index, urlArray) }
|
||||
fbl?.addView(line)
|
||||
line = null
|
||||
}
|
||||
i++
|
||||
}
|
||||
} else line?.l2cr?.apply {
|
||||
lct.text = it.name
|
||||
val index = i
|
||||
setOnClickListener { Reader.viewMangaAt(comic.name, index, urlArray) }
|
||||
line?.let { l -> addVolumesView(l) }
|
||||
line = null
|
||||
}
|
||||
endSetLayouts()
|
||||
i++
|
||||
}
|
||||
}
|
||||
sendEmptyMessage(9) // end set layout
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
|
||||
private fun loadVolume(name: String, path: String, nav: Int){
|
||||
if(complete) {
|
||||
@@ -311,7 +330,7 @@ class BookHandler(private val th: WeakReference<BookFragment>, val path: String)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initComicData() {
|
||||
private fun initComicData() = Thread {
|
||||
var volumes = emptyArray<VolumeStructure>()
|
||||
val counts = cnts.clone()
|
||||
gpws.forEachIndexed { i, gpw ->
|
||||
@@ -329,11 +348,11 @@ class BookHandler(private val th: WeakReference<BookFragment>, val path: String)
|
||||
counts[i] = counts[i] - 100
|
||||
CMApi.getGroupInfoApiUrl(path, gpw, offset)?.let {
|
||||
Log.d("MyBFH", "get api: $it")
|
||||
if(ComicDlFragment.exit) return
|
||||
if(ComicDlFragment.exit) return@Thread
|
||||
val ad = AutoDownloadThread(it) { result ->
|
||||
Log.d("MyBFH", "第${i}卷返回")
|
||||
val r = Gson().fromJson(result?.decodeToString(), VolumeStructure::class.java)
|
||||
re[r.results.offset / 100] = r
|
||||
Log.d("MyBFH", "第${i}卷返回, 大小: ${r.results.list.size}")
|
||||
}
|
||||
ads += ad
|
||||
ad.start()
|
||||
@@ -341,7 +360,6 @@ class BookHandler(private val th: WeakReference<BookFragment>, val path: String)
|
||||
sleep(1000)
|
||||
}
|
||||
} while (counts[i] > 0)
|
||||
Thread {
|
||||
var c = 0
|
||||
while (c++ < 80) {
|
||||
sleep(1000)
|
||||
@@ -359,23 +377,21 @@ class BookHandler(private val th: WeakReference<BookFragment>, val path: String)
|
||||
r?.results?.list = s
|
||||
r?.apply { volumes += this }
|
||||
} else re[0]?.apply { volumes += this }
|
||||
}.start()
|
||||
}
|
||||
Thread {
|
||||
var c = 0
|
||||
while (c < 80 && volumes.size != gpws.size) {
|
||||
sleep(1000)
|
||||
if(ComicDlFragment.exit) return@Thread
|
||||
Log.d("MyBFH", "已有:${volumes.size} 共:${gpws.size}")
|
||||
c++
|
||||
var c = 0
|
||||
while (c < 80 && volumes.size != gpws.size) {
|
||||
sleep(1000)
|
||||
if(ComicDlFragment.exit) return@Thread
|
||||
Log.d("MyBFH", "已有:${volumes.size} 共:${gpws.size}")
|
||||
c++
|
||||
}
|
||||
if (volumes.size == gpws.size) {
|
||||
that?.activity?.runOnUiThread {
|
||||
saveVolumes(volumes)
|
||||
sendEmptyMessage(7)
|
||||
}
|
||||
if (volumes.size == gpws.size) {
|
||||
that?.activity?.runOnUiThread {
|
||||
saveVolumes(volumes)
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
|
||||
private fun saveVolumes(volumes: Array<VolumeStructure>) {
|
||||
that?.context?.getExternalFilesDir("")?.let { home ->
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.lang.Thread.sleep
|
||||
|
||||
@ExperimentalStdlibApi
|
||||
class SortFragment : InfoCardLoader(R.layout.fragment_sort, R.id.action_nav_sort_to_nav_book) {
|
||||
private val sortWay = listOf("datetime_updated", "-datetime_updated", "-popular", "popular")
|
||||
private val sortWay = listOf("-datetime_updated", "datetime_updated", "-popular", "popular")
|
||||
private var theme = -1
|
||||
private var region = -1
|
||||
private var sortValue = 0
|
||||
|
||||
@@ -86,7 +86,7 @@ class ComicDlFragment: NoBackRefreshFragment(R.layout.fragment_dlcomic) {
|
||||
menu.findItem(R.id.action_download)?.isVisible = false
|
||||
}*/
|
||||
|
||||
private fun initComicData(pw: String?, gpws: Array<String>?, counts: IntArray?) {
|
||||
private fun initComicData(pw: String?, gpws: Array<String>?, counts: IntArray?) = Thread {
|
||||
var volumes = emptyArray<VolumeStructure>()
|
||||
if (gpws != null) {
|
||||
gpws.forEachIndexed { i, gpw ->
|
||||
@@ -99,7 +99,7 @@ class ComicDlFragment: NoBackRefreshFragment(R.layout.fragment_dlcomic) {
|
||||
do {
|
||||
counts?.set(i, counts[i] - 100)
|
||||
CMApi.getGroupInfoApiUrl(pw, gpw, offset)?.let {
|
||||
if(exit) return
|
||||
if(exit) return@Thread
|
||||
val ad = AutoDownloadThread(it) { result ->
|
||||
Log.d("MyCDF", "第${i}卷返回")
|
||||
val r = Gson().fromJson(result?.decodeToString(), VolumeStructure::class.java)
|
||||
@@ -110,42 +110,38 @@ class ComicDlFragment: NoBackRefreshFragment(R.layout.fragment_dlcomic) {
|
||||
offset += 100
|
||||
}
|
||||
} while ((counts?.get(i) ?: 0) > 0)
|
||||
Thread {
|
||||
var c = 0
|
||||
while (c++ < 80) {
|
||||
sleep(1000)
|
||||
if(exit) return@Thread
|
||||
if(re.all { it != null }) break
|
||||
}
|
||||
if(re.size > 1) {
|
||||
val r = re[0]
|
||||
var s = emptyArray<ChapterStructure>()
|
||||
re.forEach {
|
||||
it?.results?.list?.forEach {
|
||||
s += it
|
||||
}
|
||||
}
|
||||
r?.results?.list = s
|
||||
r?.apply { volumes += this }
|
||||
} else re[0]?.apply { volumes += this }
|
||||
}.start()
|
||||
}
|
||||
Thread {
|
||||
var c = 0
|
||||
while (c < 80 && volumes.size != gpws.size) {
|
||||
while (c++ < 80) {
|
||||
sleep(1000)
|
||||
if(exit) return@Thread
|
||||
Log.d("MyCDF", "已有:${volumes.size} 共:${gpws.size}")
|
||||
c++
|
||||
if(re.all { it != null }) break
|
||||
}
|
||||
if (volumes.size == gpws.size) {
|
||||
activity?.runOnUiThread {
|
||||
start2load(volumes)
|
||||
if(re.size > 1) {
|
||||
val r = re[0]
|
||||
var s = emptyArray<ChapterStructure>()
|
||||
re.forEach {
|
||||
it?.results?.list?.forEach {
|
||||
s += it
|
||||
}
|
||||
}
|
||||
r?.results?.list = s
|
||||
r?.apply { volumes += this }
|
||||
} else re[0]?.apply { volumes += this }
|
||||
}
|
||||
var c = 0
|
||||
while (c < 80 && volumes.size != gpws.size) {
|
||||
sleep(1000)
|
||||
if(exit) return@Thread
|
||||
Log.d("MyCDF", "已有:${volumes.size} 共:${gpws.size}")
|
||||
c++
|
||||
}
|
||||
if (volumes.size == gpws.size) {
|
||||
activity?.runOnUiThread {
|
||||
start2load(volumes)
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
|
||||
private fun initOldComicData() {
|
||||
handler = ComicDlHandler(Looper.myLooper()!!,
|
||||
|
||||
@@ -352,10 +352,9 @@ class ComicDlHandler(looper: Looper, private val th: WeakReference<ComicDlFragme
|
||||
ViewMangaActivity.dlhandler = this
|
||||
ViewMangaActivity.position = it.tbtn.index
|
||||
dl?.show()
|
||||
|
||||
that?.startActivity(Intent(that!!.context, ViewMangaActivity::class.java)
|
||||
.putExtra("callFrom", "zipFirst")
|
||||
)
|
||||
val intent = Intent(that?.context, ViewMangaActivity::class.java)
|
||||
intent.putExtra("urlArray", urlArray).putExtra("callFrom", "zipFirst")
|
||||
that?.startActivity(intent)
|
||||
} else {
|
||||
it.tbtn.setBackgroundResource(R.drawable.toggle_button)
|
||||
if (it.tbtn.isChecked) that?.tdwn?.text = "$dldChapter/${++checkedChapter}"
|
||||
|
||||
@@ -207,7 +207,8 @@ class HomeFragment : NoBackRefreshFragment(R.layout.fragment_home) {
|
||||
holder.itemView.ta.text = "搜索 \"$query\""
|
||||
holder.itemView.tb.text = "共 $count 条结果"
|
||||
holder.itemView.lwi.visibility = View.INVISIBLE
|
||||
if (query?.isNotEmpty() == true) holder.itemView.lwc.setOnClickListener {
|
||||
holder.itemView.lwc.setOnClickListener {
|
||||
if (query?.isNotEmpty() != true) return@setOnClickListener
|
||||
val bundle = Bundle()
|
||||
bundle.putCharSequence("query", query)
|
||||
bundle.putString("type", type)
|
||||
|
||||
@@ -212,7 +212,7 @@ class HomeHandler(private val that: WeakReference<HomeFragment>) : AutoDownloadH
|
||||
}
|
||||
}
|
||||
|
||||
private fun inflateCardLines() {
|
||||
private fun inflateCardLines() = Thread{
|
||||
if (indexLines.isNotEmpty()) indexLines = arrayOf()
|
||||
inflateRec()
|
||||
inflateTopics()
|
||||
@@ -220,14 +220,12 @@ class HomeHandler(private val that: WeakReference<HomeFragment>) : AutoDownloadH
|
||||
inflateNew()
|
||||
inflateFinish()
|
||||
inflateRank()
|
||||
Thread{
|
||||
for(i in indexLines.indices) {
|
||||
obtainMessage(8, i, 0).sendToTarget()
|
||||
sleep(512)
|
||||
}
|
||||
obtainMessage(-1, false).sendToTarget() //closeLoad
|
||||
}.start()
|
||||
}
|
||||
for(i in indexLines.indices) {
|
||||
obtainMessage(8, i, 0).sendToTarget()
|
||||
sleep(512)
|
||||
}
|
||||
obtainMessage(-1, false).sendToTarget() //closeLoad
|
||||
}.start()
|
||||
|
||||
private fun setBanner(v: Banner): Banner {
|
||||
v.viewTreeObserver.addOnGlobalLayoutListener(object :
|
||||
@@ -311,7 +309,7 @@ class HomeHandler(private val that: WeakReference<HomeFragment>) : AutoDownloadH
|
||||
private fun setCards(cv: CardView, pw: String, name: String, img: String, isFinal: Boolean, isTopic: Boolean) {
|
||||
cv.tic.text = name
|
||||
homeF?.let {
|
||||
if(img.startsWith("http")) {
|
||||
if(img.startsWith("http")) it.activity?.runOnUiThread {
|
||||
Glide.with(it).load(GlideUrl(CMApi.proxy?.wrap(img)?:img, CMApi.myGlideHeaders)).timeout(20000).into(cv.imic)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.lang.Thread.sleep
|
||||
import java.lang.ref.WeakReference
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
|
||||
url, Chapter2Return::class.java, Looper.myLooper()!!
|
||||
@@ -59,6 +60,7 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
private var remainingImageCount = 0
|
||||
|
||||
@SuppressLint("SimpleDateFormat", "SetTextI18n")
|
||||
override fun handleMessage(msg: Message) {
|
||||
@@ -81,13 +83,14 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
|
||||
//simg.setHeight2FitImgWidth()
|
||||
//if(msg.arg2 == 1) sendEmptyMessage(DELAYED_RESTORE_PAGE_NUMBER)
|
||||
}
|
||||
CLEAR_IMG_ON -> wv.get()?.clearImgOn(msg.obj as ScaleImageView)
|
||||
CLEAR_IMG_ON -> {
|
||||
val img = msg.obj as ScaleImageView
|
||||
img.visibility = View.GONE
|
||||
//sendEmptyMessage(DECREASE_IMAGE_COUNT_AND_RESTORE_PAGE_NUMBER_AT_ZERO)
|
||||
}
|
||||
PREPARE_LAST_PAGE -> wv.get()?.prepareLastPage(msg.arg1, msg.arg2)
|
||||
DIALOG_SHOW -> dl.show()
|
||||
DELAYED_RESTORE_PAGE_NUMBER -> Thread{
|
||||
sleep(233)
|
||||
sendEmptyMessage(RESTORE_PAGE_NUMBER)
|
||||
}.start()
|
||||
|
||||
LOAD_ITEM_SCROLL_MODE -> loadScrollMode(msg.arg1)
|
||||
LOAD_SCROLL_MODE -> loadScrollMode()
|
||||
LOAD_ITEM_IMAGES_INTO_LINE -> loadImagesIntoLine(msg.arg1)
|
||||
@@ -97,7 +100,8 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
|
||||
wv.get()?.restorePN()
|
||||
}
|
||||
LOAD_PAGE_FROM_ITEM -> {
|
||||
val item = (pn - 1) / (wv.get()?.verticalLoadMaxCount?:20) * (wv.get()?.verticalLoadMaxCount?:20)
|
||||
val verticalMaxCount = wv.get()?.verticalLoadMaxCount?:20
|
||||
val item = (pn - 1) / verticalMaxCount * verticalMaxCount
|
||||
loadScrollMode(item)
|
||||
Log.d("MyVMH", "Load page from $item")
|
||||
}
|
||||
@@ -113,6 +117,17 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
|
||||
} else {
|
||||
showInfCardFull(); true
|
||||
}
|
||||
INIT_IMAGE_COUNT -> {
|
||||
remainingImageCount = msg.arg1
|
||||
Log.d("MyVMH", "init remainingImageCount = $remainingImageCount")
|
||||
}
|
||||
DECREASE_IMAGE_COUNT_AND_RESTORE_PAGE_NUMBER_AT_ZERO -> {
|
||||
if (--remainingImageCount == 0) {
|
||||
Log.d("MyVMH", "last load page, restore pn...")
|
||||
sendEmptyMessageDelayed(RESTORE_PAGE_NUMBER, 233)
|
||||
}
|
||||
Log.d("MyVMH", "remainingImageCount = $remainingImageCount")
|
||||
}
|
||||
SET_NET_INFO -> wv.get()?.idtime?.text = SimpleDateFormat("HH:mm").format(Date()) + week + wv.get()?.toolsBox?.netInfo
|
||||
}
|
||||
}
|
||||
@@ -176,20 +191,21 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
|
||||
wv.get()?.initManga()
|
||||
wv.get()?.vprog?.visibility = View.GONE
|
||||
}
|
||||
private fun loadImagesIntoLine(item: Int = (wv.get()?.currentItem?:0), maxCount: Int = (wv.get()?.verticalLoadMaxCount?:20)) /*= Thread*/{
|
||||
private fun loadImagesIntoLine(item: Int = (wv.get()?.currentItem?:0), maxCount: Int = (wv.get()?.verticalLoadMaxCount?:20)) = Thread{
|
||||
Log.d("MyVMH", "Fun: loadImagesIntoLine($item, $maxCount)")
|
||||
wv.get()?.realCount?.let { count ->
|
||||
if(count > 0){
|
||||
val notFull = item + maxCount > count
|
||||
val loadCount = (if(notFull) count - item else maxCount) - 1
|
||||
obtainMessage(INIT_IMAGE_COUNT, loadCount+1, 0).sendToTarget()
|
||||
Log.d("MyVMH", "count: $count, loadCount: $loadCount, notFull: $notFull")
|
||||
if(loadCount >= 0) for(i in 0..loadCount) obtainMessage(LOAD_IMG_ON,item + i, if(i == loadCount - 1) 1 else 0, wv.get()?.scrollImages?.get(i)).sendToTarget()
|
||||
else sendEmptyMessage(DELAYED_RESTORE_PAGE_NUMBER)
|
||||
//else sendEmptyMessageDelayed(RESTORE_PAGE_NUMBER, 233)
|
||||
if(notFull) obtainMessage(PREPARE_LAST_PAGE, loadCount + 1, maxCount).sendToTarget()
|
||||
wv.get()?.updateSeekBar()
|
||||
wv.get()?.let { it.runOnUiThread { it.updateSeekBar() } }
|
||||
}
|
||||
}
|
||||
}//.start()
|
||||
}.start()
|
||||
|
||||
private fun loadScrollMode() {
|
||||
sendEmptyMessage(DIALOG_SHOW)
|
||||
@@ -233,7 +249,7 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
|
||||
const val CLEAR_IMG_ON = 5
|
||||
const val PREPARE_LAST_PAGE = 6
|
||||
const val DIALOG_SHOW = 7
|
||||
const val DELAYED_RESTORE_PAGE_NUMBER = 8
|
||||
//const val DELAYED_RESTORE_PAGE_NUMBER = 8
|
||||
const val LOAD_ITEM_SCROLL_MODE = 9
|
||||
const val LOAD_SCROLL_MODE = 10
|
||||
const val LOAD_ITEM_IMAGES_INTO_LINE = 11
|
||||
@@ -244,6 +260,8 @@ class VMHandler(activity: ViewMangaActivity, url: String) : AutoDownloadHandler(
|
||||
const val HIDE_INFO_CARD_FULL = 16
|
||||
const val SHOW_INFO_CARD_FULL = 17
|
||||
const val TRIGGER_INFO_CARD_FULL = 18
|
||||
const val INIT_IMAGE_COUNT = 19
|
||||
const val DECREASE_IMAGE_COUNT_AND_RESTORE_PAGE_NUMBER_AT_ZERO = 20
|
||||
|
||||
const val SET_NET_INFO = 22
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
||||
private var indexMap = intArrayOf()
|
||||
private var volTurnPage = false
|
||||
private var am: AudioManager? = null
|
||||
private var pm: PagesManager? = null
|
||||
var pm: PagesManager? = null
|
||||
private var fullyHideInfo = false
|
||||
val realCount get() = if(cut) indexMap.size else count
|
||||
|
||||
@@ -171,10 +171,11 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
||||
)
|
||||
}
|
||||
|
||||
fun restorePN(){
|
||||
fun restorePN() {
|
||||
if (isPnValid) {
|
||||
isInScroll = false
|
||||
pageNum = pn
|
||||
Log.d("MyVM", "restore pageNum to $pn")
|
||||
pn = -1
|
||||
}
|
||||
setProgress()
|
||||
@@ -342,9 +343,10 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
||||
}
|
||||
}
|
||||
|
||||
fun clearImgOn(imgView: ScaleImageView){
|
||||
/*fun clearImgOn(imgView: ScaleImageView){
|
||||
imgView.visibility = View.GONE
|
||||
}
|
||||
handler.sendEmptyMessage(VMHandler.DECREASE_IMAGE_COUNT_AND_RESTORE_PAGE_NUMBER_AT_ZERO)
|
||||
}*/
|
||||
|
||||
//private fun getTempFile(position: Int) = File(cacheDir, "$position")
|
||||
|
||||
@@ -362,13 +364,14 @@ 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 loadImg(imgView: ScaleImageView, bitmap: Bitmap, isLast: Int = 0, useCut: Boolean, isLeft: Boolean, isPlaceholder: Boolean = true){
|
||||
val bitmap2load = if(useCut) cutBitmap(bitmap, isLeft) else bitmap
|
||||
private fun loadImg(imgView: ScaleImageView, bitmap: Bitmap, isLast: Int = 0, useCut: Boolean, isLeft: Boolean, isPlaceholder: Boolean = true) {
|
||||
val bitmap2load = if(!isPlaceholder && useCut) cutBitmap(bitmap, isLeft) else bitmap
|
||||
runOnUiThread {
|
||||
imgView.setImageBitmap(bitmap2load)
|
||||
if(isVertical){
|
||||
if(!isPlaceholder && isVertical) {
|
||||
imgView.setHeight2FitImgWidth()
|
||||
if (!isPlaceholder && isLast == 1) handler.sendEmptyMessage(VMHandler.DELAYED_RESTORE_PAGE_NUMBER)
|
||||
handler.sendEmptyMessage(VMHandler.DECREASE_IMAGE_COUNT_AND_RESTORE_PAGE_NUMBER_AT_ZERO)
|
||||
//if (!isPlaceholder && isLast == 1) handler.sendEmptyMessageDelayed(VMHandler.RESTORE_PAGE_NUMBER, 233)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -410,8 +413,8 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
||||
if(data != null && data.isNotEmpty()) {
|
||||
BitmapFactory.decodeByteArray(data, 0, data.size)?.let {
|
||||
loadImg(imgView, it, isLast, useCut, isLeft, false)
|
||||
Log.d("MyVM", "Load from task")
|
||||
}?:Log.d("MyVM", "null bitmap")
|
||||
Log.d("MyVM", "Load position $position from task")
|
||||
}?:Log.d("MyVM", "null bitmap at $position")
|
||||
}
|
||||
else getImgUrl(index2load)?.let { loadImgUrlInto(imgView, it, isLast, useCut, isLeft) }
|
||||
}.start()
|
||||
@@ -586,11 +589,11 @@ class ViewMangaActivity : TitleActivityTemplate() {
|
||||
@ExperimentalStdlibApi
|
||||
private fun prepareIdBtVH() {
|
||||
idtbvh.isChecked = isVertical
|
||||
pm = PagesManager(WeakReference(this))
|
||||
if (isVertical) {
|
||||
val vsps = vsp as SpringView
|
||||
vsps.footerView.lht.text = "更多"
|
||||
vsps.headerView.lht.text = "更多"
|
||||
pm = PagesManager(WeakReference(this))
|
||||
vsps.setListener(object :SpringView.OnFreshListener{
|
||||
override fun onLoadmore() {
|
||||
//scrollForward()
|
||||
|
||||
@@ -679,7 +679,7 @@ class ScaleImageView : ImageView {
|
||||
override fun onSingleTapConfirmed(event: MotionEvent): Boolean {
|
||||
if(v == null) {
|
||||
v = ViewMangaActivity.va
|
||||
v?.let { pm = PagesManager(it) }
|
||||
v?.get()?.let { pm = it.pm }
|
||||
}
|
||||
//触发点击
|
||||
if (mOnClickListener != null) {
|
||||
@@ -1632,6 +1632,6 @@ class ScaleImageView : ImageView {
|
||||
*/
|
||||
const val PINCH_MODE_SCALE = 2
|
||||
|
||||
var pm:PagesManager? = null
|
||||
var pm: PagesManager? = null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user