diff --git a/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt b/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt index c4515a4..648cf53 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt @@ -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.RssItem 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.ComicsGetter import rasel.lunar.launcher.utils.ComicsGetter2 @@ -121,9 +123,9 @@ internal class LauncherActivity : AppCompatActivity() { val COMIC_WORK_TAG = "ComicGetter" val COMIC2_WORK_TAG = "ComicGetter2" val REDDIT_WORK_TAG = "RedditGetter" - val shortTimePeriod = 60L + val shortTimePeriod = 15L val longTimePeriod = 60L - val midTimePeriod = 60L + val midTimePeriod = 30L var isOpendFold = false var rssSetTouchCount = 0 @@ -184,14 +186,15 @@ internal class LauncherActivity : AppCompatActivity() { }, 2, TimeUnit.SECONDS) } fun refreshComics() { + refreshComics3() Executors.newSingleThreadScheduledExecutor().schedule({ mWorkManager?.cancelAllWorkByTag(COMIC_WORK_TAG) mWorkManager?.enqueueUniquePeriodicWork( COMIC_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(shortTimePeriod, TimeUnit.MINUTES) + PeriodicWorkRequestBuilder(midTimePeriod, TimeUnit.MINUTES) .addTag(COMIC_WORK_TAG) .build()) - refreshComics2() + refreshComics2() }, 2, TimeUnit.SECONDS) } fun refreshComics2() { @@ -199,11 +202,35 @@ internal class LauncherActivity : AppCompatActivity() { mWorkManager?.cancelAllWorkByTag(COMIC2_WORK_TAG) mWorkManager?.enqueueUniquePeriodicWork( COMIC2_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(shortTimePeriod, TimeUnit.MINUTES) + PeriodicWorkRequestBuilder(midTimePeriod, TimeUnit.MINUTES) .addTag(COMIC2_WORK_TAG) .build()) }, 2, TimeUnit.SECONDS) } + fun refreshComics3() { + Executors.newSingleThreadScheduledExecutor().schedule({ + mWorkManager?.cancelAllWorkByTag(DCGetter.TAG) + mWorkManager?.enqueueUniquePeriodicWork( + DCGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(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(midTimePeriod, TimeUnit.MINUTES) + .addTag(ArcaGetter.TAG) + .build()) + + }, 2, TimeUnit.SECONDS) + } + fun workmanager() : WorkManager? { if (mWorkManager == null && lActivity != null) { mWorkManager = WorkManager.getInstance(lActivity!!) @@ -468,10 +495,10 @@ internal class LauncherActivity : AppCompatActivity() { BLog.LOGE("binding.otherCheck before ThreadRun") binding.searcher01.webViewClient = object : WebViewClient() { - override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean { - view?.loadUrl(url!!) - return false - } +// override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean { +//// view?.loadUrl(url!!) +// return false +// } override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { BLog.LOGE("binding.otherCheck searcher01 in onPageStarted ${url}") @@ -482,7 +509,7 @@ internal class LauncherActivity : AppCompatActivity() { request: WebResourceRequest?, error: WebResourceError? ) { - super.onReceivedError(view, request, error) +// super.onReceivedError(view, request, error) } override fun onReceivedSslError( view: WebView?, @@ -531,12 +558,15 @@ internal class LauncherActivity : AppCompatActivity() { // .timeout(30000).get()?.apply { // BLog.LOGE("Jsoup.connect(missAv).get() ${this}") // } + try { + this.removeJavascriptInterface("MyJavaScriptInterface") + }catch (e :Exception) {} this.addJavascriptInterface(MyJavaScriptInterface(this),"MyJavaScriptInterface") setBackgroundColor(Color.WHITE) // 백그라운드 색상 설정 setLayerType(View.LAYER_TYPE_SOFTWARE, null) // 랜더링 이슈 해결 try { 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 // 자바스크립트 사용 가능하도록 설정 loadWithOverviewMode = true // 전체 웹페이지를 화면에 맞게 로드 useWideViewPort = true // 화면에 맞게 페이지 확대/축소 @@ -549,8 +579,11 @@ internal class LauncherActivity : AppCompatActivity() { allowContentAccess = true // 웹뷰를 통해 content url에 접근할지 여부 layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING // 웹페이지의 레이아웃을 화면에 맞게 자동으로 조정 } - } catch (ignore: NoSuchMethodError) {} - loadUrl(url) // 웹페이지 연결 + } catch (ignore: NoSuchMethodError) { + + }.apply { + loadUrl(url) // 웹페이지 연결 + } } } @@ -614,21 +647,22 @@ internal class LauncherActivity : AppCompatActivity() { // listItem.sortByDescending { it.date } // binding.searcher01.postDelayed({binding.searcher01.loadUrl(prevUrl)}, 5000L) //// } else { - var itemC = 0 - listItem.sortByDescending { it.date } - listItem?.forEach { - if(it.date > beforeDay(Date(),1)) { - if (itemC < 10) { - it.date = it.date + (10000L * itemC) - rssSet.put(it.pageLink, it) - } - itemC = itemC + 1 + var itemC = 0 + listItem.sortByDescending { it.date } + listItem?.forEach { + if(it.date > beforeDay(Date(),1)) { + if (itemC < 10) { + 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, - "Stored data :: ${listItem.size} items :: [${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))}] \n set in ${itemC}", Toast.LENGTH_LONG).show() + } + BLog.LOGE("Stored data :: ${listItem.size}items ${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))} set in ${itemC}") + 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("",null,null) } this@LauncherActivity.callBack?.invoke() } } @@ -659,7 +693,7 @@ internal class LauncherActivity : AppCompatActivity() { @JavascriptInterface fun sendValueFromHtml(result: String) { - + BLog.LOGE("binding.otherCheck start with ${result}") if (lastedFinishedPageUrl.contains(jGuruMain)) { var htmlString = result.replace("\\u003","<") val doc: Document = Jsoup.parse(htmlString) @@ -669,16 +703,19 @@ internal class LauncherActivity : AppCompatActivity() { ) { jGuruMain(doc) } else if (lastedFinishedPageUrl?.contains("/most-watched-rank") == true) { -jGuruToday(doc) + jGuruToday(doc) } else if (lastedFinishedPageUrl?.contains("/tags/") == true) { jGuruTag(doc) } } else if (lastedFinishedPageUrl?.contains("youtube") == true) { // val doc: Document = Jsoup.parse(result) // ytChannel(doc) - } else if (lastedFinishedPageUrl?.contains("missav")==true) { + } else if (lastedFinishedPageUrl?.contains("missjav")==true) { val doc: Document = Jsoup.parse(result) BLog.LOGE("missav >>> ${doc}") + doc.getElementsByTag("li").forEach { miss_li -> + BLog.LOGE("miss_li >>>> ${miss_li}") + } } BLog.LOGE("binding.otherCheck after ThreadRun") } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt b/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt index 6edae36..d7ea0df 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt @@ -40,6 +40,10 @@ import kotlinx.coroutines.* import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetManager 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.databinding.FeedsBinding import rasel.lunar.launcher.feeds.rss.RssAdapter @@ -145,8 +149,19 @@ internal class Feeds : Fragment() { DialogInterface.OnClickListener { dialog, which -> dialog.dismiss() when(input.text.toString()) { - "jJguru","vVioPup*383v" -> { - + "ytb" -> { + refreshYoutube() + } + "reddit"->{ + refreshReddit() + } + "fedd"->{ + refreshFeeds() + } + "comic"->{ + refreshComics() + } + "jshow" -> { binding.feedsRss.apply { rss.adapter = mRssAdapter loading.visibility = View.VISIBLE @@ -169,12 +184,20 @@ internal class Feeds : Fragment() { },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")) { binding.feedsRss.apply { diff --git a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt index e5d1064..31e2daa 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt @@ -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.lockMethod 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.settings.SettingsActivity import rasel.lunar.launcher.todos.MissedCallsAdapter @@ -183,9 +185,22 @@ internal class LauncherHome : Fragment() { commandHandler.postDelayed(infoUpdate,UPDATE_DELAY) 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() val filter = IntentFilter() // filter.addAction("com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE") diff --git a/app/src/main/kotlin/rasel/lunar/launcher/model/CommunityData.kt b/app/src/main/kotlin/rasel/lunar/launcher/model/CommunityData.kt index c97fa95..79eb894 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/model/CommunityData.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/model/CommunityData.kt @@ -4,23 +4,187 @@ import android.annotation.SuppressLint import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters -import com.google.gson.Gson -import org.json.JSONObject 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.todos.Root import rasel.lunar.launcher.todos.RssDataItem import rasel.lunar.launcher.todos.RssDataType -import rasel.lunar.launcher.todos.RssFeedsParser import rasel.lunar.launcher.utils.BLog -import rasel.lunar.launcher.utils.RssList -import rasel.lunar.launcher.utils.RssList.feedJsons +import rasel.lunar.launcher.utils.USAGT +import rasel.lunar.launcher.utils.afterDay import rasel.lunar.launcher.utils.beforeDay import java.text.SimpleDateFormat +import java.util.Calendar 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() + + 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 { + var tempArray = arrayListOf() +// 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 { companion object { val TAG = "DCGetter" @@ -55,11 +219,11 @@ class DCGetter : Worker { .get(0).text() else "" link = link.replace("&","&") thumbnail = thumbnail.replace("&","&") - 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}") +// 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 @@ -82,7 +246,9 @@ class DCGetter : Worker { try { 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}") dc.getElementsByTag("li").forEach { dc_li -> if (dc_li.html().contains("main_log") == true) { @@ -92,6 +258,8 @@ class DCGetter : Worker { } } } + + } catch (e:Exception){e.printStackTrace()} return tempArray.forEach { rssSet.put(it.originPage(),it) @@ -103,51 +271,7 @@ class DCGetter : Worker { -fun parseDcLi(dc_li : org.jsoup.nodes.Element) : ArrayList{ - var temp = arrayListOf() - if (dc_li.html().contains("
    ") && 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("&","&") - thumbnail = thumbnail.replace("&","&") - 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 { var link : String? = null @@ -156,8 +280,11 @@ class DcInside : RssDataItem { var desc : String? = null var dateTiem : String? = null - val dateF = SimpleDateFormat("MM:dd") - val timeF = SimpleDateFormat("hh:mm") + var dateTiemL : Long = 0L + + + val dateF = SimpleDateFormat("MM-dd") + val timeF = SimpleDateFormat("HH:mm") override fun title(): String { return title ?:"" } @@ -175,56 +302,34 @@ class DcInside : RssDataItem { } 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 { - return RssDataType.NewsFeed + return RssDataType.DcInside } - fun parseDcLi(dc_li : org.jsoup.nodes.Element) : ArrayList{ - var temp = arrayListOf() - if (dc_li.html().contains("
      ") && 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("&","&") - thumbnail = thumbnail.replace("&","&") - 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 - } } \ No newline at end of file diff --git a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssDataItem.kt b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssDataItem.kt index 9118f3b..6dc35dc 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssDataItem.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssDataItem.kt @@ -9,6 +9,8 @@ enum class RssDataType { REDDIT, Dotax, FmKorae, + DcInside, + Arca, } interface RssDataItem { diff --git a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt index 0aa837e..9b5121d 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt @@ -120,19 +120,35 @@ internal class RssItemAdapter ( 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)) { + } 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) + } 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) { Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview) } holder.view.desc.text = todo.description().plus(" ").plus(todo.category().name) 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 -> // if (holder.view.date.equals(v)) { // when(e.action) { @@ -144,12 +160,7 @@ internal class RssItemAdapter ( // 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 { if ( todo.category().equals(RssDataType.GURU)) { openOpera(todo.originPage()) @@ -157,7 +168,7 @@ internal class RssItemAdapter ( openReddit(todo.originPage()) } else if( todo.category().equals(RssDataType.Dotax)) { 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()) } true diff --git a/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt b/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt index 13ba6c7..bf2c650 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt @@ -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 { val cal: Calendar = Calendar.getInstance() cal.setTime(date) @@ -142,7 +144,7 @@ fun before30Min(date: Date): Long { } fun beforeDay(date: Date?, day: Int): Long { - val cal: Calendar = Calendar.getInstance() + val cal: Calendar = Calendar.getInstance() cal.setTime(date) cal.add(Calendar.DAY_OF_YEAR, Math.abs(day) * -1) return cal.timeInMillis @@ -576,7 +578,7 @@ class YoutubeGetter : Worker { rssUrls.addAll(RssList.youtubeUrls) val temp = arrayListOf() for (url in rssUrls) { - ytChannel(Jsoup.connect(url).get()) + ytChannel(Jsoup.connect(url).userAgent(USAGT).get()) } return temp.forEach { synchronized(rssSet){ @@ -592,6 +594,8 @@ class YoutubeGetter : Worker { if(it.html().contains("var ytInitialData", false)) {/**/ var ytInitialData = it.html().split("var ytInitialData = ")[1].split("")[0].toString() var tempJSONObject : JSONObject? = null + + JSONObject(ytInitialData).apply{ tempJSONObject = this val root = Gson().fromJson(tempJSONObject.toString(), Root::class.java) @@ -646,10 +650,10 @@ class ComicsGetter : Worker { 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" + "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 -> + fmkoreaUrls.forEach { Jsoup.connect(it).userAgent(USAGT).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) { @@ -697,24 +701,25 @@ class ComicsGetter2 : Worker { 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" + "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()}") + Jsoup.connect(it).userAgent(USAGT).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 dateTime = dotax_li.getElementsByClass("created_at").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) { + BLog.LOGE("dotax_li >>> ${dotax_li}") 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)) { temp.add(this) } diff --git a/app/src/main/res/drawable/arca.xml b/app/src/main/res/drawable/arca.xml new file mode 100644 index 0000000..f13a3b8 --- /dev/null +++ b/app/src/main/res/drawable/arca.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/app/src/main/res/drawable/dcinside.png b/app/src/main/res/drawable/dcinside.png new file mode 100644 index 0000000..8d855b7 Binary files /dev/null and b/app/src/main/res/drawable/dcinside.png differ