From 96f6323d54f90314e4b7994a2b9fc7876ac8cb11 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Tue, 18 Jan 2022 09:04:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EQQ=E9=A2=91=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 1 + .../myreader/model/sourceAnalyzer/BookSourceManager.java | 4 ++++ .../fycz/myreader/ui/activity/SourceEditActivity.java | 9 +++++++++ app/src/main/res/layout/activity_search_book.xml | 2 +- app/src/main/res/menu/menu_source_edit.xml | 5 +++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index a92f8ed..6f853a3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -52,6 +52,7 @@ + diff --git a/app/src/main/java/xyz/fycz/myreader/model/sourceAnalyzer/BookSourceManager.java b/app/src/main/java/xyz/fycz/myreader/model/sourceAnalyzer/BookSourceManager.java index 2985c0c..606ecc6 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/sourceAnalyzer/BookSourceManager.java +++ b/app/src/main/java/xyz/fycz/myreader/model/sourceAnalyzer/BookSourceManager.java @@ -189,6 +189,10 @@ public class BookSourceManager { DbManager.getDaoSession().getBookSourceDao().deleteInTx(sources); } + public static boolean isBookSourceExist(BookSource source){ + if (source == null) return false; + return DbManager.getDaoSession().getBookSourceDao().load(source.getSourceUrl()) != null; + } public static String getBookSourceSort() { switch (SharedPreUtils.getInstance().getInt("SourceSort", 0)) { diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java index 7dcd369..41efdee 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java @@ -182,6 +182,15 @@ public class SourceEditActivity extends BaseActivity { } else if (item.getItemId() == R.id.action_clear_cookie) { DbManager.getDaoSession().getCookieBeanDao().deleteByKey(getSource().getSourceUrl()); ToastUtils.showSuccess("Cookie清除成功"); + } else if (item.getItemId() == R.id.action_delete) { + if (BookSourceManager.isBookSourceExist(source)) { + BookSourceManager.removeBookSource(source); + setResult(Activity.RESULT_OK); + ToastUtils.showSuccess("书源删除成功"); + finish(); + } else { + ToastUtils.showWarring("当前书源暂未保存,无法删除"); + } } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/res/layout/activity_search_book.xml b/app/src/main/res/layout/activity_search_book.xml index 56bf83e..d9f2477 100644 --- a/app/src/main/res/layout/activity_search_book.xml +++ b/app/src/main/res/layout/activity_search_book.xml @@ -151,7 +151,7 @@ android:layout_height="wrap_content" android:orientation="vertical" android:paddingHorizontal="5dp" - android:visibility="visible"> + android:visibility="gone"> + + \ No newline at end of file