@Override public void setDownloadJobProgress(PutlockerUpDownloadJob job, Long bytes, Long bytesTotal) { PutlockerUpDownloadJob listJob = _adapter.getListJob(job); if (listJob != null) { if (listJob instanceof PutlockerUploadJob) { ((PutlockerUploadJob) job).setTotalUploaded(bytes); } else { ((PutlockerDownloadJob) job).downloadedFileSize = bytes; } } _adapter.setProgressOfJob(job, job.getProgressForDownload()); }
@Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { final PutlockerUpDownloadJob job = _adapter.getItem(position); if (job instanceof PutlockerDownloadJob) { if (isVideo(job.getName())) { if (!hasMxPlayerInstalled() && !hasToldNotToPrompt()) { LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.mx_player_dialog, null); final CheckBox dontWarn = (CheckBox) layout.findViewById(R.id.dont_ask_again); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(layout); builder .setPositiveButton( R.string.take_to_mx_player, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final String appName = "com.mxtech.videoplayer.ad"; startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appName))); if (dontWarn.isChecked()) { setDontWarnAgain(); } } }) .setNegativeButton( R.string.no_thanks, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (dontWarn.isChecked()) { setDontWarnAgain(); startJob((PutlockerDownloadJob) job); } } }); builder.create(); builder.show(); } else { startJob((PutlockerDownloadJob) job); } } else { startJob((PutlockerDownloadJob) job); } } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (v.getId() == R.id.list) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; PutlockerUpDownloadJob job = _adapter.getItem(info.position); DownloadStatus st = job.getStatus(); menu.setHeaderTitle(job.getName()); menu.add(0, DOWNLOAD_DELETE_DOWNLOAD, 0, R.string.context_menu_delete); if (st.getValue().equals(DownloadStatus.JobStarted.getValue())) { menu.add(0, DOWNLOAD_STOP_DOWNLOAD, 0, R.string.context_menu_stop); } _menuItemSelected = job; } }