public void startDownloadFromJson(GetApkInfoJson json, long id, Download download) {
    ArrayList<DownloadModel> filesToDownload = new ArrayList<DownloadModel>();

    if (json.getObb() != null) {
      DownloadModel mainObbDownload =
          new DownloadModel(
              json.getObb().getMain().getPath(),
              OBB_DESTINATION
                  + download.getPackageName()
                  + "/"
                  + json.getObb().getMain().getFilename(),
              json.getObb().getMain().getMd5sum(),
              json.getObb().getMain().getFilesize().longValue());
      filesToDownload.add(mainObbDownload);
      if (json.getObb().getPatch() != null) {
        DownloadModel patchObbDownload =
            new DownloadModel(
                json.getObb().getPatch().getPath(),
                OBB_DESTINATION
                    + download.getPackageName()
                    + "/"
                    + json.getObb().getPatch().getFilename(),
                json.getObb().getPatch().getMd5sum(),
                json.getObb().getPatch().getFilesize().longValue());
        filesToDownload.add(patchObbDownload);
      }
    }

    String path = Aptoide.getConfiguration().getPathCacheApks();

    if (json.getApk().getMd5sum() != null) {
      download.setId(json.getApk().getMd5sum().hashCode());
    }

    DownloadModel downloadModel =
        new DownloadModel(
            json.getApk().getPath(),
            path + json.getApk().getMd5sum() + ".apk",
            json.getApk().getMd5sum(),
            json.getApk().getSize().longValue());
    downloadModel.setAutoExecute(true);
    downloadModel.setFallbackUrl(json.getApk().getAltPath());
    filesToDownload.add(downloadModel);

    FinishedApk apk =
        new FinishedApk(
            download.getName(),
            download.getPackageName(),
            download.getVersion(),
            id,
            download.getIcon(),
            path + json.getApk().getMd5sum() + ".apk",
            new ArrayList<String>(json.getApk().getPermissions()));
    apk.setId(json.getApk().getId().longValue());

    download(download.getId(), download, apk, filesToDownload);
  }
  public void startDownloadFromV6(Download download, UpdatesResponse.UpdateApk apk) {
    ArrayList<DownloadModel> filesToDownload = new ArrayList<>();

    String path = Aptoide.getConfiguration().getPathCacheApks();

    if (apk.md5sum != null) {
      download.setId(apk.md5sum.hashCode());
    }

    DownloadModel downloadModel =
        new DownloadModel(
            apk.apk.path, path + apk.md5sum + ".apk", apk.md5sum, apk.apk.filesize.longValue());
    downloadModel.setAutoExecute(true);
    downloadModel.setFallbackUrl(apk.apk.path_alt);
    filesToDownload.add(downloadModel);

    FinishedApk fapk =
        new FinishedApk(
            download.getName(),
            download.getPackageName(),
            download.getVersion(),
            apk.md5sum.hashCode(),
            download.getIcon(),
            path + apk.md5sum + ".apk",
            new ArrayList<String>());
    fapk.setId(apk.md5sum.hashCode());

    download(download.getId(), download, fapk, filesToDownload);
  }
  public void startDownloadFromUrl(
      String remotePath, String md5, long id, Download download, String repoName) {
    ArrayList<DownloadModel> filesToDownload = new ArrayList<DownloadModel>();

    String path = Aptoide.getConfiguration().getPathCacheApks();

    DownloadModel downloadModel = new DownloadModel(remotePath, path + md5 + ".apk", md5, 0);
    downloadModel.setAutoExecute(true);
    filesToDownload.add(downloadModel);

    FinishedApk apk =
        new FinishedApk(
            download.getName(),
            download.getPackageName(),
            download.getVersion(),
            id,
            download.getIcon(),
            path + md5 + ".apk",
            new ArrayList<String>());
    apk.setRepoName(repoName);

    download(id, download, apk, filesToDownload);
  }