修复朗读到章节最后一页时停止的bug

master
fengyuecanzhu 3 years ago
parent e82030a0bc
commit 525b59acda
  1. 6
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java
  2. 7
      app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java

@ -419,8 +419,10 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
pagePos = pos; pagePos = pos;
saveLastChapterReadPosition(); saveLastChapterReadPosition();
} }
screenOffTimerStart(); mHandler.post(()->{
initMenu(); screenOffTimerStart();
initMenu();
});
recordReadTime(); recordReadTime();
if (ReadAloudService.running) { if (ReadAloudService.running) {
if (mPageLoader.hasChapterData(mChapters.get(mPageLoader.getChapterPos()))) { if (mPageLoader.hasChapterData(mChapters.get(mPageLoader.getChapterPos()))) {

@ -114,6 +114,7 @@ public class SearchBookActivity extends BaseActivity {
private boolean foldBookcase; private boolean foldBookcase;
private boolean foldSuggest; private boolean foldSuggest;
private boolean foldHistory; private boolean foldHistory;
private boolean needReGetHistory;
@Override @Override
protected void bindView() { protected void bindView() {
@ -150,6 +151,7 @@ public class SearchBookActivity extends BaseActivity {
foldBookcase = SharedPreUtils.getInstance().getBoolean("foldBookcase"); foldBookcase = SharedPreUtils.getInstance().getBoolean("foldBookcase");
foldSuggest = SharedPreUtils.getInstance().getBoolean("foldSuggest"); foldSuggest = SharedPreUtils.getInstance().getBoolean("foldSuggest");
foldHistory = SharedPreUtils.getInstance().getBoolean("foldHistory"); foldHistory = SharedPreUtils.getInstance().getBoolean("foldHistory");
needReGetHistory = true;
searchEngine = new SearchEngine(); searchEngine = new SearchEngine();
searchEngine.setOnSearchListener(new SearchEngine.OnSearchListener() { searchEngine.setOnSearchListener(new SearchEngine.OnSearchListener() {
@Override @Override
@ -317,6 +319,7 @@ public class SearchBookActivity extends BaseActivity {
if (mCurHistories.get(pos) != null) { if (mCurHistories.get(pos) != null) {
mSearchHistoryService.deleteHistory(mCurHistories.get(pos)); mSearchHistoryService.deleteHistory(mCurHistories.get(pos));
} }
needReGetHistory = true;
initHistoryList(); initHistoryList();
} }
}); });
@ -584,7 +587,8 @@ public class SearchBookActivity extends BaseActivity {
hisDis.dispose(); hisDis.dispose();
} }
Single.create((SingleOnSubscribe<Boolean>) emitter -> { Single.create((SingleOnSubscribe<Boolean>) emitter -> {
mSearchHistories = mSearchHistoryService.findAllSearchHistory(); if (needReGetHistory)
mSearchHistories = mSearchHistoryService.findAllSearchHistory();
mHistoryNames.clear(); mHistoryNames.clear();
mCurHistories.clear(); mCurHistories.clear();
if (mSearchHistories == null || mSearchHistories.size() == 0) { if (mSearchHistories == null || mSearchHistories.size() == 0) {
@ -750,6 +754,7 @@ public class SearchBookActivity extends BaseActivity {
binding.fabSearchStop.setVisibility(View.VISIBLE); binding.fabSearchStop.setVisibility(View.VISIBLE);
getData(); getData();
mSearchHistoryService.addOrUpadteHistory(searchKey); mSearchHistoryService.addOrUpadteHistory(searchKey);
needReGetHistory = true;
//收起软键盘 //收起软键盘
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(binding.etSearchKey.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); imm.hideSoftInputFromWindow(binding.etSearchKey.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

Loading…
Cancel
Save