Пример #1
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);
   }
 }
Пример #2
0
 @Override
 public void onReceiveAPIResult(Map<String, String> result, int requestCode) {
   String responseStatus;
   CommonDialogUtils.stopProgressDialog(progressDialog);
   if (requestCode == Constants.APP_LIST_REQUEST_CODE) {
     if (result != null && result.get(Constants.RESPONSE) != null) {
       responseStatus = result.get(Constants.STATUS);
       if (Constants.Status.SUCCESSFUL.equals(responseStatus)) {
         try {
           JSONObject payload = new JSONObject(result.get(Constants.RESPONSE));
           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);
     }
   }
 }