build: Task 21 완료 - :core:core-database 모듈 분리 및 Realm 모델/WorkersDb 격리
- core/core-database 모듈 신규 생성 (namespace: bums.lunatic.launcher.core.database, io.realm.kotlin 플러그인/의존성 격리): * app/src/main/kotlin/.../model/* (UI 헬퍼 WeatherInfoManager, RssDataTypeUiExt 제외) 및 model/others/* 이동 * WorkersDb.kt, CustMigration, RecentCallGetter.kt 이동 및 BuildConfig.BuildDateTime 직접 참조를 WorkersDb.schemaVersion 프로퍼티로 디커플링 * HistoryManager.kt에서 Realm 모델 5종(LastInfo, HistoryItem, ReaderConfig, ContentsCollection, ContentsPageInfo)을 TokizModels.kt로 분리 이동 - RssDataInterface.kt 디커플링: * R.drawable 참조(getResId)를 :app의 RssDataTypeUiExt.kt로 분리 (RssItemAdapter.kt에 import 추가) * PrefHelper 직접 참조를 RssDataType.enabledChecker 람다 주입으로 분리하고 LunaticLauncher.onCreate()에서 바인딩 - settings.gradle.kts, app/build.gradle.kts, ARCHITECTURE.md, TODO.md 갱신 (6-1 완료) - 검증: ./gradlew :app:compileDebugKotlin 빌드 성공 확인 (7s, 85 actionable tasks)
This commit is contained in:
+2
-1
@@ -11,7 +11,8 @@
|
||||
| 모듈 | 역할 | 비고 |
|
||||
| :--- | :--- | :--- |
|
||||
| `:app` | 메인 Android 애플리케이션 (`bums.lunatic.launcher`) | `compileSdk 35`, `minSdk 26`, `arm64-v8a` 네이티브(C++/CMake) 포함 |
|
||||
| `:core:core-common` | 공통 로거(`Blog`) 및 ML Kit 번역/언어감지 헬퍼(`MlKitTranslationHelper`) | `:app`, `:feature:*`에서 참조 |
|
||||
| `:core:core-common` | 공통 로거(`Blog`), 유틸(`JamoUtils`, `DataUtils`), ML Kit 헬퍼(`MlKitTranslationHelper`) | `:app`, `:core:core-database`, `:feature:*`에서 참조 |
|
||||
| `:core:core-database` | Realm Kotlin 모델(`model/*`, `TokizModels`, `RecentCall`), `WorkersDb`, `CustMigration` | `io.realm.kotlin` api 노출 |
|
||||
| `:core:core-network` | 공용 `OkHttpClient` 싱글톤(`NetworkClient`) | OkHttp3 커넥션 풀 공유 |
|
||||
| `:feature:feature-torrent` | `TorrentService`/`TorrentTask` 및 `jlibtorrent` JAR 격리 모듈 | `:core:core-common` 의존 |
|
||||
| `:gdrive` | Google Drive `appDataFolder` 기반 로그인 및 백업 모듈 | `:app`에서 `implementation(project(":gdrive"))`로 참조 |
|
||||
|
||||
@@ -182,7 +182,7 @@ lunar_launcher/
|
||||
```
|
||||
|
||||
#### 단계별 모듈화 실행 순서
|
||||
- [x] **6-1. `:core:common`, `:core:network`, `:core:database` 분리** (`:core:core-common`, `:core:core-network` 생성 및 `NetworkClient`·`MlKitTranslationHelper` 이동 완료; `:core:database`는 후속 진행)
|
||||
- [x] **6-1. `:core:common`, `:core:network`, `:core:database` 분리** (`:core:core-common`, `:core:core-database`, `:core:core-network` 모두 분리 완료)
|
||||
- [x] **6-2. 독립 기능 우선 분리 (`:feature:torrent`, `:feature:wallpaper`)** (`:feature:feature-torrent` 분리 및 `jlibtorrent` JAR 격리 완료; `:feature:wallpaper`는 후속 진행)
|
||||
- [ ] **6-3. 뷰어/리더 분리 (`:feature:player`, `:feature:reader`)**: `PlayerActivity`/`NativePlayer`(+ `PlayerEngine.cpp`)와 `DocumentViewerActivity`/`ImageViewerActivity`, `TokiFragment`/`WebReaderActivity`를 분리.
|
||||
- [ ] **6-4. 피드/수집기 분리 (`:feature:feeds`)**: `RssHome`, `NeoRssActivity`, `TaskAggregator`, `*Getter`군을 분리하고 `:app`은 런처 홈과 서비스 진입점만 유지.
|
||||
|
||||
@@ -136,6 +136,7 @@ dependencies {
|
||||
"include" to listOf("*.aar", "*.jar"),
|
||||
)))
|
||||
implementation(project(":core:core-common"))
|
||||
implementation(project(":core:core-database"))
|
||||
implementation(project(":core:core-network"))
|
||||
implementation(project(":feature:feature-torrent"))
|
||||
implementation(project(":gdrive"))
|
||||
|
||||
@@ -116,6 +116,8 @@ prefs:
|
||||
appContext = this
|
||||
privateCompletedDir = File(getExternalFilesDir(null), "completed_torrents")
|
||||
PrefHelper.initialize(this)
|
||||
bums.lunatic.launcher.model.RssDataType.enabledChecker = { key -> PrefHelper.getBoolean(key, false) }
|
||||
bums.lunatic.launcher.workers.WorkersDb.schemaVersion = BuildConfig.BuildDateTime
|
||||
Base64ImageCache.init(this)
|
||||
val dir = try {
|
||||
val externalDir = File("/storage/emulated/0/bums_ob/BUM'S PACED /scraped/logs")
|
||||
|
||||
@@ -33,6 +33,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import bums.lunatic.launcher.databinding.ListItemWithBinding
|
||||
import bums.lunatic.launcher.model.RssData
|
||||
import bums.lunatic.launcher.model.RssDataInterface
|
||||
import bums.lunatic.launcher.model.getResId
|
||||
import bums.lunatic.launcher.utils.Blog
|
||||
import bums.lunatic.launcher.utils.SimpleFingerGestures
|
||||
import bums.lunatic.launcher.workers.WorkersDb
|
||||
|
||||
@@ -20,274 +20,6 @@ import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class LastInfo : RealmObject {
|
||||
@PrimaryKey
|
||||
var _id : String = ""
|
||||
var pageUrl : String = ""
|
||||
var title : String = ""
|
||||
var chapter : Int = 0
|
||||
var pageIndex : Int = 0
|
||||
var contentsName : String = ""
|
||||
var contentsType : String? = ""
|
||||
set(value) {
|
||||
_id = value ?: ""
|
||||
field = value
|
||||
}
|
||||
var displayOrientation : Int = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
|
||||
fun makeHistoryItem() : HistoryItem = HistoryItem().apply {
|
||||
title = this@LastInfo.title
|
||||
pageUrl = this@LastInfo.pageUrl
|
||||
chapter = this@LastInfo.chapter
|
||||
pageIndex = this@LastInfo.pageIndex
|
||||
contentsName = this@LastInfo.contentsName
|
||||
displayOrientation = this@LastInfo.displayOrientation
|
||||
contentsType = this@LastInfo.contentsType
|
||||
}
|
||||
}
|
||||
class HistoryItem : RealmObject {
|
||||
@PrimaryKey
|
||||
var title : String = ""
|
||||
var pageUrl : String = ""
|
||||
var chapter : Int = 0
|
||||
var pageIndex : Int = 0
|
||||
var contentsName : String = ""
|
||||
var displayOrientation : Int = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
var contentsType : String? = ""
|
||||
|
||||
fun makeLastInfo() = LastInfo().apply{
|
||||
_id = "UniqLastId"
|
||||
title = this@HistoryItem.title
|
||||
pageUrl = this@HistoryItem.pageUrl
|
||||
chapter = this@HistoryItem.chapter
|
||||
pageIndex = this@HistoryItem.pageIndex
|
||||
contentsName = this@HistoryItem.contentsName
|
||||
displayOrientation = this@HistoryItem.displayOrientation
|
||||
contentsType = this@HistoryItem.contentsType
|
||||
}
|
||||
fun putHistory(contentsPageInfo: ContentsPageInfo?, currentPath : String) : HistoryItem {
|
||||
title = contentsPageInfo?.bookTitle ?: SimpleDateFormat("YY-mm-DD-HH:mm").format(Date())
|
||||
pageUrl = contentsPageInfo?.pathUrl ?: currentPath
|
||||
chapter = contentsPageInfo?.chapterNum ?: 0
|
||||
pageIndex = contentsPageInfo?.lastPage ?: 0
|
||||
contentsName = contentsPageInfo?.chapterTitle ?: ""
|
||||
contentsType = contentsPageInfo?.contentsType ?: ""
|
||||
return this
|
||||
}
|
||||
}
|
||||
class Bookmark() : RealmObject {
|
||||
@PrimaryKey
|
||||
var pageUrl : String = ""
|
||||
}
|
||||
class ReaderConfig : RealmObject {
|
||||
@PrimaryKey
|
||||
var id : String? = "ReaderConfig"
|
||||
var textSize : Int? = 14
|
||||
var textColor : String? = "#FFFFFF"
|
||||
var bgColor : String? = "#000000"
|
||||
var style : Int? = 0
|
||||
var lineSpace : Int? = 1
|
||||
var letterSpace : Int? = 1
|
||||
var font : String? = ""
|
||||
var padding : Int? = 5
|
||||
}
|
||||
class PortMessage {
|
||||
var type : String? = ""
|
||||
var bookInfos : PageInfosJ? = null
|
||||
var book : BookContents? = null
|
||||
var msg : String? = null
|
||||
var contents : String? = null
|
||||
var privates : ArrayList<RssData>? = null
|
||||
var currentPage : String? = null
|
||||
var cookies : String? = null
|
||||
var urls : List<String> = emptyList()
|
||||
var imgSrc: String? = null
|
||||
var base64Data: String? = null
|
||||
var value : String? = null
|
||||
var url : String? = null
|
||||
var subTitles : List<Map<String, String>> = listOf()
|
||||
}
|
||||
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 ?: "") }
|
||||
return arrayList
|
||||
}
|
||||
|
||||
fun getR() : ContentsCollection{
|
||||
var r = ContentsCollection()
|
||||
r.bookTitle = this.bookTitle
|
||||
r.bookPageUrl = this.bookPageUrl
|
||||
r.contentsType = this.contentsType
|
||||
return r
|
||||
}
|
||||
}
|
||||
class PageInfoJ {
|
||||
var chapterID : Int = 0
|
||||
var contents : String? = ""
|
||||
var bookPageUrl : String? = ""
|
||||
var chapterTitle : String? = ""
|
||||
var bookTitle : String? = ""
|
||||
var chapterNum : Int = 0
|
||||
var lastPage : Int? = 0
|
||||
var pathUrl : String? = ""
|
||||
var contentsType : String? = ""
|
||||
|
||||
fun getRealm() : ContentsPageInfo {
|
||||
var r = ContentsPageInfo()
|
||||
r.chapterID = this.chapterID
|
||||
r.contents = this.contents
|
||||
r.bookPageUrl = this.bookPageUrl ?: ""
|
||||
r.chapterTitle = this.chapterTitle
|
||||
r.bookTitle = this.bookTitle ?: ""
|
||||
r.chapterNum = this.chapterNum
|
||||
r.lastPage = this.lastPage
|
||||
r.pathUrl = this.pathUrl?.replace("'","")
|
||||
r.contentsType = this.contentsType
|
||||
return r
|
||||
}
|
||||
}
|
||||
class ContentsCollection : RealmObject {
|
||||
|
||||
var bookTitle : String = ""
|
||||
|
||||
@PrimaryKey
|
||||
var bookPageUrl : String? = ""
|
||||
var pages : RealmList<ContentsPageInfo> = realmListOf()
|
||||
var contentsType : String? = ""
|
||||
|
||||
fun getTitleArray() : ArrayList<String> {
|
||||
var arrayList = ArrayList<String>()
|
||||
pages.forEach {
|
||||
arrayList.add(it.getTitleItem())}
|
||||
return arrayList
|
||||
}
|
||||
|
||||
fun sort() {
|
||||
val comparator : Comparator<ContentsPageInfo> = compareBy { it.chapterID }
|
||||
pages.sortWith(comparator)
|
||||
}
|
||||
|
||||
fun hasItem(item: ContentsPageInfo) : Boolean {
|
||||
var hasItem = false
|
||||
for (c in pages) {
|
||||
if (!hasItem) {
|
||||
hasItem = c.pathUrl.equals(item.pathUrl)
|
||||
}
|
||||
}
|
||||
return hasItem
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
class ContentsPageInfo : RealmObject {
|
||||
|
||||
var chapterID : Int = 0
|
||||
var contents : String? = ""
|
||||
|
||||
var bookPageUrl : String? = ""
|
||||
var chapterTitle : String? = ""
|
||||
var bookTitle : String? = ""
|
||||
var chapterNum : Int = 0
|
||||
var lastPage : Int? = 0
|
||||
var contentsType : String? = ""
|
||||
|
||||
fun isValidBook() = (pathUrl?.length ?: 0) > 1
|
||||
|
||||
@PrimaryKey
|
||||
var pathUrl : String? = ""
|
||||
|
||||
fun getTitleItem() : String {
|
||||
var result = StringBuilder()
|
||||
result.append(if ((contents?.length ?: 0) > 10) {
|
||||
"S:[0] "
|
||||
} else {
|
||||
"[X] "
|
||||
})
|
||||
|
||||
result.append(chapterTitle?: "")
|
||||
|
||||
result.append(if ((lastPage ?: 0) > 0) {
|
||||
" [0] "
|
||||
} else {
|
||||
" [X] "
|
||||
})
|
||||
|
||||
return result.toString()
|
||||
}
|
||||
}
|
||||
object HistoryManager {
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package bums.lunatic.launcher.model
|
||||
|
||||
import bums.lunatic.launcher.R
|
||||
|
||||
fun RssDataType.getResId() = when (this) {
|
||||
RssDataType.YOUTUBE -> R.drawable.youtube
|
||||
RssDataType.REDDIT, RssDataType.REDDIT_NSFW -> R.drawable.reddit
|
||||
RssDataType.DOTAX -> R.drawable.daum
|
||||
RssDataType.FMKORAE -> R.drawable.fmk
|
||||
RssDataType.DCINSIDE -> R.drawable.dcinside
|
||||
RssDataType.ARCA -> R.drawable.arca
|
||||
else -> R.drawable.ic_news
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
id("kotlin-android")
|
||||
id("io.realm.kotlin")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "bums.lunatic.launcher.core.database"
|
||||
compileSdk = 35
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 26
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":core:core-common"))
|
||||
api("io.realm.kotlin:library-base:2.0.0")
|
||||
implementation("org.jsoup:jsoup:1.21.2")
|
||||
implementation("com.google.code.gson:gson:2.13.1")
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest />
|
||||
@@ -0,0 +1,280 @@
|
||||
package bums.lunatic.launcher.home.tokiz
|
||||
|
||||
import android.content.pm.ActivityInfo
|
||||
import bums.lunatic.launcher.model.RssData
|
||||
import io.realm.kotlin.ext.realmListOf
|
||||
import io.realm.kotlin.types.RealmList
|
||||
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
|
||||
var _id : String = ""
|
||||
var pageUrl : String = ""
|
||||
var title : String = ""
|
||||
var chapter : Int = 0
|
||||
var pageIndex : Int = 0
|
||||
var contentsName : String = ""
|
||||
var contentsType : String? = ""
|
||||
set(value) {
|
||||
_id = value ?: ""
|
||||
field = value
|
||||
}
|
||||
var displayOrientation : Int = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
|
||||
fun makeHistoryItem() : HistoryItem = HistoryItem().apply {
|
||||
title = this@LastInfo.title
|
||||
pageUrl = this@LastInfo.pageUrl
|
||||
chapter = this@LastInfo.chapter
|
||||
pageIndex = this@LastInfo.pageIndex
|
||||
contentsName = this@LastInfo.contentsName
|
||||
displayOrientation = this@LastInfo.displayOrientation
|
||||
contentsType = this@LastInfo.contentsType
|
||||
}
|
||||
}
|
||||
class HistoryItem : RealmObject {
|
||||
@PrimaryKey
|
||||
var title : String = ""
|
||||
var pageUrl : String = ""
|
||||
var chapter : Int = 0
|
||||
var pageIndex : Int = 0
|
||||
var contentsName : String = ""
|
||||
var displayOrientation : Int = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
var contentsType : String? = ""
|
||||
|
||||
fun makeLastInfo() = LastInfo().apply{
|
||||
_id = "UniqLastId"
|
||||
title = this@HistoryItem.title
|
||||
pageUrl = this@HistoryItem.pageUrl
|
||||
chapter = this@HistoryItem.chapter
|
||||
pageIndex = this@HistoryItem.pageIndex
|
||||
contentsName = this@HistoryItem.contentsName
|
||||
displayOrientation = this@HistoryItem.displayOrientation
|
||||
contentsType = this@HistoryItem.contentsType
|
||||
}
|
||||
fun putHistory(contentsPageInfo: ContentsPageInfo?, currentPath : String) : HistoryItem {
|
||||
title = contentsPageInfo?.bookTitle ?: SimpleDateFormat("YY-mm-DD-HH:mm").format(Date())
|
||||
pageUrl = contentsPageInfo?.pathUrl ?: currentPath
|
||||
chapter = contentsPageInfo?.chapterNum ?: 0
|
||||
pageIndex = contentsPageInfo?.lastPage ?: 0
|
||||
contentsName = contentsPageInfo?.chapterTitle ?: ""
|
||||
contentsType = contentsPageInfo?.contentsType ?: ""
|
||||
return this
|
||||
}
|
||||
}
|
||||
class Bookmark() : RealmObject {
|
||||
@PrimaryKey
|
||||
var pageUrl : String = ""
|
||||
}
|
||||
class ReaderConfig : RealmObject {
|
||||
@PrimaryKey
|
||||
var id : String? = "ReaderConfig"
|
||||
var textSize : Int? = 14
|
||||
var textColor : String? = "#FFFFFF"
|
||||
var bgColor : String? = "#000000"
|
||||
var style : Int? = 0
|
||||
var lineSpace : Int? = 1
|
||||
var letterSpace : Int? = 1
|
||||
var font : String? = ""
|
||||
var padding : Int? = 5
|
||||
}
|
||||
class PortMessage {
|
||||
var type : String? = ""
|
||||
var bookInfos : PageInfosJ? = null
|
||||
var book : BookContents? = null
|
||||
var msg : String? = null
|
||||
var contents : String? = null
|
||||
var privates : ArrayList<RssData>? = null
|
||||
var currentPage : String? = null
|
||||
var cookies : String? = null
|
||||
var urls : List<String> = emptyList()
|
||||
var imgSrc: String? = null
|
||||
var base64Data: String? = null
|
||||
var value : String? = null
|
||||
var url : String? = null
|
||||
var subTitles : List<Map<String, String>> = listOf()
|
||||
}
|
||||
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 ?: "") }
|
||||
return arrayList
|
||||
}
|
||||
|
||||
fun getR() : ContentsCollection{
|
||||
var r = ContentsCollection()
|
||||
r.bookTitle = this.bookTitle
|
||||
r.bookPageUrl = this.bookPageUrl
|
||||
r.contentsType = this.contentsType
|
||||
return r
|
||||
}
|
||||
}
|
||||
class PageInfoJ {
|
||||
var chapterID : Int = 0
|
||||
var contents : String? = ""
|
||||
var bookPageUrl : String? = ""
|
||||
var chapterTitle : String? = ""
|
||||
var bookTitle : String? = ""
|
||||
var chapterNum : Int = 0
|
||||
var lastPage : Int? = 0
|
||||
var pathUrl : String? = ""
|
||||
var contentsType : String? = ""
|
||||
|
||||
fun getRealm() : ContentsPageInfo {
|
||||
var r = ContentsPageInfo()
|
||||
r.chapterID = this.chapterID
|
||||
r.contents = this.contents
|
||||
r.bookPageUrl = this.bookPageUrl ?: ""
|
||||
r.chapterTitle = this.chapterTitle
|
||||
r.bookTitle = this.bookTitle ?: ""
|
||||
r.chapterNum = this.chapterNum
|
||||
r.lastPage = this.lastPage
|
||||
r.pathUrl = this.pathUrl?.replace("'","")
|
||||
r.contentsType = this.contentsType
|
||||
return r
|
||||
}
|
||||
}
|
||||
class ContentsCollection : RealmObject {
|
||||
|
||||
var bookTitle : String = ""
|
||||
|
||||
@PrimaryKey
|
||||
var bookPageUrl : String? = ""
|
||||
var pages : RealmList<ContentsPageInfo> = realmListOf()
|
||||
var contentsType : String? = ""
|
||||
|
||||
fun getTitleArray() : ArrayList<String> {
|
||||
var arrayList = ArrayList<String>()
|
||||
pages.forEach {
|
||||
arrayList.add(it.getTitleItem())}
|
||||
return arrayList
|
||||
}
|
||||
|
||||
fun sort() {
|
||||
val comparator : Comparator<ContentsPageInfo> = compareBy { it.chapterID }
|
||||
pages.sortWith(comparator)
|
||||
}
|
||||
|
||||
fun hasItem(item: ContentsPageInfo) : Boolean {
|
||||
var hasItem = false
|
||||
for (c in pages) {
|
||||
if (!hasItem) {
|
||||
hasItem = c.pathUrl.equals(item.pathUrl)
|
||||
}
|
||||
}
|
||||
return hasItem
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
class ContentsPageInfo : RealmObject {
|
||||
|
||||
var chapterID : Int = 0
|
||||
var contents : String? = ""
|
||||
|
||||
var bookPageUrl : String? = ""
|
||||
var chapterTitle : String? = ""
|
||||
var bookTitle : String? = ""
|
||||
var chapterNum : Int = 0
|
||||
var lastPage : Int? = 0
|
||||
var contentsType : String? = ""
|
||||
|
||||
fun isValidBook() = (pathUrl?.length ?: 0) > 1
|
||||
|
||||
@PrimaryKey
|
||||
var pathUrl : String? = ""
|
||||
|
||||
fun getTitleItem() : String {
|
||||
var result = StringBuilder()
|
||||
result.append(if ((contents?.length ?: 0) > 10) {
|
||||
"S:[0] "
|
||||
} else {
|
||||
"[X] "
|
||||
})
|
||||
|
||||
result.append(chapterTitle?: "")
|
||||
|
||||
result.append(if ((lastPage ?: 0) > 0) {
|
||||
" [0] "
|
||||
} else {
|
||||
" [X] "
|
||||
})
|
||||
|
||||
return result.toString()
|
||||
}
|
||||
}
|
||||
+2
-15
@@ -1,8 +1,6 @@
|
||||
package bums.lunatic.launcher.model
|
||||
|
||||
import android.view.View
|
||||
import bums.lunatic.launcher.R
|
||||
import bums.lunatic.launcher.helpers.PrefHelper
|
||||
|
||||
enum class RssDataType {
|
||||
NO_DATA,
|
||||
@@ -26,18 +24,6 @@ enum class RssDataType {
|
||||
NAMU,
|
||||
ARCA;
|
||||
|
||||
fun getResId() = when (this) {
|
||||
YOUTUBE -> R.drawable.youtube
|
||||
REDDIT, REDDIT_NSFW -> R.drawable.reddit
|
||||
DOTAX -> R.drawable.daum
|
||||
FMKORAE -> R.drawable.fmk
|
||||
DCINSIDE -> R.drawable.dcinside
|
||||
ARCA -> R.drawable.arca
|
||||
else -> {
|
||||
R.drawable.ic_news
|
||||
}
|
||||
}
|
||||
|
||||
fun defaultImgSize() = when (this) {
|
||||
YOUTUBE -> 200
|
||||
REDDIT_NSFW,PRIVATE -> 240
|
||||
@@ -51,12 +37,13 @@ enum class RssDataType {
|
||||
}
|
||||
|
||||
fun isOn(block : ()->Unit) {
|
||||
if(PrefHelper.getBoolean(name,false)) {
|
||||
if (enabledChecker?.invoke(name) == true) {
|
||||
block.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
var enabledChecker: ((String) -> Boolean)? = null
|
||||
fun getExcAdt() = arrayListOf(NEWSFEED, REDDIT, DOTAX, FMKORAE, DCINSIDE, RULIWEB, CLIEN, THEQOO).map { it.name }
|
||||
fun getAdts() = arrayListOf( REDDIT_NSFW).map { it.name }
|
||||
fun getAll() = arrayListOf(YOUTUBE, NEWSFEED, REDDIT, DOTAX, FMKORAE, DCINSIDE, RULIWEB, CLIEN, THEQOO, PRIVATE,REDDIT_NSFW)
|
||||
-1
@@ -3,7 +3,6 @@ package bums.lunatic.launcher.workers
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.provider.CallLog
|
||||
import androidx.work.WorkerParameters
|
||||
import bums.lunatic.launcher.utils.beforeDay
|
||||
import bums.lunatic.launcher.utils.getContactId
|
||||
import com.google.gson.Gson
|
||||
+1
-2
@@ -2,7 +2,6 @@ package bums.lunatic.launcher.workers
|
||||
|
||||
import android.app.usage.UsageStatsManager
|
||||
import android.content.Context
|
||||
import bums.lunatic.launcher.BuildConfig
|
||||
import bums.lunatic.launcher.common.letTrue
|
||||
import bums.lunatic.launcher.model.AppInfo
|
||||
import bums.lunatic.launcher.model.AppUsageLog
|
||||
@@ -283,7 +282,7 @@ object WorkersDb {
|
||||
}
|
||||
}
|
||||
|
||||
val schemaVersion : Long = BuildConfig.BuildDateTime
|
||||
var schemaVersion : Long = 202611160000L
|
||||
|
||||
private var pRealm : Realm? = null
|
||||
fun getRealm() : Realm {
|
||||
@@ -24,6 +24,7 @@ dependencyResolutionManagement {
|
||||
rootProject.name = "LunarLauncher"
|
||||
include ("app")
|
||||
include(":core:core-common")
|
||||
include(":core:core-database")
|
||||
include(":core:core-network")
|
||||
include(":feature:feature-torrent")
|
||||
include(":gdrive")
|
||||
|
||||
Reference in New Issue
Block a user