public void leaveTransferProgress() { if (mProgressListener != null) { if (mContainerActivity.getFileDownloaderBinder() != null) { mContainerActivity .getFileDownloaderBinder() .removeDatatransferProgressListener(mProgressListener, mAccount, getFile()); mListening = false; } } }
public void listenForTransferProgress() { if (mProgressListener != null && !mListening) { if (mContainerActivity.getFileDownloaderBinder() != null) { mContainerActivity .getFileDownloaderBinder() .addDatatransferProgressListener(mProgressListener, mAccount, getFile()); mListening = true; setButtonsForTransferring(); } } }
/** * Updates the view depending upon the state of the downloading file. * * @param transferring When true, the view must be updated assuming that the holded file is * downloading, no matter what the downloaderBinder says. */ public void updateView(boolean transferring) { // configure UI for depending upon local state of the file FileDownloaderBinder downloaderBinder = (mContainerActivity == null) ? null : mContainerActivity.getFileDownloaderBinder(); if (transferring || (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile()))) { setButtonsForTransferring(); } else if (getFile().isDown()) { setButtonsForDown(); } else { setButtonsForRemote(); } getView().invalidate(); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.cancelBtn: { FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder(); if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile())) { downloaderBinder.cancel(mAccount, getFile()); getActivity().finish(); // :) /* leaveTransferProgress(); if (mFile.isDown()) { setButtonsForDown(); } else { setButtonsForRemote(); } */ } break; } default: Log_OC.e(TAG, "Incorrect view clicked!"); } }