fix bug 多本书共用一个章节内容缓存

This commit is contained in:
mwang 2019-03-10 12:36:32 +08:00
parent 8b79e3dd06
commit cc5ac05e12
2 changed files with 14 additions and 5 deletions

View File

@ -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()));
}
chaptCache = new HashMap<Integer,Cache>();
if(directoryList.isEmpty()) {
if (bookPath == null || !bookPath.equals(book.getBookpath())) {
@ -471,7 +471,7 @@ public class BookUtil {
return block;
}
Map<Integer,Cache> chaptCache = new HashMap<Integer,Cache>();
private Map<Integer,Cache> chaptCache = new HashMap<Integer,Cache>();
//获取chapter 缓存
public char[] chaptChars(int index) {
@ -482,6 +482,15 @@ public class BookUtil {
if (block == null) {
try {
File file = new File(fileChapterName(index));
if(!file.exists()){
/* 章节内容没有缓存在本地
1. 根据本地的章节网络地址信息读取章节内容到本地若读取失败则
2. 查询主服务器若有地址更新则更新本地信息并重复1若没有更新地址则地址无效返回章节内容正待手打
*/
}
int size = (int)file.length();
if (size < 0) {
throw new RuntimeException("Error during reading " + fileChapterName(index));

View File

@ -802,11 +802,11 @@ public class PageFactory {
public void preChapter(){
if (mBookUtil.getDirectoryList().size() > 0){
int num = currentChapter;
if (num ==0){
if (num ==1){
num =getCurrentCharter();
}
num --;
if (num >= 0){
if (num >= 1){
nextChaptPages =currentChaptPages;
currentChapter = num;
@ -826,7 +826,7 @@ public class PageFactory {
num =getCurrentCharter();
}
num ++;
if (num < getDirectoryList().size()){
if (num <= getDirectoryList().size()){
preChaptPages =currentChaptPages;
currentChapter = num;