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);
  }
 @Override
 public void onRequestSuccess(GetApkInfoJson getApkInfoJson) {
   if (getApkInfoJson != null) {
     if (getApkInfoJson.getStatus().equals("OK")) {
       startDownloadFromJson(getApkInfoJson, id, download);
     } else {
       final HashMap<String, Integer> errorsMapConversion = Errors.getErrorsMap();
       Integer stringId;
       String message;
       for (ErrorResponse error : getApkInfoJson.getErrors()) {
         stringId = errorsMapConversion.get(error.getCode());
         if (stringId != null) {
           message = getString(stringId);
         } else {
           message = error.getMsg();
         }
         Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
       }
     }
   }
 }