Merge branch 'main' of https://dev.lunaticbum.kr/lun_admin/lun_launcher
This commit is contained in:
commit
92240b9819
@ -63,6 +63,7 @@
|
|||||||
android:theme="@style/Theme.LunarLauncher.Starting"
|
android:theme="@style/Theme.LunarLauncher.Starting"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|screenLayout|layoutDirection"
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|screenLayout|layoutDirection"
|
||||||
android:windowSoftInputMode="adjustResize"
|
android:windowSoftInputMode="adjustResize"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|||||||
@ -32,16 +32,15 @@ import android.net.Uri
|
|||||||
import android.net.http.SslError
|
import android.net.http.SslError
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.CallLog
|
|
||||||
import android.provider.ContactsContract
|
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.telephony.TelephonyManager
|
import android.telephony.TelephonyManager
|
||||||
import android.util.Log
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowInsets
|
import android.view.WindowInsets
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.webkit.JavascriptInterface
|
import android.webkit.JavascriptInterface
|
||||||
import android.webkit.SslErrorHandler
|
import android.webkit.SslErrorHandler
|
||||||
|
import android.webkit.WebResourceError
|
||||||
|
import android.webkit.WebResourceRequest
|
||||||
import android.webkit.WebSettings
|
import android.webkit.WebSettings
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import android.webkit.WebViewClient
|
import android.webkit.WebViewClient
|
||||||
@ -83,12 +82,21 @@ import rasel.lunar.launcher.home.LauncherHome
|
|||||||
import rasel.lunar.launcher.home.LauncherHome.Companion.lastedFinishedPageUrl
|
import rasel.lunar.launcher.home.LauncherHome.Companion.lastedFinishedPageUrl
|
||||||
import rasel.lunar.launcher.home.LauncherHome.Companion.listItem
|
import rasel.lunar.launcher.home.LauncherHome.Companion.listItem
|
||||||
import rasel.lunar.launcher.home.LauncherHome.Companion.listTags
|
import rasel.lunar.launcher.home.LauncherHome.Companion.listTags
|
||||||
|
import rasel.lunar.launcher.home.LauncherHome.Companion.rssSet
|
||||||
import rasel.lunar.launcher.home.RssItem
|
import rasel.lunar.launcher.home.RssItem
|
||||||
import rasel.lunar.launcher.home.RssTagItem
|
import rasel.lunar.launcher.home.RssTagItem
|
||||||
import rasel.lunar.launcher.utils.BLog
|
import rasel.lunar.launcher.utils.BLog
|
||||||
|
import rasel.lunar.launcher.utils.ComicsGetter
|
||||||
|
import rasel.lunar.launcher.utils.ComicsGetter2
|
||||||
import rasel.lunar.launcher.utils.MissedCallGetter
|
import rasel.lunar.launcher.utils.MissedCallGetter
|
||||||
import rasel.lunar.launcher.utils.NewsFeedsGetter
|
import rasel.lunar.launcher.utils.NewsFeedsGetter
|
||||||
import rasel.lunar.launcher.utils.RecentSmsGetter
|
import rasel.lunar.launcher.utils.RecentSmsGetter
|
||||||
|
import rasel.lunar.launcher.utils.RedditGetter
|
||||||
|
import rasel.lunar.launcher.utils.RssList.jGuruMain
|
||||||
|
import rasel.lunar.launcher.utils.RssList.jGuruRanks
|
||||||
|
import rasel.lunar.launcher.utils.YoutubeGetter
|
||||||
|
import rasel.lunar.launcher.utils.beforeDay
|
||||||
|
import rasel.lunar.launcher.utils.make0H
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
@ -103,15 +111,21 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
lateinit var viewPager: ViewPager2
|
lateinit var viewPager: ViewPager2
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val TEST_PAG = "https://jav.guru/"
|
|
||||||
private var mWorkManager: WorkManager? = null
|
private var mWorkManager: WorkManager? = null
|
||||||
val TEST_PAG2 = "https://torrentsee246.com/topic/index?category1=129&category2=132"
|
|
||||||
|
|
||||||
val SMS_WORK_TAG = "RecentSmsGetter"
|
val SMS_WORK_TAG = "RecentSmsGetter"
|
||||||
val CALL_WORK_TAG = "MissedCallGetter"
|
val CALL_WORK_TAG = "MissedCallGetter"
|
||||||
val FEDDS_WORK_TAG = "NewsFeedsGetter"
|
val FEDDS_WORK_TAG = "NewsFeedsGetter"
|
||||||
|
val YT_WORK_TAG = "YoutubeGetter"
|
||||||
|
val COMIC_WORK_TAG = "ComicGetter"
|
||||||
|
val COMIC2_WORK_TAG = "ComicGetter2"
|
||||||
|
val REDDIT_WORK_TAG = "RedditGetter"
|
||||||
|
val shortTimePeriod = 60L
|
||||||
|
val longTimePeriod = 60L
|
||||||
|
val midTimePeriod = 60L
|
||||||
var isOpendFold = false
|
var isOpendFold = false
|
||||||
|
var rssSetTouchCount = 0
|
||||||
|
|
||||||
@JvmStatic var lActivity: LauncherActivity? = null
|
@JvmStatic var lActivity: LauncherActivity? = null
|
||||||
@JvmStatic var appWidgetManager: AppWidgetManager? = null
|
@JvmStatic var appWidgetManager: AppWidgetManager? = null
|
||||||
@ -122,7 +136,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
mWorkManager?.enqueueUniquePeriodicWork(
|
mWorkManager?.enqueueUniquePeriodicWork(
|
||||||
SMS_WORK_TAG,
|
SMS_WORK_TAG,
|
||||||
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||||
PeriodicWorkRequestBuilder<RecentSmsGetter>(30, TimeUnit.MINUTES)
|
PeriodicWorkRequestBuilder<RecentSmsGetter>(longTimePeriod, TimeUnit.MINUTES)
|
||||||
.addTag(SMS_WORK_TAG)
|
.addTag(SMS_WORK_TAG)
|
||||||
.build())
|
.build())
|
||||||
}, 2, TimeUnit.SECONDS)
|
}, 2, TimeUnit.SECONDS)
|
||||||
@ -133,7 +147,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
mWorkManager?.enqueueUniquePeriodicWork(
|
mWorkManager?.enqueueUniquePeriodicWork(
|
||||||
CALL_WORK_TAG,
|
CALL_WORK_TAG,
|
||||||
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||||
PeriodicWorkRequestBuilder<MissedCallGetter>(30, TimeUnit.MINUTES)
|
PeriodicWorkRequestBuilder<MissedCallGetter>(longTimePeriod, TimeUnit.MINUTES)
|
||||||
.addTag(CALL_WORK_TAG)
|
.addTag(CALL_WORK_TAG)
|
||||||
.build())
|
.build())
|
||||||
}, 2, TimeUnit.SECONDS)
|
}, 2, TimeUnit.SECONDS)
|
||||||
@ -143,12 +157,53 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
mWorkManager?.cancelAllWorkByTag(FEDDS_WORK_TAG)
|
mWorkManager?.cancelAllWorkByTag(FEDDS_WORK_TAG)
|
||||||
mWorkManager?.enqueueUniquePeriodicWork(
|
mWorkManager?.enqueueUniquePeriodicWork(
|
||||||
FEDDS_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
FEDDS_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||||
PeriodicWorkRequestBuilder<NewsFeedsGetter>(30, TimeUnit.MINUTES)
|
PeriodicWorkRequestBuilder<NewsFeedsGetter>(shortTimePeriod, TimeUnit.MINUTES)
|
||||||
.addTag(FEDDS_WORK_TAG)
|
.addTag(FEDDS_WORK_TAG)
|
||||||
.build())
|
.build())
|
||||||
}, 2, TimeUnit.SECONDS)
|
}, 2, TimeUnit.SECONDS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun refreshYoutube() {
|
||||||
|
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||||
|
mWorkManager?.cancelAllWorkByTag(YT_WORK_TAG)
|
||||||
|
mWorkManager?.enqueueUniquePeriodicWork(
|
||||||
|
YT_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||||
|
PeriodicWorkRequestBuilder<YoutubeGetter>(longTimePeriod, TimeUnit.MINUTES)
|
||||||
|
.addTag(YT_WORK_TAG)
|
||||||
|
.build())
|
||||||
|
}, 2, TimeUnit.SECONDS)
|
||||||
|
}
|
||||||
|
fun refreshReddit() {
|
||||||
|
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||||
|
mWorkManager?.cancelAllWorkByTag(REDDIT_WORK_TAG)
|
||||||
|
mWorkManager?.enqueueUniquePeriodicWork(
|
||||||
|
REDDIT_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||||
|
PeriodicWorkRequestBuilder<RedditGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||||
|
.addTag(REDDIT_WORK_TAG)
|
||||||
|
.build())
|
||||||
|
}, 2, TimeUnit.SECONDS)
|
||||||
|
}
|
||||||
|
fun refreshComics() {
|
||||||
|
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||||
|
mWorkManager?.cancelAllWorkByTag(COMIC_WORK_TAG)
|
||||||
|
mWorkManager?.enqueueUniquePeriodicWork(
|
||||||
|
COMIC_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||||
|
PeriodicWorkRequestBuilder<ComicsGetter>(shortTimePeriod, TimeUnit.MINUTES)
|
||||||
|
.addTag(COMIC_WORK_TAG)
|
||||||
|
.build())
|
||||||
|
refreshComics2()
|
||||||
|
}, 2, TimeUnit.SECONDS)
|
||||||
|
}
|
||||||
|
fun refreshComics2() {
|
||||||
|
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||||
|
mWorkManager?.cancelAllWorkByTag(COMIC2_WORK_TAG)
|
||||||
|
mWorkManager?.enqueueUniquePeriodicWork(
|
||||||
|
COMIC2_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||||
|
PeriodicWorkRequestBuilder<ComicsGetter2>(shortTimePeriod, TimeUnit.MINUTES)
|
||||||
|
.addTag(COMIC2_WORK_TAG)
|
||||||
|
.build())
|
||||||
|
}, 2, TimeUnit.SECONDS)
|
||||||
|
}
|
||||||
fun workmanager() : WorkManager? {
|
fun workmanager() : WorkManager? {
|
||||||
if (mWorkManager == null && lActivity != null) {
|
if (mWorkManager == null && lActivity != null) {
|
||||||
mWorkManager = WorkManager.getInstance(lActivity!!)
|
mWorkManager = WorkManager.getInstance(lActivity!!)
|
||||||
@ -213,6 +268,9 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
refreshSms()
|
refreshSms()
|
||||||
refreshCalls()
|
refreshCalls()
|
||||||
refreshFeeds()
|
refreshFeeds()
|
||||||
|
refreshYoutube()
|
||||||
|
refreshReddit()
|
||||||
|
refreshComics()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
@ -225,6 +283,12 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
BLog.LOGE("LauncherActivity onStart()")
|
BLog.LOGE("LauncherActivity onStart()")
|
||||||
statusBarView()
|
statusBarView()
|
||||||
setBgColor()
|
setBgColor()
|
||||||
|
|
||||||
|
if (listItem.size < 2) {
|
||||||
|
lActivity?.doWebParseStart(jGuruRanks) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
@ -398,15 +462,28 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var callBack : (()->Unit)? = null
|
var callBack : (()->Unit)? = null
|
||||||
fun doWebPare(url : String, callBack : (()->Unit)?) {
|
fun doWebParseStart(url : String, callBack : (()->Unit)?) {
|
||||||
this.callBack = callBack
|
this.callBack = callBack
|
||||||
|
binding.searcher01.post { binding.searcher01.visibility = View.VISIBLE }
|
||||||
BLog.LOGE("binding.otherCheck before ThreadRun")
|
BLog.LOGE("binding.otherCheck before ThreadRun")
|
||||||
binding.searcher01.webViewClient = object : WebViewClient() {
|
binding.searcher01.webViewClient = object : WebViewClient() {
|
||||||
|
|
||||||
|
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
|
||||||
|
view?.loadUrl(url!!)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
|
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
|
||||||
BLog.LOGE("binding.otherCheck searcher01 in onPageStarted ${url}")
|
BLog.LOGE("binding.otherCheck searcher01 in onPageStarted ${url}")
|
||||||
super.onPageStarted(view, url, favicon)
|
super.onPageStarted(view, url, favicon)
|
||||||
}
|
}
|
||||||
|
override fun onReceivedError(
|
||||||
|
view: WebView?,
|
||||||
|
request: WebResourceRequest?,
|
||||||
|
error: WebResourceError?
|
||||||
|
) {
|
||||||
|
super.onReceivedError(view, request, error)
|
||||||
|
}
|
||||||
override fun onReceivedSslError(
|
override fun onReceivedSslError(
|
||||||
view: WebView?,
|
view: WebView?,
|
||||||
handler: SslErrorHandler?,
|
handler: SslErrorHandler?,
|
||||||
@ -432,6 +509,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//if (url?.contains("guru", true) == true)
|
||||||
view?.evaluateJavascript(
|
view?.evaluateJavascript(
|
||||||
"function getAll() {\n" +
|
"function getAll() {\n" +
|
||||||
" MyJavaScriptInterface.sendValueFromHtml(document.getElementsByTagName('html')[0].innerHTML)" +
|
" MyJavaScriptInterface.sendValueFromHtml(document.getElementsByTagName('html')[0].innerHTML)" +
|
||||||
@ -443,15 +521,22 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
callBack?.invoke()
|
callBack?.invoke()
|
||||||
|
binding.searcher01.post { binding.searcher01.visibility = View.GONE }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WebView.setWebContentsDebuggingEnabled(false)
|
WebView.setWebContentsDebuggingEnabled(false)
|
||||||
binding.searcher01.apply {
|
binding.searcher01.apply {
|
||||||
|
// Jsoup.connect("https://missav.com/dm11/ko").userAgent()
|
||||||
|
// .timeout(30000).get()?.apply {
|
||||||
|
// BLog.LOGE("Jsoup.connect(missAv).get() ${this}")
|
||||||
|
// }
|
||||||
this.addJavascriptInterface(MyJavaScriptInterface(this),"MyJavaScriptInterface")
|
this.addJavascriptInterface(MyJavaScriptInterface(this),"MyJavaScriptInterface")
|
||||||
setBackgroundColor(Color.WHITE) // 백그라운드 색상 설정
|
setBackgroundColor(Color.WHITE) // 백그라운드 색상 설정
|
||||||
setLayerType(View.LAYER_TYPE_SOFTWARE, null) // 랜더링 이슈 해결
|
setLayerType(View.LAYER_TYPE_SOFTWARE, null) // 랜더링 이슈 해결
|
||||||
try {
|
try {
|
||||||
settings.apply {
|
settings.apply {
|
||||||
|
userAgentString = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"
|
||||||
javaScriptEnabled = true // 자바스크립트 사용 가능하도록 설정
|
javaScriptEnabled = true // 자바스크립트 사용 가능하도록 설정
|
||||||
loadWithOverviewMode = true // 전체 웹페이지를 화면에 맞게 로드
|
loadWithOverviewMode = true // 전체 웹페이지를 화면에 맞게 로드
|
||||||
useWideViewPort = true // 화면에 맞게 페이지 확대/축소
|
useWideViewPort = true // 화면에 맞게 페이지 확대/축소
|
||||||
@ -471,13 +556,47 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
var maxDate : Long = Long.MIN_VALUE
|
var maxDate : Long = Long.MIN_VALUE
|
||||||
var minDate : Long = Long.MAX_VALUE
|
var minDate : Long = Long.MAX_VALUE
|
||||||
val triple = 1000L * 60L * 60L * 24L * 3L
|
val triple = 1000L * 60L * 60L * 24L * 2L
|
||||||
val simpldateFormat = SimpleDateFormat("d MMM, yy", Locale.US)
|
val simpldateFormat = SimpleDateFormat("d MMM, yy", Locale.US)
|
||||||
|
fun jGuruToday(doc: Document) {
|
||||||
|
doc.getElementsByTag("li").forEach {
|
||||||
|
if (it.getElementsByTag("img").size > 0) {
|
||||||
|
var title = it.getElementsByTag("a").get(0).attr("title")
|
||||||
|
var model = title.replace("[", "").split("]")[0]
|
||||||
|
var pageLink = it.getElementsByTag("a").get(0).attr("href")
|
||||||
|
var imgg = it.getElementsByTag("img").get(0).attr("src")
|
||||||
|
var actor = if (it.getElementsByClass("wpptax").size > 0 )it.getElementsByClass("wpptax").get(0).text() else ""
|
||||||
|
if (pageLink.length > 0 && imgg.length > 0 && title.length > 0 && model.length > 0) {
|
||||||
|
listItem.add(
|
||||||
|
RssItem(
|
||||||
|
model = model,
|
||||||
|
title = title,
|
||||||
|
pageLink = pageLink,
|
||||||
|
image = imgg,
|
||||||
|
tags = actor,
|
||||||
|
date = beforeDay(Date(),3) + 360000
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.apply {
|
||||||
|
this@LauncherActivity.callBack?.invoke()
|
||||||
|
var idx = 0
|
||||||
|
listItem?.forEach {
|
||||||
|
if(it.date > beforeDay(Date(),3) && idx < 10) {
|
||||||
|
it.date = it.date + (10000L * idx)
|
||||||
|
rssSet.put(it.pageLink,it)
|
||||||
|
idx += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Toast.makeText(this@LauncherActivity,
|
||||||
|
"Stored rank data", Toast.LENGTH_LONG).show()
|
||||||
|
binding.searcher01?.post { binding.searcher01.loadUrl(jGuruMain) }
|
||||||
|
}
|
||||||
|
}
|
||||||
fun jGuruMain(doc: Document) {
|
fun jGuruMain(doc: Document) {
|
||||||
// BLog.LOGE("do default parsing")
|
|
||||||
// BLog.LOGE("SimpleDateFormat D MM yy => ${SimpleDateFormat("d MMM yy", Locale.US).format(Date())}")
|
// BLog.LOGE("SimpleDateFormat D MM yy => ${SimpleDateFormat("d MMM yy", Locale.US).format(Date())}")
|
||||||
val prevUrl = doc.getElementsByClass("prev").get(0).getElementsByAttribute("href").get(0).attr("href")
|
val prevUrl = doc.getElementsByClass("prev").get(0).getElementsByAttribute("href").get(0).attr("href")
|
||||||
// BLog.LOGE("doc.getElementsByClass(prev).get(0).html() ${prevUrl}")
|
|
||||||
doc.getElementsByClass("column").forEach {
|
doc.getElementsByClass("column").forEach {
|
||||||
var title = it.getElementsByAttribute("title").get(0).text()
|
var title = it.getElementsByAttribute("title").get(0).text()
|
||||||
var model = title.replace("[","").split("]")[0]
|
var model = title.replace("[","").split("]")[0]
|
||||||
@ -486,21 +605,30 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
var tags = it.getElementsByClass("tags").get(0).text()
|
var tags = it.getElementsByClass("tags").get(0).text()
|
||||||
var date = it.getElementsByClass("date").get(0).text()
|
var date = it.getElementsByClass("date").get(0).text()
|
||||||
var regDate = simpldateFormat.parse(date).time
|
var regDate = simpldateFormat.parse(date).time
|
||||||
|
|
||||||
minDate = Math.min(minDate,regDate)
|
minDate = Math.min(minDate,regDate)
|
||||||
maxDate = Math.max(maxDate,regDate)
|
maxDate = Math.max(maxDate,regDate)
|
||||||
listItem.add(RssItem(model = model, title = title, pageLink = pageLink, image = imgg, tags = tags, date = simpldateFormat.parse(date).time))
|
listItem.add(RssItem(model = model, title = title, pageLink = pageLink, image = imgg, tags = tags, date = make0H(simpldateFormat.parse(date))))
|
||||||
}.apply {
|
}.apply {
|
||||||
|
// if (prevUrl!=null && prevUrl.length > TEST_PAG.length && prevUrl.contains("/page/") && ((maxDate - minDate) < triple)) {
|
||||||
BLog.LOGE("listItem.size >>> ${listItem.size}")
|
// listItem.sortByDescending { it.date }
|
||||||
if (prevUrl!=null && prevUrl.length > TEST_PAG.length && prevUrl.contains("/page/") && ((maxDate - minDate) < triple)) {
|
// binding.searcher01.postDelayed({binding.searcher01.loadUrl(prevUrl)}, 5000L)
|
||||||
|
//// } else {
|
||||||
|
var itemC = 0
|
||||||
listItem.sortByDescending { it.date }
|
listItem.sortByDescending { it.date }
|
||||||
binding.searcher01.postDelayed({binding.searcher01.loadUrl(prevUrl)}, 5000L)
|
listItem?.forEach {
|
||||||
} else {
|
if(it.date > beforeDay(Date(),1)) {
|
||||||
listItem.sortByDescending { it.date }
|
if (itemC < 10) {
|
||||||
BLog.LOGE("Stored data :: ${listItem.size}items ${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))}")
|
it.date = it.date + (10000L * itemC)
|
||||||
|
rssSet.put(it.pageLink, it)
|
||||||
|
}
|
||||||
|
itemC = itemC + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BLog.LOGE("Stored data :: ${listItem.size}items ${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))} set in ${itemC}")
|
||||||
Toast.makeText(this@LauncherActivity,
|
Toast.makeText(this@LauncherActivity,
|
||||||
"Stored data :: ${listItem.size} items :: [${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))}]", Toast.LENGTH_LONG).show()
|
"Stored data :: ${listItem.size} items :: [${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))}] \n set in ${itemC}", Toast.LENGTH_LONG).show()
|
||||||
}
|
// }
|
||||||
this@LauncherActivity.callBack?.invoke()
|
this@LauncherActivity.callBack?.invoke()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -532,20 +660,25 @@ internal class LauncherActivity : AppCompatActivity() {
|
|||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun sendValueFromHtml(result: String) {
|
fun sendValueFromHtml(result: String) {
|
||||||
|
|
||||||
if (lastedFinishedPageUrl.contains(TEST_PAG)) {
|
if (lastedFinishedPageUrl.contains(jGuruMain)) {
|
||||||
var htmlString = result.replace("\\u003","<")
|
var htmlString = result.replace("\\u003","<")
|
||||||
val doc: Document = Jsoup.parse(htmlString)
|
val doc: Document = Jsoup.parse(htmlString)
|
||||||
if (lastedFinishedPageUrl?.contains("page") == true || lastedFinishedPageUrl?.equals(
|
if (lastedFinishedPageUrl?.contains("page") == true || lastedFinishedPageUrl?.equals(
|
||||||
TEST_PAG
|
jGuruMain
|
||||||
) == true
|
) == true
|
||||||
) {
|
) {
|
||||||
jGuruMain(doc)
|
jGuruMain(doc)
|
||||||
|
} else if (lastedFinishedPageUrl?.contains("/most-watched-rank") == true) {
|
||||||
|
jGuruToday(doc)
|
||||||
} else if (lastedFinishedPageUrl?.contains("/tags/") == true) {
|
} else if (lastedFinishedPageUrl?.contains("/tags/") == true) {
|
||||||
jGuruTag(doc)
|
jGuruTag(doc)
|
||||||
}
|
}
|
||||||
} else if (lastedFinishedPageUrl?.contains("youtube") == true) {
|
} else if (lastedFinishedPageUrl?.contains("youtube") == true) {
|
||||||
// val doc: Document = Jsoup.parse(result)
|
// val doc: Document = Jsoup.parse(result)
|
||||||
// ytChannel(doc)
|
// ytChannel(doc)
|
||||||
|
} else if (lastedFinishedPageUrl?.contains("missav")==true) {
|
||||||
|
val doc: Document = Jsoup.parse(result)
|
||||||
|
BLog.LOGE("missav >>> ${doc}")
|
||||||
}
|
}
|
||||||
BLog.LOGE("binding.otherCheck after ThreadRun")
|
BLog.LOGE("binding.otherCheck after ThreadRun")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,6 +124,9 @@ internal class AppDrawer : Fragment() {
|
|||||||
binding.searchNmap.setOnClickListener {
|
binding.searchNmap.setOnClickListener {
|
||||||
openSearchApps("nmap://search?query=${getInputText()}&appname=${BuildConfig.APPLICATION_ID}","com.nhn.android.nmap")
|
openSearchApps("nmap://search?query=${getInputText()}&appname=${BuildConfig.APPLICATION_ID}","com.nhn.android.nmap")
|
||||||
}
|
}
|
||||||
|
binding.searchYoutube.setOnClickListener {
|
||||||
|
openSearchApps("https://www.youtube.com/results?search_query=${getInputText()}","com.google.android.youtube")
|
||||||
|
}
|
||||||
binding.searchGoogleMap.setOnClickListener {
|
binding.searchGoogleMap.setOnClickListener {
|
||||||
openSearchApps("geo:0,0?q=${getInputText()}","com.google.android.apps.maps")
|
openSearchApps("geo:0,0?q=${getInputText()}","com.google.android.apps.maps")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package rasel.lunar.launcher.feeds
|
package rasel.lunar.launcher.feeds
|
||||||
|
|
||||||
import android.R.attr.*
|
|
||||||
import android.app.Activity.RESULT_CANCELED
|
import android.app.Activity.RESULT_CANCELED
|
||||||
import android.app.Activity.RESULT_OK
|
import android.app.Activity.RESULT_OK
|
||||||
import android.appwidget.AppWidgetManager
|
import android.appwidget.AppWidgetManager
|
||||||
@ -36,13 +35,10 @@ import androidx.fragment.app.Fragment
|
|||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
|
||||||
import com.google.android.material.button.MaterialButtonToggleGroup
|
import com.google.android.material.button.MaterialButtonToggleGroup
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.TEST_PAG
|
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost
|
import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetManager
|
import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetManager
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.isOpendFold
|
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||||
import rasel.lunar.launcher.R
|
import rasel.lunar.launcher.R
|
||||||
import rasel.lunar.launcher.databinding.FeedsBinding
|
import rasel.lunar.launcher.databinding.FeedsBinding
|
||||||
@ -57,6 +53,7 @@ import rasel.lunar.launcher.home.LauncherHome.Companion.listItem
|
|||||||
import rasel.lunar.launcher.home.LauncherHome.Companion.listTags
|
import rasel.lunar.launcher.home.LauncherHome.Companion.listTags
|
||||||
import rasel.lunar.launcher.home.RssItem
|
import rasel.lunar.launcher.home.RssItem
|
||||||
import rasel.lunar.launcher.home.RssTagItem
|
import rasel.lunar.launcher.home.RssTagItem
|
||||||
|
import rasel.lunar.launcher.utils.RssList.jGuruMain
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
@ -162,7 +159,7 @@ internal class Feeds : Fragment() {
|
|||||||
refresh.visibility = View.VISIBLE
|
refresh.visibility = View.VISIBLE
|
||||||
rss.visibility = View.GONE
|
rss.visibility = View.GONE
|
||||||
refresh.setOnClickListener {
|
refresh.setOnClickListener {
|
||||||
lActivity?.doWebPare(TEST_PAG) {
|
var call = {
|
||||||
if (listItem.size > 0) {
|
if (listItem.size > 0) {
|
||||||
rss?.postDelayed( {
|
rss?.postDelayed( {
|
||||||
mRssAdapter?.updateData(listItem)
|
mRssAdapter?.updateData(listItem)
|
||||||
@ -172,6 +169,7 @@ internal class Feeds : Fragment() {
|
|||||||
},500L)
|
},500L)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,7 +190,7 @@ internal class Feeds : Fragment() {
|
|||||||
refresh.visibility = View.VISIBLE
|
refresh.visibility = View.VISIBLE
|
||||||
rss2.visibility = View.GONE
|
rss2.visibility = View.GONE
|
||||||
refresh.setOnClickListener {
|
refresh.setOnClickListener {
|
||||||
lActivity?.doWebPare(TEST_PAG.plus("tags")) {
|
lActivity?.doWebParseStart(jGuruMain.plus("tags")) {
|
||||||
if (listTags.size > 0) {
|
if (listTags.size > 0) {
|
||||||
rss2?.postDelayed( {
|
rss2?.postDelayed( {
|
||||||
mRssAdapter2?.updateData(listTags)
|
mRssAdapter2?.updateData(listTags)
|
||||||
|
|||||||
@ -39,14 +39,22 @@ import androidx.core.content.ContextCompat.RECEIVER_EXPORTED
|
|||||||
import androidx.core.content.ContextCompat.registerReceiver
|
import androidx.core.content.ContextCompat.registerReceiver
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import org.jsoup.Jsoup
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.CALL_WORK_TAG
|
import rasel.lunar.launcher.LauncherActivity.Companion.CALL_WORK_TAG
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.FEDDS_WORK_TAG
|
import rasel.lunar.launcher.LauncherActivity.Companion.FEDDS_WORK_TAG
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.SMS_WORK_TAG
|
import rasel.lunar.launcher.LauncherActivity.Companion.SMS_WORK_TAG
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||||
|
import rasel.lunar.launcher.LauncherActivity.Companion.refreshComics
|
||||||
|
import rasel.lunar.launcher.LauncherActivity.Companion.refreshFeeds
|
||||||
|
import rasel.lunar.launcher.LauncherActivity.Companion.refreshReddit
|
||||||
|
import rasel.lunar.launcher.LauncherActivity.Companion.refreshYoutube
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.workmanager
|
import rasel.lunar.launcher.LauncherActivity.Companion.workmanager
|
||||||
import rasel.lunar.launcher.R
|
import rasel.lunar.launcher.R
|
||||||
import rasel.lunar.launcher.databinding.LauncherHomeBinding
|
import rasel.lunar.launcher.databinding.LauncherHomeBinding
|
||||||
@ -76,6 +84,8 @@ import rasel.lunar.launcher.utils.beforeDay
|
|||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import java.util.concurrent.Executors
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
|
||||||
internal class LauncherHome : Fragment() {
|
internal class LauncherHome : Fragment() {
|
||||||
@ -98,7 +108,6 @@ internal class LauncherHome : Fragment() {
|
|||||||
|
|
||||||
var rssList = arrayListOf<RssDataItem>()
|
var rssList = arrayListOf<RssDataItem>()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var nReceiver: NotificationReceiver? = null
|
private var nReceiver: NotificationReceiver? = null
|
||||||
@ -139,15 +148,20 @@ internal class LauncherHome : Fragment() {
|
|||||||
batteryReceiver = BatteryReceiver(binding.batteryProgress)
|
batteryReceiver = BatteryReceiver(binding.batteryProgress)
|
||||||
mMissedCallsAdapter = MissedCallsAdapter(callList, requireContext())
|
mMissedCallsAdapter = MissedCallsAdapter(callList, requireContext())
|
||||||
mSmsLogsAdapter = SmsLogsAdapter(smsList, requireContext())
|
mSmsLogsAdapter = SmsLogsAdapter(smsList, requireContext())
|
||||||
mRssAdapter = RssItemAdapter(rssList, requireContext())
|
mRssAdapter = RssItemAdapter(requireContext())
|
||||||
binding.mainList.adapter = mMissedCallsAdapter
|
binding.mainList.adapter = mMissedCallsAdapter
|
||||||
binding.smsList.adapter = mSmsLogsAdapter
|
binding.smsList.adapter = mSmsLogsAdapter
|
||||||
binding.infoList.adapter = mRssAdapter
|
binding.infoList.adapter = mRssAdapter
|
||||||
|
val decoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL)
|
||||||
|
binding.mainList.addItemDecoration(decoration)
|
||||||
|
binding.smsList.addItemDecoration(decoration)
|
||||||
|
binding.infoList.addItemDecoration(decoration)
|
||||||
binding.missedCalls.isChecked = true
|
binding.missedCalls.isChecked = true
|
||||||
binding.smsList.visibility = View.GONE
|
binding.smsList.visibility = View.GONE
|
||||||
binding.infoList.visibility = View.GONE
|
binding.infoList.visibility = View.GONE
|
||||||
|
|
||||||
binding.favAppsGroup.visibility = View.GONE
|
binding.favAppsGroup.visibility = View.GONE
|
||||||
|
|
||||||
binding.mainList.layoutManager = LinearLayoutManager(requireContext())
|
binding.mainList.layoutManager = LinearLayoutManager(requireContext())
|
||||||
binding.smsList.layoutManager = LinearLayoutManager(requireContext())
|
binding.smsList.layoutManager = LinearLayoutManager(requireContext())
|
||||||
binding.infoList.layoutManager = LinearLayoutManager(requireContext())
|
binding.infoList.layoutManager = LinearLayoutManager(requireContext())
|
||||||
@ -223,11 +237,26 @@ internal class LauncherHome : Fragment() {
|
|||||||
chooseAdpater()
|
chooseAdpater()
|
||||||
}
|
}
|
||||||
|
|
||||||
// binding.otherCheck.setOnLongClickListener {
|
binding.otherCheck.setOnLongClickListener {
|
||||||
// listItem.clear()
|
synchronized(rssSet) {
|
||||||
// lActivity?.doWebPare(TEST_PAG, null)
|
val now = Date()
|
||||||
// true
|
var keys = arrayListOf<String>()
|
||||||
// }
|
rssSet.forEach { t, u ->
|
||||||
|
if (u.pubDate() <= beforeDay(now,3)) {
|
||||||
|
keys.add(t)
|
||||||
|
}
|
||||||
|
}.apply {
|
||||||
|
keys.forEach { rssSet.remove(it) }
|
||||||
|
}.apply {
|
||||||
|
refreshYoutube()
|
||||||
|
refreshComics()
|
||||||
|
refreshFeeds()
|
||||||
|
refreshReddit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
// binding.summaryChoose.setOnCheckedChangeListener { group, checkedId ->
|
// binding.summaryChoose.setOnCheckedChangeListener { group, checkedId ->
|
||||||
// chooseAdpater()
|
// chooseAdpater()
|
||||||
// }
|
// }
|
||||||
@ -236,7 +265,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
//// lActivity?.sendBroadcast(i)
|
//// lActivity?.sendBroadcast(i)
|
||||||
//// BLog.LOGE("intent >>> ${i.action}")
|
//// BLog.LOGE("intent >>> ${i.action}")
|
||||||
}
|
}
|
||||||
|
// https://www.youtube.com/results?search_query=sds
|
||||||
|
|
||||||
|
|
||||||
fun chooseAdpater () {
|
fun chooseAdpater () {
|
||||||
@ -252,8 +281,8 @@ internal class LauncherHome : Fragment() {
|
|||||||
}.apply {
|
}.apply {
|
||||||
callList.sortByDescending { it.date }
|
callList.sortByDescending { it.date }
|
||||||
Handler(Looper.getMainLooper()).post {
|
Handler(Looper.getMainLooper()).post {
|
||||||
mMissedCallsAdapter.updateData(callList)
|
|
||||||
binding.mainList.visibility = View.VISIBLE
|
binding.mainList.visibility = View.VISIBLE
|
||||||
|
mMissedCallsAdapter.updateData(callList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e : Exception) {
|
} catch (e : Exception) {
|
||||||
@ -265,8 +294,8 @@ internal class LauncherHome : Fragment() {
|
|||||||
smsList.sortByDescending { it.rcvDate }
|
smsList.sortByDescending { it.rcvDate }
|
||||||
binding.smsList.visibility = View.VISIBLE
|
binding.smsList.visibility = View.VISIBLE
|
||||||
Handler(Looper.getMainLooper()).post {
|
Handler(Looper.getMainLooper()).post {
|
||||||
mSmsLogsAdapter.updateData(smsList)
|
|
||||||
binding.smsList.visibility = View.VISIBLE
|
binding.smsList.visibility = View.VISIBLE
|
||||||
|
mSmsLogsAdapter.updateData(smsList)
|
||||||
}
|
}
|
||||||
} catch (e : Exception) {
|
} catch (e : Exception) {
|
||||||
|
|
||||||
@ -274,19 +303,26 @@ internal class LauncherHome : Fragment() {
|
|||||||
}
|
}
|
||||||
} else if(binding.otherCheck.isChecked) {
|
} else if(binding.otherCheck.isChecked) {
|
||||||
try {
|
try {
|
||||||
rssList.clear()
|
GlobalScope.launch {
|
||||||
rssSet.forEach { k,v ->
|
(rssSet.clone() as? HashMap<String,RssDataItem>)?.let { temMap ->
|
||||||
if(v.pubDate() > beforeDay(Date(),3)) {
|
synchronized(binding.infoList) {
|
||||||
rssList.add(v)
|
var tempList = arrayListOf<RssDataItem>()
|
||||||
} else {
|
temMap.forEach { k,v ->
|
||||||
rssSet.remove(k,v)
|
if(v.pubDate() > beforeDay(Date(),3)) {
|
||||||
}
|
tempList.add(v)
|
||||||
}.apply {
|
} else {
|
||||||
rssList.sortByDescending{ it.pubDate() }
|
|
||||||
binding.infoList.visibility = View.VISIBLE
|
}
|
||||||
Handler(Looper.getMainLooper()).post {
|
}.apply {
|
||||||
mRssAdapter.updateData(rssList)
|
tempList.sortByDescending { it.pubDate() }
|
||||||
binding.infoList.visibility = View.VISIBLE
|
rssList.clear()
|
||||||
|
rssList.addAll(tempList)
|
||||||
|
Handler(Looper.getMainLooper()).post {
|
||||||
|
binding.infoList.visibility = View.VISIBLE
|
||||||
|
mRssAdapter.updateData(rssList)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (e : Exception){}
|
}catch (e : Exception){}
|
||||||
@ -311,6 +347,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
/* show weather */
|
/* show weather */
|
||||||
WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather)
|
WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import rasel.lunar.launcher.todos.Image
|
|||||||
import rasel.lunar.launcher.todos.RssDataItem
|
import rasel.lunar.launcher.todos.RssDataItem
|
||||||
import rasel.lunar.launcher.todos.RssDataType
|
import rasel.lunar.launcher.todos.RssDataType
|
||||||
import rasel.lunar.launcher.todos.Source
|
import rasel.lunar.launcher.todos.Source
|
||||||
|
import rasel.lunar.launcher.utils.beforeDay
|
||||||
|
import java.sql.Date
|
||||||
|
|
||||||
|
|
||||||
class Reddit {
|
class Reddit {
|
||||||
@ -255,6 +257,9 @@ class Data : RssDataItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun originPage(): String {
|
override fun originPage(): String {
|
||||||
|
if (post_hint?.contains("video") == true && (permalink?.length ?: 0 > 3)) {
|
||||||
|
return "https://www.reddit.com".plus(permalink)
|
||||||
|
}
|
||||||
return url ?: ""
|
return url ?: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,6 +268,7 @@ class Data : RssDataItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun pubDate(): Long {
|
override fun pubDate(): Long {
|
||||||
|
// return beforeDay(java.util.Date(),2)
|
||||||
if (created_utc != null) {
|
if (created_utc != null) {
|
||||||
return created_utc!!.toLong() * 1000L
|
return created_utc!!.toLong() * 1000L
|
||||||
} else if (created != null) {
|
} else if (created != null) {
|
||||||
|
|||||||
@ -7,6 +7,8 @@ enum class RssDataType {
|
|||||||
GURU,
|
GURU,
|
||||||
TAGS,
|
TAGS,
|
||||||
REDDIT,
|
REDDIT,
|
||||||
|
Dotax,
|
||||||
|
FmKorae,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RssDataItem {
|
interface RssDataItem {
|
||||||
|
|||||||
@ -41,8 +41,8 @@ object RssFeedsParser {
|
|||||||
// BLog.LOGE("getReddit >>>>> link ${URLDecoder.decode(url,"utf-8")} , itemSize = ${Gson().toJson(it)}")
|
// BLog.LOGE("getReddit >>>>> link ${URLDecoder.decode(url,"utf-8")} , itemSize = ${Gson().toJson(it)}")
|
||||||
if(((it.data?.created_utc ?: 0).toLong() * 1000L > dateTime)) {
|
if(((it.data?.created_utc ?: 0).toLong() * 1000L > dateTime)) {
|
||||||
// BLog.LOGE("getReddit >>>>> link ${URLDecoder.decode(url,"utf-8")} , itemSize = ${Gson().toJson(it)}")
|
// BLog.LOGE("getReddit >>>>> link ${URLDecoder.decode(url,"utf-8")} , itemSize = ${Gson().toJson(it)}")
|
||||||
(it.data as? RssDataItem)?.let {
|
(it.data as? RssDataItem)?.let { rss ->
|
||||||
returnList.add(it)
|
returnList.add(rss)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,63 +19,54 @@
|
|||||||
package rasel.lunar.launcher.todos
|
package rasel.lunar.launcher.todos
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.ClipData
|
|
||||||
import android.content.ClipboardManager
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.text.Html
|
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat.startActivity
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||||
import rasel.lunar.launcher.R
|
import rasel.lunar.launcher.R
|
||||||
import rasel.lunar.launcher.databinding.ListItemBinding
|
|
||||||
import rasel.lunar.launcher.databinding.ListItemWithBinding
|
import rasel.lunar.launcher.databinding.ListItemWithBinding
|
||||||
import rasel.lunar.launcher.home.RssItem
|
import rasel.lunar.launcher.home.RssItem
|
||||||
import rasel.lunar.launcher.home.RssTagItem
|
|
||||||
import rasel.lunar.launcher.utils.BLog
|
|
||||||
import rasel.lunar.launcher.utils.Hashids
|
|
||||||
import rasel.lunar.launcher.utils.RecentSmsLog
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
|
|
||||||
internal class RssItemAdapter (
|
internal class RssItemAdapter (
|
||||||
private val smsList: ArrayList<RssDataItem>,
|
|
||||||
private val context: Context) : RecyclerView.Adapter<RssTag>() {
|
private val context: Context) : RecyclerView.Adapter<RssTag>() {
|
||||||
|
private var rssDataItemLis: ArrayList<RssDataItem> = arrayListOf()
|
||||||
override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): RssTag {
|
override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): RssTag {
|
||||||
val binding = ListItemWithBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
|
val binding = ListItemWithBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
|
||||||
return RssTag(binding)
|
return RssTag(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return smsList.size
|
return rssDataItemLis.size
|
||||||
}
|
}
|
||||||
|
|
||||||
val dateFormat = SimpleDateFormat("hh:mm / yy - MM - dd")
|
val dateFormat = SimpleDateFormat("hh:mm / yy - MM - dd")
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBindViewHolder(holder: RssTag, position: Int) {
|
override fun onBindViewHolder(holder: RssTag, position: Int) {
|
||||||
val todo = smsList[position]
|
val todo = rssDataItemLis[position]
|
||||||
|
|
||||||
holder.view.date.text = "${dateFormat.format(Date(todo.pubDate()))}"
|
holder.view.date.text = "${dateFormat.format(Date(todo.pubDate()))}"
|
||||||
// holder.view.desc.visibility = View.GONE
|
// holder.view.desc.visibility = View.GONE
|
||||||
|
holder.view.date.setOnClickListener { }
|
||||||
when(todo.category()) {
|
when(todo.category()) {
|
||||||
RssDataType.YOUTUBE -> {
|
RssDataType.YOUTUBE -> {
|
||||||
if(todo.thumbnailUrl()?.length ?: 0 > 6) {
|
if(todo.thumbnailUrl()?.length ?: 0 > 6) {
|
||||||
Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview)
|
Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview)
|
||||||
holder.view.circlePreview.visibility = View.VISIBLE
|
holder.view.circlePreview.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(280,280)
|
||||||
holder.view.title.text = "${todo.title()}"
|
holder.view.title.text = "${todo.title()}"
|
||||||
holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||||
holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||||
@ -83,15 +74,30 @@ internal class RssItemAdapter (
|
|||||||
holder.view.desc.visibility = View.VISIBLE
|
holder.view.desc.visibility = View.VISIBLE
|
||||||
holder.view.desc.text = if(todo.description().contains("게시자")) todo.description().split("게시자")[0] else todo.description()
|
holder.view.desc.text = if(todo.description().contains("게시자")) todo.description().split("게시자")[0] else todo.description()
|
||||||
// holder.view.root.setOnClickListener { openYouTube(todo.originPage()) }
|
// holder.view.root.setOnClickListener { openYouTube(todo.originPage()) }
|
||||||
|
holder.view.root.setOnClickListener {
|
||||||
|
|
||||||
|
}
|
||||||
|
holder.view.root.setOnLongClickListener {
|
||||||
|
|
||||||
|
openYouTube(todo.originPage())
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
RssDataType.NewsFeed -> {
|
RssDataType.NewsFeed -> {
|
||||||
holder.view.desc.text = ""
|
holder.view.desc.text = todo.category().name
|
||||||
holder.view.circlePreview.visibility = View.GONE
|
holder.view.circlePreview.visibility = View.GONE
|
||||||
holder.view.title.text = if(todo.title().length > 30)todo.title().substring(0,30).plus("...") else todo.title()
|
holder.view.title.text = if(todo.title().length > 30)todo.title().substring(0,30).plus("...") else todo.title()
|
||||||
holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.LEFT)
|
holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||||
holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.LEFT)
|
holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||||
holder.view.date.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
holder.view.date.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||||
// holder.view.root.setOnClickListener { openNews(todo.originPage()) }
|
holder.view.root.setOnClickListener {
|
||||||
|
|
||||||
|
}
|
||||||
|
holder.view.root.setOnLongClickListener {
|
||||||
|
openNews(todo.originPage())
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
RssDataType.NO_DATA -> {}
|
RssDataType.NO_DATA -> {}
|
||||||
else -> {
|
else -> {
|
||||||
@ -102,45 +108,85 @@ internal class RssItemAdapter (
|
|||||||
if (todo.pubDate() > 1000L) {
|
if (todo.pubDate() > 1000L) {
|
||||||
holder.view.date.text = dateFormat.format(Date(todo.pubDate()))
|
holder.view.date.text = dateFormat.format(Date(todo.pubDate()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(todo.description().contains("nsfw") || todo.category().equals(RssDataType.GURU)) {
|
||||||
|
holder.view.circlePreview.visibility = View.GONE
|
||||||
|
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(360,360)
|
||||||
|
} else if( todo.category().equals(RssDataType.Dotax)) {
|
||||||
|
holder.view.circlePreview.setImageResource(R.drawable.daum)
|
||||||
|
holder.view.circlePreview.visibility = View.VISIBLE
|
||||||
|
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120)
|
||||||
|
} else if( todo.category().equals(RssDataType.REDDIT)) {
|
||||||
|
holder.view.circlePreview.setImageResource(R.drawable.reddit)
|
||||||
|
holder.view.circlePreview.visibility = View.VISIBLE
|
||||||
|
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120)
|
||||||
|
} else if( todo.category().equals(RssDataType.FmKorae)) {
|
||||||
|
holder.view.circlePreview.setImageResource(R.drawable.fmk)
|
||||||
|
holder.view.circlePreview.visibility = View.VISIBLE
|
||||||
|
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120)
|
||||||
|
}
|
||||||
|
|
||||||
if(todo.thumbnailUrl()?.length ?: 0 > 6) {
|
if(todo.thumbnailUrl()?.length ?: 0 > 6) {
|
||||||
Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview)
|
Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview)
|
||||||
}
|
}
|
||||||
holder.view.circlePreview.visibility = View.GONE
|
|
||||||
holder.view.desc.text = todo.description()
|
holder.view.desc.text = todo.description().plus(" ").plus(todo.category().name)
|
||||||
holder.view.desc.visibility = View.VISIBLE
|
holder.view.desc.visibility = View.VISIBLE
|
||||||
holder.view.date.visibility = View.VISIBLE
|
holder.view.date.visibility = View.VISIBLE
|
||||||
holder.view.root.setOnClickListener {
|
// holder.view.date.setOnTouchListener { v,e ->
|
||||||
|
// if (holder.view.date.equals(v)) {
|
||||||
|
// when(e.action) {
|
||||||
|
// MotionEvent.ACTION_DOWN -> {holder.view.circlePreview.visibility = View.VISIBLE}
|
||||||
|
// MotionEvent.ACTION_UP -> {holder.view.circlePreview.visibility = View.GONE}
|
||||||
|
// MotionEvent.ACTION_UP -> {holder.view.circlePreview.visibility = View.GONE}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// false
|
||||||
|
// }
|
||||||
|
|
||||||
|
holder.view.date.setOnClickListener {
|
||||||
holder.view.circlePreview.visibility = View.VISIBLE
|
holder.view.circlePreview.visibility = View.VISIBLE
|
||||||
holder.view.circlePreview.postDelayed({
|
holder.view.circlePreview.postDelayed({
|
||||||
holder.view.circlePreview.visibility = View.GONE
|
holder.view.circlePreview.visibility = View.GONE
|
||||||
},500L)
|
},1000L)
|
||||||
|
}
|
||||||
|
holder.view.root.setOnLongClickListener {
|
||||||
|
if ( todo.category().equals(RssDataType.GURU)) {
|
||||||
|
openOpera(todo.originPage())
|
||||||
|
} else if( todo.category().equals(RssDataType.REDDIT)) {
|
||||||
|
openReddit(todo.originPage())
|
||||||
|
} else if( todo.category().equals(RssDataType.Dotax)) {
|
||||||
|
openDotax(todo.originPage())
|
||||||
|
}else if( todo.category().equals(RssDataType.FmKorae)) {
|
||||||
|
openNews(todo.originPage())
|
||||||
|
}
|
||||||
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.view.root.setOnLongClickListener {
|
|
||||||
when(todo.category()) {
|
|
||||||
RssDataType.YOUTUBE -> {
|
|
||||||
openYouTube(todo.originPage())
|
|
||||||
}
|
|
||||||
RssDataType.NewsFeed -> {
|
|
||||||
openNews(todo.originPage())
|
|
||||||
}
|
|
||||||
RssDataType.NO_DATA -> {}
|
|
||||||
else -> {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// val clipBoard =
|
|
||||||
// lActivity!!.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
|
||||||
// clipBoard.setPrimaryClip(ClipData.newPlainText("", todo.thumbnailUrl()))
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openOpera(schemeString : String) {
|
||||||
|
val gmmIntentUri = Uri.parse(schemeString)
|
||||||
|
val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri)
|
||||||
|
mapIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
|
||||||
|
mapIntent.setPackage("com.opera.browser")
|
||||||
|
lActivity?.startActivity(mapIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun updateData(newList: List<RssDataItem>) {
|
fun updateData(newList: List<RssDataItem>) {
|
||||||
DiffUtil.calculateDiff(RssItemDiffUtil(smsList, newList)).dispatchUpdatesTo(this)
|
try {
|
||||||
|
DiffUtil.calculateDiff(RssItemDiffUtil(rssDataItemLis, newList)).apply {
|
||||||
|
|
||||||
|
}.dispatchUpdatesTo(this).apply {
|
||||||
|
notifyItemRangeChanged(0,10)
|
||||||
|
}
|
||||||
|
rssDataItemLis.clear()
|
||||||
|
rssDataItemLis.addAll(newList)
|
||||||
|
}catch ( e : Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fun openNews(schemeString : String) {
|
fun openNews(schemeString : String) {
|
||||||
val gmmIntentUri = Uri.parse(schemeString)
|
val gmmIntentUri = Uri.parse(schemeString)
|
||||||
@ -156,18 +202,41 @@ internal class RssItemAdapter (
|
|||||||
mapIntent.setPackage("com.google.android.youtube")
|
mapIntent.setPackage("com.google.android.youtube")
|
||||||
lActivity?.startActivity(mapIntent)
|
lActivity?.startActivity(mapIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openReddit(schemeString : String) {
|
||||||
|
val gmmIntentUri = Uri.parse(schemeString)
|
||||||
|
val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri)
|
||||||
|
mapIntent.setPackage("com.reddit.frontpage")
|
||||||
|
lActivity?.startActivity(mapIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun openDotax(schemeString : String) {
|
||||||
|
val gmmIntentUri = Uri.parse(schemeString)
|
||||||
|
val mapIntent = Intent(Intent.ACTION_VIEW)
|
||||||
|
mapIntent.setPackage("net.daum.android.cafe")
|
||||||
|
mapIntent.setData(gmmIntentUri)
|
||||||
|
lActivity?.startActivity(mapIntent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fun dp2px(dp: Float): Float {
|
||||||
|
// val resources: Resources = this.getResources()
|
||||||
|
// val metrics = resources.displayMetrics
|
||||||
|
// val px = dp * (metrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT)
|
||||||
|
// return px
|
||||||
|
//}
|
||||||
|
|
||||||
internal class RssTag(var view: ListItemWithBinding) : RecyclerView.ViewHolder(view.root)
|
internal class RssTag(var view: ListItemWithBinding) : RecyclerView.ViewHolder(view.root)
|
||||||
internal class RssItemDiffUtil(
|
internal class RssItemDiffUtil(
|
||||||
private val oldList: List<RssDataItem>, private val newList: List<RssDataItem>
|
var oldList: List<RssDataItem>, var newList: List<RssDataItem>
|
||||||
) : DiffUtil.Callback() {
|
) : DiffUtil.Callback() {
|
||||||
|
|
||||||
override fun getOldListSize(): Int = oldList.size
|
override fun getOldListSize(): Int = oldList.size
|
||||||
override fun getNewListSize(): Int = newList.size
|
override fun getNewListSize(): Int = newList.size
|
||||||
|
|
||||||
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean =
|
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean =
|
||||||
oldList[oldItemPosition].originPage() == newList[newItemPosition].originPage()
|
oldList[oldItemPosition].originPage() == if (newList.size > newItemPosition) newList[newItemPosition].originPage() else ""
|
||||||
|
|
||||||
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean =
|
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean =
|
||||||
oldList[oldItemPosition].originPage() == newList[newItemPosition].originPage()
|
oldList[oldItemPosition].originPage() == if (newList.size > newItemPosition) newList[newItemPosition].originPage() else ""
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,13 +15,16 @@ import org.json.JSONObject
|
|||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||||
|
import rasel.lunar.launcher.LauncherActivity.Companion.rssSetTouchCount
|
||||||
import rasel.lunar.launcher.home.LauncherHome.Companion.missedCalls
|
import rasel.lunar.launcher.home.LauncherHome.Companion.missedCalls
|
||||||
import rasel.lunar.launcher.home.LauncherHome.Companion.rssSet
|
import rasel.lunar.launcher.home.LauncherHome.Companion.rssSet
|
||||||
import rasel.lunar.launcher.home.LauncherHome.Companion.smsList
|
import rasel.lunar.launcher.home.LauncherHome.Companion.smsList
|
||||||
import rasel.lunar.launcher.home.MissedCall
|
import rasel.lunar.launcher.home.MissedCall
|
||||||
|
import rasel.lunar.launcher.home.RssItem
|
||||||
import rasel.lunar.launcher.todos.Root
|
import rasel.lunar.launcher.todos.Root
|
||||||
|
|
||||||
import rasel.lunar.launcher.todos.RssDataItem
|
import rasel.lunar.launcher.todos.RssDataItem
|
||||||
|
import rasel.lunar.launcher.todos.RssDataType
|
||||||
import rasel.lunar.launcher.todos.RssFeedsParser
|
import rasel.lunar.launcher.todos.RssFeedsParser
|
||||||
import rasel.lunar.launcher.utils.RssList.feedJsons
|
import rasel.lunar.launcher.utils.RssList.feedJsons
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
@ -131,6 +134,13 @@ class MissedCallGetter : Worker {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun before30Min(date: Date): Long {
|
||||||
|
val cal: Calendar = Calendar.getInstance()
|
||||||
|
cal.setTime(date)
|
||||||
|
cal.add(Calendar.MINUTE, -30)
|
||||||
|
return cal.timeInMillis
|
||||||
|
}
|
||||||
|
|
||||||
fun beforeDay(date: Date?, day: Int): Long {
|
fun beforeDay(date: Date?, day: Int): Long {
|
||||||
val cal: Calendar = Calendar.getInstance()
|
val cal: Calendar = Calendar.getInstance()
|
||||||
cal.setTime(date)
|
cal.setTime(date)
|
||||||
@ -138,6 +148,13 @@ fun beforeDay(date: Date?, day: Int): Long {
|
|||||||
return cal.timeInMillis
|
return cal.timeInMillis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun make0H(date: Date?): Long {
|
||||||
|
val cal: Calendar = Calendar.getInstance()
|
||||||
|
cal.setTime(date)
|
||||||
|
cal.set(Calendar.HOUR, 1)
|
||||||
|
return cal.timeInMillis
|
||||||
|
}
|
||||||
|
|
||||||
fun afterDay(date: Date?, day: Int): Long {
|
fun afterDay(date: Date?, day: Int): Long {
|
||||||
val cal: Calendar = Calendar.getInstance()
|
val cal: Calendar = Calendar.getInstance()
|
||||||
cal.setTime(date)
|
cal.setTime(date)
|
||||||
@ -487,9 +504,65 @@ fun getContactId(contentResolver: ContentResolver, phoneNumber: String?): String
|
|||||||
return contactName
|
return contactName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class NewsFeedsGetter : Worker {
|
class NewsFeedsGetter : Worker {
|
||||||
var feddsUrls = arrayListOf<String>()
|
var feddsUrls = arrayListOf<String>()
|
||||||
|
|
||||||
|
var limitDateTime = beforeDay(Date(),3)
|
||||||
|
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("RestrictedApi")
|
||||||
|
override fun doWork(): Result {
|
||||||
|
rssSetTouchCount += 1
|
||||||
|
val temp = arrayListOf<RssDataItem>()
|
||||||
|
feddsUrls.clear()
|
||||||
|
feddsUrls.addAll(RssList.newsFeeds)
|
||||||
|
feddsUrls.addAll(RssList.getFeedUrls())
|
||||||
|
|
||||||
|
for(url in feddsUrls) {
|
||||||
|
for (it in RssFeedsParser.getFeeds(url)) {
|
||||||
|
if (it.pubDate() >= limitDateTime) {
|
||||||
|
temp.add(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return temp.forEach { synchronized(rssSet){
|
||||||
|
rssSet.put(it.originPage(), it)
|
||||||
|
} }.run {
|
||||||
|
rssSetTouchCount -= 1
|
||||||
|
Result.success() }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
class RedditGetter : Worker {
|
||||||
|
var limitDateTime = beforeDay(Date(),3)
|
||||||
|
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("RestrictedApi")
|
||||||
|
override fun doWork(): Result {
|
||||||
|
rssSetTouchCount += 1
|
||||||
|
val temp = arrayListOf<RssDataItem>()
|
||||||
|
for (url in feedJsons) {
|
||||||
|
for (it in RssFeedsParser.getReddit(url)) {
|
||||||
|
if (it.pubDate() >= limitDateTime) {
|
||||||
|
temp.add(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return temp.forEach { synchronized(rssSet){
|
||||||
|
rssSet.put(it.originPage(), it)
|
||||||
|
} }.run {
|
||||||
|
rssSetTouchCount -= 1
|
||||||
|
Result.success() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class YoutubeGetter : Worker {
|
||||||
var rssUrls = arrayListOf<String>()
|
var rssUrls = arrayListOf<String>()
|
||||||
var limitDateTime = beforeDay(Date(),3)
|
var limitDateTime = beforeDay(Date(),3)
|
||||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||||
@ -498,30 +571,19 @@ class NewsFeedsGetter : Worker {
|
|||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
feddsUrls.clear()
|
rssSetTouchCount += 1
|
||||||
feddsUrls.addAll(RssList.newsFeeds)
|
|
||||||
feddsUrls.addAll(RssList.getFeedUrls())
|
|
||||||
rssUrls.clear()
|
rssUrls.clear()
|
||||||
rssUrls.addAll(RssList.youtubeUrls)
|
rssUrls.addAll(RssList.youtubeUrls)
|
||||||
|
val temp = arrayListOf<RssDataItem>()
|
||||||
for (url in rssUrls) {
|
for (url in rssUrls) {
|
||||||
ytChannel(Jsoup.connect(url).get())
|
ytChannel(Jsoup.connect(url).get())
|
||||||
}
|
}
|
||||||
for(url in feddsUrls) {
|
|
||||||
for (it in RssFeedsParser.getFeeds(url)) {
|
return temp.forEach { synchronized(rssSet){
|
||||||
if (it.pubDate() >= limitDateTime) {
|
rssSet.put(it.originPage(), it)
|
||||||
rssSet.put(it.originPage(), it)
|
} }.run {
|
||||||
}
|
rssSetTouchCount -= 1
|
||||||
}
|
Result.success() }
|
||||||
}
|
|
||||||
for (url in feedJsons) {
|
|
||||||
for (it in RssFeedsParser.getReddit(url)) {
|
|
||||||
if (it.pubDate() >= limitDateTime) {
|
|
||||||
rssSet.put(it.originPage(), it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Result.success()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ytChannel(doc: Document) {
|
fun ytChannel(doc: Document) {
|
||||||
@ -571,4 +633,193 @@ class NewsFeedsGetter : Worker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class ComicsGetter : Worker {
|
||||||
|
var limitDateTime = beforeDay(Date(),3)
|
||||||
|
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("RestrictedApi")
|
||||||
|
override fun doWork(): Result {
|
||||||
|
rssSetTouchCount += 1
|
||||||
|
val temp = arrayListOf<RssDataItem>()
|
||||||
|
val now = Date()
|
||||||
|
try {
|
||||||
|
val fmkoreaUrls = arrayListOf("https://www.fmkorea.com",
|
||||||
|
// "https://www.fmkorea.com/index.php?mid=best&page=2",
|
||||||
|
// "https://www.fmkorea.com/index.php?mid=best&page=3"
|
||||||
|
)
|
||||||
|
fmkoreaUrls.forEach { Jsoup.connect(it).get().let { fmkorea ->
|
||||||
|
// BLog.LOGE("fmkorea >>> ${fmkorea.title()}")
|
||||||
|
fmkorea.getElementsByTag("li").forEach { fmkorea_li ->
|
||||||
|
if (fmkorea_li.getElementsByClass("title").text().length > 0 && fmkorea_li.getElementsByTag("a").size > 0 &&fmkorea_li.getElementsByTag("a").get(0).attr("href").length > 0) {
|
||||||
|
// BLog.LOGE("fmkorea_li >>> ${fmkorea_li}")
|
||||||
|
val title = fmkorea_li.getElementsByClass("title").text()
|
||||||
|
val tumb = "https://".plus(
|
||||||
|
fmkorea_li.getElementsByClass("thumb").attr("data-original")
|
||||||
|
)
|
||||||
|
val pageUrl = "https://www.fmkorea.com".plus(
|
||||||
|
fmkorea_li.getElementsByTag("a").get(0).attr("href")
|
||||||
|
)
|
||||||
|
val desc = fmkorea_li.getElementsByClass("category").text()
|
||||||
|
val date = fmkorea_li.getElementsByClass("regdate").text()
|
||||||
|
FmKorea(pageUrl, desc, date, title, tumb).apply {
|
||||||
|
if(desc?.contains("유머") == true|| desc?.contains("음악") == true|| desc?.contains("영화")== true ||
|
||||||
|
desc?.contains("TV")== true || desc?.contains("미스터리")== true || desc?.contains("역사")== true) {
|
||||||
|
if (this.pubDate() > before30Min(now)) {
|
||||||
|
temp.add(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} }
|
||||||
|
} catch (e : Exception) {e.printStackTrace()}
|
||||||
|
|
||||||
|
return temp.forEach { synchronized(rssSet){
|
||||||
|
rssSet.put(it.originPage(), it)
|
||||||
|
} }.run {
|
||||||
|
rssSetTouchCount -= 1
|
||||||
|
Result.success() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class ComicsGetter2 : Worker {
|
||||||
|
var limitDateTime = beforeDay(Date(),3)
|
||||||
|
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("RestrictedApi")
|
||||||
|
override fun doWork(): Result {
|
||||||
|
rssSetTouchCount += 1
|
||||||
|
val temp = arrayListOf<RssDataItem>()
|
||||||
|
val now = Date()
|
||||||
|
try {
|
||||||
|
val dotaxUrls = arrayListOf("https://m.cafe.daum.net/dotax",
|
||||||
|
// "https://m.cafe.daum.net/dotax/_rec?page=2",
|
||||||
|
// "https://m.cafe.daum.net/dotax/_rec?page=3"
|
||||||
|
)
|
||||||
|
dotaxUrls?.forEach {
|
||||||
|
Jsoup.connect(it)?.get()?.let { dotax ->
|
||||||
|
BLog.LOGE("dotax_li >>> ${dotax.title()}")
|
||||||
|
dotax.getElementsByTag("li").forEach { dotax_li ->
|
||||||
|
if (dotax_li.getElementsByTag("a").size > 0 && dotax_li.getElementsByClass("board_name")
|
||||||
|
.html().contains("웃긴")
|
||||||
|
) {
|
||||||
|
val pageLink = dotax_li.getElementsByTag("a").get(0).attr("href")
|
||||||
|
val desc = dotax_li.getElementsByClass("board_name").text()
|
||||||
|
val dateTime = dotax_li.getElementsByClass("sr_only").text()
|
||||||
|
val title = dotax_li.getElementsByClass("txt_detail").text()
|
||||||
|
val thumbnail = dotax_li.getElementsByClass("article_thumb").text()
|
||||||
|
if (pageLink.length > 0 && desc.length > 0 && dateTime.length > 0 && title.length > 0) {
|
||||||
|
Dotax(pageLink, desc, dateTime, title, thumbnail).apply {
|
||||||
|
BLog.LOGE("dotax_li >>> ${Gson().toJson(this)}")
|
||||||
|
if(this.pubDate() > before30Min(now)) {
|
||||||
|
temp.add(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e : Exception) {e.printStackTrace()}
|
||||||
|
return temp.forEach { synchronized(rssSet){
|
||||||
|
rssSet.put(it.originPage(), it)
|
||||||
|
} }.run {
|
||||||
|
rssSetTouchCount -= 1
|
||||||
|
Result.success() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Dotax(var pageLink : String,
|
||||||
|
var desc : String,
|
||||||
|
var dateTime : String,
|
||||||
|
var title : String,
|
||||||
|
var thumbnail : String) : RssDataItem {
|
||||||
|
var updateDateTime = 0L
|
||||||
|
override fun title(): String {
|
||||||
|
return title
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun thumbnailUrl(): String {
|
||||||
|
return thumbnail
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun originPage(): String {
|
||||||
|
return "https://m.cafe.daum.net".plus(pageLink)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun description(): String {
|
||||||
|
return desc
|
||||||
|
}
|
||||||
|
override fun pubDate(): Long {
|
||||||
|
var date = Date()
|
||||||
|
var dateTime = date.time
|
||||||
|
var before = 0
|
||||||
|
if (updateDateTime == 0L) {
|
||||||
|
try {
|
||||||
|
var targetDate = this.dateTime ?: ""
|
||||||
|
if (targetDate?.length ?: 0 > 1) {
|
||||||
|
var dateDesc = targetDate
|
||||||
|
var isBefore = dateDesc.contains("전")
|
||||||
|
val dayString = dateDesc.replace("[^0-9]".toRegex(), "")
|
||||||
|
before = dayString.toInt()
|
||||||
|
if (dateDesc.contains("년")) {
|
||||||
|
before = 365 * before
|
||||||
|
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
||||||
|
} else if (dateDesc.contains("월")) {
|
||||||
|
before = 30 * before
|
||||||
|
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
||||||
|
} else if (dateDesc.contains("주")) {
|
||||||
|
before = 7 * before
|
||||||
|
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
||||||
|
} else if (dateDesc.contains("일")) {
|
||||||
|
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
||||||
|
} else if (dateDesc.contains("시간")) {
|
||||||
|
dateTime =
|
||||||
|
if (isBefore) dateTime.minus(before.times(1000L * 60L * 60L)) else dateTime.plus(
|
||||||
|
before.times(1000L * 60L * 60L)
|
||||||
|
)
|
||||||
|
} else if (dateDesc.contains("분")) {
|
||||||
|
dateTime =
|
||||||
|
if (isBefore) dateTime.minus(before.times(1000L * 60L)) else dateTime.plus(
|
||||||
|
before.times(1000L * 60L)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else if (dateDesc.contains("초")) {
|
||||||
|
dateTime =
|
||||||
|
if (isBefore) dateTime.minus(before.times(1000L)) else dateTime.plus(
|
||||||
|
before.times(1000L)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e: Exception) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
updateDateTime = dateTime
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dateTime = updateDateTime
|
||||||
|
}
|
||||||
|
|
||||||
|
return dateTime
|
||||||
|
}
|
||||||
|
override fun category(): RssDataType {
|
||||||
|
return RssDataType.Dotax
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data class FmKorea(var apageLink : String,
|
||||||
|
var adesc : String,
|
||||||
|
var adateTime : String,
|
||||||
|
var atitle : String,
|
||||||
|
var athumbnail : String) : Dotax(apageLink, adesc, adateTime, atitle, athumbnail) {
|
||||||
|
override fun originPage(): String {
|
||||||
|
return pageLink
|
||||||
|
}
|
||||||
|
override fun category(): RssDataType {
|
||||||
|
return RssDataType.FmKorae
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,16 +1,15 @@
|
|||||||
package rasel.lunar.launcher.utils
|
package rasel.lunar.launcher.utils
|
||||||
|
|
||||||
import android.widget.Toast
|
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.TEST_PAG
|
|
||||||
import rasel.lunar.launcher.home.LauncherHome.Companion.listItem
|
|
||||||
import rasel.lunar.launcher.home.RssItem
|
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
object RssList {
|
object RssList {
|
||||||
|
|
||||||
|
val TEST_PAG2 = "https://torrentsee246.com/topic/index?category1=129&category2=132"
|
||||||
|
val jGuruMain = "https://jav.guru/"
|
||||||
|
val jGuruRanks ="https://jav.guru/most-watched-rank/"
|
||||||
|
|
||||||
|
|
||||||
val youtubeUrls = arrayListOf(
|
val youtubeUrls = arrayListOf(
|
||||||
"https://www.youtube.com/@zzanbro",
|
"https://www.youtube.com/@zzanbro",
|
||||||
"https://www.youtube.com/@sungsikyung",
|
"https://www.youtube.com/@sungsikyung",
|
||||||
@ -45,6 +44,7 @@ object RssList {
|
|||||||
"여행",
|
"여행",
|
||||||
"음반",
|
"음반",
|
||||||
"도끼",
|
"도끼",
|
||||||
|
"힙합",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
app/src/main/res/drawable/daum.png
Normal file
BIN
app/src/main/res/drawable/daum.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
app/src/main/res/drawable/fmk.png
Normal file
BIN
app/src/main/res/drawable/fmk.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/drawable/reddit.png
Normal file
BIN
app/src/main/res/drawable/reddit.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
app/src/main/res/drawable/youtube.png
Normal file
BIN
app/src/main/res/drawable/youtube.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@ -82,6 +82,10 @@
|
|||||||
android:src="@drawable/namuwiki"
|
android:src="@drawable/namuwiki"
|
||||||
android:id="@+id/search_namuwiki"
|
android:id="@+id/search_namuwiki"
|
||||||
style="@style/SearchIcons"/>
|
style="@style/SearchIcons"/>
|
||||||
|
<rasel.lunar.launcher.view.CircleImageView
|
||||||
|
android:src="@drawable/youtube"
|
||||||
|
android:id="@+id/search_youtube"
|
||||||
|
style="@style/SearchIcons"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/quickSearch2"
|
android:id="@+id/quickSearch2"
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:layout_width="120dp"
|
android:layout_width="120dp"
|
||||||
android:layout_height="120dp"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user