调整章节内容读取

This commit is contained in:
mwang 2019-06-16 23:56:32 +08:00
parent c9059c7910
commit 5b87b2f167
3 changed files with 16 additions and 12 deletions

View File

@ -604,7 +604,7 @@ public class ReadActivity extends Activity_base implements AdInterface {
}
if(!pageFactory.canExitSilent()){
if(book.isOnShelf()){
if(book.isOnShelf() ||pageFactory.getChapters().size()>0){
finish();
}else {
// showNormalDialog();

View File

@ -496,7 +496,8 @@ public class BookUtil {
chaptCache.clear();
fileRetryCnt.clear();
siteRuleRetryCnt=0;
caprint.clear();
isChangeSource=false;
}
public Site getSite() {
@ -582,7 +583,7 @@ public class BookUtil {
int chId=chapId;//chapterNo;
String title ="";
mChangeChapId = mChangeChapId >=1 ?mChangeChapId :1;//TODO: mChangeChapId 换源时不要变
mChangeChapId = mChangeChapId >=1 ?mChangeChapId :1;
if( mChapters.size() >= mChangeChapId && mChapters.get(mChangeChapId-1)!=null ){
title= mChapters.get(mChangeChapId-1).getChapterName();
Log.d(TAG, "changing Source:chapter name in new site " + title );
@ -671,10 +672,10 @@ public class BookUtil {
chapTitle = params[2];
int splet =0;
while(isChangeSource && splet <200){
while(isChangeSource && splet <Constants.MAX_SLEEP_4_CHAPT_DOWNLOAD){
try {
Thread.sleep(50);
splet++;
splet+=50;
Log.d(TAG, String.format("prepare book changing Source slept %s,isChangeSource %s ", splet, isChangeSource ));
} catch (InterruptedException e) {
e.printStackTrace();
@ -1479,8 +1480,6 @@ int muluRetryCount =0;
return true;
}
List<Integer> caprint = new ArrayList<Integer>();
//获取chapter 缓存
public char[] chaptChars(final int index) {
// Log.d(TAG, String.format("prepare book begin to load content for chapter %s ------------------------------------------------------------------------->", index));
@ -1489,10 +1488,6 @@ int muluRetryCount =0;
block = chaptCache .get(index).getData().get();
// Log.d(TAG, String.format("chaptChars get block in cache, chapter: %s", index));
if(!caprint.contains(index)) {
caprint.add(index);
// Log.d(TAG, String.format("chaptChars: load from cache chaptId %s,--->%s", index, new String(block)));
}
}
// Log.d(TAG, String.format("prepare book begin to load content for chapter %s", index));
if (block == null) {
@ -1873,5 +1868,10 @@ private void loadChaptContent(final int chapterIndex) throws JSONException, Inte
return (line.length() <= 30 && (line.matches(".*第.{1,8}章.*") || line.matches(".*第.{1,8}节.*"))) ;
}
void clear(){
clearBook();
mContext=null;
this.pagefactory =null;
}
}

View File

@ -317,7 +317,7 @@ public class PageFactory implements ChangeSource{
if(!getNovel().isLocalBook()) {
mStatus = Status.OPENING;
final int maxSleep = Constants.MAX_SLEEP_4_CHAPT_DOWNLOAD;
final int maxSleep = Constants.MAX_SLEEP_4_CHAPT_DOWNLOAD+1000;
// final File file = new File(getChapterFileName(chaptId));
@ -1478,6 +1478,10 @@ private void hideSysUI(){
}
}
if(mBookUtil!=null){
mBookUtil. clear();
mBookUtil=null;
}
mBookUtil = new BookUtil();
mBookUtil.pagefactory=this;
//this.mBookUtil.setContext(context);