Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Sep 29, 2018
1 parent 0c6c3f0 commit d6d4efe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,20 @@ public static void delChapter(String folderName, String fileName) {
/**
* 存储章节
*/
public static void saveChapterInfo(String folderName, String fileName, String content) {
public static boolean saveChapterInfo(String folderName, String fileName, String content) {
if (content == null) {
return;
return false;
}
File file = getBookFile(formatFileName(folderName), formatFileName(fileName));
//获取流并存储
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
writer.write(content);
writer.flush();
return true;
} catch (IOException e) {
MApplication.getInstance().setDownloadPath(FileHelp.getCachePath());
e.printStackTrace();
return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.hwangjr.rxbus.RxBus;
import com.monke.monkeybook.bean.BookContentBean;
import com.monke.monkeybook.bean.BookShelfBean;
import com.monke.monkeybook.bean.BookSourceBean;
import com.monke.monkeybook.bean.ChapterListBean;
import com.monke.monkeybook.bean.SearchBookBean;
import com.monke.monkeybook.dao.ChapterListBeanDao;
Expand Down Expand Up @@ -159,15 +158,16 @@ private Observable<BookContentBean> upChapterList(String bookName, String tag, B
.where(ChapterListBeanDao.Properties.DurChapterUrl.eq(bookContentBean.getDurChapterUrl())).unique();
if (chapterListBean != null) {
bookContentBean.setNoteUrl(chapterListBean.getNoteUrl());
BookshelfHelp.saveChapterInfo(bookName + "-" + tag,
if (BookshelfHelp.saveChapterInfo(bookName + "-" + tag,
String.format("%d-%s", chapterListBean.getDurChapterIndex(), chapterListBean.getDurChapterName()),
bookContentBean.getDurChapterContent());
BookshelfHelp.setChapterIsCached(bookName, chapterListBean, true);
DbHelper.getInstance().getmDaoSession().getChapterListBeanDao().update(chapterListBean);
RxBus.get().post(RxBusTag.CHAPTER_CHANGE, chapterListBean);
e.onNext(bookContentBean);
e.onComplete();
return;
bookContentBean.getDurChapterContent())) {
BookshelfHelp.setChapterIsCached(bookName, chapterListBean, true);
DbHelper.getInstance().getmDaoSession().getChapterListBeanDao().update(chapterListBean);
RxBus.get().post(RxBusTag.CHAPTER_CHANGE, chapterListBean);
e.onNext(bookContentBean);
e.onComplete();
return;
}
}
}
e.onError(new Throwable("保存章节出错"));
Expand Down

0 comments on commit d6d4efe

Please sign in to comment.