修复发现分类bug

master
fengyuecanzhu 3 years ago
parent 47fbf10db1
commit bb2c74930f
  1. 80
      app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java
  2. 25
      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,45 +478,47 @@ public class BookcasePresenter implements BasePresenter {
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_change_group:
mBookcaseFragment.getmBookcasePresenter()
.showBookGroupMenu(mMainActivity.findViewById(R.id.action_change_group));
return true;
case R.id.action_edit:
editBookcase(true);
return true;
case R.id.action_styleChange:
if (mSetting.getBookcaseStyle().equals(BookcaseStyle.listMode)) {
mSetting.setBookcaseStyle(BookcaseStyle.threePalaceMode);
ToastUtils.show("已切换为三列网格视图!");
} else {
mSetting.setBookcaseStyle(BookcaseStyle.listMode);
ToastUtils.show("已切换为列表视图!");
}
isBookcaseStyleChange = true;
SysManager.saveSetting(mSetting);
init();
return true;
case R.id.action_group_man:
showGroupManDia();
return true;
case R.id.action_addLocalBook:
addLocalBook();
break;
case R.id.action_download_all:
if (!SharedPreUtils.getInstance().getBoolean(mMainActivity.getString(R.string.isReadDownloadAllTip), false)) {
DialogCreator.createCommonDialog(mMainActivity, "一键缓存",
mMainActivity.getString(R.string.all_cathe_tip), true,
(dialog, which) -> {
downloadAll(true, true);
SharedPreUtils.getInstance().putBoolean(mMainActivity.getString(R.string.isReadDownloadAllTip), true);
}, null);
} else {
downloadAll(true, true);
}
return true;
int itemId = item.getItemId();
if (itemId == R.id.action_change_group) {
mBookcaseFragment.getmBookcasePresenter()
.showBookGroupMenu(mMainActivity.findViewById(R.id.action_change_group));
return true;
} else if (itemId == R.id.action_edit) {
editBookcase(true);
return true;
} else if (itemId == R.id.action_styleChange) {
if (mSetting.getBookcaseStyle().equals(BookcaseStyle.listMode)) {
mSetting.setBookcaseStyle(BookcaseStyle.threePalaceMode);
ToastUtils.show("已切换为三列网格视图!");
} else {
mSetting.setBookcaseStyle(BookcaseStyle.listMode);
ToastUtils.show("已切换为列表视图!");
}
isBookcaseStyleChange = true;
SysManager.saveSetting(mSetting);
init();
return true;
} else if (itemId == R.id.action_group_man) {
showGroupManDia();
return true;
} else if (itemId == R.id.action_addLocalBook) {
addLocalBook();
return true;
} 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)) {
DialogCreator.createCommonDialog(mMainActivity, "一键缓存",
mMainActivity.getString(R.string.all_cathe_tip), true,
(dialog, which) -> {
downloadAll(true, true);
SharedPreUtils.getInstance().putBoolean(mMainActivity.getString(R.string.isReadDownloadAllTip), true);
}, null);
} else {
downloadAll(true, true);
}
return true;
}
return false;
}
@ -1066,4 +1068,6 @@ public class BookcasePresenter implements BasePresenter {
}
}
/*****************************添加网址************************************/
}

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

@ -42,6 +42,13 @@
android:title="@string/menu_bookcase_add"
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
android:id="@+id/action_download_all"
android:icon="@drawable/ic_download_line"

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

Loading…
Cancel
Save