Search in sources :

Example 1 with DownloadVideoAdapter

use of com.dante.adapter.DownloadVideoAdapter 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)

Example 2 with DownloadVideoAdapter

use of com.dante.adapter.DownloadVideoAdapter in project 91Pop by DanteAndroid.

the class FinishedFragment method onViewCreated.

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

        @Override
        public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
            UnLimit91PornItem unLimit91PornItem = (UnLimit91PornItem) adapter.getItem(position);
            openMp4File(unLimit91PornItem);
        }
    });
    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) {
                    File file = new File(unLimit91PornItem.getDownLoadPath(dataManager));
                    if (file.exists()) {
                        showDeleteFileDialog(unLimit91PornItem);
                    } else {
                        presenter.deleteDownloadedTask(unLimit91PornItem, false);
                        presenter.loadFinishedData();
                    }
                }
            }).show();
            return true;
        }
    });
    presenter.loadFinishedData();
}
Also used : DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem) DownloadVideoAdapter(com.dante.adapter.DownloadVideoAdapter) File(java.io.File)

Aggregations

DialogInterface (android.content.DialogInterface)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 BindView (butterknife.BindView)2 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)2 DownloadVideoAdapter (com.dante.adapter.DownloadVideoAdapter)2 UnLimit91PornItem (com.dante.data.model.UnLimit91PornItem)2 ImageView (android.widget.ImageView)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1