From 16a6683d7a551b635d069ec919d3160ad958c36a Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 16 Sep 2022 09:32:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/main/explore/ExploreAdapter.kt | 8 ++------ .../io/legado/app/ui/main/explore/ExploreFragment.kt | 11 +++++++++++ .../io/legado/app/ui/main/explore/ExploreViewModel.kt | 8 ++++++++ app/src/main/res/layout/item_change_source.xml | 2 ++ app/src/main/res/values-es-rES/strings.xml | 4 ++-- app/src/main/res/values-ja-rJP/strings.xml | 4 ++-- app/src/main/res/values-pt-rBR/strings.xml | 4 ++-- app/src/main/res/values-zh-rHK/strings.xml | 4 ++-- app/src/main/res/values-zh-rTW/strings.xml | 4 ++-- app/src/main/res/values-zh/strings.xml | 4 ++-- app/src/main/res/values/strings.xml | 4 ++-- 11 files changed, 37 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt index 41890da49..a06dfee5c 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt @@ -10,12 +10,10 @@ import com.google.android.flexbox.FlexboxLayout import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.RecyclerAdapter -import io.legado.app.data.appDb import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.rule.ExploreKind import io.legado.app.databinding.ItemFilletTextBinding import io.legado.app.databinding.ItemFindBookBinding -import io.legado.app.help.config.SourceConfig import io.legado.app.help.coroutine.Coroutine import io.legado.app.lib.theme.accentColor import io.legado.app.ui.login.SourceLoginActivity @@ -173,10 +171,7 @@ class ExploreAdapter(context: Context, val callBack: CallBack) : }.onSuccess { callBack.refreshData() } - R.id.menu_del -> Coroutine.async(callBack.scope) { - appDb.bookSourceDao.delete(source) - SourceConfig.removeSource(source.bookSourceUrl) - } + R.id.menu_del -> callBack.deleteSource(source) } true } @@ -191,5 +186,6 @@ class ExploreAdapter(context: Context, val callBack: CallBack) : fun openExplore(sourceUrl: String, title: String, exploreUrl: String?) fun editSource(sourceUrl: String) fun toTop(source: BookSource) + fun deleteSource(source: BookSource) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt index 46b1cd1c1..d9d29b4b0 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt @@ -18,6 +18,7 @@ import io.legado.app.data.appDb import io.legado.app.data.entities.BookSource import io.legado.app.databinding.FragmentExploreBinding import io.legado.app.help.config.AppConfig +import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryTextColor import io.legado.app.ui.book.explore.ExploreShowActivity @@ -183,6 +184,16 @@ class ExploreFragment : VMBaseFragment(R.layout.fragment_explo viewModel.topSource(source) } + override fun deleteSource(source: BookSource) { + alert(R.string.draw) { + setMessage(getString(R.string.sure_del) + "\n" + source.bookSourceName) + noButton() + yesButton { + viewModel.deleteSource(source) + } + } + } + fun compressExplore() { if (!adapter.compressExplore()) { if (AppConfig.isEInkMode) { diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreViewModel.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreViewModel.kt index e6a2cc569..34bf44b9b 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreViewModel.kt @@ -4,6 +4,7 @@ import android.app.Application import io.legado.app.base.BaseViewModel import io.legado.app.data.appDb import io.legado.app.data.entities.BookSource +import io.legado.app.help.config.SourceConfig class ExploreViewModel(application: Application) : BaseViewModel(application) { @@ -15,4 +16,11 @@ class ExploreViewModel(application: Application) : BaseViewModel(application) { } } + fun deleteSource(source: BookSource) { + execute { + appDb.bookSourceDao.delete(source) + SourceConfig.removeSource(source.bookSourceUrl) + } + } + } \ No newline at end of file diff --git a/app/src/main/res/layout/item_change_source.xml b/app/src/main/res/layout/item_change_source.xml index 4be15d5b3..672c8545c 100644 --- a/app/src/main/res/layout/item_change_source.xml +++ b/app/src/main/res/layout/item_change_source.xml @@ -14,6 +14,7 @@ android:layout_marginTop="5dp" android:padding="5dp" android:src="@drawable/ic_praise" + android:contentDescription="赞" app:layout_constraintBottom_toTopOf="@+id/iv_bad" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" @@ -27,6 +28,7 @@ android:padding="5dp" android:rotationX="180" android:src="@drawable/ic_praise" + android:contentDescription="踩" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toBottomOf="@+id/iv_good" diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index b4e47cd47..d80056edd 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -1016,8 +1016,8 @@ 段评内容(contentRule) 段评回复URL(reviewQuoteUrl) 段评发布时间(postTimeRule) - 点踩URL(voteUpUrl) - 点赞URL(voteDownUrl) + 点踩URL(voteDownUrl) + 点赞URL(voteUpUrl) 发送回复URL(postReviewUrl) 发送回复段评URL(postQuoteUrl) 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index e1cdf5197..86f762a25 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -1019,8 +1019,8 @@ 段评内容(contentRule) 段评发布时间(postTimeRule) 段评回复URL(reviewQuoteUrl) - 点踩URL(voteUpUrl) - 点赞URL(voteDownUrl) + 点踩URL(voteDownUrl) + 点赞URL(voteUpUrl) 发送回复URL(postReviewUrl) 发送回复段评URL(postQuoteUrl) 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 6c7f0b320..85dd66c8f 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1019,8 +1019,8 @@ 段评内容(contentRule) 段评发布时间(postTimeRule) 段评回复URL(reviewQuoteUrl) - 点踩URL(voteUpUrl) - 点赞URL(voteDownUrl) + 点踩URL(voteDownUrl) + 点赞URL(voteUpUrl) 发送回复URL(postReviewUrl) 发送回复段评URL(postQuoteUrl) 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 0857f25d7..c3ed8508d 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1016,8 +1016,8 @@ 段评内容(contentRule) 段评发布时间(postTimeRule) 段评回复URL(reviewQuoteUrl) - 点踩URL(voteUpUrl) - 点赞URL(voteDownUrl) + 点踩URL(voteDownUrl) + 点赞URL(voteUpUrl) 发送回复URL(postReviewUrl) 发送回复段评URL(postQuoteUrl) 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index dbc30e0e4..1735d2c71 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1018,8 +1018,8 @@ 段评内容(contentRule) 段评发布时间(postTimeRule) 段评回复URL(reviewQuoteUrl) - 点踩URL(voteUpUrl) - 点赞URL(voteDownUrl) + 点踩URL(voteDownUrl) + 点赞URL(voteUpUrl) 发送回复URL(postReviewUrl) 发送回复段评URL(postQuoteUrl) 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 014b0e727..a8479735a 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1018,8 +1018,8 @@ 段评内容(contentRule) 段评发布时间(postTimeRule) 段评回复URL(reviewQuoteUrl) - 点踩URL(voteUpUrl) - 点赞URL(voteDownUrl) + 点踩URL(voteDownUrl) + 点赞URL(voteUpUrl) 发送回复URL(postReviewUrl) 发送回复段评URL(postQuoteUrl) 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b8e307ae6..1774d7326 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1019,8 +1019,8 @@ 段评内容(contentRule) 段评发布时间(postTimeRule) 段评回复URL(reviewQuoteUrl) - 点踩URL(voteUpUrl) - 点赞URL(voteDownUrl) + 点踩URL(voteDownUrl) + 点赞URL(voteUpUrl) 发送回复URL(postReviewUrl) 发送回复段评URL(postQuoteUrl) 删除段评URL(deleteUrl)