Ellie29

Untitled

Dec 8th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.28 KB | None | 0 0
  1. //loading all invitationa - memers with status INVITED
  2.     class LoadAllInvitations extends AsyncTask<String, String, String> {
  3.  
  4.         @Override
  5.         protected void onPreExecute() {
  6.             super.onPreExecute();
  7.             pDialog = new ProgressDialog(UserActivity.this);
  8.             pDialog.setMessage("Loading invitations. Please wait...");
  9.             pDialog.setIndeterminate(false);
  10.             pDialog.setCancelable(false);
  11.             pDialog.show();
  12.         }
  13.  
  14.         protected String doInBackground(String... args) {
  15.  
  16.             // Building Parameters
  17.             List<NameValuePair> params = new ArrayList<NameValuePair>();
  18.             params.add(new BasicNameValuePair(TAG_USERID, String.valueOf(userID)));
  19.  
  20.             //getting JSON string from URL
  21.             JSONObject json = jParser.makeHttpRequest(url_procedure_select_invitations_groups_with_names, "POST", params);
  22.             Log.d("All Invitaions: ", json.toString());
  23.  
  24.             try {
  25.                 // Checking for SUCCESS TAG
  26.                 int success = json.getInt(TAG_SUCCESS);
  27.  
  28.                 if (success == 1) {
  29.                     // users found Getting Array of membership
  30.                     memberships = json.getJSONArray(TAG_MEMBERSHIP);
  31.  
  32.                     // looping through memberships with invitations status
  33.                     for (int i = 0; i < memberships.length(); i++) {
  34.  
  35.                         JSONObject c = memberships.getJSONObject(i);
  36.                         String groupID = c.getString(TAG_GROUPID);
  37.                         String groupName = c.getString(TAG_GROUPNAME);
  38.  
  39.                         HashMap<String, String> map = new HashMap<String, String>();
  40.                         map.put(TAG_GROUPID, groupID);
  41.                         map.put(TAG_GROUPNAME, groupName);
  42.  
  43.                         invitationsList.add(map);
  44.                     }
  45.                 } else
  46.                     {
  47.                     Toast.makeText(getBaseContext(), "Error, can't load invitations", Toast.LENGTH_LONG).show();
  48.                 }
  49.  
  50.             } catch (JSONException e) {
  51.                 e.printStackTrace();
  52.             }
  53.  
  54.             return null;
  55.         }
  56.  
  57.         protected void onPostExecute(String file_url) {
  58.             pDialog.dismiss();
  59.         }
  60.     }
Advertisement
Add Comment
Please, Sign In to add comment