This commit is contained in:
lunaticbum 2024-09-03 17:37:58 +09:00
parent 92240b9819
commit 3708f094bd
9 changed files with 380 additions and 161 deletions

View File

@ -85,6 +85,8 @@ import rasel.lunar.launcher.home.LauncherHome.Companion.listTags
import rasel.lunar.launcher.home.LauncherHome.Companion.rssSet 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.model.ArcaGetter
import rasel.lunar.launcher.model.DCGetter
import rasel.lunar.launcher.utils.BLog import rasel.lunar.launcher.utils.BLog
import rasel.lunar.launcher.utils.ComicsGetter import rasel.lunar.launcher.utils.ComicsGetter
import rasel.lunar.launcher.utils.ComicsGetter2 import rasel.lunar.launcher.utils.ComicsGetter2
@ -121,9 +123,9 @@ internal class LauncherActivity : AppCompatActivity() {
val COMIC_WORK_TAG = "ComicGetter" val COMIC_WORK_TAG = "ComicGetter"
val COMIC2_WORK_TAG = "ComicGetter2" val COMIC2_WORK_TAG = "ComicGetter2"
val REDDIT_WORK_TAG = "RedditGetter" val REDDIT_WORK_TAG = "RedditGetter"
val shortTimePeriod = 60L val shortTimePeriod = 15L
val longTimePeriod = 60L val longTimePeriod = 60L
val midTimePeriod = 60L val midTimePeriod = 30L
var isOpendFold = false var isOpendFold = false
var rssSetTouchCount = 0 var rssSetTouchCount = 0
@ -184,14 +186,15 @@ internal class LauncherActivity : AppCompatActivity() {
}, 2, TimeUnit.SECONDS) }, 2, TimeUnit.SECONDS)
} }
fun refreshComics() { fun refreshComics() {
refreshComics3()
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(COMIC_WORK_TAG) mWorkManager?.cancelAllWorkByTag(COMIC_WORK_TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
COMIC_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, COMIC_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
PeriodicWorkRequestBuilder<ComicsGetter>(shortTimePeriod, TimeUnit.MINUTES) PeriodicWorkRequestBuilder<ComicsGetter>(midTimePeriod, TimeUnit.MINUTES)
.addTag(COMIC_WORK_TAG) .addTag(COMIC_WORK_TAG)
.build()) .build())
refreshComics2() refreshComics2()
}, 2, TimeUnit.SECONDS) }, 2, TimeUnit.SECONDS)
} }
fun refreshComics2() { fun refreshComics2() {
@ -199,11 +202,35 @@ internal class LauncherActivity : AppCompatActivity() {
mWorkManager?.cancelAllWorkByTag(COMIC2_WORK_TAG) mWorkManager?.cancelAllWorkByTag(COMIC2_WORK_TAG)
mWorkManager?.enqueueUniquePeriodicWork( mWorkManager?.enqueueUniquePeriodicWork(
COMIC2_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, COMIC2_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
PeriodicWorkRequestBuilder<ComicsGetter2>(shortTimePeriod, TimeUnit.MINUTES) PeriodicWorkRequestBuilder<ComicsGetter2>(midTimePeriod, TimeUnit.MINUTES)
.addTag(COMIC2_WORK_TAG) .addTag(COMIC2_WORK_TAG)
.build()) .build())
}, 2, TimeUnit.SECONDS) }, 2, TimeUnit.SECONDS)
} }
fun refreshComics3() {
Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(DCGetter.TAG)
mWorkManager?.enqueueUniquePeriodicWork(
DCGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
PeriodicWorkRequestBuilder<DCGetter>(midTimePeriod, TimeUnit.MINUTES)
.addTag(DCGetter.TAG)
.build())
refreshArca()
}, 2, TimeUnit.SECONDS)
}
fun refreshArca() {
Executors.newSingleThreadScheduledExecutor().schedule({
mWorkManager?.cancelAllWorkByTag(ArcaGetter.TAG)
mWorkManager?.enqueueUniquePeriodicWork(
ArcaGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
PeriodicWorkRequestBuilder<ArcaGetter>(midTimePeriod, TimeUnit.MINUTES)
.addTag(ArcaGetter.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!!)
@ -468,10 +495,10 @@ internal class LauncherActivity : AppCompatActivity() {
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 { // override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
view?.loadUrl(url!!) //// view?.loadUrl(url!!)
return false // 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}")
@ -482,7 +509,7 @@ internal class LauncherActivity : AppCompatActivity() {
request: WebResourceRequest?, request: WebResourceRequest?,
error: WebResourceError? error: WebResourceError?
) { ) {
super.onReceivedError(view, request, error) // super.onReceivedError(view, request, error)
} }
override fun onReceivedSslError( override fun onReceivedSslError(
view: WebView?, view: WebView?,
@ -531,12 +558,15 @@ internal class LauncherActivity : AppCompatActivity() {
// .timeout(30000).get()?.apply { // .timeout(30000).get()?.apply {
// BLog.LOGE("Jsoup.connect(missAv).get() ${this}") // BLog.LOGE("Jsoup.connect(missAv).get() ${this}")
// } // }
try {
this.removeJavascriptInterface("MyJavaScriptInterface")
}catch (e :Exception) {}
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" // 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 // 화면에 맞게 페이지 확대/축소
@ -549,8 +579,11 @@ internal class LauncherActivity : AppCompatActivity() {
allowContentAccess = true // 웹뷰를 통해 content url에 접근할지 여부 allowContentAccess = true // 웹뷰를 통해 content url에 접근할지 여부
layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING // 웹페이지의 레이아웃을 화면에 맞게 자동으로 조정 layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING // 웹페이지의 레이아웃을 화면에 맞게 자동으로 조정
} }
} catch (ignore: NoSuchMethodError) {} } catch (ignore: NoSuchMethodError) {
loadUrl(url) // 웹페이지 연결
}.apply {
loadUrl(url) // 웹페이지 연결
}
} }
} }
@ -614,21 +647,22 @@ internal class LauncherActivity : AppCompatActivity() {
// listItem.sortByDescending { it.date } // listItem.sortByDescending { it.date }
// binding.searcher01.postDelayed({binding.searcher01.loadUrl(prevUrl)}, 5000L) // binding.searcher01.postDelayed({binding.searcher01.loadUrl(prevUrl)}, 5000L)
//// } else { //// } else {
var itemC = 0 var itemC = 0
listItem.sortByDescending { it.date } listItem.sortByDescending { it.date }
listItem?.forEach { listItem?.forEach {
if(it.date > beforeDay(Date(),1)) { if(it.date > beforeDay(Date(),1)) {
if (itemC < 10) { if (itemC < 10) {
it.date = it.date + (10000L * itemC) it.date = it.date + (10000L * itemC)
rssSet.put(it.pageLink, it) rssSet.put(it.pageLink, it)
}
itemC = itemC + 1
} }
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, BLog.LOGE("Stored data :: ${listItem.size}items ${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))} set in ${itemC}")
"Stored data :: ${listItem.size} items :: [${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))}] \n set in ${itemC}", Toast.LENGTH_LONG).show() Toast.makeText(this@LauncherActivity,
"Stored data :: ${listItem.size} items :: [${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))}] \n set in ${itemC}", Toast.LENGTH_LONG).show()
// } // }
binding.searcher01?.post { binding.searcher01.loadData("<html></html>",null,null) }
this@LauncherActivity.callBack?.invoke() this@LauncherActivity.callBack?.invoke()
} }
} }
@ -659,7 +693,7 @@ internal class LauncherActivity : AppCompatActivity() {
@JavascriptInterface @JavascriptInterface
fun sendValueFromHtml(result: String) { fun sendValueFromHtml(result: String) {
BLog.LOGE("binding.otherCheck start with ${result}")
if (lastedFinishedPageUrl.contains(jGuruMain)) { 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)
@ -669,16 +703,19 @@ internal class LauncherActivity : AppCompatActivity() {
) { ) {
jGuruMain(doc) jGuruMain(doc)
} else if (lastedFinishedPageUrl?.contains("/most-watched-rank") == true) { } else if (lastedFinishedPageUrl?.contains("/most-watched-rank") == true) {
jGuruToday(doc) 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) { } else if (lastedFinishedPageUrl?.contains("missjav")==true) {
val doc: Document = Jsoup.parse(result) val doc: Document = Jsoup.parse(result)
BLog.LOGE("missav >>> ${doc}") BLog.LOGE("missav >>> ${doc}")
doc.getElementsByTag("li").forEach { miss_li ->
BLog.LOGE("miss_li >>>> ${miss_li}")
}
} }
BLog.LOGE("binding.otherCheck after ThreadRun") BLog.LOGE("binding.otherCheck after ThreadRun")
} }

