pull/21/head
fengyuecanzhu 3 years ago
parent 2aa90ca4a8
commit d4190694a9
  1. 11
      app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java
  2. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/JsExtensions.kt
  3. 16
      app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java
  4. 8
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java
  5. 5
      app/src/main/java/xyz/fycz/myreader/ui/dialog/SourceExchangeDialog.java

@ -45,6 +45,7 @@ public class SearchEngine {
private int searchSiteIndex; private int searchSiteIndex;
private int searchSuccessNum; private int searchSuccessNum;
private int searchFinishNum; private int searchFinishNum;
private boolean isFinish;
private OnSearchListener searchListener; private OnSearchListener searchListener;
@ -70,6 +71,7 @@ public class SearchEngine {
public void stopSearch() { public void stopSearch() {
if (compositeDisposable != null) compositeDisposable.dispose(); if (compositeDisposable != null) compositeDisposable.dispose();
compositeDisposable = new CompositeDisposable(); compositeDisposable = new CompositeDisposable();
isFinish = true;
searchListener.loadMoreFinish(true); searchListener.loadMoreFinish(true);
} }
@ -109,6 +111,7 @@ public class SearchEngine {
searchSuccessNum = 0; searchSuccessNum = 0;
searchSiteIndex = -1; searchSiteIndex = -1;
searchFinishNum = 0; searchFinishNum = 0;
isFinish = false;
for (int i = 0; i < Math.min(mSourceList.size(), threadsNum); i++) { for (int i = 0; i < Math.min(mSourceList.size(), threadsNum); i++) {
searchOnEngine(keyword); searchOnEngine(keyword);
} }
@ -130,6 +133,7 @@ public class SearchEngine {
searchSuccessNum = 0; searchSuccessNum = 0;
searchSiteIndex = -1; searchSiteIndex = -1;
searchFinishNum = 0; searchFinishNum = 0;
isFinish = false;
for (int i = 0; i < Math.min(mSourceList.size(), threadsNum); i++) { for (int i = 0; i < Math.min(mSourceList.size(), threadsNum); i++) {
searchOnEngine(title, author); searchOnEngine(title, author);
} }
@ -170,8 +174,9 @@ public class SearchEngine {
} }
}); });
} else { } else if (!isFinish){
if (searchFinishNum == mSourceList.size()) { if (searchFinishNum == mSourceList.size()) {
isFinish = true;
if (searchSuccessNum == 0) { if (searchSuccessNum == 0) {
searchListener.searchBookError(new Throwable("未搜索到内容")); searchListener.searchBookError(new Throwable("未搜索到内容"));
} }
@ -220,13 +225,13 @@ public class SearchEngine {
} }
}); });
} else { } else if (!isFinish){
if (searchFinishNum >= mSourceList.size()) { if (searchFinishNum >= mSourceList.size()) {
isFinish = true;
if (searchSuccessNum == 0) { if (searchSuccessNum == 0) {
searchListener.searchBookError(new Throwable("未搜索到内容")); searchListener.searchBookError(new Throwable("未搜索到内容"));
} }
searchListener.loadMoreFinish(true); searchListener.loadMoreFinish(true);
} }
} }

@ -487,7 +487,7 @@ interface JsExtensions {
Debug.log(it.sourceUrl, msg) Debug.log(it.sourceUrl, msg)
} ?: Debug.log(msg)*/ } ?: Debug.log(msg)*/
if (App.isDebug()) { if (App.isDebug()) {
Log.d(TAG, msg) Log.d(TAG + "-" + getSource()?.sourceUrl, msg)
} }
return msg return msg
} }

@ -128,10 +128,12 @@ public class BookDetailedActivity extends BaseActivity {
protected void onSaveInstanceState(@NonNull Bundle outState) { protected void onSaveInstanceState(@NonNull Bundle outState) {
aBooks = mSourceDialog.getaBooks(); aBooks = mSourceDialog.getaBooks();
Intent intent = new Intent(); Intent intent = new Intent();
if (aBooks != null) { if (aBooks != null && aBooks.size() > 0) {
aBooks.set(mSourceDialog.getSourceIndex(), mBook); int sourceIndex = mSourceDialog.getSourceIndex();
if (mSourceDialog.hasCurBookSource())
aBooks.set(sourceIndex, mBook);
BitIntentDataManager.getInstance().putData(intent, aBooks); BitIntentDataManager.getInstance().putData(intent, aBooks);
intent.putExtra(APPCONST.SOURCE_INDEX, mSourceDialog.getSourceIndex()); intent.putExtra(APPCONST.SOURCE_INDEX, sourceIndex);
} else { } else {
BitIntentDataManager.getInstance().putData(intent, mBook); BitIntentDataManager.getInstance().putData(intent, mBook);
} }
@ -511,10 +513,12 @@ public class BookDetailedActivity extends BaseActivity {
} }
Intent intent = new Intent(this, ReadActivity.class); Intent intent = new Intent(this, ReadActivity.class);
aBooks = mSourceDialog.getaBooks(); aBooks = mSourceDialog.getaBooks();
if (aBooks != null) { if (aBooks != null && aBooks.size() > 0) {
aBooks.set(mSourceDialog.getSourceIndex(), mBook); int sourceIndex = mSourceDialog.getSourceIndex();
if (mSourceDialog.hasCurBookSource())
aBooks.set(sourceIndex, mBook);
BitIntentDataManager.getInstance().putData(intent, aBooks); BitIntentDataManager.getInstance().putData(intent, aBooks);
intent.putExtra(APPCONST.SOURCE_INDEX, mSourceDialog.getSourceIndex()); intent.putExtra(APPCONST.SOURCE_INDEX, sourceIndex);
} else { } else {
BitIntentDataManager.getInstance().putData(intent, mBook); BitIntentDataManager.getInstance().putData(intent, mBook);
} }

@ -246,10 +246,12 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
protected void onSaveInstanceState(@NonNull Bundle outState) { protected void onSaveInstanceState(@NonNull Bundle outState) {
aBooks = mSourceDialog.getaBooks(); aBooks = mSourceDialog.getaBooks();
Intent intent = new Intent(); Intent intent = new Intent();
if (aBooks != null) { if (aBooks != null && aBooks.size() > 0) {
aBooks.set(mSourceDialog.getSourceIndex(), mBook); int sourceIndex = mSourceDialog.getSourceIndex();
if (mSourceDialog.hasCurBookSource())
aBooks.set(sourceIndex, mBook);
BitIntentDataManager.getInstance().putData(intent, aBooks); BitIntentDataManager.getInstance().putData(intent, aBooks);
intent.putExtra(APPCONST.SOURCE_INDEX, mSourceDialog.getSourceIndex()); intent.putExtra(APPCONST.SOURCE_INDEX, sourceIndex);
} else { } else {
BitIntentDataManager.getInstance().putData(intent, mBook); BitIntentDataManager.getInstance().putData(intent, mBook);
} }

@ -83,6 +83,11 @@ public class SourceExchangeDialog extends Dialog {
} }
return sourceIndex == -1 ? 0 : sourceIndex; return sourceIndex == -1 ? 0 : sourceIndex;
} }
public boolean hasCurBookSource(){
return getSourceIndex() == sourceIndex;
}
public void setOnSourceChangeListener(OnSourceChangeListener listener) { public void setOnSourceChangeListener(OnSourceChangeListener listener) {
this.listener = listener; this.listener = listener;
} }

Loading…
Cancel
Save