..
This commit is contained in:
@@ -919,6 +919,7 @@ class GeckoWeb : BWebview {
|
||||
message: Any, port: WebExtension.Port
|
||||
) {
|
||||
|
||||
|
||||
Blog.LOGE("PortDelegate", "Received message from extension: $message")
|
||||
if (message is String && message.contains("type")) {
|
||||
try {
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.WebView
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import bums.lunatic.launcher.R
|
||||
import bums.lunatic.launcher.databinding.RssViewerBinding
|
||||
@@ -58,6 +59,11 @@ internal class RssViewer : DialogFragment() {
|
||||
binding = RssViewerBinding.inflate(inflater, container, false)
|
||||
binding.webview.loadUrl(tag!!)
|
||||
binding.webview.setDesktopMode(false)
|
||||
|
||||
var mWebView = WebView(requireContext())
|
||||
mWebView.requestFocus()
|
||||
mWebView.evaluateJavascript("try {document.querySelector('.my-point-box').focus()}catch(err){}") { }
|
||||
|
||||
// binding.pdfPrint.setOnClickListener { pdfPring() }
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ abstract class BaseToki : Fragment(), PagedTextViewInterface {
|
||||
Gson().fromJson<PortMessage>(message, PortMessage::class.java)
|
||||
when(lPortMessage.type) {
|
||||
"getListResult" -> {
|
||||
lPortMessage.bookInfos?.let { onBookInfos(it) }
|
||||
lPortMessage.bookInfos?.let { onBookInfos(it.sort()) }
|
||||
}
|
||||
"BookContents"->{
|
||||
lPortMessage?.book?.chapterTitle?.let { onFindTitle(it) }
|
||||
@@ -752,6 +752,7 @@ abstract class BaseToki : Fragment(), PagedTextViewInterface {
|
||||
try {
|
||||
var infosj: PageInfosJ? = null
|
||||
infosj = Gson().fromJson(jsonString, PageInfosJ::class.java)
|
||||
|
||||
HistoryManager.getBookInfos(contentsType,infosj.bookPageUrl!!) {
|
||||
if (it != null) {
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class LastInfo : RealmObject {
|
||||
@PrimaryKey
|
||||
@@ -107,12 +108,75 @@ class BookContents {
|
||||
var chapterTitle : String? = null
|
||||
var bookContents : String? = null
|
||||
}
|
||||
|
||||
|
||||
// PageInfoJ를 정렬하기 위한 Comparator 클래스
|
||||
class PageInfoComparator : Comparator<PageInfoJ> {
|
||||
|
||||
// 문자열에서 숫자 부분과 문자 부분을 분리하는 정규표현식
|
||||
private val pattern = Pattern.compile("(\\d+)|(\\D+)")
|
||||
|
||||
override fun compare(p1: PageInfoJ?, p2: PageInfoJ?): Int {
|
||||
// null 객체에 대한 안전장치
|
||||
if (p1 == null && p2 == null) return 0
|
||||
if (p1 == null) return -1
|
||||
if (p2 == null) return 1
|
||||
|
||||
// 비교할 문자열 추출 (여기서는 bookTitle을 기준으로 정렬)
|
||||
// 만약 chapterTitle로 정렬하고 싶다면 이 부분을 수정하세요.
|
||||
val s1 = p1.bookTitle ?: ""
|
||||
val s2 = p2.bookTitle ?: ""
|
||||
|
||||
val m1 = pattern.matcher(s1)
|
||||
val m2 = pattern.matcher(s2)
|
||||
|
||||
while (m1.find() && m2.find()) {
|
||||
val part1 = m1.group()
|
||||
val part2 = m2.group()
|
||||
|
||||
// 각 부분이 숫자인지 확인
|
||||
val isPart1Numeric = part1.firstOrNull()?.isDigit() ?: false
|
||||
val isPart2Numeric = part2.firstOrNull()?.isDigit() ?: false
|
||||
|
||||
// 1. 둘 다 숫자인 경우: 숫자 값으로 비교
|
||||
if (isPart1Numeric && isPart2Numeric) {
|
||||
val num1 = part1.toInt()
|
||||
val num2 = part2.toInt()
|
||||
if (num1 != num2) {
|
||||
return num1.compareTo(num2)
|
||||
}
|
||||
}
|
||||
// 2. 한쪽만 숫자인 경우: 숫자가 항상 앞으로 오도록 설정
|
||||
else if (isPart1Numeric) {
|
||||
return -1 // s1(p1)이 숫자이므로 앞으로
|
||||
} else if (isPart2Numeric) {
|
||||
return 1 // s2(p2)가 숫자이므로 s1(p1)이 뒤로
|
||||
}
|
||||
// 3. 둘 다 문자인 경우: 사전 순으로 비교
|
||||
else {
|
||||
val result = part1.compareTo(part2)
|
||||
if (result != 0) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 모든 부분이 동일하면 전체 문자열 길이로 비교 (짧은 것이 앞으로)
|
||||
return s1.compareTo(s2)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PageInfosJ {
|
||||
var bookTitle : String = ""
|
||||
var bookPageUrl : String = ""
|
||||
var contentsType : String? = ""
|
||||
var pages : ArrayList<PageInfoJ> = arrayListOf<PageInfoJ>()
|
||||
|
||||
fun sort() : PageInfosJ {
|
||||
pages.sortWith(PageInfoComparator())
|
||||
return this
|
||||
}
|
||||
fun getTitleArray() : ArrayList<String> {
|
||||
var arrayList = ArrayList<String>()
|
||||
pages.forEach { arrayList.add(it.bookTitle ?: "") }
|
||||
|
||||
@@ -77,7 +77,8 @@ object WorkersDb {
|
||||
.schemaVersion(schemaVersion)
|
||||
.build())
|
||||
} catch (e : IllegalStateException) {
|
||||
getRealm()
|
||||
// getRealm()
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return pRealm!!
|
||||
|
||||
Reference in New Issue
Block a user