This commit is contained in:
lunaticbum 2024-08-07 16:18:36 +09:00
parent 55a0b209ec
commit 536e917b29
3 changed files with 63 additions and 29 deletions

View File

@ -261,6 +261,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} }
fun showHistory(infos: List<HistoryItem>) { fun showHistory(infos: List<HistoryItem>) {
val builderSingle: AlertDialog.Builder = AlertDialog.Builder(this@Intro) val builderSingle: AlertDialog.Builder = AlertDialog.Builder(this@Intro)
builderSingle.setTitle("${currentTitle} : ${currentChapter} -> Select One ") builderSingle.setTitle("${currentTitle} : ${currentChapter} -> Select One ")
val arrayAdapter = val arrayAdapter =
@ -491,25 +492,43 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
currentBooinfo = it currentBooinfo = it
paged_layer.text = it!!.contents!! paged_layer.text = it!!.contents!!
paged_layer.visibility = VISIBLE paged_layer.visibility = VISIBLE
} if(it?.pathUrl?.length ?: 0 > 0) {
if(it?.pathUrl?.length ?: 0 > 0) { HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!))
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!)) Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})")
Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})") if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) {
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) { Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})")
Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})") mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!))
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!)) } else {
paged_layer?.visibility = GONE Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})")
} else { mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})") }
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!) it?.pathUrl?.let {
paged_layer?.visibility = GONE HistoryManager.getBooInfo(it) {
saveItem(it)
}
}
} }
it?.pathUrl?.let { } else {
HistoryManager.getBooInfo(it) { if(it?.pathUrl?.length ?: 0 > 0) {
saveItem(it) HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!))
Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})")
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) {
Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})")
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!))
paged_layer?.visibility = GONE
} else {
Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})")
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
paged_layer?.visibility = GONE
}
it?.pathUrl?.let {
HistoryManager.getBooInfo(it) {
saveItem(it)
}
} }
} }
} }
} }
} }
} }

View File

@ -153,7 +153,7 @@ class PagedTextView : AppCompatTextView {
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh) super.onSizeChanged(w, h, oldw, oldh)
Blog.LOGD(log = "onSizeChanged>> ${this::class.java.name}") Blog.LOGD(log = "onSizeChanged>> ${this::class.java.name}")
pageHeight = ((h - (marginTop + marginBottom + paddingTop + paddingBottom)) * 0.85f).toInt() pageHeight = ((h - (marginTop + marginBottom + paddingTop + paddingBottom)) * 0.8f).toInt()
} }
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {

View File

@ -2,12 +2,14 @@ package com.mime.dualscreenview.webcontents
import android.app.AlertDialog import android.app.AlertDialog
import android.graphics.Bitmap import android.graphics.Bitmap
import android.net.Uri
import android.net.http.SslError import android.net.http.SslError
import android.util.Log import android.util.Log
import android.webkit.* import android.webkit.*
import com.mime.dualscreenview.common.Blog import com.mime.dualscreenview.common.Blog
import com.mime.dualscreenview.data.HistoryManager import com.mime.dualscreenview.data.HistoryManager
import com.mime.dualscreenview.data.model.LastInfo import com.mime.dualscreenview.data.model.LastInfo
import com.mime.dualscreenview.webcontents.contentsinfo.Booktoki
import com.mime.dualscreenview.webcontents.contentsinfo.DidFindContents import com.mime.dualscreenview.webcontents.contentsinfo.DidFindContents
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -22,16 +24,16 @@ open class BaseWebContentsViewer {
@JavascriptInterface @JavascriptInterface
fun onBookInfo(jsonData : String) { fun onBookInfo(jsonData : String) {
GlobalScope.launch { GlobalScope.launch {
try { try {
Blog.LOGE("BaseWebContentsViewer",jsonData) Blog.LOGE("BaseWebContentsViewer",jsonData)
val data: JSONObject = JSONObject(jsonData) val data: JSONObject = JSONObject(jsonData)
Blog.LOGE("BaseWebContentsViewer",data.toString()) Blog.LOGE("BaseWebContentsViewer",data.toString())
mainControllInterface?.onBookInfos(jsonData) mainControllInterface?.onBookInfos(jsonData)
} catch (e : Exception) { } catch (e : Exception) {
}
} }
}
} }
constructor(webview : WebView, mainControllInterface : MainControllInterface ) { constructor(webview : WebView, mainControllInterface : MainControllInterface ) {
@ -83,7 +85,20 @@ open class BaseWebContentsViewer {
// webview.loadUrl(last.pageUrl) // webview.loadUrl(last.pageUrl)
// } // }
// } else { // } else {
webview.loadUrl(last.pageUrl) if (last.pageUrl.startsWith("http")) {
webview.loadUrl(last.pageUrl)
} else {
try {
var uri = Uri.parse(webview.url)
uri.path?.let {
webview.loadUrl(uri.toString().replace(it,last.pageUrl))
}
} catch (e : Exception) {
webview.loadUrl(Booktoki.getLastedDoamin().plus("/").plus(last.pageUrl))
}
}
// } // }
// }) // })
} }
@ -111,7 +126,7 @@ open class BaseWebContentsViewer {
mainControllInterface?.onStartLoad() mainControllInterface?.onStartLoad()
} }
var alertDialogs : ArrayList<AlertDialog> = arrayListOf() var alertDialogs : ArrayList<AlertDialog> = arrayListOf()
// override fun onReceivedError( // override fun onReceivedError(
// view: WebView?, // view: WebView?,
// request: WebResourceRequest?, // request: WebResourceRequest?,
// error: WebResourceError? // error: WebResourceError?
@ -175,9 +190,9 @@ open class BaseWebContentsViewer {
view?.let { view?.let {
if(url?.contains("/list/") ?: false && url?.contains("agit") ?: false){ if(url?.contains("/list/") ?: false && url?.contains("agit") ?: false){
findListItem { findListItem {
Blog.LOGE("onPageFinished", url ?: "") Blog.LOGE("onPageFinished", url ?: "")
} }
} else if (url?.contains("booktoki") ?: false){ } else if (url?.contains("booktoki") ?: false){
findListItem { findListItem {
Blog.LOGE("onPageFinished", url ?: "") Blog.LOGE("onPageFinished", url ?: "")