예제 #1
0
        @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);
            }
          }
        }
예제 #2
0
  @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);
  }
예제 #3
0
 @Override
 public void onServiceConnected(ComponentName className, IBinder binder) {
   TransferService.TransferBinder transferBinder = (TransferService.TransferBinder) binder;
   mTransferService = transferBinder.getService();
   updateMgr.onTransferServiceConnected(mTransferService);
 }