public void download() {
   if (curStatus == STATUS_UM) {
     UmFunc.getIns().downloadFile(message, resource);
   } else if (curStatus == STATUS_GROUP_ZONE) {
     GroupZoneFunc.ins().downloadFile(groupFile);
   } else if (curStatus == STATUS_PREVIEW) {
     // do nothing
     Logger.error(LocalLog.APPTAG, "local file, don't download.");
   }
 }
 public void cancelTransfer() {
   if (curStatus == STATUS_UM) {
     AutoCancelStack.getIns().cancelAuto(message.getMessageId());
     UmFunc.getIns().cancelTransFile(message.getId(), resource.getMediaId(), false);
   } else if (curStatus == STATUS_GROUP_ZONE) {
     GroupZoneFunc.ins().cancelDownload(groupFile);
   } else if (curStatus == STATUS_PREVIEW) {
     // do nothing
     Logger.error(LocalLog.APPTAG, "local file, don't download.");
   }
 }
  private boolean checkUmState() {
    long mId = message.getId();
    int mediaId = resource.getMediaId();
    if (UmFunc.getIns().isInTransFile(mId, mediaId, false)) {
      FileTransfer.ProgressInfo info = UmFunc.getIns().getTransProcess(mId, mediaId, false);

      if (info != null) {
        updateProgress(info.getCurSize(), info.getTotalSize());
      }
      return false;
    }

    int resType = resource.getResourceType();
    if (MediaResource.RES_LOCAL == resType) {
      String path =
          resource
              .getLocalPath(); // UmUtil.createResPath(MediaResource.MEDIA_FILE, resource.getName(),
      // "");
      return !checkFileExistAndOpen(path);
    }

    return true;
  }
  private void registerUm() {
    mediaBroadcast = new String[] {UmFunc.DOWNLOADFILEFINISH, UmFunc.DOWNLOADPROCESSUPDATE};
    umReceiver =
        new BaseReceiver() {
          @Override
          public void onReceive(String broadcastName, BaseData d) {
            if (!(d instanceof UmFunc.UmReceiveData)) {
              return;
            }

            UmFunc.UmReceiveData data = (UmFunc.UmReceiveData) d;
            if (data.msg == null || data.media == null) {
              return;
            }

            InstantMessage iMsg = data.msg;
            if (iMsg.getId() != message.getId()) {
              return;
            }

            if (UmFunc.DOWNLOADFILEFINISH.equals(broadcastName)) {
              if (UmFunc.UmReceiveData.FINISH_FAIL == data.status) {
                handler.sendEmptyMessage(DOWNLOAD_FAIL);
              } else if (UmFunc.UmReceiveData.FINISH_SUCCESS == data.status) {
                updateMsg(data.msg, data.media);
                openFile(data.media.getLocalPath());
              }
            } else if (UmFunc.DOWNLOADPROCESSUPDATE.endsWith(broadcastName)) {
              if (null != data.process) {
                updateProgress(data.process.getCurSize(), data.process.getTotalSize());
              }
            }
          }
        };

    UmFunc.getIns().registerBroadcast(umReceiver, mediaBroadcast);
  }
  public void unRegister() {
    UmFunc.getIns().unRegisterBroadcast(umReceiver, mediaBroadcast);

    GroupZoneFunc.ins().unRegisterBroadcast(zoneReceiver, zoneBroadcast);
  }