@Override public void onReceive(Context context, Intent intent) { if (mTransferService == null) { return; } String type = intent.getStringExtra("type"); if (type == null) { return; } if (type.equals(DownloadTaskManager.BROADCAST_FILE_DOWNLOAD_SUCCESS)) { int taskID = intent.getIntExtra("taskID", 0); DownloadTaskInfo info = mTransferService.getDownloadTaskInfo(taskID); if (info != null) { if (monitor.isStarted()) { monitor.onFileDownloaded( info.account, info.repoID, info.repoName, info.pathInRepo, info.localFilePath); } } } else if (type.equals(UploadTaskManager.BROADCAST_FILE_UPLOAD_SUCCESS)) { int taskID = intent.getIntExtra("taskID", 0); UploadTaskInfo info = mTransferService.getUploadTaskInfo(taskID); if (info != null && info.isUpdate) { updateMgr.onFileUpdateSuccess( info.account, info.repoID, info.repoName, info.parentDir, info.localFilePath, info.version); } } else if (type.equals(UploadTaskManager.BROADCAST_FILE_UPLOAD_FAILED)) { int taskID = intent.getIntExtra("taskID", 0); UploadTaskInfo info = mTransferService.getUploadTaskInfo(taskID); if (info != null && info.isUpdate) { updateMgr.onFileUpdateFailure( info.account, info.repoID, info.repoName, info.parentDir, info.localFilePath, info.err, info.version); } } }
@Override public void onDestroy() { Log.d(DEBUG_TAG, "onDestroy"); updateMgr.stop(); if (monitor != null) { try { monitor.stop(); } catch (Exception e) { Log.d(DEBUG_TAG, "failed to stop file monitor"); } } if (mTransferService != null) { unbindService(mTransferConnection); mTransferService = null; } LocalBroadcastManager.getInstance(this).unregisterReceiver(transferReceiver); }
public void removeAccount(Account account) { Log.d(DEBUG_TAG, account.email); if (monitor != null) monitor.stopMonitorFilesForAccount(account); }