调整章节内容读取
This commit is contained in:
		
							parent
							
								
									c9059c7910
								
							
						
					
					
						commit
						5b87b2f167
					
				|  | @ -604,7 +604,7 @@ public class ReadActivity extends  Activity_base implements   AdInterface { | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|             if(!pageFactory.canExitSilent()){ |             if(!pageFactory.canExitSilent()){ | ||||||
|                 if(book.isOnShelf()){ |                 if(book.isOnShelf() ||pageFactory.getChapters().size()>0){ | ||||||
|                     finish(); |                     finish(); | ||||||
|                 }else { |                 }else { | ||||||
|                    // showNormalDialog(); |                    // showNormalDialog(); | ||||||
|  |  | ||||||
|  | @ -496,7 +496,8 @@ public class BookUtil { | ||||||
|         chaptCache.clear(); |         chaptCache.clear(); | ||||||
|         fileRetryCnt.clear(); |         fileRetryCnt.clear(); | ||||||
|         siteRuleRetryCnt=0; |         siteRuleRetryCnt=0; | ||||||
|         caprint.clear(); |         isChangeSource=false; | ||||||
|  | 
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Site getSite() { |     public Site getSite() { | ||||||
|  | @ -582,7 +583,7 @@ public class BookUtil { | ||||||
| 
 | 
 | ||||||
|                 int chId=chapId;//chapterNo; |                 int chId=chapId;//chapterNo; | ||||||
|                 String title =""; |                 String title =""; | ||||||
|                 mChangeChapId = mChangeChapId >=1 ?mChangeChapId :1;//TODO: mChangeChapId 换源时不要变 |                 mChangeChapId = mChangeChapId >=1 ?mChangeChapId :1; | ||||||
|                 if( mChapters.size() >= mChangeChapId && mChapters.get(mChangeChapId-1)!=null ){ |                 if( mChapters.size() >= mChangeChapId && mChapters.get(mChangeChapId-1)!=null ){ | ||||||
|                     title= mChapters.get(mChangeChapId-1).getChapterName(); |                     title= mChapters.get(mChangeChapId-1).getChapterName(); | ||||||
|                     Log.d(TAG, "changing Source:chapter name in new site " + title ); |                     Log.d(TAG, "changing Source:chapter name in new site " + title ); | ||||||
|  | @ -671,10 +672,10 @@ public class BookUtil { | ||||||
|             chapTitle = params[2]; |             chapTitle = params[2]; | ||||||
| 
 | 
 | ||||||
|             int splet =0; |             int splet =0; | ||||||
|             while(isChangeSource && splet <200){ |             while(isChangeSource && splet <Constants.MAX_SLEEP_4_CHAPT_DOWNLOAD){ | ||||||
|                 try { |                 try { | ||||||
|                     Thread.sleep(50); |                     Thread.sleep(50); | ||||||
|                     splet++; |                     splet+=50; | ||||||
|                     Log.d(TAG, String.format("prepare book changing Source slept %s,isChangeSource %s ", splet, isChangeSource )); |                     Log.d(TAG, String.format("prepare book changing Source slept %s,isChangeSource %s ", splet, isChangeSource )); | ||||||
|                 } catch (InterruptedException e) { |                 } catch (InterruptedException e) { | ||||||
|                     e.printStackTrace(); |                     e.printStackTrace(); | ||||||
|  | @ -1479,8 +1480,6 @@ int muluRetryCount =0; | ||||||
|      return  true; |      return  true; | ||||||
|  } |  } | ||||||
| 
 | 
 | ||||||
|     List<Integer> caprint = new ArrayList<Integer>(); |  | ||||||
| 
 |  | ||||||
|     //获取chapter 缓存 |     //获取chapter 缓存 | ||||||
|     public char[] chaptChars(final int index) { |     public char[] chaptChars(final int index) { | ||||||
|       //  Log.d(TAG, String.format("prepare book  begin to load content for chapter %s ------------------------------------------------------------------------->", 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(); |             block = chaptCache .get(index).getData().get(); | ||||||
|          //   Log.d(TAG, String.format("chaptChars  get block in cache, chapter: %s", index)); |          //   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)); |       //  Log.d(TAG, String.format("prepare book  begin to load content for chapter %s", index)); | ||||||
|         if (block == null) { |         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}节.*")))  ; |         return (line.length() <= 30 && (line.matches(".*第.{1,8}章.*") || line.matches(".*第.{1,8}节.*")))  ; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | void clear(){ | ||||||
|  |         clearBook(); | ||||||
|  |         mContext=null; | ||||||
|  |         this.pagefactory =null; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -317,7 +317,7 @@ public class PageFactory implements ChangeSource{ | ||||||
|          if(!getNovel().isLocalBook()) { |          if(!getNovel().isLocalBook()) { | ||||||
| 
 | 
 | ||||||
|              mStatus = Status.OPENING; |              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)); |           // 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 = new BookUtil(); | ||||||
|         mBookUtil.pagefactory=this; |         mBookUtil.pagefactory=this; | ||||||
|         //this.mBookUtil.setContext(context); |         //this.mBookUtil.setContext(context); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue