Exemple #1
0
    @Override
    protected Boolean doInBackground(Boolean... params) {

      allStats = db.getAllAppsLatestStats(accountname);

      for (AppInfo appInfo : allStats) {

        if (!appInfo.isGhost()) {
          String admobSiteId = Preferences.getAdmobSiteId(Main.this, appInfo.getPackageName());
          if (admobSiteId != null) {
            List<Admob> admobStats =
                db.getAdmobStats(admobSiteId, Timeframe.LAST_TWO_DAYS).getAdmobs();
            if (admobStats.size() > 0) {
              Admob admob = admobStats.get(admobStats.size() - 1);
              appInfo.setAdmobStats(admob);
            }
          }
          filteredStats.add(appInfo);
        }
      }

      triggerRemoteCall = params[0];

      return null;
    }
Exemple #2
0
    @SuppressWarnings("unchecked")
    @Override
    protected Exception doInBackground(String... params) {

      // authentication failed before, retry with token invalidation

      Exception exception = null;

      String authtoken = ((AndlyticsApp) getApplication()).getAuthToken();

      List<AppInfo> appDownloadInfos = null;
      try {

        DeveloperConsole console = new DeveloperConsole(Main.this);
        appDownloadInfos = console.getAppDownloadInfos(authtoken, accountname);

        if (cancelRequested) {
          cancelRequested = false;
          return null;
        }

        Map<String, List<String>> admobAccountSiteMap = new HashMap<String, List<String>>();

        for (AppInfo appDownloadInfo : appDownloadInfos) {
          // update in database
          db.insertOrUpdateStats(appDownloadInfo);
          String admobSiteId =
              Preferences.getAdmobSiteId(Main.this, appDownloadInfo.getPackageName());
          if (admobSiteId != null) {
            String admobAccount = Preferences.getAdmobAccount(Main.this, admobSiteId);
            if (admobAccount != null) {
              List<String> siteList = admobAccountSiteMap.get(admobAccount);
              if (siteList == null) {
                siteList = new ArrayList<String>();
              }
              siteList.add(admobSiteId);
              admobAccountSiteMap.put(admobAccount, siteList);
            }
          }
        }

        // sync admob accounts
        Set<String> admobAccuntKeySet = admobAccountSiteMap.keySet();
        for (String admobAccount : admobAccuntKeySet) {

          AdmobRequest.syncSiteStats(
              admobAccount, Main.this, admobAccountSiteMap.get(admobAccount), null);
        }

        new LoadIconInCache().execute(appDownloadInfos);

      } catch (Exception e) {

        if (e instanceof IOException) {
          e = new NetworkException(e);
        }

        exception = e;

        Log.e(TAG, "error while requesting developer console", e);
      }

      if (dotracking == true) {
        int size = 0;
        if (appDownloadInfos != null) {
          size = appDownloadInfos.size();
        }
        // TODO endless loop in case of exception!!!
        if (exception == null) {
          Map<String, String> map = new HashMap<String, String>();
          map.put("num", size + "");
        } else {
        }
        dotracking = false;
      }

      return exception;
    }