fix bug 多本书共用一个章节内容缓存
This commit is contained in:
		
							parent
							
								
									8b79e3dd06
								
							
						
					
					
						commit
						cc5ac05e12
					
				|  | @ -91,7 +91,7 @@ public class BookUtil { | ||||||
|             Log.d(TAG, String.format("bookchapter  :%s,fileName :%s, chapter Size %s",c.getChapterName(),c.getChapterPath(),c.getLength())); |             Log.d(TAG, String.format("bookchapter  :%s,fileName :%s, chapter Size %s",c.getChapterName(),c.getChapterPath(),c.getLength())); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 
 |         chaptCache = new HashMap<Integer,Cache>(); | ||||||
|         if(directoryList.isEmpty()) { |         if(directoryList.isEmpty()) { | ||||||
| 
 | 
 | ||||||
|             if (bookPath == null || !bookPath.equals(book.getBookpath())) { |             if (bookPath == null || !bookPath.equals(book.getBookpath())) { | ||||||
|  | @ -471,7 +471,7 @@ public class BookUtil { | ||||||
|         return block; |         return block; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Map<Integer,Cache> chaptCache = new HashMap<Integer,Cache>(); |     private Map<Integer,Cache> chaptCache = new HashMap<Integer,Cache>(); | ||||||
| 
 | 
 | ||||||
|     //获取chapter 缓存 |     //获取chapter 缓存 | ||||||
|     public char[] chaptChars(int index) { |     public char[] chaptChars(int index) { | ||||||
|  | @ -482,6 +482,15 @@ public class BookUtil { | ||||||
|         if (block == null) { |         if (block == null) { | ||||||
|             try { |             try { | ||||||
|                 File file = new File(fileChapterName(index)); |                 File file = new File(fileChapterName(index)); | ||||||
|  | 
 | ||||||
|  |                 if(!file.exists()){ | ||||||
|  |                     /* 章节内容没有缓存在本地 | ||||||
|  |                         1. 根据本地的章节网络地址信息,读取章节内容到本地,若读取失败则 | ||||||
|  |                         2. 查询主服务器,若有地址更新则更新本地信息,并重复1,若没有更新地址,则地址无效,返回章节内容正待手打 | ||||||
|  |                     */ | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|                 int size = (int)file.length(); |                 int size = (int)file.length(); | ||||||
|                 if (size < 0) { |                 if (size < 0) { | ||||||
|                     throw new RuntimeException("Error during reading " + fileChapterName(index)); |                     throw new RuntimeException("Error during reading " + fileChapterName(index)); | ||||||
|  |  | ||||||
|  | @ -802,11 +802,11 @@ public class PageFactory { | ||||||
|     public void preChapter(){ |     public void preChapter(){ | ||||||
|         if (mBookUtil.getDirectoryList().size() > 0){ |         if (mBookUtil.getDirectoryList().size() > 0){ | ||||||
|             int num = currentChapter; |             int num = currentChapter; | ||||||
|             if (num ==0){ |             if (num ==1){ | ||||||
|                 num =getCurrentCharter(); |                 num =getCurrentCharter(); | ||||||
|             } |             } | ||||||
|             num --; |             num --; | ||||||
|             if (num >= 0){ |             if (num >= 1){ | ||||||
| 
 | 
 | ||||||
|                 nextChaptPages =currentChaptPages; |                 nextChaptPages =currentChaptPages; | ||||||
|                 currentChapter = num; |                 currentChapter = num; | ||||||
|  | @ -826,7 +826,7 @@ public class PageFactory { | ||||||
|             num =getCurrentCharter(); |             num =getCurrentCharter(); | ||||||
|         } |         } | ||||||
|         num ++; |         num ++; | ||||||
|         if (num < getDirectoryList().size()){ |         if (num <= getDirectoryList().size()){ | ||||||
| 
 | 
 | ||||||
|             preChaptPages =currentChaptPages; |             preChaptPages =currentChaptPages; | ||||||
|             currentChapter = num; |             currentChapter = num; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue