Search in sources :

Example 11 with UnLimit91PornItem

use of com.dante.data.model.UnLimit91PornItem in project 91Pop by DanteAndroid.

the class DownloadingFragment method update.

@Override
public void update(BaseDownloadTask task) {
    Logger.t(TAG).d("updateUnLimit91PornItem(BaseDownloadTask task)");
    if (mUnLimit91PornItemList == null || mUnLimit91PornItemList.size() == 0) {
        return;
    }
    UnLimit91PornItem unLimit91PornItem = presenter.findUnLimit91PornItemByDownloadId(task.getId());
    if (unLimit91PornItem != null) {
        int position = mUnLimit91PornItemList.indexOf(unLimit91PornItem);
        Logger.t(TAG).d("position" + position);
        if (position >= 0 && position < mUnLimit91PornItemList.size()) {
            mUnLimit91PornItemList.set(position, unLimit91PornItem);
            mDownloadAdapter.notifyItemChanged(position);
        } else {
            mUnLimit91PornItemList.add(unLimit91PornItem);
            mDownloadAdapter.notifyItemInserted(mUnLimit91PornItemList.size());
        }
    } else {
        presenter.loadDownloadingData();
    }
}
Also used : UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem)

Example 12 with UnLimit91PornItem

use of com.dante.data.model.UnLimit91PornItem in project 91Pop by DanteAndroid.

the class DownloadingFragment method complete.

@Override
public void complete(BaseDownloadTask task) {
    if (mUnLimit91PornItemList == null || mUnLimit91PornItemList.size() == 0) {
        return;
    }
    Logger.t(TAG).d("已经下载完成了");
    UnLimit91PornItem unLimit91PornItem = presenter.findUnLimit91PornItemByDownloadId(task.getId());
    if (unLimit91PornItem != null) {
        int position = mUnLimit91PornItemList.indexOf(unLimit91PornItem);
        if (position >= 0 && position < mUnLimit91PornItemList.size()) {
            mUnLimit91PornItemList.remove(position);
            mDownloadAdapter.notifyItemRemoved(position);
        } else {
            presenter.loadDownloadingData();
        }
    } else {
        presenter.loadDownloadingData();
    }
}
Also used : UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem)

Example 13 with UnLimit91PornItem

use of com.dante.data.model.UnLimit91PornItem in project 91Pop by DanteAndroid.

the class BasePlayVideo method initData.

private void initData() {
    UnLimit91PornItem tmp = dataManager.findUnLimit91PornItemByViewKey(unLimit91PornItem.getViewKey());
    if (tmp == null || tmp.getVideoResult() == null) {
        presenter.loadVideoUrl(unLimit91PornItem);
    } else {
        unLimit91PornItem = tmp;
        videoplayerContainer.setVisibility(View.VISIBLE);
        Logger.t(TAG).d("使用已有播放地址");
        // 浏览历史
        unLimit91PornItem.setViewHistoryDate(new Date());
        dataManager.updateUnLimit91PornItem(unLimit91PornItem);
        VideoResult videoResult = unLimit91PornItem.getVideoResult();
        setToolBarLayoutInfo(unLimit91PornItem);
        playVideo(unLimit91PornItem.getTitle(), videoResult.getVideoUrl(), videoResult.getVideoName(), videoResult.getThumbImgUrl());
        // 加载评论
        presenter.loadVideoComment(videoResult.getVideoId(), unLimit91PornItem.getViewKey(), true);
    }
}
Also used : VideoResult(com.dante.data.model.VideoResult) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem) Date(java.util.Date)

Example 14 with UnLimit91PornItem

use of com.dante.data.model.UnLimit91PornItem in project 91Pop by DanteAndroid.

the class AuthorPresenter method authorVideos.

