From 3e8c29346d231c2eeb11b4b2d6f55e37562dba99 Mon Sep 17 00:00:00 2001 From: lunaticbum <> Date: Fri, 13 Sep 2024 14:54:46 +0900 Subject: [PATCH] ... --- .../rasel/lunar/launcher/home/LauncherHome.kt | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) 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 82b3a377..6067cef2 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt @@ -379,7 +379,7 @@ internal class LauncherHome : Fragment() { infosJob?.start() } - fun queryInfos(keyword : String, category : String? = null) { + fun queryInfos(keyword : String, category : ArrayList = arrayListOf()) { BLog.LOGE("${this} ::::: queryInfos >>>> ${keyword}") try { infosJob?.cancel() } catch (e:Exception) {e.printStackTrace()} mRssDataResult = null @@ -406,6 +406,7 @@ internal class LauncherHome : Fragment() { keyword ) }else { + rQ = rQ.query( "title CONTAINS $0 OR title CONTAINS $1", keyword.toUpperCase(), @@ -413,10 +414,16 @@ internal class LauncherHome : Fragment() { ) } } - - category?.let { - rQ = rQ.query("category == $0", it) + var queryString = "" + category.forEachIndexed { idx , it -> + if (idx == 0) { + queryString = queryString.plus("category == '${it}'") + } else { + queryString = queryString.plus(" OR category == '${it}' ") + } } + + rQ = rQ.query(queryString) BLog.LOGE("queryInfos rQ.description() >>>>> ${rQ.description()}") //limit(1000) mRssDataResult = rQ.sort("pubDate ", Sort.DESCENDING).find() @@ -566,10 +573,17 @@ internal class LauncherHome : Fragment() { var tb = TableRow(requireContext()) it.forEach { c -> if(c.equals(RssDataType.NO_DATA) == false) { - tb.addView(RadioButton(requireContext()).apply { - this.tag = c.name - this.text = c.name - }) + tb.addView( + RadioButton(requireContext()).apply { + this.tag = c.name + this.text = c.name + setOnClickListener { + (it as? RadioButton)?.let { + it.isChecked = !it.isChecked + } + } + } + ) } } categoryz.addView(tb) @@ -579,12 +593,12 @@ internal class LauncherHome : Fragment() { builder.setPositiveButton(android.R.string.ok, DialogInterface.OnClickListener { dialog, which -> dialog.dismiss() - var category : String? = null + var category = arrayListOf() categoryz.children.forEach { if(it is TableRow) { it.children.forEach { if (it is RadioButton && it.isChecked) { - (it.tag as? String)?.let { category = it } + (it.tag as? String)?.let { category.add(it) } } } }