@AfterViews protected final void initAttachmentsDownloadDetailActivity() { share = AttachmentsDownloadDetailActivity.this.getSharedPreferences( FileUtil.DOWNLOAD_SETTING, Context.MODE_PRIVATE); defaultPath = Environment.DIRECTORY_DOWNLOADS + File.separator + FileUtil.DOWNLOAD_FOLDER; mFileObject = mAttachmentFileObject; if (mAttachmentFileObject != null) { File file = FileUtil.getDestinationInExternalPublicDir( getFileDownloadPath(), mAttachmentFileObject.getSaveName(mProjectObjectId)); if (file.exists() && file.isFile()) { jumpTextHtmlActivity(); showState(STATE_FINISHDOWNLOAD); } } getSupportActionBar().setTitle(mAttachmentFileObject.getName()); handler = new MyHandler(); downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); downloadManagerPro = new DownloadManagerPro(downloadManager); completeReceiver = new CompleteReceiver(); registerReceiver(completeReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); downloadList = AttachmentsDownloadDetailActivity.this.getSharedPreferences( FileUtil.DOWNLOAD_LIST, Context.MODE_PRIVATE); downloadListEditor = downloadList.edit(); client = MyAsyncHttpClient.createClient(AttachmentsDownloadDetailActivity.this); // urlPages = String.format(urlFiles, mProjectObjectId, mAttachmentFileObject.file_id, // mAttachmentFolderObject.file_id); urlFiles = String.format(urlFiles, mProjectObjectId, mAttachmentFileObject.file_id); urlDownload = String.format(urlDownload, mProjectObjectId, mAttachmentFileObject.file_id); if (mAttachmentFileObject == null) { mainLayout.setVisibility(View.GONE); showDialogLoading(); getFileUrlFromNetwork(); } else { bindView(); } if (mHideHistoryLayout) { layout_dynamic_history.setVisibility(View.INVISIBLE); } }
@AfterViews void init() { getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setTitle(mAttachmentFileObject.name); handler = new MyHandler(); downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); downloadManagerPro = new DownloadManagerPro(downloadManager); completeReceiver = new CompleteReceiver(); /** register download success broadcast * */ registerReceiver(completeReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); share = AttachmentsDownloadDetailActivity.this.getSharedPreferences( FileUtil.DOWNLOAD_SETTING, Context.MODE_PRIVATE); defaultPath = Environment.DIRECTORY_DOWNLOADS + File.separator + FileUtil.DOWNLOAD_FOLDER; downloadList = AttachmentsDownloadDetailActivity.this.getSharedPreferences( FileUtil.DOWNLOAD_LIST, Context.MODE_PRIVATE); downloadListEditor = downloadList.edit(); client = MyAsyncHttpClient.createClient(AttachmentsDownloadDetailActivity.this); mainLayout.setVisibility(View.GONE); urlFiles = String.format(urlFiles, mProjectObjectId, mAttachmentFileObject.file_id); urlPages = String.format( urlFiles, mProjectObjectId, mAttachmentFileObject.file_id, mAttachmentFolderObject.file_id); urlDownload = String.format(urlDownload, mProjectObjectId, mAttachmentFileObject.file_id); showDialogLoading(); getNetwork(urlFiles, urlFiles); btnDownload.setOnClickListener(onDownloadListener); btnOpen.setOnClickListener(onOpenListener); ivDownloadCancel.setOnClickListener(onCancelListener); }