This commit is contained in:
lunaticbum 2024-09-06 18:13:00 +09:00
parent 1ca2b360d7
commit b963bbedaf
16 changed files with 538 additions and 241 deletions

View File

@ -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"

View File

@ -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("<html></html>",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("<html></html>",null,null) }
this@LauncherActivity.callBack?.invoke()
this@LauncherActivity.callBack?.collectComplete()
}
}
@ -745,6 +745,30 @@ internal class LauncherActivity : AppCompatActivity() {
// binding.searcher01?.post { binding.searcher01.loadData("<html></html>",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()
}

View File

@ -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()
}

View File

@ -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() {

View File

@ -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<View>(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<CiliMagnet>()
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("&amp;","&")
}
}
}
}.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<RssDataType>().apply {
addAll(RssDataType.values())
remove(RssDataType.GURU)
remove(RssDataType.Most)
})
"onews" -> home?.queryInfos(arrayListOf<RssDataType>().apply {
addAll(RssDataType.values())
remove(RssDataType.NewsFeed)
})
"ored" -> home?.queryInfos(arrayListOf<RssDataType>().apply {
addAll(RssDataType.values())
remove(RssDataType.REDDIT)
})
"most" -> {
consoleLog("current j req() ${WorkersDb.getRealm()
.query<RssData>("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<RssData>("category == $0", RssDataType.GURU.name)
.query<RssData>("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<RssData>("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<RssData>("category == $0", RssDataType.GURU.name).find().size}")
}
})
// {
// consoleLog("excuted j req() ${WorkersDb.getRealm()
// .query<RssData>("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<RssData>("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) {

View File

@ -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<RssDataInterface>()
}
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<RssData>? = null
var lastedNoti : RealmResults<NotificationItem>? = 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<RssData>().query("pubDate > $0",beforeDay(Date(),3)).query("category != $0", RssDataType.GURU.name).sort("pubDate ", Sort.DESCENDING).find()
mNotificationResult = WorkersDb.getRealm().query<NotificationItem>().sort("postTime",Sort.DESCENDING).find()
job = CoroutineScope(Dispatchers.Default).launch {
mRssDataResult.asFlow().collect { changes: ResultsChange<RssData> ->
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<RssData>().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<NotificationItem> ->
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<NotificationItem>().sort("postTime",Sort.DESCENDING).find()
noticeJob = CoroutineScope(Dispatchers.Default).launch {
mNotificationResult?.asFlow()?.collect { changes: ResultsChange<NotificationItem> ->
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<NotificationItem>().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<RssDataType>? = 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<RssData>().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<RssData>().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<RssData> ->
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<RssData>
lateinit var mNotificationResult : RealmResults<NotificationItem>
var mRssDataResult : RealmResults<RssData>? = null
var mNotificationResult : RealmResults<NotificationItem>? = 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)
}
}

View File

@ -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)
}

View File

@ -5,6 +5,7 @@ enum class RssDataType {
YOUTUBE,
NewsFeed,
GURU,
Most,
TAGS,
REDDIT,
Dotax,

View File

@ -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
}
}
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
}
}

View File

@ -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

View File

@ -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)
}

View File

@ -30,7 +30,7 @@ object WorkersDb {
fun insertData(rssData: RssData) {
getRealm().apply {
this.writeBlocking {
this.copyToRealm(rssData)
this.copyToRealm(rssData, UpdatePolicy.ALL)
}
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
@ -7,6 +7,7 @@
android:orientation="vertical">
<com.google.android.material.button.MaterialButtonToggleGroup
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/expandableButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -31,7 +32,15 @@
/>
</com.google.android.material.button.MaterialButtonToggleGroup>
<TextView
app:layout_constraintTop_toBottomOf="@id/expandableButtons"
android:id="@+id/consoleLog"
android:maxHeight="300dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<RelativeLayout
app:layout_constraintTop_toBottomOf="@id/consoleLog"
android:id="@+id/explayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
@ -50,10 +59,12 @@
</RelativeLayout>
<ScrollView
app:layout_constraintTop_toBottomOf="@id/explayer"
android:layout_margin="10dp"
android:background="@drawable/base_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
android:fillViewport="true"
android:scrollbars="none">
<androidx.appcompat.widget.LinearLayoutCompat
@ -63,4 +74,4 @@
android:orientation="vertical"/>
</ScrollView>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,19 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_margin="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!--rasel.lunar.launcher.view.CircleImageView-->
<ImageView
app:layout_constraintTop_toTopOf="parent"
<com.google.android.material.imageview.ShapeableImageView
app:layout_constraintTop_toTopOf="@id/title"
app:shapeAppearanceOverlay="@style/roundedImageView"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toBottomOf="@id/date"
android:id="@+id/circle_preview"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_width="120dp"
android:layout_height="wrap_content"/>
android:layout_width="wrap_content"
android:layout_height="0dp"/>
<TextView
android:id="@+id/title"

View File

@ -7,7 +7,7 @@
android:id="@+id/colorInputLayout"
android:layout_width="@dimen/oneNinetySix"
android:layout_height="wrap_content"
android:hint="@string/argb"
android:hint="inpout text"
app:boxBackgroundColor="?attr/colorSurface"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
@ -23,5 +23,4 @@
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -15,4 +15,9 @@
<item name="sliderStyle">@style/Slider</item>
<item name="scrimBackground">@color/almost_transparent</item>
</style>
<style name="roundedImageView" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">8dp</item>
</style>
</resources>