View File

@ -40,6 +40,10 @@ import kotlinx.coroutines.*
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.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.R import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.FeedsBinding import rasel.lunar.launcher.databinding.FeedsBinding
import rasel.lunar.launcher.feeds.rss.RssAdapter import rasel.lunar.launcher.feeds.rss.RssAdapter
@ -145,8 +149,19 @@ internal class Feeds : Fragment() {
DialogInterface.OnClickListener { dialog, which -> DialogInterface.OnClickListener { dialog, which ->
dialog.dismiss() dialog.dismiss()
when(input.text.toString()) { when(input.text.toString()) {
"jJguru","vVioPup*383v" -> { "ytb" -> {
refreshYoutube()
}
"reddit"->{
refreshReddit()
}
"fedd"->{
refreshFeeds()
}
"comic"->{
refreshComics()
}
"jshow" -> {
binding.feedsRss.apply { binding.feedsRss.apply {
rss.adapter = mRssAdapter rss.adapter = mRssAdapter
loading.visibility = View.VISIBLE loading.visibility = View.VISIBLE
@ -169,12 +184,20 @@ internal class Feeds : Fragment() {
},500L) },500L)
} }
} }
} }
} }
} }
} }
"jJTag"-> { "jjp" -> {
lActivity?.doWebParseStart("https://projectjav.com") {}
}
"jmiss" -> {
lActivity?.doWebParseStart("https://missjav.com") {}
}
"jreq" -> {
lActivity?.doWebParseStart(jGuruMain) {}
}
"jtag"-> {
// lActivity?.doWebPare(TEST_PAG.plus("tags")) { // lActivity?.doWebPare(TEST_PAG.plus("tags")) {
binding.feedsRss.apply { binding.feedsRss.apply {

View File

@ -70,6 +70,8 @@ import rasel.lunar.launcher.helpers.UniUtils.Companion.canAuthenticate
import rasel.lunar.launcher.helpers.UniUtils.Companion.expandNotificationPanel import rasel.lunar.launcher.helpers.UniUtils.Companion.expandNotificationPanel
import rasel.lunar.launcher.helpers.UniUtils.Companion.lockMethod import rasel.lunar.launcher.helpers.UniUtils.Companion.lockMethod
import rasel.lunar.launcher.home.weather.WeatherExecutor import rasel.lunar.launcher.home.weather.WeatherExecutor
import rasel.lunar.launcher.model.ArcaGetter
import rasel.lunar.launcher.model.DCGetter
import rasel.lunar.launcher.qaccess.QuickAccess import rasel.lunar.launcher.qaccess.QuickAccess
import rasel.lunar.launcher.settings.SettingsActivity import rasel.lunar.launcher.settings.SettingsActivity
import rasel.lunar.launcher.todos.MissedCallsAdapter import rasel.lunar.launcher.todos.MissedCallsAdapter
@ -183,9 +185,22 @@ internal class LauncherHome : Fragment() {
commandHandler.postDelayed(infoUpdate,UPDATE_DELAY) commandHandler.postDelayed(infoUpdate,UPDATE_DELAY)
it.clear() it.clear()
} }
workmanager()?.getWorkInfosByTagLiveData(FEDDS_WORK_TAG)?.observeForever {
commandHandler.removeCallbacks(infoUpdate)
commandHandler.postDelayed(infoUpdate,UPDATE_DELAY)
it.clear()
}
workmanager()?.getWorkInfosByTagLiveData(ArcaGetter.TAG)?.observeForever {
commandHandler.removeCallbacks(infoUpdate)
commandHandler.postDelayed(infoUpdate,UPDATE_DELAY)
it.clear()
}
workmanager()?.getWorkInfosByTagLiveData(DCGetter.TAG)?.observeForever {
commandHandler.removeCallbacks(infoUpdate)
commandHandler.postDelayed(infoUpdate,UPDATE_DELAY)
it.clear()
}
nReceiver = NotificationReceiver() nReceiver = NotificationReceiver()
val filter = IntentFilter() val filter = IntentFilter()
// filter.addAction("com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE") // filter.addAction("com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE")

View File

@ -4,23 +4,187 @@ import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import com.google.gson.Gson
import org.json.JSONObject
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Document import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import rasel.lunar.launcher.home.LauncherHome.Companion.rssSet import rasel.lunar.launcher.home.LauncherHome.Companion.rssSet
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.RssDataType
import rasel.lunar.launcher.todos.RssFeedsParser
import rasel.lunar.launcher.utils.BLog import rasel.lunar.launcher.utils.BLog
import rasel.lunar.launcher.utils.RssList import rasel.lunar.launcher.utils.USAGT
import rasel.lunar.launcher.utils.RssList.feedJsons import rasel.lunar.launcher.utils.afterDay
import rasel.lunar.launcher.utils.beforeDay import rasel.lunar.launcher.utils.beforeDay
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date import java.util.Date
import java.util.TimeZone
class ArcaGetter : Worker {
companion object {
val TAG = "DCGetter"
}
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
}
override fun doWork(): Result {
var tempArray = arrayListOf<RssDataItem>()
try {
val urls = arrayListOf(
"https://arca.live/b/singbung?mode=best",
"https://arca.live/b/headline",
"https://arca.live/b/live",
"https://arca.live/b/namuhotnow",
"https://arca.live/b/society",
"https://arca.live/b/replay",
"https://arca.live/b/breaking"
)
urls.forEach {
Jsoup.connect(it)
.userAgent(USAGT)
.get().let { arca ->
// BLog.LOGE("url >> ${it} >> ${arca}")
arca.getElementsByClass("vrow hybrid").forEach { araca_li ->
if (araca_li.html().contains("title ") == true) {
parseArcaLi(araca_li).apply {
tempArray.addAll(this)
}
}
}
}
}
// Jsoup.connect("https://projrctjav.com").userAgent(USAGT).get().let { projectj ->
// BLog.LOGE("projectj >>>>> ${projectj}")
// }
} catch (e:Exception){e.printStackTrace()}
return tempArray.forEach {
rssSet.put(it.originPage(),it)
}.run {
Result.success()
}
}
private fun parseArcaLi(aracaLi: Element) : ArrayList<RssDataItem> {
var tempArray = arrayListOf<RssDataItem>()
// BLog.LOGE("aracaLi >>> ${aracaLi}")
var title = aracaLi.getElementsByClass("title hybrid-title").getT()
var desc = aracaLi.getElementsByClass("badge").getT()
desc.plus(aracaLi.getElementsByClass("user-info ").getT())
var dateTime = aracaLi.getElementsByTag("time").attr("datetime")
var tumbnail = aracaLi.getElementsByTag("img").attr("src")
var link = "https://arca.live".plus(if(aracaLi.getElementsByClass("title hybrid-title").size > 0) aracaLi.getElementsByClass("title hybrid-title").get(0).attr("href") else if(aracaLi.getElementsByTag("a").size > 0) aracaLi.getElementsByTag("a").get(0).attr("href") else "")
if (title.length > 0 && link.length > 20) {
Arca().apply {
this.link = link
this.title = title
if (tumbnail.length > 0) {
this.thumbnail = "https:".plus(tumbnail)
//
// BLog.LOGE("Arca thumbnail >>> ${thumbnail}")
}
this.desc = desc
this.dateTiem = dateTime
}.apply {
// BLog.LOGE("parseArcaLi >>>> ${this}")
if(this.pubDate() > beforeDay(Date(),3)) {
tempArray.add(this)
}
}
}
return tempArray
}
fun Elements.getT() = if (size > 0) get(0).text() else ""
}
class Arca : RssDataItem {
var link : String? = null
var title : String? = null
var thumbnail : String? = null
var desc : String? = null
var dateTiem : String? = null
var updateDateTime : Long = 0L
override fun title(): String {
return title ?: ""
}
override fun thumbnailUrl(): String {
return thumbnail ?: ""
}
override fun originPage(): String {
return link ?: ""
}
override fun description(): String {
return desc ?: ""
}
val dateFormat = SimpleDateFormat("hh:mm / yy - MM - dd")
override fun pubDate(): Long {
var date = Date()
var dateTime = date.time
var before = 0
if (updateDateTime == 0L) {
try {
BLog.LOGE("this.dateTiem >>> ${this.dateTiem}")
val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
sdf.timeZone = TimeZone.getTimeZone("GMT")
updateDateTime = sdf.parse(this.dateTiem!!).time
BLog.LOGE("updateDateTime >>>> ${dateFormat.format(Date(updateDateTime))}" )
// var targetDate = this.dateTiem ?: ""
// 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.Arca
}
}
class DCGetter : Worker { class DCGetter : Worker {
companion object { companion object {
val TAG = "DCGetter" val TAG = "DCGetter"
@ -55,11 +219,11 @@ class DCGetter : Worker {
.get(0).text() else "" .get(0).text() else ""
link = link.replace("&amp;","&") link = link.replace("&amp;","&")
thumbnail = thumbnail.replace("&amp;","&") thumbnail = thumbnail.replace("&amp;","&")
BLog.LOGE("DC_LI >>>> link >>>> ${link}") // BLog.LOGE("DC_LI >>>> link >>>> ${link}")
BLog.LOGE("DC_LI >>>> title >>>> ${title}") // BLog.LOGE("DC_LI >>>> title >>>> ${title}")
BLog.LOGE("DC_LI >>>> thumbnail >>>> ${thumbnail}") // BLog.LOGE("DC_LI >>>> thumbnail >>>> ${thumbnail}")
BLog.LOGE("DC_LI >>>> desc >>>> ${desc}") // BLog.LOGE("DC_LI >>>> desc >>>> ${desc}")
BLog.LOGE("DC_LI >>>> dateTiem >>>> ${dateTiem}") // BLog.LOGE("DC_LI >>>> dateTiem >>>> ${dateTiem}")
if (title.length > 0 && link.length > 0) { if (title.length > 0 && link.length > 0) {
DcInside().apply { DcInside().apply {
this.link = link this.link = link
@ -82,7 +246,9 @@ class DCGetter : Worker {
try { try {
val testUrl2 = "https://www.dcinside.com/" val testUrl2 = "https://www.dcinside.com/"
Jsoup.connect(testUrl2).userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15").get().let { dc -> Jsoup.connect(testUrl2)
.userAgent(USAGT)
.get().let { dc ->
// BLog.LOGE("test ${testUrl2} >> ${this}") // BLog.LOGE("test ${testUrl2} >> ${this}")
dc.getElementsByTag("li").forEach { dc_li -> dc.getElementsByTag("li").forEach { dc_li ->
if (dc_li.html().contains("main_log") == true) { if (dc_li.html().contains("main_log") == true) {
@ -92,6 +258,8 @@ class DCGetter : Worker {
} }
} }
} }
} catch (e:Exception){e.printStackTrace()} } catch (e:Exception){e.printStackTrace()}
return tempArray.forEach { return tempArray.forEach {
rssSet.put(it.originPage(),it) rssSet.put(it.originPage(),it)
@ -103,51 +271,7 @@ class DCGetter : Worker {
fun parseDcLi(dc_li : org.jsoup.nodes.Element) : ArrayList<RssDataItem>{
var temp = arrayListOf<RssDataItem>()
if (dc_li.html().contains("<ul class=>") && dc_li.html().contains("con_list img")) {
dc_li.child(0).getElementsByTag("li").forEach {
parseDcLi(it)
}
} else {
var link = if (dc_li.getElementsByTag("a").size > 0) dc_li.getElementsByTag("a").get(0)
.attr("href") else ""
var title =
if (dc_li.getElementsByClass("box besttxt").size > 0) dc_li.getElementsByClass("box besttxt")
.get(0)
.text() else if (dc_li.getElementsByClass("tit").size > 0) dc_li.getElementsByClass(
"tit"
).get(0).text() else ""
var thumbnail =
if (dc_li.getElementsByTag("img").size > 0) dc_li.getElementsByTag("img").get(0)
.attr("src") else ""
var desc =
if (dc_li.getElementsByClass("box best_info").size > 0) dc_li.getElementsByClass("box best_info")
.get(0).text() else ""
var dateTiem =
if (dc_li.getElementsByClass("time").size > 0) dc_li.getElementsByClass("time")
.get(0).text() else ""
link = link.replace("&amp;","&")
thumbnail = thumbnail.replace("&amp;","&")
BLog.LOGE("DC_LI >>>> link >>>> ${link}")
BLog.LOGE("DC_LI >>>> title >>>> ${title}")
BLog.LOGE("DC_LI >>>> thumbnail >>>> ${thumbnail}")
BLog.LOGE("DC_LI >>>> desc >>>> ${desc}")
BLog.LOGE("DC_LI >>>> dateTiem >>>> ${dateTiem}")
if (title.length > 0 && link.length > 0) {
DcInside().apply {
this.link = link
this.title = title
this.thumbnail = thumbnail
this.desc = desc
this.dateTiem = dateTiem
}.apply {
temp.add(this)
}
}
}
return temp
}
class DcInside : RssDataItem { class DcInside : RssDataItem {
var link : String? = null var link : String? = null
@ -156,8 +280,11 @@ class DcInside : RssDataItem {
var desc : String? = null var desc : String? = null
var dateTiem : String? = null var dateTiem : String? = null
val dateF = SimpleDateFormat("MM:dd") var dateTiemL : Long = 0L
val timeF = SimpleDateFormat("hh:mm")
val dateF = SimpleDateFormat("MM-dd")
val timeF = SimpleDateFormat("HH:mm")
override fun title(): String { override fun title(): String {
return title ?:"" return title ?:""
} }
@ -175,56 +302,34 @@ class DcInside : RssDataItem {
} }
override fun pubDate(): Long { override fun pubDate(): Long {
return if(dateTiem?.contains(":") == true) timeF.parse(dateTiem).time else dateF.parse(dateTiem).time if (dateTiemL < 1L) {
if (dateTiem?.length ?: 0 < 1) return 0L
return if (dateTiem?.contains(":") == true) {
val cal: Calendar = Calendar.getInstance()
cal.setTime(Date())
cal.set(Calendar.HOUR_OF_DAY, dateTiem!!.split(":")[0].toInt()- 1)
cal.set(Calendar.MINUTE, dateTiem!!.split(":")[1].toInt())
// cal.set(Calendar.MINUTE, dateTiem!!.split(":")[1].toI nt())
dateTiemL = cal.timeInMillis
dateTiemL
} else if (dateTiem?.contains("-") == true) {
val cal: Calendar = Calendar.getInstance()
cal.setTime(Date())
cal.set(Calendar.MONTH, dateTiem!!.split("-")[0].toInt() - 1)
cal.set(Calendar.DAY_OF_MONTH, dateTiem!!.split("-")[1].toInt())
cal.add(Calendar.DAY_OF_MONTH, -1)
dateTiemL = cal.timeInMillis
dateTiemL
} else {
0L
}
} else {
return dateTiemL
}
} }
override fun category(): RssDataType { override fun category(): RssDataType {
return RssDataType.NewsFeed return RssDataType.DcInside
} }
fun parseDcLi(dc_li : org.jsoup.nodes.Element) : ArrayList<RssDataItem>{
var temp = arrayListOf<RssDataItem>()
if (dc_li.html().contains("<ul class=>") && dc_li.html().contains("con_list img")) {
dc_li.child(0).getElementsByTag("li").forEach {
parseDcLi(it)
}
} else {
var link = if (dc_li.getElementsByTag("a").size > 0) dc_li.getElementsByTag("a").get(0)
.attr("href") else ""
var title =
if (dc_li.getElementsByClass("box besttxt").size > 0) dc_li.getElementsByClass("box besttxt")
.get(0)
.text() else if (dc_li.getElementsByClass("tit").size > 0) dc_li.getElementsByClass(
"tit"
).get(0).text() else ""
var thumbnail =
if (dc_li.getElementsByTag("img").size > 0) dc_li.getElementsByTag("img").get(0)
.attr("src") else ""
var desc =
if (dc_li.getElementsByClass("box best_info").size > 0) dc_li.getElementsByClass("box best_info")
.get(0).text() else ""
var dateTiem =
if (dc_li.getElementsByClass("time").size > 0) dc_li.getElementsByClass("time")
.get(0).text() else ""
link = link.replace("&amp;","&")
thumbnail = thumbnail.replace("&amp;","&")
BLog.LOGE("DC_LI >>>> link >>>> ${link}")
BLog.LOGE("DC_LI >>>> title >>>> ${title}")
BLog.LOGE("DC_LI >>>> thumbnail >>>> ${thumbnail}")
BLog.LOGE("DC_LI >>>> desc >>>> ${desc}")
BLog.LOGE("DC_LI >>>> dateTiem >>>> ${dateTiem}")
if (title.length > 0 && link.length > 0) {
DcInside().apply {
this.link = link
this.title = title
this.thumbnail = thumbnail
this.desc = desc
this.dateTiem = dateTiem
}.apply {
temp.add(this)
}
}
}
return temp
}
} }

View File

@ -9,6 +9,8 @@ enum class RssDataType {
REDDIT, REDDIT,
Dotax, Dotax,
FmKorae, FmKorae,
DcInside,
Arca,
} }
interface RssDataItem { interface RssDataItem {

View File

@ -120,19 +120,35 @@ internal class RssItemAdapter (
holder.view.circlePreview.setImageResource(R.drawable.reddit) holder.view.circlePreview.setImageResource(R.drawable.reddit)
holder.view.circlePreview.visibility = View.VISIBLE holder.view.circlePreview.visibility = View.VISIBLE
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120) holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120)
} else if( todo.category().equals(RssDataType.FmKorae)) { } else if( todo.category().equals(RssDataType.FmKorae) ) {
holder.view.circlePreview.setImageResource(R.drawable.fmk) holder.view.circlePreview.setImageResource(R.drawable.fmk)
holder.view.circlePreview.visibility = View.VISIBLE holder.view.circlePreview.visibility = View.VISIBLE
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120) holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120)
} else if(todo.category().equals(RssDataType.DcInside)) {
holder.view.circlePreview.setImageResource(R.drawable.dcinside)
holder.view.circlePreview.visibility = View.VISIBLE
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120)
} else if(todo.category().equals(RssDataType.Arca)) {
holder.view.circlePreview.setImageResource(R.drawable.arca)
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.desc.text = todo.description().plus(" ").plus(todo.category().name) 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.setOnClickListener {
if (holder.view.desc.visibility == View.GONE) {
holder.view.circlePreview.visibility = View.VISIBLE
holder.view.circlePreview.postDelayed({
holder.view.circlePreview.visibility = View.GONE
}, 1000L)
}
}
// holder.view.date.setOnTouchListener { v,e -> // holder.view.date.setOnTouchListener { v,e ->
// if (holder.view.date.equals(v)) { // if (holder.view.date.equals(v)) {
// when(e.action) { // when(e.action) {
@ -144,12 +160,7 @@ internal class RssItemAdapter (
// false // false
// } // }
holder.view.date.setOnClickListener {
holder.view.circlePreview.visibility = View.VISIBLE
holder.view.circlePreview.postDelayed({
holder.view.circlePreview.visibility = View.GONE
},1000L)
}
holder.view.root.setOnLongClickListener { holder.view.root.setOnLongClickListener {
if ( todo.category().equals(RssDataType.GURU)) { if ( todo.category().equals(RssDataType.GURU)) {
openOpera(todo.originPage()) openOpera(todo.originPage())
@ -157,7 +168,7 @@ internal class RssItemAdapter (
openReddit(todo.originPage()) openReddit(todo.originPage())
} else if( todo.category().equals(RssDataType.Dotax)) { } else if( todo.category().equals(RssDataType.Dotax)) {
openDotax(todo.originPage()) openDotax(todo.originPage())
}else if( todo.category().equals(RssDataType.FmKorae)) { }else if(todo.category().equals(RssDataType.FmKorae)|| todo.category().equals(RssDataType.DcInside)|| todo.category().equals(RssDataType.Arca)) {
openNews(todo.originPage()) openNews(todo.originPage())
} }
true true

View File

@ -134,6 +134,8 @@ class MissedCallGetter : Worker {
} }
val USAGT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15"
fun before30Min(date: Date): Long { fun before30Min(date: Date): Long {
val cal: Calendar = Calendar.getInstance() val cal: Calendar = Calendar.getInstance()
cal.setTime(date) cal.setTime(date)
@ -142,7 +144,7 @@ fun before30Min(date: Date): Long {
} }
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)
cal.add(Calendar.DAY_OF_YEAR, Math.abs(day) * -1) cal.add(Calendar.DAY_OF_YEAR, Math.abs(day) * -1)
return cal.timeInMillis return cal.timeInMillis
@ -576,7 +578,7 @@ class YoutubeGetter : Worker {
rssUrls.addAll(RssList.youtubeUrls) rssUrls.addAll(RssList.youtubeUrls)
val temp = arrayListOf<RssDataItem>() val temp = arrayListOf<RssDataItem>()
for (url in rssUrls) { for (url in rssUrls) {
ytChannel(Jsoup.connect(url).get()) ytChannel(Jsoup.connect(url).userAgent(USAGT).get())
} }
return temp.forEach { synchronized(rssSet){ return temp.forEach { synchronized(rssSet){
@ -592,6 +594,8 @@ class YoutubeGetter : Worker {
if(it.html().contains("var ytInitialData", false)) {/**/ if(it.html().contains("var ytInitialData", false)) {/**/
var ytInitialData = it.html().split("var ytInitialData = ")[1].split("</script>")[0].toString() var ytInitialData = it.html().split("var ytInitialData = ")[1].split("</script>")[0].toString()
var tempJSONObject : JSONObject? = null var tempJSONObject : JSONObject? = null
JSONObject(ytInitialData).apply{ JSONObject(ytInitialData).apply{
tempJSONObject = this tempJSONObject = this
val root = Gson().fromJson(tempJSONObject.toString(), Root::class.java) val root = Gson().fromJson(tempJSONObject.toString(), Root::class.java)
@ -646,10 +650,10 @@ class ComicsGetter : Worker {
val now = Date() val now = Date()
try { try {
val fmkoreaUrls = arrayListOf("https://www.fmkorea.com", 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=2",
// "https://www.fmkorea.com/index.php?mid=best&page=3" "https://www.fmkorea.com/index.php?mid=best&page=3"
) )
fmkoreaUrls.forEach { Jsoup.connect(it).get().let { fmkorea -> fmkoreaUrls.forEach { Jsoup.connect(it).userAgent(USAGT).get().let { fmkorea ->
// BLog.LOGE("fmkorea >>> ${fmkorea.title()}") // BLog.LOGE("fmkorea >>> ${fmkorea.title()}")
fmkorea.getElementsByTag("li").forEach { fmkorea_li -> 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) { if (fmkorea_li.getElementsByClass("title").text().length > 0 && fmkorea_li.getElementsByTag("a").size > 0 &&fmkorea_li.getElementsByTag("a").get(0).attr("href").length > 0) {
@ -697,24 +701,25 @@ class ComicsGetter2 : Worker {
val now = Date() val now = Date()
try { try {
val dotaxUrls = arrayListOf("https://m.cafe.daum.net/dotax", 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=2",
// "https://m.cafe.daum.net/dotax/_rec?page=3" "https://m.cafe.daum.net/dotax/_rec?page=3"
) )
dotaxUrls?.forEach { dotaxUrls?.forEach {
Jsoup.connect(it)?.get()?.let { dotax -> Jsoup.connect(it).userAgent(USAGT).get()?.let { dotax ->
BLog.LOGE("dotax_li >>> ${dotax.title()}") // BLog.LOGE("dotax_li >>> ${dotax.title()}")
dotax.getElementsByTag("li").forEach { dotax_li -> dotax.getElementsByTag("li").forEach { dotax_li ->
if (dotax_li.getElementsByTag("a").size > 0 && dotax_li.getElementsByClass("board_name") if (dotax_li.getElementsByTag("a").size > 0 && dotax_li.getElementsByClass("board_name")
.html().contains("웃긴") .html().contains("웃긴")
) { ) {
val pageLink = dotax_li.getElementsByTag("a").get(0).attr("href") val pageLink = dotax_li.getElementsByTag("a").get(0).attr("href")
val desc = dotax_li.getElementsByClass("board_name").text() val desc = dotax_li.getElementsByClass("board_name").text()
val dateTime = dotax_li.getElementsByClass("sr_only").text() val dateTime = dotax_li.getElementsByClass("created_at").text()
val title = dotax_li.getElementsByClass("txt_detail").text() val title = dotax_li.getElementsByClass("txt_detail").text()
val thumbnail = dotax_li.getElementsByClass("article_thumb").text() val thumbnail = dotax_li.getElementsByClass("article_thumb").text()
if (pageLink.length > 0 && desc.length > 0 && dateTime.length > 0 && title.length > 0) { if (pageLink.length > 0 && desc.length > 0 && dateTime.length > 0 && title.length > 0) {
BLog.LOGE("dotax_li >>> ${dotax_li}")
Dotax(pageLink, desc, dateTime, title, thumbnail).apply { Dotax(pageLink, desc, dateTime, title, thumbnail).apply {
BLog.LOGE("dotax_li >>> ${Gson().toJson(this)}") // BLog.LOGE("dotax_li >>> ${Gson().toJson(this)}")
if(this.pubDate() > before30Min(now)) { if(this.pubDate() > before30Min(now)) {
temp.add(this) temp.add(this)
} }

View File

@ -0,0 +1,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="1000dp"
android:height="1000dp"
android:viewportWidth="1000"
android:viewportHeight="1000">
<path
android:fillColor="#FF000000"
android:pathData="M545.6,159.7h65.9v633.2h-65.9zM231.5,539.7h172.2v253.3h65.9V473.8H231.5zM298.1,409.8c35.1,0 63.5,-28.4 63.5,-63.5 0,-35.1 -28.4,-63.5 -63.5,-63.5 -35.1,0 -63.5,28.4 -63.5,63.5 0,35.1 28.4,63.5 63.5,63.5z"/>
<path
android:fillColor="#FF000000"
android:pathData="M297.7,600.3c-35.1,0 -63.5,28.5 -63.5,63.5 0,35.1 28.4,63.5 63.5,63.5 35.1,0 63.5,-28.4 63.5,-63.5 0,-35 -28.4,-63.5 -63.5,-63.5z"/>
<path
android:fillColor="#FF000000"
android:pathData="M500,0C223.9,0 0,223.9 0,500c0,276.1 223.9,500 500,500 276.1,0 500,-223.9 500,-500C1000,223.9 776.1,0 500,0zM500,976.2c-263,0 -476.2,-213.2 -476.2,-476.2C23.8,237 237,23.8 500,23.8c263,0 476.2,213.2 476.2,476.2 0,263 -213.2,476.2 -476.2,476.2z"/>
<path
android:fillColor="#FF000000"
android:pathData="M711,282.8c-35.1,0 -63.5,28.4 -63.5,63.5 0,35.1 28.4,63.5 63.5,63.5 35.1,0 63.5,-28.4 63.5,-63.5 0,-35.1 -28.4,-63.5 -63.5,-63.5zM711,600.3c-35.1,0 -63.5,28.5 -63.5,63.5 0,35.1 28.4,63.5 63.5,63.5 35,0 63.5,-28.4 63.5,-63.5 0,-35 -28.4,-63.5 -63.5,-63.5z"/>
<path
android:pathData="M500,23.8c-263,0 -476.2,213.2 -476.2,476.2C23.8,763 237,976.2 500,976.2c263,0 476.2,-213.2 476.2,-476.2C976.2,237 763,23.8 500,23.8zM298.1,282.8c35.1,0 63.5,28.4 63.5,63.5 0,35.1 -28.4,63.5 -63.5,63.5 -35.1,0 -63.5,-28.4 -63.5,-63.5 0,-35.1 28.4,-63.5 63.5,-63.5zM297.7,727.3c-35.1,0 -63.5,-28.4 -63.5,-63.5 0,-35 28.4,-63.5 63.5,-63.5 35.1,0 63.5,28.5 63.5,63.5 0,35.1 -28.4,63.5 -63.5,63.5zM469.6,793h-65.9L403.7,539.7L231.5,539.7v-65.9h238.1v319.2zM611.4,793h-65.9L545.6,159.7h65.9v633.2zM711,727.3c-35.1,0 -63.5,-28.4 -63.5,-63.5 0,-35 28.4,-63.5 63.5,-63.5 35.1,0 63.5,28.5 63.5,63.5 0,35.1 -28.4,63.5 -63.5,63.5zM711,409.8c-35.1,0 -63.5,-28.4 -63.5,-63.5 0,-35.1 28.4,-63.5 63.5,-63.5 35.1,0 63.5,28.4 63.5,63.5 0,35.1 -28.4,63.5 -63.5,63.5z"
android:fillColor="#FFFDFD"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB