Exemple #1
0
 @Override
 protected AppInfo doInBackground(String... params) {
   isRunning = true;
   AppInfo result = new AppInfo();
   DataManager dm = new DataManager();
   try {
     result = dm.getAppInfo();
   } catch (ClientProtocolException e) {
     result.setFailed(true);
     result.setFailedReason(e.toString());
     e.printStackTrace();
   } catch (JSONException e) {
     result.setFailed(true);
     result.setFailedReason(e.toString());
     e.printStackTrace();
   } catch (IOException e) {
     result.setFailed(true);
     result.setFailedReason(e.toString());
     e.printStackTrace();
   }
   return result;
 }
Exemple #2
0
    @Override
    protected void onPostExecute(AppInfo result) {
      isRunning = false;
      super.onPostExecute(result);
      stopPbDialog(DIALOG_CHECK_VERSION);
      if (result != null) {
        String name = null;
        int number = 0;

        try {
          name =
              TimeClock.this
                  .getPackageManager()
                  .getPackageInfo(TimeClock.this.getPackageName(), 0)
                  .versionName;
          number =
              TimeClock.this
                  .getPackageManager()
                  .getPackageInfo(TimeClock.this.getPackageName(), 0)
                  .versionCode;
        } catch (NameNotFoundException e) {
          e.printStackTrace();
          isAllowedToPress = false;
          buildNeedUpdateDialog();
        }
        if (name == null && number == 0) {
          isAllowedToPress = false;
          buildNeedUpdateDialog();
        } else {
          if (name.equalsIgnoreCase(result.getCurrentVersion())
              && number == result.getCurrentNumber()) {
            isAllowedToPress = true;
            return;
          } else {
            if (result.isStrict()) {
              isAllowedToPress = false;
              buildNeedUpdateDialog();
              return;
            } else {
              ArrayList<OldVersion> lol = result.getOlds();
              for (int i = 0; i < lol.size(); i++) {
                OldVersion tmp = lol.get(i);
                if (tmp.getCurrentNumber() == number
                    && tmp.getCurrentVersion().equalsIgnoreCase(name)) {
                  if (tmp.isIsAllowed()) {
                    isAllowedToPress = true;
                    return;
                  } else {
                    isAllowedToPress = false;
                    buildNeedUpdateDialog();
                    return;
                  }
                } else {
                  isAllowedToPress = false;
                  buildNeedUpdateDialog();
                }
              }
            }
          }
        }
      } else {
        isAllowedToPress = false;
        buildNeedUpdateDialog();
      }
    }