From 463487f1613aaa1ce372ea8f03cc64d9cdd94881 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Fri, 23 Jul 2021 12:28:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=8F=91=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/sourceedit/EditEntityUtil.kt | 157 +++++++++++++++--- .../ui/activity/FindBookActivity.java | 6 +- .../myreader/ui/activity/MainActivity.java | 4 + .../ui/activity/SourceEditActivity.java | 10 +- .../ui/adapter/holder/FindSourceHolder.java | 1 + .../myreader/ui/fragment/FindFragment.java | 73 +++++--- .../crawler/find/QiDianFindCrawler.java | 3 + .../crawler/find/QianDianNSFindCrawler.java | 11 ++ .../crawler/source/find/ThirdFindCrawler.java | 2 +- .../main/res/layout/activity_source_edit.xml | 4 +- app/src/main/res/layout/fragment_find.xml | 91 ---------- app/src/main/res/layout/item_find_source.xml | 17 +- app/src/main/res/layout/item_read_record.xml | 2 +- app/src/main/res/menu/menu_book.xml | 92 +++++----- 14 files changed, 283 insertions(+), 190 deletions(-) create mode 100644 app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QianDianNSFindCrawler.java diff --git a/app/src/main/java/xyz/fycz/myreader/entity/sourceedit/EditEntityUtil.kt b/app/src/main/java/xyz/fycz/myreader/entity/sourceedit/EditEntityUtil.kt index 11b781a..14b60b3 100644 --- a/app/src/main/java/xyz/fycz/myreader/entity/sourceedit/EditEntityUtil.kt +++ b/app/src/main/java/xyz/fycz/myreader/entity/sourceedit/EditEntityUtil.kt @@ -3,6 +3,7 @@ package xyz.fycz.myreader.entity.sourceedit import xyz.fycz.myreader.R import xyz.fycz.myreader.greendao.entity.rule.* import java.util.* +import kotlin.collections.ArrayList /** * @author fengyue @@ -15,8 +16,22 @@ object EditEntityUtil { add(EditEntity("sourceUrl", source?.sourceUrl, R.string.source_url, "不能为空且唯一")) add(EditEntity("sourceName", source?.sourceName, R.string.source_name, "不能为空")) add(EditEntity("sourceGroup", source?.sourceGroup, R.string.source_group, "不同分组以;/,隔开")) - add(EditEntity("sourceCharset", source?.sourceCharset, R.string.source_charset, "默认UTF-8")) - add(EditEntity("sourceHeaders", source?.sourceHeaders, R.string.source_headers, "json格式")) + add( + EditEntity( + "sourceCharset", + source?.sourceCharset, + R.string.source_charset, + "默认UTF-8" + ) + ) + add( + EditEntity( + "sourceHeaders", + source?.sourceHeaders, + R.string.source_headers, + "json格式" + ) + ) add(EditEntity("loginUrl", source?.loginUrl, R.string.login_url, "")) add(EditEntity("sourceComment", source?.sourceComment, R.string.comment, "这是您留给使用者的说明")) } @@ -26,12 +41,20 @@ object EditEntityUtil { fun getSearchEntities(searchRule: SearchRule? = SearchRule()): List { val searchEntities: ArrayList = ArrayList() searchEntities.apply { - add(EditEntity("searchUrl", searchRule?.searchUrl, R.string.r_search_url, - "搜索关键词以{key}进行占位;post请求以“,”分隔url,“,”前是搜索地址,“,”后是请求体")) + add( + EditEntity( + "searchUrl", searchRule?.searchUrl, R.string.r_search_url, + "搜索关键词以{key}进行占位;post请求以“,”分隔url,“,”前是搜索地址,“,”后是请求体" + ) + ) add(EditEntity("charset", searchRule?.charset, R.string.r_search_charset, "默认使用书源字符编码")) - add(EditEntity("list", searchRule?.list, R.string.r_book_list, + add( + EditEntity( + "list", searchRule?.list, R.string.r_book_list, "对于Matcher解析器:此处填写书籍列表所在区间,仅支持普通函数;" + - "\n对于Xpath/JsonPath解析器:此处填写书籍列表规则,仅支持列表函数")) + "\n对于Xpath/JsonPath解析器:此处填写书籍列表规则,仅支持列表函数" + ) + ) add(EditEntity("name", searchRule?.name, R.string.r_book_name)) add(EditEntity("author", searchRule?.author, R.string.r_author)) add(EditEntity("type", searchRule?.type, R.string.rule_book_type)) @@ -43,12 +66,44 @@ object EditEntityUtil { add(EditEntity("imgUrl", searchRule?.imgUrl, R.string.rule_img_url)) add(EditEntity("tocUrl", searchRule?.tocUrl, R.string.rule_toc_url)) add(EditEntity("infoUrl", searchRule?.infoUrl, R.string.r_info_url, "为空时使用目录URL")) - add(EditEntity("relatedWithInfo", searchRule?.isRelatedWithInfo?.toString(), R.string.r_search_related_with_info, - "搜索时是否关联书籍详情页,填true/t表示关联,false/f表示不关联,测试时不生效")) + add( + EditEntity( + "relatedWithInfo", + searchRule?.isRelatedWithInfo?.toString(), + R.string.r_search_related_with_info, + "搜索时是否关联书籍详情页,填true/t表示关联,false/f表示不关联,测试时不生效" + ) + ) } return searchEntities } + fun getFindEntities(findRule: FindRule? = FindRule()): List { + val findEntities: ArrayList = ArrayList() + findEntities.apply { + add(EditEntity("url", findRule?.url, R.string.r_find_url)) + add( + EditEntity( + "bookList", findRule?.bookList, R.string.r_book_list, + "对于Matcher解析器:此处填写书籍列表所在区间,仅支持普通函数;" + + "\n对于Xpath/JsonPath解析器:此处填写书籍列表规则,仅支持列表函数" + ) + ) + add(EditEntity("name", findRule?.name, R.string.r_book_name)) + add(EditEntity("author", findRule?.author, R.string.r_author)) + add(EditEntity("type", findRule?.type, R.string.rule_book_type)) + add(EditEntity("wordCount", findRule?.wordCount, R.string.rule_word_count)) + add(EditEntity("status", findRule?.status, R.string.rule_status)) + add(EditEntity("desc", findRule?.desc, R.string.rule_book_desc)) + add(EditEntity("lastChapter", findRule?.lastChapter, R.string.rule_last_chapter)) + add(EditEntity("updateTime", findRule?.updateTime, R.string.rule_update_time)) + add(EditEntity("imgUrl", findRule?.imgUrl, R.string.rule_img_url)) + add(EditEntity("tocUrl", findRule?.tocUrl, R.string.rule_toc_url)) + add(EditEntity("infoUrl", findRule?.infoUrl, R.string.r_info_url)) + } + return findEntities + } + fun getInfoEntities(infoRule: InfoRule? = InfoRule()): List { val infoEntities: ArrayList = ArrayList() infoEntities.apply { @@ -71,19 +126,39 @@ object EditEntityUtil { fun getTocEntities(tocRule: TocRule? = TocRule()): List { val tocEntities: ArrayList = ArrayList() tocEntities.apply { - add(EditEntity("chapterBaseUrl", tocRule?.chapterBaseUrl, R.string.rule_chapter_base_url, - "如果章节URL(一般为相对路径)无法定位章节,可填写此规则获取,默认为书源URL")) - add(EditEntity("chapterList", tocRule?.chapterList, R.string.rule_chapter_list, - "对于Mathcer解析器:此处填写书籍列表所在区间,仅支持普通函数;" + - "\n对于Xpath/JsonPath解析器:此处填写书籍列表规则,仅支持列表函数")) - add(EditEntity("chapterName", tocRule?.chapterName, R.string.rule_chapter_name, - "对于Mathcer解析器:此处填写章节名称和URL规则,其中章节名称以占位,章节URL以<link>占位,仅支持列表函数\n" + - "对于Xpath/JsonPath解析器:此处填写章节名称,仅支持普通函数")) - add(EditEntity("chapterUrl", tocRule?.chapterUrl, R.string.rule_chapter_url, - "对于Mathcer解析器:此处不用填写\n" + - "对于Xpath/JsonPath解析器:此处填写章节URL规则")) - add(EditEntity("tocUrlNext", tocRule?.tocUrlNext, R.string.rule_next_toc_url, - "填写后获取目录时将会不断地从目录下一页获取章节,直至下一页URL为空时停止,注意:千万不要获取恒存在的URL,否则将出现死循环甚至崩溃")) + add( + EditEntity( + "chapterBaseUrl", tocRule?.chapterBaseUrl, R.string.rule_chapter_base_url, + "如果章节URL(一般为相对路径)无法定位章节,可填写此规则获取,默认为书源URL" + ) + ) + add( + EditEntity( + "chapterList", tocRule?.chapterList, R.string.rule_chapter_list, + "对于Mathcer解析器:此处填写书籍列表所在区间,仅支持普通函数;" + + "\n对于Xpath/JsonPath解析器:此处填写书籍列表规则,仅支持列表函数" + ) + ) + add( + EditEntity( + "chapterName", tocRule?.chapterName, R.string.rule_chapter_name, + "对于Mathcer解析器:此处填写章节名称和URL规则,其中章节名称以<title>占位,章节URL以<link>占位,仅支持列表函数\n" + + "对于Xpath/JsonPath解析器:此处填写章节名称,仅支持普通函数" + ) + ) + add( + EditEntity( + "chapterUrl", tocRule?.chapterUrl, R.string.rule_chapter_url, + "对于Mathcer解析器:此处不用填写\n" + + "对于Xpath/JsonPath解析器:此处填写章节URL规则" + ) + ) + add( + EditEntity( + "tocUrlNext", tocRule?.tocUrlNext, R.string.rule_next_toc_url, + "填写后获取目录时将会不断地从目录下一页获取章节,直至下一页URL为空时停止,注意:千万不要获取恒存在的URL,否则将出现死循环甚至崩溃" + ) + ) } return tocEntities } @@ -92,14 +167,23 @@ object EditEntityUtil { val contentEntities: ArrayList<EditEntity> = ArrayList() contentEntities.apply { add(EditEntity("content", contentRule?.content, R.string.rule_book_content)) - add(EditEntity("contentBaseUrl", contentRule?.contentBaseUrl, R.string.rule_base_url_content, - "如果下一页URL(一般为相对路径)无法定位下一页,可填写此规则获取,默认为书源URL")) - add(EditEntity("contentUrlNext", contentRule?.contentUrlNext, R.string.rule_next_content, - "填写后正文时将会不断地从下一页获取内容,直至下一页URL为空时停止,注意:千万不要获取恒存在的URL,否则将出现死循环甚至崩溃")) + add( + EditEntity( + "contentBaseUrl", contentRule?.contentBaseUrl, R.string.rule_base_url_content, + "如果下一页URL(一般为相对路径)无法定位下一页,可填写此规则获取,默认为书源URL" + ) + ) + add( + EditEntity( + "contentUrlNext", contentRule?.contentUrlNext, R.string.rule_next_content, + "填写后正文时将会不断地从下一页获取内容,直至下一页URL为空时停止,注意:千万不要获取恒存在的URL,否则将出现死循环甚至崩溃" + ) + ) } return contentEntities } + fun getSource(bookSource: BookSource, sourceEntities: List<EditEntity>): BookSource { val source = bookSource.clone() as BookSource sourceEntities.forEach { @@ -140,6 +224,28 @@ object EditEntityUtil { return searchRule } + fun getFindRule(findEntities: List<EditEntity>): FindRule { + val findRule = FindRule() + findEntities.forEach { + when (it.key) { + "url" -> findRule.url = it.value + "bookList" -> findRule.bookList = it.value + "name" -> findRule.name = it.value + "author" -> findRule.author = it.value + "type" -> findRule.type = it.value + "desc" -> findRule.desc = it.value + "wordCount" -> findRule.wordCount = it.value + "status" -> findRule.status = it.value + "lastChapter" -> findRule.lastChapter = it.value + "updateTime" -> findRule.updateTime = it.value + "imgUrl" -> findRule.imgUrl = it.value + "tocUrl" -> findRule.tocUrl = it.value + "infoUrl" -> findRule.infoUrl = it.value + } + } + return findRule + } + fun getInfoRule(infoRuleEntities: List<EditEntity>): InfoRule { val infoRule = InfoRule() infoRuleEntities.forEach { @@ -186,4 +292,5 @@ object EditEntityUtil { } return contentRule } + } \ No newline at end of file diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/FindBookActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/FindBookActivity.java index f902bea..5748fd3 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/FindBookActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/FindBookActivity.java @@ -6,13 +6,9 @@ import android.view.MenuItem; import android.view.View; import androidx.appcompat.widget.Toolbar; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentPagerAdapter; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.List; import io.reactivex.disposables.Disposable; @@ -28,7 +24,6 @@ import xyz.fycz.myreader.ui.fragment.FindBook1Fragment; import xyz.fycz.myreader.util.ToastUtils; import xyz.fycz.myreader.util.utils.RxUtils; import xyz.fycz.myreader.webapi.crawler.base.FindCrawler; -import xyz.fycz.myreader.webapi.crawler.find.QiDianFindCrawler; import xyz.fycz.myreader.webapi.crawler.source.find.ThirdFindCrawler; /** @@ -58,6 +53,7 @@ public class FindBookActivity extends BaseActivity { findCrawler = (FindCrawler) obj; } if (findCrawler == null) { + ToastUtils.showError("findCrawler为null"); finish(); return; } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java index 382d380..5616c24 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java @@ -266,6 +266,7 @@ public class MainActivity extends BaseActivity { menu.setGroupVisible(R.id.bookcase_menu, false); menu.findItem(R.id.action_finish).setVisible(false); } + menu.setGroupVisible(R.id.find_menu, binding.viewPagerMain.getCurrentItem() == 1); return super.onPrepareOptionsMenu(menu); } @@ -305,6 +306,9 @@ public class MainActivity extends BaseActivity { } else if (itemId == R.id.action_qr_scan) { Intent intent = new Intent(this, QRCodeScanActivity.class); startActivityForResult(intent, APPCONST.REQUEST_QR_SCAN); + } else if (itemId == R.id.action_refresh_find){ + mFindFragment.refreshFind(); + return true; } return mBookcaseFragment.getmBookcasePresenter().onOptionsItemSelected(item); } 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 049bb5f..7dcd369 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 @@ -45,6 +45,7 @@ public class SourceEditActivity extends BaseActivity { private List<EditEntity> infoEntities; private List<EditEntity> tocEntities; private List<EditEntity> contentEntities; + private List<EditEntity> findEntities; private EditEntityUtil entityUtil; private SourceEditAdapter adapter; @@ -83,6 +84,7 @@ public class SourceEditActivity extends BaseActivity { private void initEntities(BookSource source) { sourceEntities = entityUtil.getSourceEntities(source); searchEntities = entityUtil.getSearchEntities(source.getSearchRule()); + findEntities = entityUtil.getFindEntities(source.getFindRule()); infoEntities = entityUtil.getInfoEntities(source.getInfoRule()); tocEntities = entityUtil.getTocEntities(source.getTocRule()); contentEntities = entityUtil.getContentEntities(source.getContentRule()); @@ -243,12 +245,15 @@ public class SourceEditActivity extends BaseActivity { adapter.refreshItems(searchEntities); break; case 2: - adapter.refreshItems(infoEntities); + adapter.refreshItems(findEntities); break; case 3: - adapter.refreshItems(tocEntities); + adapter.refreshItems(infoEntities); break; case 4: + adapter.refreshItems(tocEntities); + break; + case 5: adapter.refreshItems(contentEntities); break; default: @@ -284,6 +289,7 @@ public class SourceEditActivity extends BaseActivity { } source.setSourceType(sourceType); source.setSearchRule(entityUtil.getSearchRule(searchEntities)); + source.setFindRule(entityUtil.getFindRule(findEntities)); source.setInfoRule(entityUtil.getInfoRule(infoEntities)); source.setTocRule(entityUtil.getTocRule(tocEntities)); source.setContentRule(entityUtil.getContentRule(contentEntities)); diff --git a/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/FindSourceHolder.java b/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/FindSourceHolder.java index ee0cac7..5910762 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/FindSourceHolder.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/FindSourceHolder.java @@ -1,6 +1,7 @@ package xyz.fycz.myreader.ui.adapter.holder; import android.content.Intent; +import android.widget.ImageView; import android.widget.TextView; import androidx.recyclerview.widget.RecyclerView; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/FindFragment.java b/app/src/main/java/xyz/fycz/myreader/ui/fragment/FindFragment.java index 0d8fb47..cd26735 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/fragment/FindFragment.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/FindFragment.java @@ -25,21 +25,20 @@ import xyz.fycz.myreader.base.adapter.BaseListAdapter; import xyz.fycz.myreader.base.adapter.IViewHolder; import xyz.fycz.myreader.base.observer.MyObserver; import xyz.fycz.myreader.base.observer.MySingleObserver; +import xyz.fycz.myreader.common.APPCONST; import xyz.fycz.myreader.common.URLCONST; import xyz.fycz.myreader.databinding.FragmentFindBinding; import xyz.fycz.myreader.entity.Quotation; import xyz.fycz.myreader.greendao.entity.rule.BookSource; import xyz.fycz.myreader.model.sourceAnalyzer.BookSourceManager; import xyz.fycz.myreader.ui.activity.FindBookActivity; +import xyz.fycz.myreader.ui.activity.SourceEditActivity; import xyz.fycz.myreader.ui.adapter.holder.FindSourceHolder; +import xyz.fycz.myreader.util.ToastUtils; import xyz.fycz.myreader.util.utils.GsonExtensionsKt; import xyz.fycz.myreader.util.utils.OkHttpUtils; import xyz.fycz.myreader.util.utils.RxUtils; import xyz.fycz.myreader.webapi.crawler.base.FindCrawler; -import xyz.fycz.myreader.webapi.crawler.find.MiaoBiGeFindCrawler; -import xyz.fycz.myreader.webapi.crawler.find.QB5FindCrawler; -import xyz.fycz.myreader.webapi.crawler.find.QiDianFindCrawler; -import xyz.fycz.myreader.widget.DividerItemDecoration; /** * @author fengyue @@ -60,9 +59,10 @@ public class FindFragment extends BaseFragment { protected void initData(Bundle savedInstanceState) { Observable.create((ObservableOnSubscribe<List<BookSource>>) emitter -> { List<BookSource> findSources = new ArrayList<>(); + initLocalFind(findSources); List<BookSource> sources = BookSourceManager.getEnabledBookSourceByOrderNum(); - for (BookSource source : sources){ - if (source.getFindRule() != null && !TextUtils.isEmpty(source.getFindRule().getUrl())){ + for (BookSource source : sources) { + if (source.getFindRule() != null && !TextUtils.isEmpty(source.getFindRule().getUrl())) { findSources.add(source); } } @@ -81,6 +81,25 @@ public class FindFragment extends BaseFragment { }); } + private void initLocalFind(List<BookSource> findSources) { + BookSource source1 = new BookSource(); + source1.setSourceName("起点中文网"); + source1.setSourceUrl("xyz.fycz.myreader.webapi.crawler.find.QiDianFindCrawler"); + BookSource source2 = new BookSource(); + source2.setSourceName("起点女生网"); + source2.setSourceUrl("xyz.fycz.myreader.webapi.crawler.find.QianDianNSFindCrawler"); + BookSource source3 = new BookSource(); + source3.setSourceName("妙笔阁"); + source3.setSourceUrl("xyz.fycz.myreader.webapi.crawler.find.MiaoBiGeFindCrawler"); + BookSource source4 = new BookSource(); + source4.setSourceName("全本小说"); + source4.setSourceUrl("xyz.fycz.myreader.webapi.crawler.find.QB5FindCrawler"); + findSources.add(source1); + findSources.add(source2); + findSources.add(source3); + findSources.add(source4); + } + private void initFindSources(List<BookSource> findSources) { findSourcesAdapter = new BaseListAdapter<BookSource>() { @Override @@ -91,14 +110,36 @@ public class FindFragment extends BaseFragment { binding.rvFindSources.setLayoutManager(new LinearLayoutManager(getContext())); binding.rvFindSources.setAdapter(findSourcesAdapter); //设置分割线 - binding.rvFindSources.addItemDecoration(new DividerItemDecoration(getContext())); +// binding.rvFindSources.addItemDecoration(new DividerItemDecoration(getContext())); findSourcesAdapter.setOnItemClickListener((view, pos) -> { Intent intent = new Intent(getContext(), FindBookActivity.class); - BitIntentDataManager.getInstance().putData(intent, findSourcesAdapter.getItem(pos)); + BookSource source = findSourcesAdapter.getItem(pos); + if (source.getFindRule() == null) { + FindCrawler findCrawler = null; + try { + findCrawler = (FindCrawler) Class.forName(source.getSourceUrl()).newInstance(); + } catch (IllegalAccessException | java.lang.InstantiationException | ClassNotFoundException e) { + e.printStackTrace(); + } + BitIntentDataManager.getInstance().putData(intent, findCrawler); + } else { + BitIntentDataManager.getInstance().putData(intent, source); + } getContext().startActivity(intent); }); + findSourcesAdapter.setOnItemLongClickListener((view, pos) -> { + BookSource source = findSourcesAdapter.getItem(pos); + if (source.getFindRule() == null) { + ToastUtils.showWarring("内置发现无法编辑"); + } else { + Intent intent = new Intent(getContext(), SourceEditActivity.class); + intent.putExtra(APPCONST.BOOK_SOURCE, findSourcesAdapter.getItem(pos)); + getContext().startActivity(intent); + } + return true; + }); findSourcesAdapter.refreshItems(findSources); } @@ -111,17 +152,6 @@ public class FindFragment extends BaseFragment { protected void initClick() { super.initClick(); binding.findRlQuotation.setOnClickListener(v -> getQuotation()); - binding.findRlQidian.setOnClickListener(v -> comeToBookstore(new QiDianFindCrawler(false))); - binding.findRlQidianNs.setOnClickListener(v -> comeToBookstore(new QiDianFindCrawler(true))); - binding.findRlMiaoquStore.setOnClickListener(v -> comeToBookstore(new MiaoBiGeFindCrawler())); - binding.findRlQb5Store.setOnClickListener(v -> comeToBookstore(new QB5FindCrawler())); - } - - - private void comeToBookstore(FindCrawler findCrawler) { - Intent intent = new Intent(getContext(), FindBookActivity.class); - BitIntentDataManager.getInstance().putData(intent, findCrawler); - startActivity(intent); } private void getQuotation() { @@ -133,6 +163,7 @@ public class FindFragment extends BaseFragment { public void onSubscribe(Disposable d) { addDisposable(d); } + @Override public void onSuccess(@NotNull Quotation q) { binding.tvQuotation.setText(q.getHitokoto()); @@ -141,6 +172,10 @@ public class FindFragment extends BaseFragment { }); } + public void refreshFind() { + initData(null); + } + public boolean isRecreate() { return binding == null; } diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianFindCrawler.java b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianFindCrawler.java index dab4c9e..8bee38f 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianFindCrawler.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianFindCrawler.java @@ -43,6 +43,9 @@ public class QiDianFindCrawler extends BaseFindCrawler { private LinkedHashMap<String, Integer> sortName = new LinkedHashMap<>(); private boolean isFemale; + public QiDianFindCrawler() { + } + public QiDianFindCrawler(boolean isFemale) { this.isFemale = isFemale; } diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QianDianNSFindCrawler.java b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QianDianNSFindCrawler.java new file mode 100644 index 0000000..07cb083 --- /dev/null +++ b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QianDianNSFindCrawler.java @@ -0,0 +1,11 @@ +package xyz.fycz.myreader.webapi.crawler.find; + +/** + * @author fengyue + * @date 2021/7/23 12:15 + */ +public class QianDianNSFindCrawler extends QiDianFindCrawler { + public QianDianNSFindCrawler() { + super(true); + } +} diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/source/find/ThirdFindCrawler.java b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/source/find/ThirdFindCrawler.java index 4a19f62..9ff7c3a 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/source/find/ThirdFindCrawler.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/source/find/ThirdFindCrawler.java @@ -80,7 +80,7 @@ public class ThirdFindCrawler extends BaseFindCrawler { } FindKind findKindBean = new FindKind(); findKindBean.setTag(source.getSourceUrl()); - findKindBean.setName(kind[0]); + findKindBean.setName(kind[0].replaceAll("\\s", "")); findKindBean.setUrl(kind[1]); children.add(findKindBean); } diff --git a/app/src/main/res/layout/activity_source_edit.xml b/app/src/main/res/layout/activity_source_edit.xml index 3bcc9fc..95b9fdd 100644 --- a/app/src/main/res/layout/activity_source_edit.xml +++ b/app/src/main/res/layout/activity_source_edit.xml @@ -58,10 +58,10 @@ android:layout_height="wrap_content" android:text="@string/source_tab_search" /> - <!--<com.google.android.material.tabs.TabItem + <com.google.android.material.tabs.TabItem android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/source_tab_find" />--> + android:text="@string/source_tab_find" /> <com.google.android.material.tabs.TabItem android:layout_width="wrap_content" diff --git a/app/src/main/res/layout/fragment_find.xml b/app/src/main/res/layout/fragment_find.xml index 87124c8..9fdb271 100644 --- a/app/src/main/res/layout/fragment_find.xml +++ b/app/src/main/res/layout/fragment_find.xml @@ -92,97 +92,6 @@ android:textSize="@dimen/text_small_size" /> </RelativeLayout> - <RelativeLayout - android:id="@+id/find_rl_qidian" - android:layout_width="match_parent" - android:layout_height="50dp" - android:background="@drawable/selector_common_bg" - android:paddingLeft="20dp" - android:paddingRight="20dp"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerVertical="true" - android:text="@string/find_qidian" - android:textColor="@color/textSecondary" - android:textSize="@dimen/text_normal_size" /> - - </RelativeLayout> - - <RelativeLayout - android:id="@+id/find_rl_qidian_ns" - android:layout_width="match_parent" - android:layout_height="50dp" - android:background="@drawable/selector_common_bg" - android:paddingLeft="20dp" - android:paddingRight="20dp"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerVertical="true" - android:text="@string/find_qidian_ns" - android:textColor="@color/textSecondary" - android:textSize="@dimen/text_normal_size" /> - - </RelativeLayout> - - - <RelativeLayout - android:id="@+id/find_rl_qb5_store" - android:layout_width="match_parent" - android:layout_height="50dp" - android:background="@drawable/selector_common_bg" - android:paddingLeft="20dp" - android:paddingRight="20dp"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerVertical="true" - android:text="@string/read_qb5" - android:textColor="@color/textSecondary" - android:textSize="@dimen/text_normal_size" /> - - </RelativeLayout> - - <RelativeLayout - android:id="@+id/find_rl_miaoqu_store" - android:layout_width="match_parent" - android:layout_height="50dp" - android:background="@drawable/selector_common_bg" - android:paddingLeft="20dp" - android:paddingRight="20dp"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerVertical="true" - android:text="@string/read_miaobi" - android:textColor="@color/textSecondary" - android:textSize="@dimen/text_normal_size" /> - - </RelativeLayout> - - <!--<RelativeLayout - android:id="@+id/find_rl_xs7_store" - android:layout_width="match_parent" - android:layout_height="50dp" - android:paddingLeft="20dp" - android:paddingRight="20dp" - android:background="@drawable/selector_common_bg"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerVertical="true" - android:textColor="@color/textSecondary" - android:textSize="@dimen/text_normal_size" - android:text="@string/read_xs7"/> - - </RelativeLayout>--> - <androidx.recyclerview.widget.RecyclerView android:id="@+id/rv_find_sources" android:layout_width="match_parent" diff --git a/app/src/main/res/layout/item_find_source.xml b/app/src/main/res/layout/item_find_source.xml index c2d9b59..93b3fe7 100644 --- a/app/src/main/res/layout/item_find_source.xml +++ b/app/src/main/res/layout/item_find_source.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> - <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/rl_find_source" android:layout_width="match_parent" android:layout_height="50dp" android:background="@drawable/selector_common_bg" - android:paddingLeft="20dp" - android:paddingRight="20dp"> + android:paddingStart="20dp" + android:paddingEnd="10dp"> <TextView android:id="@+id/tv_name" @@ -17,4 +17,15 @@ android:textColor="@color/textSecondary" android:textSize="@dimen/text_normal_size" /> + <!-- <androidx.appcompat.widget.AppCompatImageView + android:id="@+id/iv_more" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_alignParentEnd="true" + android:layout_centerVertical="true" + android:background="?android:attr/selectableItemBackground" + android:padding="8dp" + app:srcCompat="@drawable/ic_more" + app:tint="@color/textSecondary" />--> + </RelativeLayout> diff --git a/app/src/main/res/layout/item_read_record.xml b/app/src/main/res/layout/item_read_record.xml index e0b6e1e..26e1c84 100644 --- a/app/src/main/res/layout/item_read_record.xml +++ b/app/src/main/res/layout/item_read_record.xml @@ -95,7 +95,7 @@ android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:background="?android:attr/selectableItemBackground" - android:padding="5dp" + android:padding="8dp" app:srcCompat="@drawable/ic_more" app:tint="@color/textSecondary" /> </RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/menu/menu_book.xml b/app/src/main/res/menu/menu_book.xml index 95d3566..480b1bb 100644 --- a/app/src/main/res/menu/menu_book.xml +++ b/app/src/main/res/menu/menu_book.xml @@ -1,57 +1,67 @@ <?xml version="1.0" encoding="utf-8"?> -<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="match_parent"> +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent"> <item - android:id="@+id/action_finish" - android:title="@string/finish" - app:showAsAction="always" - android:visible="false"/> + android:id="@+id/action_finish" + android:title="@string/finish" + android:visible="false" + app:showAsAction="always" /> <group android:id="@+id/bookcase_menu"> <item - android:id="@+id/action_search" - android:icon="@drawable/ic_search" - android:title="@string/menu_bookcase_search" - app:showAsAction="always"/> + android:id="@+id/action_search" + android:icon="@drawable/ic_search" + android:title="@string/menu_bookcase_search" + app:showAsAction="always" /> <item - android:id="@+id/action_change_group" - android:icon="@drawable/ic_change" - android:title="@string/menu_change_group" - app:showAsAction="always"/> + android:id="@+id/action_change_group" + android:icon="@drawable/ic_change" + android:title="@string/menu_change_group" + app:showAsAction="always" /> <item - android:id="@+id/action_edit" - android:icon="@drawable/ic_arrange" - android:title="@string/menu_bookcase_edit" - app:showAsAction="never"/> - <item - android:id="@+id/action_styleChange" - android:icon="@drawable/ic_view_quilt" - android:title="@string/menu_bookcase_style" - app:showAsAction="never"/> - <item - android:id="@+id/action_group_man" - android:icon="@drawable/ic_group" - android:title="@string/menu_group_man" - app:showAsAction="never"/> - <item - android:id="@+id/action_addLocalBook" - android:icon="@drawable/ic_add" - android:title="@string/menu_bookcase_add" - app:showAsAction="never"/> + android:id="@+id/action_edit" + android:icon="@drawable/ic_arrange" + android:title="@string/menu_bookcase_edit" + app:showAsAction="never" /> + <item + android:id="@+id/action_styleChange" + android:icon="@drawable/ic_view_quilt" + android:title="@string/menu_bookcase_style" + app:showAsAction="never" /> + <item + android:id="@+id/action_group_man" + android:icon="@drawable/ic_group" + android:title="@string/menu_group_man" + app:showAsAction="never" /> + <item + android:id="@+id/action_addLocalBook" + android:icon="@drawable/ic_add" + android:title="@string/menu_bookcase_add" + app:showAsAction="never" /> <item - android:id="@+id/action_download_all" - android:icon="@drawable/ic_download_line" - android:title="@string/menu_bookcase_download_all" - app:showAsAction="never" - android:visible="true"/> + android:id="@+id/action_download_all" + android:icon="@drawable/ic_download_line" + android:title="@string/menu_bookcase_download_all" + android:visible="true" + app:showAsAction="never" /> <item android:id="@+id/action_qr_scan" android:icon="@drawable/ic_scan" android:title="@string/menu_scan" - app:showAsAction="never" - android:visible="true"/> + android:visible="true" + app:showAsAction="never" /> + </group> + <group + android:id="@+id/find_menu" + android:visible="false"> + <item + android:id="@+id/action_refresh_find" + android:icon="@drawable/ic_refresh" + android:title="@string/refresh" + app:showAsAction="always" /> </group> </menu>