From 0da3abcc883c18b9ad7d2b56702547b34be5eef4 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 16 Jan 2021 19:36:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=B9=A6=E6=BA=90=E6=98=AF?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=88=86=E7=BB=84=E5=8F=AF=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/dao/RssSourceDao.kt | 5 ++++- .../app/ui/association/ImportRssSourceDialog.kt | 15 +++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt b/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt index 001877246..deaa45726 100644 --- a/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt @@ -37,9 +37,12 @@ interface RssSourceDao { @Query("SELECT * FROM rssSources where enabled = 1 and sourceGroup like :searchKey order by customOrder") fun liveEnabledByGroup(searchKey: String): LiveData> - @Query("select sourceGroup from rssSources where trim(sourceGroup) <> ''") + @Query("select distinct sourceGroup from rssSources where trim(sourceGroup) <> ''") fun liveGroup(): LiveData> + @get:Query("select distinct sourceGroup from rssSources where trim(sourceGroup) <> ''") + val allGroup: List + @get:Query("select min(customOrder) from rssSources") val minOrder: Int diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt index 41bda67fd..5ad9aeee7 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt @@ -10,10 +10,12 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.widget.Toolbar import androidx.recyclerview.widget.LinearLayoutManager +import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.RecyclerAdapter +import io.legado.app.constant.AppPattern import io.legado.app.constant.PreferKey import io.legado.app.data.entities.RssSource import io.legado.app.databinding.DialogEditTextBinding @@ -21,10 +23,8 @@ import io.legado.app.databinding.DialogRecyclerViewBinding import io.legado.app.databinding.ItemSourceImportBinding import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert -import io.legado.app.utils.getViewModelOfActivity -import io.legado.app.utils.putPrefBoolean +import io.legado.app.utils.* import io.legado.app.utils.viewbindingdelegate.viewBinding -import io.legado.app.utils.visible import org.jetbrains.anko.sdk27.listeners.onClick /** @@ -85,7 +85,14 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe when (item.itemId) { R.id.menu_new_group -> { alert(R.string.diy_edit_source_group) { - val alertBinding = DialogEditTextBinding.inflate(layoutInflater) + val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { + val groups = linkedSetOf() + App.db.rssSourceDao.allGroup.forEach { group -> + groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex)) + } + editView.setFilterValues(groups.toList()) + editView.dropDownHeight = 180.dp + } customView = alertBinding.root okButton { alertBinding.editView.text?.toString()?.let { group ->