use of com.dante.data.model.UnLimit91PornItem in project 91Pop by DanteAndroid.
the class FavoritePresenter method exportData.
@Override
public void exportData(final boolean onlyUrl) {
Observable.create(new ObservableOnSubscribe<List<UnLimit91PornItem>>() {
@Override
public void subscribe(ObservableEmitter<List<UnLimit91PornItem>> e) throws Exception {
List<UnLimit91PornItem> unLimit91PornItems = dataManager.loadAllLimit91PornItems();
e.onNext(unLimit91PornItems);
e.onComplete();
}
}).map(new Function<List<UnLimit91PornItem>, String>() {
@Override
public String apply(List<UnLimit91PornItem> unLimit91PornItems) throws Exception {
File file = new File(SDCardUtils.EXPORT_FILE);
if (file.exists()) {
if (!file.delete()) {
throw new Exception("导出失败,因为删除原文件失败了");
}
}
if (!file.createNewFile()) {
throw new Exception("导出失败,创建新文件失败了");
}
if (onlyUrl) {
for (UnLimit91PornItem unLimit91PornItem : unLimit91PornItems) {
CharSequence data = unLimit91PornItem.getVideoResult().getVideoUrl() + "\r\n\r\n";
if (TextUtils.isEmpty(data)) {
continue;
}
FileUtils.writeChars(file, "UTF-8", data);
}
} else {
for (UnLimit91PornItem unLimit91PornItem : unLimit91PornItems) {
String title = unLimit91PornItem.getTitle();
String videoUrl = unLimit91PornItem.getVideoResult().getVideoUrl();
CharSequence data = title + "\r\n" + videoUrl + "\r\n\r\n";
if (TextUtils.isEmpty(data)) {
continue;
}
FileUtils.writeChars(file, "UTF-8", data);
}
}
return "导出成功";
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).compose(provider.<String>bindUntilEvent(Lifecycle.Event.ON_STOP)).subscribe(new CallBackWrapper<String>() {
@Override
public void onBegin(Disposable d) {
}
@Override
public void onSuccess(final String s) {
ifViewAttached(new ViewAction<FavoriteView>() {
@Override
public void run(@NonNull FavoriteView view) {
view.showMessage(s, TastyToast.SUCCESS);
}
});
}
@Override
public void onError(final String msg, int code) {
ifViewAttached(new ViewAction<FavoriteView>() {
@Override
public void run(@NonNull FavoriteView view) {
view.showMessage(msg, TastyToast.ERROR);
}
});
}
});
}
use of com.dante.data.model.UnLimit91PornItem in project 91Pop by DanteAndroid.
the class HistoryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
ButterKnife.bind(this);
initToolBar(toolbar);
mUnLimit91PornItemList = new ArrayList<>();
mUnLimit91Adapter = new HistoryAdapter(R.layout.item_unlimit_91porn, mUnLimit91PornItemList);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(mUnLimit91Adapter);
mUnLimit91Adapter.setEmptyView(R.layout.empty_view, recyclerView);
mUnLimit91Adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
goToPlayVideo((UnLimit91PornItem) adapter.getItem(position));
}
});
mUnLimit91Adapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
presenter.loadHistoryData(false);
}
}, recyclerView);
presenter.loadHistoryData(false);
}
use of com.dante.data.model.UnLimit91PornItem in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPorn91VideoRecentUpdates.
@Override
public Observable<BaseResult<List<UnLimit91PornItem>>> loadPorn91VideoRecentUpdates(String next, int page, boolean cleanCache, boolean isLoadMoreCleanCache) {
DynamicKeyGroup dynamicKeyGroup = new DynamicKeyGroup(next, page);
EvictDynamicKey evictDynamicKey = new EvictDynamicKey(cleanCache || isLoadMoreCleanCache);
Observable<String> categoryPage = noLimit91PornServiceApi.recentUpdates(next, page, HeaderUtils.getIndexHeader(addressHelper));
return cacheProviders.getRecentUpdates(categoryPage, dynamicKeyGroup, evictDynamicKey).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> responseBody) throws Exception {
return responseBody.getData();
}
}).map(new Function<String, BaseResult<List<UnLimit91PornItem>>>() {
@Override
public BaseResult<List<UnLimit91PornItem>> apply(String s) throws Exception {
return Parse91PronVideo.parseHot(s);
}
});
}
use of com.dante.data.model.UnLimit91PornItem in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPorn91VideoByCategory.
@Override
public Observable<BaseResult<List<UnLimit91PornItem>>> loadPorn91VideoByCategory(String category, String viewType, int page, String m, boolean cleanCache, boolean isLoadMoreCleanCache) {
// RxCache条件区别
String condition;
if (TextUtils.isEmpty(m)) {
condition = category;
} else {
condition = category + m;
}
DynamicKeyGroup dynamicKeyGroup = new DynamicKeyGroup(condition, page);
EvictDynamicKey evictDynamicKey = new EvictDynamicKey(cleanCache || isLoadMoreCleanCache);
Observable<String> categoryPage = noLimit91PornServiceApi.getCategoryPage(category, viewType, page, m, HeaderUtils.getIndexHeader(addressHelper));
return cacheProviders.getCategoryPage(categoryPage, dynamicKeyGroup, evictDynamicKey).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> responseBody) throws Exception {
return responseBody.getData();
}
}).map(new Function<String, BaseResult<List<UnLimit91PornItem>>>() {
@Override
public BaseResult<List<UnLimit91PornItem>> apply(String s) throws Exception {
return Parse91PronVideo.parseHot(s);
}
});
}
use of com.dante.data.model.UnLimit91PornItem in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPorn91authorVideos.
@Override
public Observable<BaseResult<List<UnLimit91PornItem>>> loadPorn91authorVideos(String uid, String type, int page, boolean cleanCache) {
// RxCache条件区别
String condition = null;
if (!TextUtils.isEmpty(uid)) {
condition = uid;
}
DynamicKeyGroup dynamicKeyGroup = new DynamicKeyGroup(condition, page);
EvictDynamicKey evictDynamicKey = new EvictDynamicKey(cleanCache);
Observable<String> stringObservable = noLimit91PornServiceApi.authorVideos(uid, type, page);
return cacheProviders.authorVideos(stringObservable, dynamicKeyGroup, evictDynamicKey).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> responseBody) throws Exception {
return responseBody.getData();
}
}).map(new Function<String, BaseResult<List<UnLimit91PornItem>>>() {
@Override
public BaseResult<List<UnLimit91PornItem>> apply(String s) throws Exception {
return Parse91PronVideo.parseAuthorVideos(s);
}
});
}
Aggregations