Search in sources :

Example 6 with UnLimit91PornItem

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

the class UnLimit91PornItemDao method loadCurrentDeep.

protected UnLimit91PornItem loadCurrentDeep(Cursor cursor, boolean lock) {
    UnLimit91PornItem entity = loadCurrent(cursor, 0, lock);
    int offset = getAllColumns().length;
    VideoResult videoResult = loadCurrentOther(daoSession.getVideoResultDao(), cursor, offset);
    if (videoResult != null) {
        entity.setVideoResult(videoResult);
    }
    return entity;
}
Also used : VideoResult(com.dante.data.model.VideoResult) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem)

Example 7 with UnLimit91PornItem

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

the class SearchPresenter method searchVideos.

@Override
public void searchVideos(String searchId, String sort, final boolean pullToRefresh) {
    String viewType = "basic";
    String searchType = "search_videos";
    if (pullToRefresh) {
        page = 1;
    }
    dataManager.searchPorn91Videos(viewType, page, searchType, searchId, sort).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(2)).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<SearchView>() {

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

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

                @Override
                public void run(@NonNull SearchView 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<SearchView>() {

                @Override
                public void run(@NonNull SearchView 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 8 with UnLimit91PornItem

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

the class VideoListFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ArrayList<UnLimit91PornItem> mUnLimit91PornItemList = new ArrayList<>();
    mUnLimit91Adapter = new UnLimit91Adapter(R.layout.item_unlimit_91porn, mUnLimit91PornItemList);
    skipPageAdapter = new SkipPageAdapter(R.layout.item_skip_page);
}
Also used : ArrayList(java.util.ArrayList) UnLimit91Adapter(com.dante.adapter.UnLimit91Adapter) SkipPageAdapter(com.dante.adapter.SkipPageAdapter) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem)

Example 9 with UnLimit91PornItem

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

the class VideoListFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    unbinder = ButterKnife.bind(this, view);
    // Setup contentView == SwipeRefreshView
    contentView.setOnRefreshListener(this);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(mUnLimit91Adapter);
    mUnLimit91Adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
            UnLimit91PornItem unLimit91PornItems = (UnLimit91PornItem) adapter.getItem(position);
            goToPlayVideo(unLimit91PornItems);
        }
    });
    // 使用缓存的FragmentPagerAdapter之后会导致新方法的加载更多失效,暂时切换回过时api,可正常运行
    mUnLimit91Adapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {

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

        @Override
        public void onRetryClick() {
            loadData(false, true, 0);
        }
    });
    // loadData(false);
    AppUtils.setColorSchemeColors(context, contentView);
    handlerSkipPage();
}
Also used : BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) OnLoadViewListener(com.helper.loadviewhelper.help.OnLoadViewListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LoadViewHelper(com.helper.loadviewhelper.load.LoadViewHelper) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem)

Example 10 with UnLimit91PornItem

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

the class DownloadingFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    unbinder = ButterKnife.bind(this, view);
    mUnLimit91PornItemList = new ArrayList<>();
    mDownloadAdapter = new DownloadVideoAdapter(R.layout.item_unlimit_91porn_download, mUnLimit91PornItemList);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.getItemAnimator().setChangeDuration(0);
    recyclerView.setAdapter(mDownloadAdapter);
    mDownloadAdapter.setEmptyView(R.layout.empty_view, recyclerView);
    mDownloadAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {

        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            UnLimit91PornItem unLimit91PornItem = (UnLimit91PornItem) adapter.getItem(position);
            if (unLimit91PornItem == null) {
                return;
            }
            Logger.t(TAG).d("当前状态:" + unLimit91PornItem.getStatus());
            if (view.getId() == R.id.iv_download_control) {
                if (FileDownloader.getImpl().isServiceConnected()) {
                    if (unLimit91PornItem.getStatus() == FileDownloadStatus.progress) {
                        FileDownloader.getImpl().pause(unLimit91PornItem.getDownloadId());
                        ((ImageView) view).setImageResource(R.drawable.start_download);
                    } else if (unLimit91PornItem.getStatus() == FileDownloadStatus.warn) {
                        startDownload(unLimit91PornItem, view, true);
                    } else if (unLimit91PornItem.getStatus() == FileDownloadStatus.paused) {
                        startDownload(unLimit91PornItem, view, false);
                    } else if (unLimit91PornItem.getStatus() == FileDownloadStatus.error) {
                        startDownload(unLimit91PornItem, view, false);
                    }
                }
            }
        }
    });
    mDownloadAdapter.setOnItemLongClickListener(new BaseQuickAdapter.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(BaseQuickAdapter adapter, View view, int position) {
            final UnLimit91PornItem unLimit91PornItem = (UnLimit91PornItem) adapter.getItem(position);
            if (unLimit91PornItem == null)
                return false;
            new AlertDialog.Builder(context).setMessage("刪除此任务?").setPositiveButton("好的", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    presenter.deleteDownloadingTask(unLimit91PornItem);
                    presenter.loadDownloadingData();
                }
            }).show();
            return true;
        }
    });
}
Also used : DialogInterface(android.content.DialogInterface) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) DownloadVideoAdapter(com.dante.adapter.DownloadVideoAdapter) 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