修复发现分类bug

master
fengyuecanzhu 4 years ago
parent 47fbf10db1
commit bb2c74930f
  1. 22
      app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java
  2. 17
      app/src/main/java/xyz/fycz/myreader/webapi/crawler/source/find/ThirdFindCrawler.java
  3. 7
      app/src/main/res/menu/menu_book.xml
  4. 1
      app/src/main/res/values/strings.xml

@ -478,15 +478,15 @@ public class BookcasePresenter implements BasePresenter {
} }
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { int itemId = item.getItemId();
case R.id.action_change_group: if (itemId == R.id.action_change_group) {
mBookcaseFragment.getmBookcasePresenter() mBookcaseFragment.getmBookcasePresenter()
.showBookGroupMenu(mMainActivity.findViewById(R.id.action_change_group)); .showBookGroupMenu(mMainActivity.findViewById(R.id.action_change_group));
return true; return true;
case R.id.action_edit: } else if (itemId == R.id.action_edit) {
editBookcase(true); editBookcase(true);
return true; return true;
case R.id.action_styleChange: } else if (itemId == R.id.action_styleChange) {
if (mSetting.getBookcaseStyle().equals(BookcaseStyle.listMode)) { if (mSetting.getBookcaseStyle().equals(BookcaseStyle.listMode)) {
mSetting.setBookcaseStyle(BookcaseStyle.threePalaceMode); mSetting.setBookcaseStyle(BookcaseStyle.threePalaceMode);
ToastUtils.show("已切换为三列网格视图!"); ToastUtils.show("已切换为三列网格视图!");
@ -498,13 +498,16 @@ public class BookcasePresenter implements BasePresenter {
SysManager.saveSetting(mSetting); SysManager.saveSetting(mSetting);
init(); init();
return true; return true;
case R.id.action_group_man: } else if (itemId == R.id.action_group_man) {
showGroupManDia(); showGroupManDia();
return true; return true;
case R.id.action_addLocalBook: } else if (itemId == R.id.action_addLocalBook) {
addLocalBook(); addLocalBook();
break; return true;
case R.id.action_download_all: } else if (itemId == R.id.action_add_url) {
return true;
} else if (itemId == R.id.action_download_all) {
if (!SharedPreUtils.getInstance().getBoolean(mMainActivity.getString(R.string.isReadDownloadAllTip), false)) { if (!SharedPreUtils.getInstance().getBoolean(mMainActivity.getString(R.string.isReadDownloadAllTip), false)) {
DialogCreator.createCommonDialog(mMainActivity, "一键缓存", DialogCreator.createCommonDialog(mMainActivity, "一键缓存",
mMainActivity.getString(R.string.all_cathe_tip), true, mMainActivity.getString(R.string.all_cathe_tip), true,
@ -516,7 +519,6 @@ public class BookcasePresenter implements BasePresenter {
downloadAll(true, true); downloadAll(true, true);
} }
return true; return true;
} }
return false; return false;
} }
@ -1066,4 +1068,6 @@ public class BookcasePresenter implements BasePresenter {
} }
} }
/*****************************添加网址************************************/
} }

@ -67,23 +67,32 @@ public class ThirdFindCrawler extends BaseFindCrawler {
kindA = findRule.split("(&&|\n)+"); kindA = findRule.split("(&&|\n)+");
List<FindKind> children = new ArrayList<>(); List<FindKind> children = new ArrayList<>();
String groupName = getName(); String groupName = getName();
int nameCount = 0;
for (String kindB : kindA) { for (String kindB : kindA) {
if (kindB.trim().isEmpty()) continue; kindB = StringUtils.trim(kindB);
if (TextUtils.isEmpty(kindB)) continue;
String[] kind = kindB.split("::"); String[] kind = kindB.split("::");
if (kind.length == 1){ if (kind.length == 0) {
if (children.size() > 0) { if (children.size() > 0) {
nameCount++;
kindsMap.put(groupName, children); kindsMap.put(groupName, children);
children = new ArrayList<>(); children = new ArrayList<>();
} }
groupName = kind[0].replaceAll("\\s", ""); groupName = getName() + "[" + nameCount + "]";
continue; } else if (kind.length == 1) {
if (children.size() > 0) {
kindsMap.put(groupName, children);
children = new ArrayList<>();
} }
groupName = kind[0].replaceAll("\\s", "");
} else {
FindKind findKindBean = new FindKind(); FindKind findKindBean = new FindKind();
findKindBean.setTag(source.getSourceUrl()); findKindBean.setTag(source.getSourceUrl());
findKindBean.setName(kind[0].replaceAll("\\s", "")); findKindBean.setName(kind[0].replaceAll("\\s", ""));
findKindBean.setUrl(kind[1]); findKindBean.setUrl(kind[1]);
children.add(findKindBean); children.add(findKindBean);
} }
}
kindsMap.put(groupName, children); kindsMap.put(groupName, children);
} }
emitter.onNext(true); emitter.onNext(true);

@ -42,6 +42,13 @@
android:title="@string/menu_bookcase_add" android:title="@string/menu_bookcase_add"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/action_add_url"
android:icon="@drawable/ic_online_syn"
android:visible="false"
android:title="@string/add_url"
app:showAsAction="never" />
<item <item
android:id="@+id/action_download_all" android:id="@+id/action_download_all"
android:icon="@drawable/ic_download_line" android:icon="@drawable/ic_download_line"

@ -501,6 +501,7 @@
<string name="privacy_policy">隐私政策</string> <string name="privacy_policy">隐私政策</string>
<string name="contact_author">联系作者</string> <string name="contact_author">联系作者</string>
<string name="browser">浏览器</string> <string name="browser">浏览器</string>
<string name="add_url">添加网址</string>
<string-array name="reset_screen_time"> <string-array name="reset_screen_time">

Loading…
Cancel
Save