This commit is contained in:
lunaticbum 2025-02-11 13:25:17 +09:00
parent fc5f17018a
commit a2d90b16bf
8 changed files with 47 additions and 39 deletions

View File

@ -418,11 +418,12 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
return text.trim()
}
var isLoading = false
var saveClient = object : WebViewClient() {
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
isLoading = true
}
override fun onPageFinished(webView: WebView?, url: String?) {
@ -438,6 +439,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
(result as? String)?.let {
}
isLoading = false
}
}, delayed)
}
@ -515,18 +517,19 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
}
}
Blog.LOGE("saveItem >>> saveTarget ${saveTarget.count()}")
try {
saveTarget.removeFirst().let {
Blog.LOGE("saveItem >>> ${it.pathUrl}")
runOnUiThread {
mBaseWebContentsViewer.webview.url?.let { currentUrl ->
currentUrl.replace(Uri.parse(currentUrl).path ?: "", it.pathUrl ?: "")
?.let { targetUrl ->
Blog.LOGE("targetUrl >>> ${targetUrl}")
contentsSaver?.loadUrl(targetUrl)
}
if (isLoading == false) {
saveTarget.removeFirst().let {
Blog.LOGE("saveItem >>> ${it.pathUrl}")
runOnUiThread {
mBaseWebContentsViewer.webview.url?.let { currentUrl ->
currentUrl.replace(Uri.parse(currentUrl).path ?: "", it.pathUrl ?: "")
?.let { targetUrl ->
Blog.LOGE("targetUrl >>> ${targetUrl}")
contentsSaver?.loadUrl(targetUrl)
}
}
}
}
}

View File

@ -105,20 +105,20 @@ open class BaseWebContentsViewer {
}
val rootWebViewClient = object : WebViewClient() {
override fun shouldInterceptRequest(
view: WebView?,
request: WebResourceRequest?
): WebResourceResponse? {
Log.e("shouldInterceptRequest", " >>>> ${request?.url?.toString()} , ${request?.url?.toString()?.contains("gif")}")
if(request?.url?.toString()?.contains("gif") ?: false) {
return WebResourceResponse("text/javascript", "UTF-8", null);
}
// if(request?.url?.toString()?.contains(currentContentsProvider?.acccceptResourceKeyword() ?: "") == false && request?.url?.toString()?.contains(currentContentsProvider?.getLastedDoamin() ?: "") == false) {
// override fun shouldInterceptRequest(
// view: WebView?,
// request: WebResourceRequest?
// ): WebResourceResponse? {
// Log.e("shouldInterceptRequest", " >>>> ${request?.url?.toString()} , ${request?.url?.toString()?.contains("gif")}")
//
// if(request?.url?.toString()?.contains("gif") ?: false) {
// return WebResourceResponse("text/javascript", "UTF-8", null);
// }
return super.shouldInterceptRequest(view, request)
}
//// if(request?.url?.toString()?.contains(currentContentsProvider?.acccceptResourceKeyword() ?: "") == false && request?.url?.toString()?.contains(currentContentsProvider?.getLastedDoamin() ?: "") == false) {
//// return WebResourceResponse("text/javascript", "UTF-8", null);
//// }
// return super.shouldInterceptRequest(view, request)
// }
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
@ -194,24 +194,24 @@ open class BaseWebContentsViewer {
Jsoup.parse(string)?.let { html ->
val toon_intro = html.getElementById("toon_intro")
val view_padding = html.getElementsByClass("view-padding")
val toon_intro = html.getElementsByClass("toon_index")?.first()
val view_padding = html.select("#bo_v_con")
if (toon_intro != null) {
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: ${html.title()}")
Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: ${html.title()}")
val bookPageInfos = BookPageInfos()
bookPageInfos.bookPageUrl = Uri.parse(finishedUrl).path
bookPageInfos.bookTitle = if (toon_intro.getElementsByTag("h3").size > 0) toon_intro.getElementsByTag("h3").get(0).text() else ""
bookPageInfos.pages = realmListOf<BookPageInfo>()
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: bookPageInfos >>>> ${Gson().toJson(bookPageInfos)}")
val listParent = html.getElementById("list_type")
Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: bookPageInfos >>>> ${Gson().toJson(bookPageInfos)}")
val listParent = toon_intro.getElementsByTag("ul").first()
if (listParent != null) {
listParent.getElementsByClass("row").forEach { bookitem ->
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: bookItemInfo ${bookitem}")
listParent.getElementsByTag("li").reversed().forEachIndexed { idx, bookitem ->
Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: bookItemInfo ${bookitem.html()}")
try {
val bookPageInfo = BookPageInfo()
bookPageInfo.bookTitle = bookPageInfos.bookTitle
bookPageInfo.chapterNum = bookitem.getElementsByClass("cell_num").getT().toInt()
bookPageInfo.chapterID = bookitem.getElementsByClass("cell_num").getT().toInt()
bookPageInfo.chapterNum = idx + 1
bookPageInfo.chapterID = idx + 1
bookPageInfo.chapterTitle = bookitem.getElementsByTag("a").getT()
bookPageInfo.bookPageUrl = bookPageInfos.bookPageUrl
val href = bookitem.getElementsByTag("a").get(0).attr("href")
@ -231,17 +231,22 @@ open class BaseWebContentsViewer {
}
}else if (view_padding.size > 0){
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: ${html.title()}")
val contents = view_padding.get(0).children().html().replace("<p>"," ").replace("</p>","\n\n")
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: view_padding.get(0)\n${contents}")
val contents = StringBuffer()
view_padding.get(0).getElementsByTag("P").forEach {
it.text().apply {
contents.append(this).append("\n")
}
}
if (contents.length > 20) {
Uri.parse(finishedUrl).path?.let {
HistoryManager.getBooPageInfoContentsSave(it, contents)
mainControllInterface.onLoadedContents(contents)
HistoryManager.getBooPageInfoContentsSave(it, contents.toString())
mainControllInterface.onLoadedContents(contents.toString())
}
}
} else {
Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: ${html.title()}")
Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: whole body ${html}")
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: whole body ${html}")
}
}
}

View File

@ -11,7 +11,7 @@ object NewtokiOne : BaseWebContents() {
}
override fun getLastedDoamin(): String {
return "https://newtoki.one"
return "https://newtoki.biz"
}
override fun getContentsList(): String {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.