From b963bbedaf6378ee918938cf8c1fab321cbbdfa9 Mon Sep 17 00:00:00 2001 From: lunaticbum <> Date: Fri, 6 Sep 2024 18:13:00 +0900 Subject: [PATCH] oh.... --- app/src/main/AndroidManifest.xml | 1 - .../rasel/lunar/launcher/LauncherActivity.kt | 43 ++- .../rasel/lunar/launcher/LunarLauncher.kt | 1 + .../rasel/lunar/launcher/apps/AppDrawer.kt | 2 +- .../rasel/lunar/launcher/feeds/Feeds.kt | 352 +++++++++++++----- .../rasel/lunar/launcher/home/LauncherHome.kt | 249 +++++++------ .../rasel/lunar/launcher/model/CiliMagnet.kt | 13 + .../lunar/launcher/model/RssDataInterface.kt | 1 + .../rasel/lunar/launcher/model/RssItem.kt | 41 +- .../launcher/todos/NotificationItemAdapter.kt | 5 + .../lunar/launcher/todos/RssItemAdapter.kt | 29 +- .../rasel/lunar/launcher/workers/WorkersDb.kt | 2 +- app/src/main/res/layout/feeds.xml | 17 +- app/src/main/res/layout/list_item_with.xml | 15 +- .../main/res/layout/text_inpu_password.xml | 3 +- app/src/main/res/values/themes.xml | 5 + 16 files changed, 538 insertions(+), 241 deletions(-) create mode 100644 app/src/main/kotlin/rasel/lunar/launcher/model/CiliMagnet.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2599db16..981c6069 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -52,7 +52,6 @@ android:stateNotNeeded="true" android:enableOnBackInvokedCallback="true" android:largeHeap="true" - android:debuggable="false" android:networkSecurityConfig="@xml/network_security_config" android:hardwareAccelerated="true" android:usesCleartextTraffic="true" diff --git a/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt b/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt index baba3ef7..7387ee7d 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt @@ -500,9 +500,9 @@ internal class LauncherActivity : AppCompatActivity() { } } - var callBack : (()->Unit)? = null + var callBack : CommadCallabck? = null var isF = false - fun doWebParseStart(url : String, callBack : (()->Unit)?) { + fun doWebParseStart(url : String, callBack :CommadCallabck?) { isF = false this.callBack = callBack binding.searcher01.post { binding.searcher01.visibility = View.VISIBLE } @@ -573,7 +573,7 @@ internal class LauncherActivity : AppCompatActivity() { // } // } } - if (isF) this@LauncherActivity.callBack?.invoke() + if (isF) this@LauncherActivity.callBack?.collectComplete() // binding.searcher01.post { binding.searcher01.visibility = View.GONE } // } } @@ -640,7 +640,7 @@ internal class LauncherActivity : AppCompatActivity() { } } }.apply { - this@LauncherActivity.callBack?.invoke() + this@LauncherActivity.callBack?.collectComplete() WorkersDb.insertBulkInteface(temp) Toast.makeText(this@LauncherActivity, "Stored rank data", Toast.LENGTH_LONG).show() @@ -666,12 +666,12 @@ internal class LauncherActivity : AppCompatActivity() { }.apply { var itemC = 0 WorkersDb.insertBulkInteface(temp) -// BLog.LOGE("Stored data :: ${listItem.size}items ${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))} set in ${itemC}") + callBack?.onConsoleLog("Stored data :: ${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() + this@LauncherActivity.callBack?.collectComplete() } } @@ -693,7 +693,7 @@ internal class LauncherActivity : AppCompatActivity() { // Toast.makeText(this@LauncherActivity, // "Stored data :: ${listTags.size}tags", Toast.LENGTH_SHORT).show() binding.searcher01?.post { binding.searcher01.loadData("",null,null) } - this@LauncherActivity.callBack?.invoke() + this@LauncherActivity.callBack?.collectComplete() } } @@ -745,6 +745,30 @@ internal class LauncherActivity : AppCompatActivity() { // binding.searcher01?.post { binding.searcher01.loadData("",null,null) } } + } else if(lastedFinishedPageUrl?.contains("javmost")==true){ + val doc: Document = Jsoup.parse(result) + callBack?.onConsoleLog("${lastedFinishedPageUrl} >>> ${doc.title()}") + doc.getElementsByClass("card").forEach { card -> + callBack?.onConsoleLog("${lastedFinishedPageUrl}_card >>> ${card}") + var model = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("src") else "" + var thumb = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("alt") else "" + var title = "" + var date = "" + if(card.getElementsByClass("card-block").size > 0) if(card.getElementsByClass("card-block").size > 0) { + title = card.getElementsByClass("card-block").get(0).getElementsByTag("a").get(0).attr("title") + date = card.getElementsByTag("span").get(0).text() + } + + callBack?.onConsoleLog("" + + "model >>>>> ${model}\n" + + "thumb >>>>> ${thumb}\n" + + "title >>>>> ${title}\n" + + "date >>>>> ${date}" + + "") + } + } else { + val doc: Document = Jsoup.parse(result) + callBack?.onConsoleLog("lastedFinishedPageUrl >>> ${doc}") } BLog.LOGE("binding.otherCheck after ThreadRun") } @@ -791,4 +815,9 @@ fun beforeDay(date: Date): Long { cal.add(Calendar.DAY_OF_YEAR, -2) cal.add(Calendar.HOUR, 8) return cal.timeInMillis +} + +interface CommadCallabck { + fun onConsoleLog(log : String) + fun collectComplete() } \ No newline at end of file diff --git a/app/src/main/kotlin/rasel/lunar/launcher/LunarLauncher.kt b/app/src/main/kotlin/rasel/lunar/launcher/LunarLauncher.kt index 30d54471..8916544a 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/LunarLauncher.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/LunarLauncher.kt @@ -31,6 +31,7 @@ internal class LunarLauncher : Application() { } override fun onTrimMemory(level: Int) { super.onTrimMemory(level) +// Picasso. if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) SQLiteDatabase.releaseMemory() } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt index ef2d064d..09a6059d 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt @@ -394,7 +394,7 @@ internal class AppDrawer : Fragment() { fun registCancelSearch() { BLog.LOGE("Called registCancelSearch") chechHandler.removeCallbacks(cancelSearch) - chechHandler.postDelayed(cancelSearch, 3000L) + chechHandler.postDelayed(cancelSearch, 8000L) } fun clearCancelSearch() { 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 80b79fae..7bcc794a 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt @@ -25,27 +25,40 @@ import android.content.DialogInterface import android.content.Intent import android.content.SharedPreferences import android.net.Uri -import android.os.* -import android.view.* +import android.os.Bundle +import android.os.Handler +import android.os.Looper +import android.os.ResultReceiver +import android.text.method.ScrollingMovementMethod +import android.view.ContextMenu +import android.view.Gravity +import android.view.LayoutInflater +import android.view.MenuItem +import android.view.View +import android.view.ViewGroup import android.widget.EditText import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AlertDialog import androidx.appcompat.widget.LinearLayoutCompat.LayoutParams import androidx.appcompat.widget.PopupMenu +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle +import androidx.work.ExistingPeriodicWorkPolicy +import androidx.work.PeriodicWorkRequestBuilder import com.google.android.material.button.MaterialButtonToggleGroup -import com.squareup.okhttp.ConnectionPool -import com.squareup.okhttp.OkHttpClient -import com.squareup.okhttp.Request -import com.squareup.okhttp.Response -import com.squareup.okhttp.ResponseBody +import com.google.gson.Gson import io.realm.kotlin.ext.query import io.realm.kotlin.query.Sort -import kotlinx.coroutines.* +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch import org.jsoup.Jsoup +import rasel.lunar.launcher.CommadCallabck import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetManager import rasel.lunar.launcher.LauncherActivity.Companion.lActivity @@ -63,22 +76,30 @@ import rasel.lunar.launcher.helpers.Constants.Companion.SEPARATOR import rasel.lunar.launcher.helpers.Constants.Companion.requestCreateWidget import rasel.lunar.launcher.helpers.Constants.Companion.requestPickWidget import rasel.lunar.launcher.home.LauncherHome.Companion.home +import rasel.lunar.launcher.home.LauncherHome.Companion.lastedFinishedPageUrl import rasel.lunar.launcher.home.LauncherHome.Companion.listTags +import rasel.lunar.launcher.model.CiliMagnet +import rasel.lunar.launcher.model.MostItem import rasel.lunar.launcher.model.RssData import rasel.lunar.launcher.model.RssDataInterface import rasel.lunar.launcher.model.RssDataType +import rasel.lunar.launcher.model.RssItem import rasel.lunar.launcher.model.RssTagItem +import rasel.lunar.launcher.model.dateFormat +import rasel.lunar.launcher.model.getRssData import rasel.lunar.launcher.utils.BLog import rasel.lunar.launcher.utils.RssList.jGuruMain +import rasel.lunar.launcher.workers.RecentCallGetter import rasel.lunar.launcher.workers.WorkersDb import java.net.URLEncoder import java.nio.charset.Charset -import java.util.* +import java.text.SimpleDateFormat +import java.util.Date import java.util.concurrent.Executors import java.util.concurrent.TimeUnit -internal class Feeds : Fragment() { +internal class Feeds : Fragment() , CommadCallabck { private lateinit var binding: FeedsBinding private val requestCodeString = "requestCode" @@ -90,6 +111,7 @@ internal class Feeds : Fragment() { mRssAdapter2 = RssAdapter(requireContext()) binding.feedsRss.rss.adapter = mRssAdapter binding.feedsRss.rss2.adapter = mRssAdapter2 + binding.consoleLog.movementMethod = ScrollingMovementMethod(); updateWidgets() return binding.root } @@ -149,6 +171,18 @@ internal class Feeds : Fragment() { } } } + + fun consoleLog(str : String) { + mMainHandler.removeCallbacks(hideConsole) + binding.consoleLog.post { + binding.consoleLog.visibility = View.VISIBLE + binding.consoleLog.text = str + } + mMainHandler.postDelayed(hideConsole,10000L) + BLog.LOGE("consoleLog >>>> ${str}") + + } + fun openOpera(schemeString : String) { BLog.LOGE("openOpera ${schemeString}") val gmmIntentUri = Uri.parse(schemeString) @@ -158,15 +192,32 @@ internal class Feeds : Fragment() { lActivity?.startActivity(mapIntent) } + override fun onConsoleLog(log: String) { + consoleLog(log) + } + + + val mMainHandler = Handler(Looper.getMainLooper()) + val hideConsole = { + binding.consoleLog.visibility = View.GONE + binding.consoleLog.text = "" + } + override fun collectComplete() { + + } + 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" /* start rss service if network is active and rss url is not empty */ private fun startService() { + try { + System.gc() + }catch (e : Exception){e.printStackTrace()} binding.feedsRss.rss.visibility = View.GONE binding.feedsRss.rss2.visibility = View.GONE binding.feedsRss.loading.visibility = View.VISIBLE binding.feedsRss.refresh.visibility = View.VISIBLE val builder: AlertDialog.Builder = AlertDialog.Builder(requireContext()) - builder.setTitle("Title") + builder.setTitle("Command Line") val viewInflated: View = LayoutInflater.from(context) .inflate(R.layout.text_inpu_password, view as ViewGroup?, false) val input = viewInflated.findViewById(R.id.input) as EditText @@ -177,45 +228,119 @@ internal class Feeds : Fragment() { if (input.text.toString().trim().contains(" ")) { val cmd = input.text.toString().trim().split(" ") when(cmd[0]) { - //lActivity?.doWebParseStart("https://missav.com/dm16/en") {} - "miss"-> lActivity?.doWebParseStart("https://missav.com/en/search/${input.text.toString().trim().split(" ")[1]}/") {} + "jf" -> { + GlobalScope.launch { excuteGetterMostByUrl("https://javmost.to/search/movie/${cmd[1]}") } + } "mgn"-> { // lActivity?.doWebParseStart("https://cili.site/search?q=${URLEncoder.encode(cmd[1], Charset.defaultCharset().name())}") {} GlobalScope.launch { - ///https://cili.site/!iAVJ - Jsoup.connect("https://cili.site/search?q=${URLEncoder.encode(cmd[1], Charset.defaultCharset().name())}").get().apply { - BLog.LOGE("this >>>> cili ${this}") + var temp = arrayListOf() + consoleLog("this >>>> cili ${cmd[0]} -> ${cmd[1]}") + Jsoup.connect("https://cili.site/search?q=${URLEncoder.encode(cmd[1], Charset.defaultCharset().name())}").get().let { cili -> + consoleLog("this >>>> cili ${cili.title()}") + cili.getElementsByTag("tr").forEach { cili_tr -> + CiliMagnet().let { ciliMgn -> + ciliMgn.link = if(cili_tr.getElementsByTag("a").size > 0)cili_tr.getElementsByTag("a").get(0).attr("href") else "" + ciliMgn.title = if(cili_tr.getElementsByTag("p").size > 0)cili_tr.getElementsByTag("p").text() else "" + ciliMgn.size = if(cili_tr.getElementsByClass("td-size").size > 0)cili_tr.getElementsByClass("td-size").text() else "" + if(ciliMgn.isValid() && temp.size < 8 ) { + Jsoup.connect(ciliMgn.getMagnetPageLink()).get().let { mgn_Page -> + consoleLog("magnet_page >>> ${mgn_Page.title()}") + if (mgn_Page.getElementsByClass("input-group magnet-box").size > 0) { + mgn_Page.getElementsByClass("input-group magnet-box") + .get(0)?.let { magnet_box -> +// BLog.LOGE("magnet_box >>> ${magnet_box}") +// if (magnet_box.getElementById("input-magnet").size > 0) { + magnet_box.getElementById( + "input-magnet" + )?.let { input_magnet -> +// BLog.LOGE("input_magnet >>> ${input_magnet}") + ciliMgn.magnetLink = input_magnet.attr("value").replace("&","&") + } + } + } + }.apply { + temp.add(ciliMgn) + } + } + } + + }.apply { + temp.forEach { + consoleLog("ciliResult >>> ${Gson().toJson(it)}") + } + } } }.start() } } - + binding.expandRss.isChecked = false } else { when (input.text.toString()) { + "ojs" -> home?.queryInfos(arrayListOf().apply { + addAll(RssDataType.values()) + remove(RssDataType.GURU) + remove(RssDataType.Most) + }) + "onews" -> home?.queryInfos(arrayListOf().apply { + addAll(RssDataType.values()) + remove(RssDataType.NewsFeed) + }) + "ored" -> home?.queryInfos(arrayListOf().apply { + addAll(RssDataType.values()) + remove(RssDataType.REDDIT) + }) + "most" -> { + consoleLog("current j req() ${WorkersDb.getRealm() + .query("category == $0", RssDataType.GURU.name).find().size}") + val urls = arrayOf("https://javmost.to/latest-updates", + "https://javmost.to/latest-updates/page-2", + "https://javmost.to/latest-updates/page-3", + "https://javmost.to/latest-updates/page-4", + "https://javmost.to/latest-updates/page-5", + "https://javmost.to/latest-updates/page-6", + "https://javmost.to/latest-updates/page-7", + "https://javmost.to/latest-updates/page-8", + "https://javmost.to/latest-updates/page-9", + "https://javmost.to/latest-updates/page-10") + GlobalScope.launch { + urls.forEach { mostUrl -> + excuteGetterMostByUrl(mostUrl) + } + }.start() + } "ytb" -> { refreshYoutube() + consoleLog("excute refreshYoutube()") } "reddit" -> { refreshReddit() + consoleLog("excute refreshReddit()") } "fedd" -> { refreshFeeds() + consoleLog("excute refreshFeeds()") } "comic" -> { refreshComics() + consoleLog("excute refreshComics()") } "taxi" -> { + consoleLog("before run State home?.binding?.alcholKatalkT?.isVisible >> ${home?.binding?.alcholKatalkT?.isVisible}") home?.showAl() + consoleLog("after run State home?.binding?.alcholKatalkT?.isVisible >> ${home?.binding?.alcholKatalkT?.isVisible}") } "tax" -> { + consoleLog("before run State home?.binding?.alcholKatalkT?.isVisible >> ${home?.binding?.alcholKatalkT?.isVisible}") home?.hideAl() + consoleLog("after run State home?.binding?.alcholKatalkT?.isVisible >> ${home?.binding?.alcholKatalkT?.isVisible}") } "jshow" -> { @@ -223,7 +348,7 @@ internal class Feeds : Fragment() { rss.adapter = mRssAdapter loading.visibility = View.VISIBLE mRssAdapter?.updateData(WorkersDb.getRealm() - .query("category == $0", RssDataType.GURU.name) + .query("category == $0 || category == $1", RssDataType.GURU.name, RssDataType.Most.name) .sort("pubDate", Sort.DESCENDING).find()) rss.visibility = View.VISIBLE loading.visibility = View.GONE @@ -232,59 +357,35 @@ internal class Feeds : Fragment() { } "jjp" -> { - lActivity?.doWebParseStart("https://projectjav.com") {} +// lActivity?.doWebParseStart("https://projectjav.com") {} } "jmnew" -> { - Executors.newSingleThreadScheduledExecutor().schedule({ - try { - val url = "https://missav.com/" - - - // OkHttp 클라이언트 객체 생성 - val client: OkHttpClient = OkHttpClient() - client.connectionPool = ConnectionPool(10, 300, TimeUnit.SECONDS) - client.setFollowSslRedirects(true) - - // GET 요청 객체 생성 - val builder: Request.Builder = Request.Builder().url(url).get() -// builder.addHeader("password", "BlahBlah") - val request: Request = builder.build() - - - // OkHttp 클라이언트로 GET 요청 객체 전송 - val response: Response = client.newCall(request).execute() - if (response.isSuccessful()) { - // 응답 받아서 처리 - val body: ResponseBody = response.body() - if (body != null) { - System.out.println("Response:" + body.string()) - } - } else System.err.println("Error Occurred") - - } catch (e: java.lang.Exception) { - e.printStackTrace() - } -// try { -// Jsoup.connect("https://missav.com/").userAgent(USAGT).timeout(300000).get().apply { -// BLog.LOGE("https://missav.com/dm507/en/release >>>> ${this}") -// } -// }catch (e : Exception) { -// e.printStackTrace() -// -// } - }, 2, TimeUnit.SECONDS) // lActivity?.doWebParseStart("https://missav.com/dm507/en/release") {} } "jmiss" -> { - lActivity?.doWebParseStart("https://missav.com/dm16/en") {} +// lActivity?.doWebParseStart("https://missav.com/dm16/en") {} } "jreq" -> { - lActivity?.doWebParseStart(jGuruMain) {} + consoleLog("current j req() ${WorkersDb.getRealm() + .query("category == $0", RssDataType.GURU.name).find().size}") + lActivity?.doWebParseStart(jGuruMain,callBack = object : CommadCallabck { + override fun onConsoleLog(log: String) { + this@Feeds.consoleLog(log) + } + + override fun collectComplete() { + consoleLog("excuted j req() ${WorkersDb.getRealm() + .query("category == $0", RssDataType.GURU.name).find().size}") + } + }) +// { +// consoleLog("excuted j req() ${WorkersDb.getRealm() +// .query("category == $0", RssDataType.GURU.name).find().size}") +// } } "jtag" -> { // lActivity?.doWebPare(TEST_PAG.plus("tags")) { - binding.feedsRss.apply { rss2.adapter = mRssAdapter2 @@ -298,16 +399,22 @@ internal class Feeds : Fragment() { refresh.visibility = View.VISIBLE rss2.visibility = View.GONE refresh.setOnClickListener { - lActivity?.doWebParseStart(jGuruMain.plus("tags")) { - if (listTags.size > 0) { - rss2?.postDelayed({ - mRssAdapter2?.updateData(listTags) - loading.visibility = View.GONE - refresh.visibility = View.GONE - rss2.visibility = View.VISIBLE - }, 500L) + lActivity?.doWebParseStart(jGuruMain.plus("tags"), callBack = object : CommadCallabck { + override fun onConsoleLog(log: String) { + this@Feeds.consoleLog(log) } - } + + override fun collectComplete() { + if (listTags.size > 0) { + rss2?.postDelayed({ + mRssAdapter2?.updateData(listTags) + loading.visibility = View.GONE + refresh.visibility = View.GONE + rss2.visibility = View.VISIBLE + }, 500L) + } + } + }) } } } @@ -366,6 +473,53 @@ internal class Feeds : Fragment() { } } + var dmy = SimpleDateFormat("dd-MM-yyyy") + fun excuteGetterMostByUrl(mostUrl : String) { + Executors.newSingleThreadScheduledExecutor().schedule({ + Jsoup.connect(mostUrl).userAgent(USAGT).get().let { doc -> + onConsoleLog("$lastedFinishedPageUrl >>> ${doc.title()}") + doc.getElementsByClass("card").forEach { card -> + onConsoleLog("${lastedFinishedPageUrl}_card >>> ${card}") + var thumb = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("src") else "" + if (thumb.contains("No+Poster")) thumb = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("data-src") else thumb + var model = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("alt") else "" + var title = "" + var date = "" + var link = "" + if(card.getElementsByClass("card-block").size > 0) if(card.getElementsByClass("card-block").size > 0) { + link = card.getElementsByClass("card-block").get(0).getElementsByTag("a").get(0).attr("href") + title = card.getElementsByClass("card-block").get(0).getElementsByTag("a").get(0).attr("title") + date = card.getElementsByTag("span").get(0).text() + } + + + MostItem().let { ms -> + ms.model = model + ms.image = thumb + ms.pageLink = link + ms.title = title + try { + ms.date = dmy.parse(date).time + consoleLog("dateFormat.format(Date(ms.date)) ${dateFormat.format(Date(ms.date))}") + }catch (e : Exception) {e.printStackTrace()} + if (ms.isValid()) { + WorkersDb.insertData(ms.getRssData()) + } + } + + onConsoleLog("" + + "model >>>>> ${model}\n" + + "thumb >>>>> ${thumb}\n" + + "title >>>>> ${title}\n" + + "date >>>>> ${date}" + + "") + } + consoleLog("excuted j req() ${WorkersDb.getRealm() + .query("category == $0", RssDataType.GURU.name).find().size}") + } + }, 1500, TimeUnit.MILLISECONDS) + } + /* rss service's result receiver */ @Suppress("UNCHECKED_CAST") private val resultReceiver: ResultReceiver = object : ResultReceiver(Handler(Looper.getMainLooper())) { @@ -443,39 +597,39 @@ internal class Feeds : Fragment() { } private fun createWidget(appWidgetId: Int, height: Int?) { - if (appWidgetId == -1) return - - val appWidgetInfo = appWidgetManager!!.getAppWidgetInfo(appWidgetId) - val params: LayoutParams? - - when (height) { - null -> { - params = LayoutParams(LayoutParams.MATCH_PARENT, appWidgetInfo.minHeight) - val updatedIds = splitWidgetIds.plus("$appWidgetId") - val updatedHeights = splitWidgetHeights.plus("${appWidgetInfo.minHeight}") - saveWidgetData(updatedIds, updatedHeights) - } - else -> params = LayoutParams(LayoutParams.MATCH_PARENT, height) - } - - (appWidgetHost?.createView(lActivity!!.applicationContext, appWidgetId, appWidgetInfo) as WidgetHostView) - .apply { - setAppWidget(appWidgetId, appWidgetInfo) - }.let { - binding.widgetContainer.addView(it, params) - widgetMenu(it) - } +// if (appWidgetId == -1) return +// +// val appWidgetInfo = appWidgetManager!!.getAppWidgetInfo(appWidgetId) +// val params: LayoutParams? +// +// when (height) { +// null -> { +// params = ConstraintLayout.LayoutParams(LayoutParams.MATCH_PARENT, appWidgetInfo.minHeight) +// val updatedIds = splitWidgetIds.plus("$appWidgetId") +// val updatedHeights = splitWidgetHeights.plus("${appWidgetInfo.minHeight}") +// saveWidgetData(updatedIds, updatedHeights) +// } +// else -> params = ConstraintLayout.LayoutParams(LayoutParams.MATCH_PARENT, height) +// } +// +// (appWidgetHost?.createView(lActivity!!.applicationContext, appWidgetId, appWidgetInfo) as WidgetHostView) +// .apply { +// setAppWidget(appWidgetId, appWidgetInfo) +// }.let { +// binding.widgetContainer.addView(it, params) +// widgetMenu(it) +// } } private fun updateWidgets() { - if (splitWidgetIds.size > 0) { - viewLifecycleOwner.lifecycleScope.launch { - binding.widgetContainer.removeAllViews() - splitWidgetIds.indices.forEach { i: Int -> - createWidget(splitWidgetIds[i]!!.int(), splitWidgetHeights[i]!!.int()) - } - } - } +// if (splitWidgetIds.size > 0) { +// viewLifecycleOwner.lifecycleScope.launch { +// binding.widgetContainer.removeAllViews() +// splitWidgetIds.indices.forEach { i: Int -> +// createWidget(splitWidgetIds[i]!!.int(), splitWidgetHeights[i]!!.int()) +// } +// } +// } } private fun widgetMenu(hostView: WidgetHostView) { 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 d1afb6cd..e6288d2e 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt @@ -32,6 +32,7 @@ import android.os.Looper import android.provider.AlarmClock import android.view.LayoutInflater import android.view.View +import android.view.View.OnScrollChangeListener import android.view.ViewGroup import android.widget.Toast import androidx.biometric.BiometricPrompt @@ -39,11 +40,13 @@ import androidx.core.content.ContextCompat.RECEIVER_EXPORTED import androidx.core.content.ContextCompat.registerReceiver import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager -import androidx.lifecycle.LiveData import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView.OnScrollListener import io.realm.kotlin.ext.query +import io.realm.kotlin.notifications.InitialResults import io.realm.kotlin.notifications.ResultsChange import io.realm.kotlin.notifications.UpdatedResults import io.realm.kotlin.query.RealmResults @@ -54,9 +57,7 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.launch import org.json.JSONArray import org.json.JSONObject -import org.jsoup.Jsoup import rasel.lunar.launcher.LauncherActivity.Companion.CALL_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.lActivity import rasel.lunar.launcher.LauncherActivity.Companion.refreshComics @@ -67,10 +68,7 @@ import rasel.lunar.launcher.LauncherActivity.Companion.workmanager import rasel.lunar.launcher.R import rasel.lunar.launcher.databinding.LauncherHomeBinding import rasel.lunar.launcher.helpers.Constants.Companion.BOTTOM_SHEET_TAG -import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_DATE_FORMAT -import rasel.lunar.launcher.helpers.Constants.Companion.KEY_DATE_FORMAT import rasel.lunar.launcher.helpers.Constants.Companion.KEY_LOCK_METHOD -import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TIME_FORMAT import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TODO_LOCK import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS import rasel.lunar.launcher.helpers.UniUtils.Companion.biometricPromptInfo @@ -91,8 +89,6 @@ import rasel.lunar.launcher.todos.SmsLogsAdapter import rasel.lunar.launcher.utils.BLog import rasel.lunar.launcher.utils.SimpleFingerGestures import rasel.lunar.launcher.utils.beforeDay -import rasel.lunar.launcher.workers.ArcaGetter -import rasel.lunar.launcher.workers.DCGetter import rasel.lunar.launcher.workers.RecentCall import rasel.lunar.launcher.workers.RecentSms import rasel.lunar.launcher.workers.WorkersDb @@ -100,13 +96,11 @@ import java.net.URLEncoder import java.text.SimpleDateFormat import java.util.Calendar import java.util.Date -import java.util.Locale -import kotlin.properties.Delegates internal class LauncherHome : Fragment() { - private lateinit var binding: LauncherHomeBinding + lateinit var binding: LauncherHomeBinding private lateinit var fragManager: FragmentManager private lateinit var settingsPrefs: SharedPreferences private lateinit var batteryReceiver: BatteryReceiver @@ -121,13 +115,13 @@ internal class LauncherHome : Fragment() { var listTags = arrayListOf() } - private var nReceiver: NotificationReceiver? = null - - class NotificationReceiver : BroadcastReceiver() { - override fun onReceive(context: Context?, intent: Intent) { - BLog.LOGE("NotificationReceiver >>>> ${intent.extras?.keySet()}") - } - } +// private var nReceiver: NotificationReceiver? = null +// +// class NotificationReceiver : BroadcastReceiver() { +// override fun onReceive(context: Context?, intent: Intent) { +// BLog.LOGE("NotificationReceiver >>>> ${intent.extras?.keySet()}") +// } +// } val UPDATE_DELAY = 1000L val commandHandler = Handler(Looper.getMainLooper()) @@ -160,9 +154,13 @@ internal class LauncherHome : Fragment() { var lasted : RealmResults? = null var lastedNoti : RealmResults? = null - - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) home = this + BLog.LOGE("${this} ::::: onCreate >>>> ") + } + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { + BLog.LOGE("${this} ::::: onCreateView >>>> ") binding = LauncherHomeBinding.inflate(inflater, container, false) fragManager = lActivity!!.supportFragmentManager settingsPrefs = requireContext().getSharedPreferences(PREFS_SETTINGS, 0) @@ -180,8 +178,6 @@ internal class LauncherHome : Fragment() { binding.smsList.visibility = View.GONE binding.infoList.visibility = View.GONE -// binding.favAppsGroup.visibility = View.GONE - binding.notiList.layoutManager = LinearLayoutManager(requireContext()) binding.mainList.layoutManager = LinearLayoutManager(requireContext()) binding.smsList.layoutManager = GridLayoutManager(requireContext(),2) @@ -192,6 +188,14 @@ internal class LauncherHome : Fragment() { binding.infoList.adapter = mRssAdapter binding.notiList.adapter = mNotiAdapter + try{binding.mainList.removeOnScrollListener(onScrChanged)}catch (e : Exception){e.printStackTrace()} + binding.mainList.addOnScrollListener(onScrChanged) + try{binding.smsList.removeOnScrollListener(onScrChanged)}catch (e : Exception){e.printStackTrace()} + binding.smsList.addOnScrollListener(onScrChanged) + try{binding.infoList.removeOnScrollListener(onScrChanged)}catch (e : Exception){e.printStackTrace()} + binding.infoList.addOnScrollListener(onScrChanged) + try{binding.notiList.removeOnScrollListener(onScrChanged)}catch (e : Exception){e.printStackTrace()} + binding.notiList.addOnScrollListener(onScrChanged) workmanager()?.getWorkInfosByTagLiveData(SMS_WORK_TAG)?.observeForever { commandHandler.removeCallbacks(smsUpdate) @@ -205,75 +209,63 @@ internal class LauncherHome : Fragment() { it.clear() } - workmanager()?.getWorkInfosByTagLiveData(FEDDS_WORK_TAG)?.observeForever { - commandHandler.removeCallbacks(infoUpdate) - 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") - registerReceiver(requireContext(),nReceiver, filter,RECEIVER_EXPORTED) +// nReceiver = NotificationReceiver() +// val filter = IntentFilter() +// registerReceiver(requireContext(),nReceiver, filter,RECEIVER_EXPORTED) BLog.LOGE("onCreateView()") - mRssDataResult = WorkersDb.getRealm().query().query("pubDate > $0",beforeDay(Date(),3)).query("category != $0", RssDataType.GURU.name).sort("pubDate ", Sort.DESCENDING).find() - mNotificationResult = WorkersDb.getRealm().query().sort("postTime",Sort.DESCENDING).find() - job = CoroutineScope(Dispatchers.Default).launch { - mRssDataResult.asFlow().collect { changes: ResultsChange -> - when (changes) { - // UpdatedResults means this change represents an update/insert/delete operation - is UpdatedResults -> { - if (mRssAdapter.itemCount != changes.list.size) { -// BLog.LOGE("ResultsChange") - lasted = changes.list - commandHandler.removeCallbacks(infoUpdate) - commandHandler.postDelayed(infoUpdate, UPDATE_DELAY) - } - WorkersDb.getRealm().apply { write { - delete(query().query("pubDate < $0",beforeDay(Date(),3)).find()) - }} - } - else -> { - // types other than UpdatedResults are not changes -- ignore them - } + queryInfos() + queryNotice() + return binding.root + } + + val hideListView = { +// binding.notiList.visibility = View.GONE +// binding.mainList.visibility = View.GONE +// binding.infoList.visibility = View.GONE +// binding.smsList.visibility = View.GONE + } + + + val onScrChanged = object : RecyclerView.OnScrollListener() { + override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { + super.onScrollStateChanged(recyclerView, newState) + when (newState) { + RecyclerView.SCROLL_STATE_IDLE -> { + commandHandler.postDelayed(hideListView, UPDATE_DELAY * 5) + } + RecyclerView.SCROLL_STATE_DRAGGING -> { + } + RecyclerView.SCROLL_STATE_SETTLING -> { } } - + commandHandler.removeCallbacks(hideListView) } - job.start() - CoroutineScope(Dispatchers.Default).launch { - mNotificationResult.asFlow().collect { changes: ResultsChange -> + + override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { + super.onScrolled(recyclerView, dx, dy) + commandHandler.removeCallbacks(hideListView) + } + } + + private fun queryNotice() { + try { noticeJob?.cancel() } catch (e:Exception) {e.printStackTrace()} + mNotificationResult = null + try { + System.gc() + }catch (e : Exception){e.printStackTrace()} + mNotificationResult = WorkersDb.getRealm().query().sort("postTime",Sort.DESCENDING).find() + noticeJob = CoroutineScope(Dispatchers.Default).launch { + mNotificationResult?.asFlow()?.collect { changes: ResultsChange -> BLog.LOGE("changes >>> ${changes}") when (changes) { - // UpdatedResults means this change represents an update/insert/delete operation is UpdatedResults -> { -// if (lasted?.size != changes.list.size) { BLog.LOGE("ResultsChange onNotificationPosted") lastedNoti = changes.list commandHandler.removeCallbacks(infoUpdate) commandHandler.postDelayed(infoUpdate, UPDATE_DELAY) -// } -// WorkersDb.getRealm().apply { write { -// delete(query().query("pubDate < $0",beforeDay(Date(),3)).find()) -// }} } else -> { @@ -281,23 +273,73 @@ internal class LauncherHome : Fragment() { } } } - }.start() - mNotiAdapter?.updateData(mNotificationResult) - mRssAdapter?.updateData(mRssDataResult) - return binding.root + } + mNotificationResult?.let { mNotiAdapter?.updateData(it) } + + noticeJob.start() } - lateinit var job : Job + + fun queryInfos(filter: Collection? = arrayListOf(RssDataType.GURU,RssDataType.Most)) { + BLog.LOGE("${this} ::::: queryInfos >>>> ${filter}") + try { infosJob?.cancel() } catch (e:Exception) {e.printStackTrace()} + mRssDataResult = null + try { + System.gc() + }catch (e : Exception){e.printStackTrace()} + + WorkersDb.getRealm().apply { writeBlocking { + delete(query().query("pubDate < $0",beforeDay(Date(),3)).query("category != $0 || category != $1 ", RssDataType.GURU.name,RssDataType.Most.name).find()) + }} + BLog.LOGE("${this} ::::: queryInfos after delete >>>> ") + var rQ = WorkersDb.getRealm().query().sort("pubDate ", Sort.DESCENDING).query("pubDate > $0",beforeDay(Date(),3)) + filter!!.forEach { + rQ = rQ.query("category != $0", it.name) + } + mRssDataResult = rQ.limit(1000).find() + BLog.LOGE("${this} ::::: queryInfos after query find >>>> ") + infosJob = CoroutineScope(Dispatchers.Default).launch { + mRssDataResult?.asFlow()?.collect { changes: ResultsChange -> + commandHandler.removeCallbacks(infoUpdate) + + when (changes) { + is InitialResults -> { + BLog.LOGE("${this} ::::: queryInfos after changes size >>>> ${changes.list.size}") + lasted = changes.list + commandHandler.postDelayed(infoUpdate, UPDATE_DELAY * 3) + } + is UpdatedResults -> { +// lasted = changes.list +// commandHandler.postDelayed(infoUpdate, UPDATE_DELAY * 3) + } + else -> { + } + } + } + } + mRssDataResult?.let { + BLog.LOGE("${this} ::::: queryInfos updateData >>>> ") +// lasted = it +// commandHandler.postDelayed(infoUpdate, UPDATE_DELAY * 3) + mRssAdapter.updateData(it) + } + infosJob.start() + } + + lateinit var infosJob : Job + lateinit var noticeJob : Job lateinit var mMissedCallsAdapter : MissedCallsAdapter lateinit var mSmsLogsAdapter : SmsLogsAdapter lateinit var mRssAdapter : RssItemAdapter lateinit var mNotiAdapter : NotificationItemAdapter - lateinit var mRssDataResult : RealmResults - lateinit var mNotificationResult : RealmResults + var mRssDataResult : RealmResults? = null + var mNotificationResult : RealmResults? = null override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - /* handle gesture events */ + + BLog.LOGE("${this} ::::: onViewCreated >>>> ") + rootViewGestures() batteryProgressGestures() todosGestures() @@ -315,9 +357,6 @@ internal class LauncherHome : Fragment() { false } } - binding.mainList.setHasFixedSize(true) - binding.mainList.setItemViewCacheSize(10) - var checkListner = object : View.OnClickListener { @@ -357,6 +396,7 @@ internal class LauncherHome : Fragment() { } else { binding.otherCheck.isSelected = true views.remove(binding.infoList) + binding.infoList.scrollToPosition(0) binding.infoList.visibility = View.VISIBLE } } @@ -372,7 +412,6 @@ internal class LauncherHome : Fragment() { } chechboxs.forEach { it.isSelected = false } views.forEach { it.visibility = View.GONE } - chooseAdpater() } } @@ -383,6 +422,7 @@ internal class LauncherHome : Fragment() { binding.notice.setOnClickListener(checkListner) binding.otherCheck.setOnLongClickListener { + queryInfos() refreshYoutube() refreshComics() refreshFeeds() @@ -416,10 +456,11 @@ internal class LauncherHome : Fragment() { } fun chooseAdpater () { - binding.mainList.visibility = View.GONE - binding.smsList.visibility = View.GONE - binding.infoList.visibility = View.GONE - binding.notiList.visibility = View.GONE + commandHandler.removeCallbacks(hideListView) + binding.mainList.visibility = View.INVISIBLE + binding.smsList.visibility = View.INVISIBLE + binding.infoList.visibility = View.INVISIBLE + binding.notiList.visibility = View.INVISIBLE if (binding.missedCalls.isSelected) { if (recentCalls.size > 0 && isAdded && isResumed && isVisible) { try { @@ -462,11 +503,9 @@ internal class LauncherHome : Fragment() { binding.recentSms.isSelected = false binding.notice.isSelected = false binding.infoList.visibility = View.VISIBLE - if (lasted?.size ?: 0 > 0) { - binding.otherCheck.text = "최근 정보[${lasted!!.size}]" - mRssAdapter.updateData(lasted!!) -// binding.infoList.smoothScrollToPosition(0) - } + binding.otherCheck.text = "최근 정보[${lasted?.size ?: "-"}]" + lasted?.let { mRssAdapter.updateData(it) } + } } else if(binding.notice.isSelected) { @@ -475,18 +514,16 @@ internal class LauncherHome : Fragment() { binding.recentSms.isSelected = false binding.otherCheck.isSelected = false binding.notiList.visibility = View.VISIBLE - if (lastedNoti?.size ?: 0 > 0) { - binding.otherCheck.text = "알림 센터[${lastedNoti!!.size}]" - mNotiAdapter.updateData(lastedNoti!!) -// binding.notiList.smoothScrollToPosition(0) - } + binding.notice.text = "알림 센터[${lastedNoti?.size ?: "-"}]" + lastedNoti?.let { mNotiAdapter.updateData(it) } + } } + commandHandler.postDelayed(hideListView, UPDATE_DELAY * 5) } override fun onResume() { super.onResume() - BLog.LOGE("onResume()") - BLog.LOGE(SimpleDateFormat("yyyy년 M월 W주차, dd일 E요일").format(Date())) + BLog.LOGE("${this} ::::: onResume >>>> ") if (shouldResume) { /* register battery changes */ @@ -502,7 +539,7 @@ internal class LauncherHome : Fragment() { // binding.date.format12Hour = dateFormat // } /* show weather */ - WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather) +// WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather) } } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/model/CiliMagnet.kt b/app/src/main/kotlin/rasel/lunar/launcher/model/CiliMagnet.kt new file mode 100644 index 00000000..e1d67416 --- /dev/null +++ b/app/src/main/kotlin/rasel/lunar/launcher/model/CiliMagnet.kt @@ -0,0 +1,13 @@ +package rasel.lunar.launcher.model + +class CiliMagnet { + var link : String? = null + var title : String? = null + var size : String? = null + var magnetLink : String? = null + + fun isValid() = (((link?.length ?: 0) > 0 && (title?.length ?: 0) > 0 && (size?.length + ?: 0) > 0)) + + fun getMagnetPageLink() = "https://cili.site".plus(link) +} diff --git a/app/src/main/kotlin/rasel/lunar/launcher/model/RssDataInterface.kt b/app/src/main/kotlin/rasel/lunar/launcher/model/RssDataInterface.kt index a34b0e58..1926240c 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/model/RssDataInterface.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/model/RssDataInterface.kt @@ -5,6 +5,7 @@ enum class RssDataType { YOUTUBE, NewsFeed, GURU, + Most, TAGS, REDDIT, Dotax, diff --git a/app/src/main/kotlin/rasel/lunar/launcher/model/RssItem.kt b/app/src/main/kotlin/rasel/lunar/launcher/model/RssItem.kt index 28daa213..f6561750 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/model/RssItem.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/model/RssItem.kt @@ -1,6 +1,6 @@ package rasel.lunar.launcher.model -class RssItem : RssDataInterface { +open class RssItem : RssDataInterface { var model : String = "" var title : String = "" var pageLink : String = "" @@ -24,6 +24,8 @@ class RssItem : RssDataInterface { this.date = date } + constructor() + override fun title(): String { return title } @@ -37,7 +39,7 @@ class RssItem : RssDataInterface { } override fun description(): String { - return tags.plus(model) + return tags.plus(", ").plus(model).plus(", ").plus(category()) } override fun pubDate(): Long { @@ -47,4 +49,37 @@ class RssItem : RssDataInterface { override fun category(): RssDataType { return RssDataType.GURU } -} \ No newline at end of file + + fun isValid() = (((pageLink.length ?:0) > 0) && ((title.length ?:0) > 0)&& ((image.length ?:0) > 0)) +} + +class MostItem : RssItem , RssDataInterface { + + constructor() : super() + + override fun title(): String { + return title + } + + override fun thumbnailUrl(): String { + return image + } + + override fun originPage(): String { + return pageLink + } + + override fun description(): String { + return tags.plus(", ").plus(model).plus(", ").plus(category()) + } + + override fun pubDate(): Long { + return date + } + + override fun category(): RssDataType { + return RssDataType.Most + } + + +} diff --git a/app/src/main/kotlin/rasel/lunar/launcher/todos/NotificationItemAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/todos/NotificationItemAdapter.kt index f4afeb74..c45a1f1c 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/todos/NotificationItemAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/todos/NotificationItemAdapter.kt @@ -25,7 +25,9 @@ import android.content.pm.PackageManager import android.graphics.drawable.Drawable import android.net.Uri import android.view.LayoutInflater +import android.view.View import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintLayout import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import rasel.lunar.launcher.LauncherActivity.Companion.lActivity @@ -55,6 +57,9 @@ internal class NotificationItemAdapter ( override fun onBindViewHolder(holder: NotiHolder, position: Int) { val todo = notiItems[position] try { + holder.view.circlePreview.visibility = View.VISIBLE + var param = holder.view.circlePreview.layoutParams + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height) val d: Drawable = context.packageManager.getApplicationIcon(todo.pkgName!!) holder.view.circlePreview.setImageDrawable(d) holder.view.title.text = todo.tikerMsg 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 b953561f..ca51efb2 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt @@ -58,9 +58,8 @@ internal class RssItemAdapter ( @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: RssTag, position: Int) { val todo = rssDataItemLis[position] - - holder.view.date.text = "${dateFormat.format(Date(todo.pubDate()))}" -// holder.view.desc.visibility = View.GONE + Picasso.get().cancelRequest(holder.view.circlePreview) + holder.view.date.text = dateFormat.format(Date(todo.pubDate())) holder.view.date.setOnClickListener { } when(todo.category()) { RssDataType.YOUTUBE -> { @@ -68,14 +67,14 @@ internal class RssItemAdapter ( Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview) holder.view.circlePreview.visibility = View.VISIBLE } - holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(280,280) + var param = holder.view.circlePreview.layoutParams + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(280,param.height) holder.view.title.text = "${todo.title()}" holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT) holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT) holder.view.date.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT) holder.view.desc.visibility = View.VISIBLE 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 { } @@ -111,29 +110,35 @@ internal class RssItemAdapter ( holder.view.date.text = dateFormat.format(Date(todo.pubDate())) } - if(todo.description().contains("nsfw") || todo.category().equals(RssDataType.GURU)) { + if(todo.description().contains("nsfw") || todo.category().equals(RssDataType.GURU) || todo.category().equals(RssDataType.Most)) { holder.view.circlePreview.visibility = View.GONE - holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(360,360) + var param = holder.view.circlePreview.layoutParams + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(360,param.height) } 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) + var param = holder.view.circlePreview.layoutParams + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height) } 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) + var param = holder.view.circlePreview.layoutParams + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height) } 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) + var param = holder.view.circlePreview.layoutParams + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height) } 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) + var param = holder.view.circlePreview.layoutParams + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height) } 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) + var param = holder.view.circlePreview.layoutParams + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height) } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/workers/WorkersDb.kt b/app/src/main/kotlin/rasel/lunar/launcher/workers/WorkersDb.kt index 0dc12d9c..3f36d435 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/workers/WorkersDb.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/workers/WorkersDb.kt @@ -30,7 +30,7 @@ object WorkersDb { fun insertData(rssData: RssData) { getRealm().apply { this.writeBlocking { - this.copyToRealm(rssData) + this.copyToRealm(rssData, UpdatePolicy.ALL) } } } diff --git a/app/src/main/res/layout/feeds.xml b/app/src/main/res/layout/feeds.xml index 26ed2b18..6b0eb86f 100644 --- a/app/src/main/res/layout/feeds.xml +++ b/app/src/main/res/layout/feeds.xml @@ -1,5 +1,5 @@ - + @@ -50,10 +59,12 @@ - + diff --git a/app/src/main/res/layout/list_item_with.xml b/app/src/main/res/layout/list_item_with.xml index 495c5591..e94a8684 100644 --- a/app/src/main/res/layout/list_item_with.xml +++ b/app/src/main/res/layout/list_item_with.xml @@ -1,19 +1,22 @@ - - + android:layout_width="wrap_content" + android:layout_height="0dp"/> - \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 8a68fe48..2cfafd1a 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -15,4 +15,9 @@ @style/Slider @color/almost_transparent + + \ No newline at end of file