示例#1
0
  /** Retriever application list from the server. */
  private void getAppListFromServer() {
    String ipSaved =
        Preference.getString(context.getApplicationContext(), Constants.PreferenceFlag.IP);

    if (ipSaved != null && !ipSaved.isEmpty()) {
      ServerConfig utils = new ServerConfig();
      utils.setServerIP(ipSaved);
      CommonUtils.callSecuredAPI(
          AppListActivity.this,
          utils.getAPIServerURL(context) + Constants.APP_LIST_ENDPOINT,
          HTTP_METHODS.GET,
          null,
          AppListActivity.this,
          Constants.APP_LIST_REQUEST_CODE);
    } else {
      Log.e(TAG, "There is no valid IP to contact the server");
    }
  }
示例#2
0
 @Override
 public void onReceive(Context context, Intent intent) {
   String status = intent.getStringExtra(Constants.INTENT_KEY_STATUS);
   Preference.putString(
       context,
       context.getResources().getString(R.string.emm_server_url),
       intent.getStringExtra(Constants.INTENT_KEY_SERVER));
   CommonDialogUtils.stopProgressDialog(progressDialog);
   if (Constants.Status.SUCCESSFUL.equals(status)) {
     if (intent.hasExtra(Constants.INTENT_KEY_PAYLOAD)
         && intent.getStringExtra(Constants.INTENT_KEY_PAYLOAD) != null) {
       try {
         JSONObject payload =
             new JSONObject(intent.getStringExtra(Constants.INTENT_KEY_PAYLOAD));
         if (!payload.isNull(Constants.ApplicationPayload.APP_LIST)) {
           JSONArray applicationList =
               payload.getJSONArray(Constants.ApplicationPayload.APP_LIST);
           appList.setVisibility(View.VISIBLE);
           btnMobileApps.setVisibility(View.VISIBLE);
           btnWebApps.setVisibility(View.VISIBLE);
           txtError.setVisibility(View.GONE);
           setAppListUI(applicationList);
         }
       } catch (JSONException e) {
         appList.setVisibility(View.GONE);
         btnMobileApps.setVisibility(View.GONE);
         btnWebApps.setVisibility(View.GONE);
         txtError.setVisibility(View.VISIBLE);
         Log.e(TAG, "Failed parsing application list response" + e);
       }
     } else {
       appList.setVisibility(View.GONE);
       btnMobileApps.setVisibility(View.GONE);
       btnWebApps.setVisibility(View.GONE);
       txtError.setVisibility(View.VISIBLE);
     }
   } else {
     appList.setVisibility(View.GONE);
     btnMobileApps.setVisibility(View.GONE);
     btnWebApps.setVisibility(View.GONE);
     txtError.setVisibility(View.VISIBLE);
   }
 }