From 420725d5d28dfaa83309a9055e606257277c04c9 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Fri, 21 Jan 2022 17:07:10 +0800 Subject: [PATCH] fix bug --- .../fycz/myreader/greendao/entity/Book.java | 30 ++++++++++++------- .../myreader/greendao/entity/Chapter.java | 3 ++ .../adapter/holder/SourceExchangeHolder.java | 3 +- .../ui/dialog/SourceExchangeDialog.java | 3 +- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/xyz/fycz/myreader/greendao/entity/Book.java b/app/src/main/java/xyz/fycz/myreader/greendao/entity/Book.java index 91f81c4..7b186c1 100644 --- a/app/src/main/java/xyz/fycz/myreader/greendao/entity/Book.java +++ b/app/src/main/java/xyz/fycz/myreader/greendao/entity/Book.java @@ -92,11 +92,11 @@ public class Book implements Serializable, RuleDataInterface { @Generated(hash = 1472063028) public Book(String id, String name, String chapterUrl, String infoUrl, String imgUrl, String desc, String author, - String type, String updateDate, String wordCount, String status, String newestChapterId, - String newestChapterTitle, String historyChapterId, int histtoryChapterNum, int sortCode, int noReadNum, - int chapterTotalNum, int lastReadPosition, String source, boolean isCloseUpdate, boolean isDownLoadAll, - String groupId, int groupSort, boolean reSeg, String tag, Boolean replaceEnable, long lastReadTime, - String variable) { + String type, String updateDate, String wordCount, String status, String newestChapterId, + String newestChapterTitle, String historyChapterId, int histtoryChapterNum, int sortCode, int noReadNum, + int chapterTotalNum, int lastReadPosition, String source, boolean isCloseUpdate, boolean isDownLoadAll, + String groupId, int groupSort, boolean reSeg, String tag, Boolean replaceEnable, long lastReadTime, + String variable) { this.id = id; this.name = name; this.chapterUrl = chapterUrl; @@ -306,8 +306,11 @@ public class Book implements Serializable, RuleDataInterface { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Book book = (Book) o; + boolean flag = chapterUrl == null ? + (infoUrl == null || infoUrl.equals(book.infoUrl)) : + chapterUrl.equals(book.chapterUrl); return name.equals(book.name) && - chapterUrl.equals(book.chapterUrl) && + flag && author != null && author.equals(book.author) && source.equals(book.source); } @@ -396,6 +399,9 @@ public class Book implements Serializable, RuleDataInterface { if (variableMap == null && !TextUtils.isEmpty(variable)) { variableMap = GsonExtensionsKt.getGSON().fromJson(variable, MAP_STRING); } + if (variableMap == null) { + variableMap = new HashMap<>(); + } return variableMap; } @@ -423,8 +429,8 @@ public class Book implements Serializable, RuleDataInterface { catheMap.put(key, value); } - public String getCathe(String key){ - if (catheMap == null){ + public String getCathe(String key) { + if (catheMap == null) { return ""; } return catheMap.get(key); @@ -434,7 +440,7 @@ public class Book implements Serializable, RuleDataInterface { this.catheMap = catheMap; } - public void clearCathe(){ + public void clearCathe() { if (catheMap != null) { catheMap.clear(); } @@ -454,7 +460,7 @@ public class Book implements Serializable, RuleDataInterface { return getVariableMap().get(key); } - public Book changeSource(Book newBook){ + public Book changeSource(Book newBook) { Book bookTem = (Book) clone(); bookTem.clearCathe(); bookTem.setChapterUrl(newBook.getChapterUrl()); @@ -482,9 +488,11 @@ public class Book implements Serializable, RuleDataInterface { bookTem.setVariable(newBook.getVariable()); bookTem.setVariableMap(newBook.getVariableMap()); } - if (newBook.getCatheMap() != null){ + if (newBook.getCatheMap() != null) { bookTem.setCatheMap(newBook.getCatheMap()); } return bookTem; } + + public void setReverseToc(boolean reverseToc){} } diff --git a/app/src/main/java/xyz/fycz/myreader/greendao/entity/Chapter.java b/app/src/main/java/xyz/fycz/myreader/greendao/entity/Chapter.java index 626545a..912802f 100644 --- a/app/src/main/java/xyz/fycz/myreader/greendao/entity/Chapter.java +++ b/app/src/main/java/xyz/fycz/myreader/greendao/entity/Chapter.java @@ -159,6 +159,9 @@ public class Chapter implements RuleDataInterface { if (variableMap == null && !TextUtils.isEmpty(variable)) { variableMap = GsonExtensionsKt.getGSON().fromJson(variable, MAP_STRING); } + if (variableMap == null) { + variableMap = new HashMap<>(); + } return variableMap; } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/SourceExchangeHolder.java b/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/SourceExchangeHolder.java index f99fa15..1518974 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/SourceExchangeHolder.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/SourceExchangeHolder.java @@ -42,7 +42,8 @@ public class SourceExchangeHolder extends ViewHolderImpl { public void onBind(RecyclerView.ViewHolder holder, Book data, int pos) { sourceTvTitle.setText(BookSourceManager.getSourceNameByStr(data.getSource())); sourceTvChapter.setText(data.getNewestChapterTitle()); - if (data.getSource() != null && data.getSource().equals(dialog.getmShelfBook().getSource())) { + if ((data.getInfoUrl() != null && data.getInfoUrl().equals(dialog.getmShelfBook().getInfoUrl())|| + data.getChapterUrl() != null && data.getChapterUrl().equals(dialog.getmShelfBook().getChapterUrl()))) { sourceIv.setVisibility(View.VISIBLE); dialog.setSourceIndex(pos); } else { diff --git a/app/src/main/java/xyz/fycz/myreader/ui/dialog/SourceExchangeDialog.java b/app/src/main/java/xyz/fycz/myreader/ui/dialog/SourceExchangeDialog.java index 6d78306..a745df7 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/dialog/SourceExchangeDialog.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/dialog/SourceExchangeDialog.java @@ -205,7 +205,8 @@ public class SourceExchangeDialog extends Dialog { searchEngine.stopSearch(); return; } - if (mShelfBook.getSource().equals(newBook.getSource())) return; + if ((mShelfBook.getInfoUrl() != null && mShelfBook.getInfoUrl().equals(newBook.getInfoUrl())|| + mShelfBook.getChapterUrl() != null && mShelfBook.getChapterUrl().equals(newBook.getChapterUrl()))) return; mShelfBook = newBook; listener.onSourceChanged(newBook, pos); mAdapter.getItem(pos).setNewestChapterId("true");