@Override
public void authorVideos(String uid, final boolean pullToRefresh) {
    String type = "public";
    if (pullToRefresh) {
        page = 1;
        cleanCache = true;
    }
    dataManager.loadPorn91authorVideos(uid, type, page, cleanCache).map(new Function<BaseResult<List<UnLimit91PornItem>>, List<UnLimit91PornItem>>() {

        @Override
        public List<UnLimit91PornItem> apply(BaseResult<List<UnLimit91PornItem>> baseResult) throws Exception {
            if (baseResult.getCode() == BaseResult.ERROR_CODE) {
                throw new MessageException(baseResult.getMessage());
            }
            if (page == 1) {
                totalPage = baseResult.getTotalPage();
            }
            return baseResult.getData();
        }
    }).retryWhen(new RetryWhenProcess(RetryWhenProcess.PROCESS_TIME)).compose(RxSchedulersHelper.<List<UnLimit91PornItem>>ioMainThread()).compose(provider.<List<UnLimit91PornItem>>bindUntilEvent(Lifecycle.Event.ON_DESTROY)).subscribe(new CallBackWrapper<List<UnLimit91PornItem>>() {

        @Override
        public void onBegin(Disposable d) {
            ifViewAttached(new ViewAction<AuthorView>() {

                @Override
                public void run(@NonNull AuthorView view) {
                    if (page == 1 && !pullToRefresh) {
                        view.showLoading(pullToRefresh);
                    }
                }
            });
        }

        @Override
        public void onSuccess(final List<UnLimit91PornItem> unLimit91PornItems) {
            ifViewAttached(new ViewAction<AuthorView>() {

                @Override
                public void run(@NonNull AuthorView view) {
                    if (page == 1) {
                        view.setData(unLimit91PornItems);
                        view.showContent();
                    } else {
                        view.loadMoreDataComplete();
                        view.setMoreData(unLimit91PornItems);
                    }
                    if (page >= totalPage) {
                        view.noMoreData();
                    } else {
                        page++;
                    }
                    view.showContent();
                }
            });
        }

        @Override
        public void onError(final String msg, int code) {
            ifViewAttached(new ViewAction<AuthorView>() {

                @Override
                public void run(@NonNull AuthorView view) {
                    if (page == 1) {
                        view.showError(msg);
                    } else {
                        view.loadMoreFailed();
                    }
                }
            });
        }
    });
}
Also used : Disposable(io.reactivex.disposables.Disposable) BaseResult(com.dante.data.model.BaseResult) RetryWhenProcess(com.dante.rxjava.RetryWhenProcess) MessageException(com.dante.exception.MessageException) MessageException(com.dante.exception.MessageException) NonNull(android.support.annotation.NonNull) List(java.util.List) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem)

Example 15 with UnLimit91PornItem

use of com.dante.data.model.UnLimit91PornItem in project 91Pop by DanteAndroid.

the class FavoriteActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_favorite);
    ButterKnife.bind(this);
    deleteAlertDialog = DialogUtils.initLodingDialog(this, "删除中,请稍后...");
    initToolBar(toolbar);
    toolbar.setContentInsetStartWithNavigation(0);
    // Setup contentView == SwipeRefreshView
    contentView.setOnRefreshListener(this);
    List<UnLimit91PornItem> mUnLimit91PornItemList = new ArrayList<>();
    mUnLimit91Adapter = new FavoriteAdapter(R.layout.item_right_menu_delete, 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.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {

        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            SwipeItemLayout swipeItemLayout = (SwipeItemLayout) view.getParent();
            swipeItemLayout.close();
            if (view.getId() == R.id.right_menu_delete) {
                UnLimit91PornItem unLimit91PornItem = (UnLimit91PornItem) adapter.getItem(position);
                if (unLimit91PornItem == null || unLimit91PornItem.getVideoResult() == null) {
                    showMessage("信息错误,无法删除", TastyToast.WARNING);
                    return;
                }
                presenter.deleteFavorite(unLimit91PornItem.getVideoResult().getVideoId());
            }
        }
    });
    mUnLimit91Adapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {

        @Override
        public void onLoadMoreRequested() {
            presenter.loadRemoteFavoriteData(false);
        }
    }, recyclerView);
    helper = new LoadViewHelper(recyclerView);
    helper.setListener(new OnLoadViewListener() {

        @Override
        public void onRetryClick() {
            presenter.loadRemoteFavoriteData(false);
        }
    });
    boolean needRefresh = dataManager.isFavoriteNeedRefresh();
    presenter.loadRemoteFavoriteData(needRefresh);
}
Also used : ArrayList(java.util.ArrayList) SwipeItemLayout(com.aitsuki.swipe.SwipeItemLayout) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) SwipeMenuRecyclerView(com.aitsuki.swipe.SwipeMenuRecyclerView) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) OnLoadViewListener(com.helper.loadviewhelper.help.OnLoadViewListener) FavoriteAdapter(com.dante.adapter.FavoriteAdapter) LoadViewHelper(com.helper.loadviewhelper.load.LoadViewHelper) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem)

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