本文整理汇总了Java中com.justwayward.reader.utils.ACache类的典型用法代码示例。如果您正苦于以下问题:Java ACache类的具体用法?Java ACache怎么用?Java ACache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ACache类属于com.justwayward.reader.utils包,在下文中一共展示了ACache类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCollection
import com.justwayward.reader.utils.ACache; //导入依赖的package包/类
public void addCollection(BookLists.BookListsBean bean) {
List<BookLists.BookListsBean> list = getCollectionList();
if (list == null) {
list = new ArrayList<>();
}
for (BookLists.BookListsBean data : list) {
if (data != null) {
if (TextUtils.equals(data._id, bean._id)) {
ToastUtils.showToast("已经收藏过啦");
return;
}
}
}
list.add(bean);
ACache.get(ReaderApplication.getsInstance()).put(getCollectionKey(), (Serializable) list);
ToastUtils.showToast("收藏成功");
}
示例2: getTocList
import com.justwayward.reader.utils.ACache; //导入依赖的package包/类
/**
* 获取目录缓存
*
* @param mContext
* @param bookId
* @return
*/
public List<BookMixAToc.mixToc.Chapters> getTocList(Context mContext, String bookId) {
Object obj = ACache.get(mContext).getAsObject(getTocListKey(bookId));
if (obj != null) {
try {
BookMixAToc data = (BookMixAToc) obj;
List<BookMixAToc.mixToc.Chapters> list = data.mixToc.chapters;
if (list != null && !list.isEmpty()) {
return list;
}
} catch (Exception e) {
ACache.get(mContext).remove(getTocListKey(bookId));
}
}
return null;
}
示例3: getTocList
import com.justwayward.reader.utils.ACache; //导入依赖的package包/类
public void getTocList(final String bookId) {
bookApi.getBookMixAToc(bookId, "chapters").subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BookMixAToc>() {
@Override
public void onNext(BookMixAToc data) {
ACache.get(mContext).put(bookId + "bookToc", data);
List<BookMixAToc.mixToc.Chapters> list = data.mixToc.chapters;
if (list != null && !list.isEmpty() && mView != null) {
mView.showBookToc(bookId, list);
}
}
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
LogUtils.e("onError: " + e);
mView.showError();
}
});
}
示例4: removeCollection
import com.justwayward.reader.utils.ACache; //导入依赖的package包/类
public void removeCollection(String bookListId) {
List<BookLists.BookListsBean> list = getCollectionList();
if (list == null) {
return;
}
for (BookLists.BookListsBean bean : list) {
if (bean != null) {
if (TextUtils.equals(bean._id, bookListId)) {
list.remove(bean);
ACache.get(ReaderApplication.getsInstance()).put(getCollectionKey(), (Serializable) list);
break;
}
}
}
}
示例5: clearCache
import com.justwayward.reader.utils.ACache; //导入依赖的package包/类
/**
* 清除缓存
*
* @param clearReadPos 是否删除阅读记录
*/
public synchronized void clearCache(boolean clearReadPos, boolean clearCollect) {
try {
// 删除内存缓存
String cacheDir = AppUtils.getAppContext().getCacheDir().getPath();
FileUtils.deleteFileOrDirectory(new File(cacheDir));
if (FileUtils.isSdCardAvailable()) {
// 删除SD书籍缓存
FileUtils.deleteFileOrDirectory(new File(Constant.PATH_DATA));
}
// 删除阅读记录(SharePreference)
if (clearReadPos) {
//防止再次弹出性别选择框,sp要重写入保存的性别
String chooseSex = SettingManager.getInstance().getUserChooseSex();
SharedPreferencesUtil.getInstance().removeAll();
SettingManager.getInstance().saveUserChooseSex(chooseSex);
}
// 清空书架
if (clearCollect) {
CollectionsManager.getInstance().clear();
}
// 清除其他缓存
ACache.get(AppUtils.getAppContext()).clear();
} catch (Exception e) {
LogUtils.e(e.toString());
}
}
示例6: putCollectionList
import com.justwayward.reader.utils.ACache; //导入依赖的package包/类
public void putCollectionList(List<Recommend.RecommendBooks> list) {
ACache.get(new File(Constant.PATH_COLLECT)).put("collection", (Serializable) list);
}
示例7: getCollectionList
import com.justwayward.reader.utils.ACache; //导入依赖的package包/类
/**
* 获取我收藏的书单列表
*
* @return
*/
public List<BookLists.BookListsBean> getCollectionList() {
List<BookLists.BookListsBean> list = (ArrayList<BookLists.BookListsBean>) ACache.get(
ReaderApplication.getsInstance()).getAsObject(getCollectionKey());
return list == null ? null : list;
}
示例8: saveTocList
import com.justwayward.reader.utils.ACache; //导入依赖的package包/类
public void saveTocList(Context mContext, String bookId, BookMixAToc data) {
ACache.get(mContext).put(getTocListKey(bookId), data);
}
示例9: removeTocList
import com.justwayward.reader.utils.ACache; //导入依赖的package包/类
public void removeTocList(Context mContext, String bookId) {
ACache.get(mContext).remove(getTocListKey(bookId));
}
示例10: getCollectionList
import com.justwayward.reader.utils.ACache; //导入依赖的package包/类
/**
* 获取收藏列表
*
* @return
*/
public List<Recommend.RecommendBooks> getCollectionList() {
List<Recommend.RecommendBooks> list = (ArrayList<Recommend.RecommendBooks>) ACache.get(new File(Constant.PATH_COLLECT)).getAsObject("collection");
return list == null ? null : list;
}