Search in sources :

Example 21 with UnLimit91PornItem

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);
                }
            });
        }
    });
}
Also used : Disposable(io.reactivex.disposables.Disposable) ObservableOnSubscribe(io.reactivex.ObservableOnSubscribe) ApiException(com.dante.exception.ApiException) NonNull(android.support.annotation.NonNull) List(java.util.List) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem) File(java.io.File) ObservableEmitter(io.reactivex.ObservableEmitter)

Example 22 with UnLimit91PornItem

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);
}
Also used : BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) HistoryAdapter(com.dante.adapter.HistoryAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) SwipeMenuRecyclerView(com.aitsuki.swipe.SwipeMenuRecyclerView) View(android.view.View) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem)

Example 23 with UnLimit91PornItem

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);
        }
    });
}
Also used : Function(io.reactivex.functions.Function) BaseResult(com.dante.data.model.BaseResult) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) Reply(io.rx_cache2.Reply) EvictDynamicKeyGroup(io.rx_cache2.EvictDynamicKeyGroup) DynamicKeyGroup(io.rx_cache2.DynamicKeyGroup) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem) FavoriteException(com.dante.exception.FavoriteException) MessageException(com.dante.exception.MessageException)

Example 24 with UnLimit91PornItem

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);
        }
    });
}
Also used : Function(io.reactivex.functions.Function) BaseResult(com.dante.data.model.BaseResult) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) Reply(io.rx_cache2.Reply) EvictDynamicKeyGroup(io.rx_cache2.EvictDynamicKeyGroup) DynamicKeyGroup(io.rx_cache2.DynamicKeyGroup) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem) FavoriteException(com.dante.exception.FavoriteException) MessageException(com.dante.exception.MessageException)

Example 25 with UnLimit91PornItem

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);
        }
    });
}
Also used : Function(io.reactivex.functions.Function) BaseResult(com.dante.data.model.BaseResult) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) Reply(io.rx_cache2.Reply) EvictDynamicKeyGroup(io.rx_cache2.EvictDynamicKeyGroup) DynamicKeyGroup(io.rx_cache2.DynamicKeyGroup) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem) FavoriteException(com.dante.exception.FavoriteException) MessageException(com.dante.exception.MessageException)

Aggregations

UnLimit91PornItem (com.dante.data.model.UnLimit91PornItem)29 BaseResult (com.dante.data.model.BaseResult)10 ArrayList (java.util.ArrayList)10 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)8 View (android.view.View)8 BindView (butterknife.BindView)8 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)8 List (java.util.List)7 RecyclerView (android.support.v7.widget.RecyclerView)6 MessageException (com.dante.exception.MessageException)6 NonNull (android.support.annotation.NonNull)5 OnLoadViewListener (com.helper.loadviewhelper.help.OnLoadViewListener)5 LoadViewHelper (com.helper.loadviewhelper.load.LoadViewHelper)5 Function (io.reactivex.functions.Function)5 Document (org.jsoup.nodes.Document)5 Element (org.jsoup.nodes.Element)5 Elements (org.jsoup.select.Elements)5 VideoResult (com.dante.data.model.VideoResult)4 FavoriteException (com.dante.exception.FavoriteException)4 Disposable (io.reactivex.disposables.Disposable)4