/**
   * Call.
   *
   * @param url the url
   * @param nameSpace the name space
   * @param methodName the method name
   * @param Params the params
   * @param listener the listener
   */
  public void call(
      final String url,
      final String nameSpace,
      final String methodName,
      AbSoapParams Params,
      final AbSoapListener listener) {
    this.mParams = Params;

    if (!AbAppUtil.isNetworkAvailable(mContext)) {
      listener.sendFailureMessage(
          AbHttpStatus.CONNECT_FAILURE_CODE,
          AbAppConfig.CONNECT_EXCEPTION,
          new AbAppException(AbAppConfig.CONNECT_EXCEPTION));
      return;
    }

    listener.sendStartMessage();

    mExecutorService.execute(
        new Runnable() {
          @Override
          public void run() {
            try {
              doCall(url, nameSpace, methodName, mParams, listener);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
  }
Esempio n. 2
0
  /**
   * 描述:初始化存储目录.
   *
   * @param context the context
   */
  public static void initFileDir(Context context) {

    PackageInfo info = AbAppUtil.getPackageInfo(context);

    // 默认下载文件根目录.
    String downloadRootPath =
        File.separator
            + AbAppConfig.DOWNLOAD_ROOT_DIR
            + File.separator
            + info.packageName
            + File.separator;

    // 默认下载图片文件目录.
    String imageDownloadPath = downloadRootPath + AbAppConfig.DOWNLOAD_IMAGE_DIR + File.separator;

    // 默认下载文件目录.
    String fileDownloadPath = downloadRootPath + AbAppConfig.DOWNLOAD_FILE_DIR + File.separator;

    // 默认缓存目录.
    String cacheDownloadPath = downloadRootPath + AbAppConfig.CACHE_DIR + File.separator;

    // 默认DB目录.
    String dbDownloadPath = downloadRootPath + AbAppConfig.DB_DIR + File.separator;

    try {
      if (!isCanUseSD()) {
        return;
      } else {

        File root = Environment.getExternalStorageDirectory();
        File downloadDir = new File(root.getAbsolutePath() + downloadRootPath);
        if (!downloadDir.exists()) {
          downloadDir.mkdirs();
        }
        downloadRootDir = downloadDir.getPath();

        File cacheDownloadDirFile = new File(root.getAbsolutePath() + cacheDownloadPath);
        if (!cacheDownloadDirFile.exists()) {
          cacheDownloadDirFile.mkdirs();
        }
        cacheDownloadDir = cacheDownloadDirFile.getPath();

        File imageDownloadDirFile = new File(root.getAbsolutePath() + imageDownloadPath);
        if (!imageDownloadDirFile.exists()) {
          imageDownloadDirFile.mkdirs();
        }
        imageDownloadDir = imageDownloadDirFile.getPath();

        File fileDownloadDirFile = new File(root.getAbsolutePath() + fileDownloadPath);
        if (!fileDownloadDirFile.exists()) {
          fileDownloadDirFile.mkdirs();
        }
        fileDownloadDir = fileDownloadDirFile.getPath();

        File dbDownloadDirFile = new File(root.getAbsolutePath() + dbDownloadPath);
        if (!dbDownloadDirFile.exists()) {
          dbDownloadDirFile.mkdirs();
        }
        dbDownloadDir = dbDownloadDirFile.getPath();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }