@Override
        public void onClick(DialogInterface dialog, int which) {
          switch (which) {
            case 0: // make user into a moderator
              ParseRelation moderators =
                  TheGroupUtil.getCurrentGroup().getRelation(TheGroupUtil.GROUP_MODERATORS);
              if (!isMod(TheGroupUtil.getAUser())) {
                moderators.add(TheGroupUtil.getAUser());
              }
              TheGroupUtil.getCurrentGroup().saveInBackground();

              break;
            case 1: // remove user
              ParseRelation members =
                  TheGroupUtil.getCurrentGroup().getRelation(TheGroupUtil.GROUP_MEMBERS);
              members.remove(TheGroupUtil.getAUser());
              TheGroupUtil.getCurrentGroup().saveInBackground();

              // check this, it will throw an error b/c user is not authenticated.
              /*ParseRelation relation = TheGroupUtil.getAUser().getRelation(TheGroupUtil.MEMBERSHIP);
              relation.remove(TheGroupUtil.getCurrentGroup());
              TheGroupUtil.getAUser().saveInBackground();
              */

              Intent intent = new Intent(SelectUserActivity.this, ViewBlogActivity.class);
              intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
              startActivity(intent);

              break;
          }
        }
 /** Sets the photo of the group. */
 private void setPhoto() {
   if (TheGroupUtil.getCurrentGroup().get(TheGroupUtil.GROUP_PHOTO) != null) {
     ParseFile picFile = (ParseFile) TheGroupUtil.getCurrentGroup().get(TheGroupUtil.GROUP_PHOTO);
     picFile.getDataInBackground(
         new GetDataCallback() {
           @Override
           public void done(byte[] bytes, ParseException e) {
             if (e == null) {
               Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
               myPhoto.setImageBitmap(bitmap);
               myPhoto.setBackgroundColor(0xFFffffff);
             } else {
               // unable to load image. //TODO
             }
           }
         });
   }
 }
 /** Sets the check boxes depending on what the founder/moderator specified previously. */
 private void setCheckBoxes() {
   if (TheGroupUtil.getCurrentGroup()
       .getString(TheGroupUtil.GROUP_TYPE)
       .equals(TheGroupUtil.GROUP_PRIVATE)) {
     myPrivateCheck.setChecked(true);
   } else {
     myPrivateCheck.setChecked(false);
   }
   if (TheGroupUtil.getCurrentGroup().getBoolean(TheGroupUtil.GROUP_BLOG_EXIST) == true) {
     myBlogCheck.setChecked(true);
   } else {
     myBlogCheck.setChecked(false);
   }
   if (TheGroupUtil.getCurrentGroup().getBoolean(TheGroupUtil.GROUP_CALENDAR_EXIST) == true) {
     myCalendarCheck.setChecked(true);
   } else {
     myCalendarCheck.setChecked(false);
   }
 }
  @OnClick(R.id.editGroupSaveButton)
  public void editGroup() {
    myProgressBar.setVisibility(View.VISIBLE);

    final ParseObject groupObject = TheGroupUtil.getCurrentGroup();

    if (editValid()) {
      groupObject.put(TheGroupUtil.GROUP_NAME, myName.getText().toString());
      groupObject.put(TheGroupUtil.GROUP_TYPE, getGroupType());
      groupObject.put(TheGroupUtil.GROUP_ONE_WORD, myOneWord.getText().toString());
      groupObject.put(TheGroupUtil.GROUP_LENGTHY_DESCRIPTION, myDescription.getText().toString());
      groupObject.put(TheGroupUtil.GROUP_BLOG_EXIST, getBlogCheck());
      groupObject.put(TheGroupUtil.GROUP_CALENDAR_EXIST, getCalendarCheck());

      if (TheNetUtil.isNetworkAvailable(this)) {
        groupObject.saveInBackground(
            new SaveCallback() {
              @Override
              public void done(ParseException e) {
                myProgressBar.setVisibility(View.INVISIBLE);
                if (e == null) {
                  // send user to the group looker page.
                  Intent intent = new Intent(EditGroupActivity.this, ViewGroupActivity.class);
                  startActivity(intent);
                }
              }
            });
      } else {
        myProgressBar.setVisibility(View.INVISIBLE);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder
            .setTitle("Network is currently unavailable")
            .setMessage(
                "This group will be updated and shared with the world automatically once network is connected!");
        builder.setPositiveButton(
            android.R.string.ok,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                groupObject.saveEventually();
              }
            });
        builder.setNegativeButton(android.R.string.cancel, null);
        builder.show();
      }
    } else {
      myProgressBar.setVisibility(View.INVISIBLE);
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder
          .setTitle("Cannot create group")
          .setMessage("Please make sure all of the information is filled out");
      builder.setPositiveButton(android.R.string.ok, null);
      builder.show();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().hide();
    TheColorUtil.onActivityCreateSetTheme(this);
    setContentView(R.layout.activity_edit_group);
    ButterKnife.bind(this);

    myProgressBar.setVisibility(View.INVISIBLE);

    mySaveButton.setBackgroundColor(TheColorUtil.getProperColor());
    myEditMembersButton.setBackgroundColor(TheColorUtil.getProperColor());
    myName.setText(TheGroupUtil.getCurrentGroup().getString(TheGroupUtil.GROUP_NAME));
    myOneWord.setText(TheGroupUtil.getCurrentGroup().getString(TheGroupUtil.GROUP_ONE_WORD));
    myDescription.setText(
        TheGroupUtil.getCurrentGroup().getString(TheGroupUtil.GROUP_LENGTHY_DESCRIPTION));
    setCheckBoxes();

    setPhoto();
  }
  /**
   * This method checks to see if the current user is a moderator.
   *
   * @param theUser the current user
   * @return true if he is a moderator or founder, false otherwise.
   */
  private boolean isMod(final ParseUser theUser) {
    ParseRelation moderators =
        TheGroupUtil.getCurrentGroup().getRelation(TheGroupUtil.GROUP_MODERATORS);
    int i = -1;
    try {
      i = moderators.getQuery().whereEqualTo("objectId", theUser.getObjectId()).count();
    } catch (ParseException e) {
      e.printStackTrace();
    }

    return i == 1;
  }
  private void setImage(Uri theUri) {
    Log.d("ProfileFragment", "Here in setImage with uri: " + theUri);
    try {
      Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), theUri);
      Log.d("ProfileFragment", "bitmap is: " + bitmap.toString());
      myPhoto.setImageBitmap(bitmap);

      // send to parse
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
      byte[] array = stream.toByteArray();
      ParseFile file = new ParseFile("profilePic.jpeg", array);
      file.saveInBackground();
      TheGroupUtil.getCurrentGroup().put(TheGroupUtil.GROUP_PHOTO, file);
      TheGroupUtil.getCurrentGroup().saveInBackground();

    } catch (FileNotFoundException e) {
      Log.e("ProfileFragment", "Error: " + e);
    } catch (IOException e) {
      Log.e("ProfileFragment", "Error: " + e);
    }
  }
  private void getAllUsers() {
    myBar.setVisibility(View.VISIBLE);

    ParseRelation userRelation =
        TheGroupUtil.getCurrentGroup().getRelation(TheGroupUtil.GROUP_MEMBERS);
    userRelation
        .getQuery()
        .findInBackground(
            new FindCallback() {
              @Override
              public void done(List list, ParseException e) {
                myBar.setVisibility(View.INVISIBLE);
                if (e == null) {
                  mUsers = new ParseUser[list.size()];
                  for (int i = 0; i < list.size(); i++) {
                    mUsers[i] = (ParseUser) list.get(i);
                  }
                  UserAdapter adapter = new UserAdapter(SelectUserActivity.this, mUsers);
                  myList.setAdapter(adapter);
                  myList.setOnItemClickListener(
                      new AdapterView.OnItemClickListener() {
                        @Override
                        public void onItemClick(
                            AdapterView<?> parent, View view, int position, long id) {
                          TheGroupUtil.setAUser(mUsers[position]);

                          if (isMod(ParseUser.getCurrentUser())) {
                            AlertDialog.Builder builder =
                                new AlertDialog.Builder(SelectUserActivity.this);
                            builder.setItems(R.array.user_choices, mDialogInterface);
                            AlertDialog dialog = builder.create();
                            dialog.show();
                          }
                        }
                      });
                } else {
                  /// Something went wrong.
                  Toast.makeText(
                          SelectUserActivity.this,
                          "Sorry, there was an error getting users!",
                          Toast.LENGTH_LONG)
                      .show();
                }
              }

              @Override
              public void done(Object o, Throwable throwable) {
                myBar.setVisibility(View.INVISIBLE);
                if (throwable == null) {
                  ArrayList<ParseUser> arrayList = (ArrayList) o;
                  mUsers = new ParseUser[arrayList.size()];
                  for (int i = 0; i < arrayList.size(); i++) {
                    mUsers[i] = (ParseUser) arrayList.get(i);
                  }
                  UserAdapter adapter = new UserAdapter(SelectUserActivity.this, mUsers);
                  myList.setAdapter(adapter);
                  myList.setOnItemClickListener(
                      new AdapterView.OnItemClickListener() {
                        @Override
                        public void onItemClick(
                            AdapterView<?> parent, View view, int position, long id) {
                          TheGroupUtil.setAUser(mUsers[position]);

                          if (isMod(ParseUser.getCurrentUser())) {
                            AlertDialog.Builder builder =
                                new AlertDialog.Builder(SelectUserActivity.this);
                            builder.setItems(R.array.user_choices, mDialogInterface);
                            AlertDialog dialog = builder.create();
                            dialog.show();
                          }
                        }
                      });
                }
              }
            });
  }