diff --git a/app/src/main/java/com/mime/dualscreenview/activity/Intro.kt b/app/src/main/java/com/mime/dualscreenview/activity/Intro.kt index 423dba9..20b2d24 100644 --- a/app/src/main/java/com/mime/dualscreenview/activity/Intro.kt +++ b/app/src/main/java/com/mime/dualscreenview/activity/Intro.kt @@ -261,6 +261,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { } fun showHistory(infos: List) { + val builderSingle: AlertDialog.Builder = AlertDialog.Builder(this@Intro) builderSingle.setTitle("${currentTitle} : ${currentChapter} -> Select One ") val arrayAdapter = @@ -491,25 +492,43 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { currentBooinfo = it paged_layer.text = it!!.contents!! paged_layer.visibility = VISIBLE - } - if(it?.pathUrl?.length ?: 0 > 0) { - 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 + if(it?.pathUrl?.length ?: 0 > 0) { + 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!!)) + } else { + Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})") + mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!) + } + it?.pathUrl?.let { + HistoryManager.getBooInfo(it) { + saveItem(it) + } + } } - it?.pathUrl?.let { - HistoryManager.getBooInfo(it) { - saveItem(it) + } else { + if(it?.pathUrl?.length ?: 0 > 0) { + 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) + } } } } + } } } diff --git a/app/src/main/java/com/mime/dualscreenview/view/PagedTextView.kt b/app/src/main/java/com/mime/dualscreenview/view/PagedTextView.kt index 504203b..d6342c5 100644 --- a/app/src/main/java/com/mime/dualscreenview/view/PagedTextView.kt +++ b/app/src/main/java/com/mime/dualscreenview/view/PagedTextView.kt @@ -153,7 +153,7 @@ class PagedTextView : AppCompatTextView { override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { super.onSizeChanged(w, h, oldw, oldh) 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) { diff --git a/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContentsViewer.kt b/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContentsViewer.kt index 1ab142d..4b9cb00 100644 --- a/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContentsViewer.kt +++ b/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContentsViewer.kt @@ -2,12 +2,14 @@ package com.mime.dualscreenview.webcontents import android.app.AlertDialog import android.graphics.Bitmap +import android.net.Uri import android.net.http.SslError import android.util.Log import android.webkit.* import com.mime.dualscreenview.common.Blog import com.mime.dualscreenview.data.HistoryManager import com.mime.dualscreenview.data.model.LastInfo +import com.mime.dualscreenview.webcontents.contentsinfo.Booktoki import com.mime.dualscreenview.webcontents.contentsinfo.DidFindContents import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -22,16 +24,16 @@ open class BaseWebContentsViewer { @JavascriptInterface fun onBookInfo(jsonData : String) { - GlobalScope.launch { - try { - Blog.LOGE("BaseWebContentsViewer",jsonData) - val data: JSONObject = JSONObject(jsonData) - Blog.LOGE("BaseWebContentsViewer",data.toString()) - mainControllInterface?.onBookInfos(jsonData) - } catch (e : Exception) { + GlobalScope.launch { + try { + Blog.LOGE("BaseWebContentsViewer",jsonData) + val data: JSONObject = JSONObject(jsonData) + Blog.LOGE("BaseWebContentsViewer",data.toString()) + mainControllInterface?.onBookInfos(jsonData) + } catch (e : Exception) { - } } + } } constructor(webview : WebView, mainControllInterface : MainControllInterface ) { @@ -83,7 +85,20 @@ open class BaseWebContentsViewer { // webview.loadUrl(last.pageUrl) // } // } 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() } var alertDialogs : ArrayList = arrayListOf() -// override fun onReceivedError( + // override fun onReceivedError( // view: WebView?, // request: WebResourceRequest?, // error: WebResourceError? @@ -175,9 +190,9 @@ open class BaseWebContentsViewer { view?.let { if(url?.contains("/list/") ?: false && url?.contains("agit") ?: false){ - findListItem { - Blog.LOGE("onPageFinished", url ?: "") - } + findListItem { + Blog.LOGE("onPageFinished", url ?: "") + } } else if (url?.contains("booktoki") ?: false){ findListItem { Blog.LOGE("onPageFinished", url ?: "")