Android Open Source - GroupGoal View Attendees Activity

From Project

Back to project page GroupGoal.


The source code is released under:

GNU General Public License

If you think the Android project GroupGoal listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.cs121.groupgoal;
//  ww  w  .j a  v a  2  s .com
import java.util.HashMap;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.parse.ParseQuery;
import com.parse.ParseUser;

 * This activity lists the names of users that have joined a particular goal and allows the user to click on 
 * those user's profiles. 
public class ViewAttendeesActivity extends Activity {

  GoalPost goal;
  ListView attendeeView;
  HashMap<String, String> userProfiles;
  HashMap<String, String> reverseLookup;
  ParseUser attendee;
  private String parseId;
  private String ownerName;
  protected void onCreate(Bundle savedInstanceState) {
    Intent intent = getIntent();
    parseId = intent.getStringExtra("goal_id");
    ownerName = intent.getStringExtra("goal_owner");
    userProfiles = new HashMap<String,String>();
    reverseLookup = new HashMap<String, String>();
    ParseQuery<GoalPost> postQuery = ParseQuery.getQuery(GoalPost.class);
      try {
        goal = postQuery.get(parseId);
      } catch (com.parse.ParseException e) {
      Log.e("Goal Error", e.getMessage());
      ParseQuery<ParseUser> userQuery = ParseUser.getQuery();
      List<String> attendeeIds = goal.getAttendees();
      for(String id : attendeeIds) {
        ParseUser user;
        try {
          user = userQuery.get(id);
          userProfiles.put(id, adaptFullName(user.get("fullName").toString()));
          reverseLookup.put(adaptFullName(user.get("fullName").toString()), id);
        } catch (com.parse.ParseException e) {
        Log.e("Goal Error", e.getMessage());
      ArrayAdapter<String> attendeesAdapter = 
          new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
    attendeeView = (ListView) findViewById(;
    attendeeView.setOnItemClickListener(new OnItemClickListener() {

      public void onItemClick(AdapterView<?>adapter,View v, int position, long id) {
        String user = (String) adapter.getItemAtPosition(position);
        String userId = reverseLookup.get(user);
        Intent intent = new Intent(ViewAttendeesActivity.this,
          .putExtra("userId", userId);
  public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent = new Intent(ViewAttendeesActivity.this, ViewGoal.class)
      .putExtra("goal_id", parseId)
      .putExtra("goal_owner", ownerName);
    return true;
  private String adaptFullName(String fullName) {
    String[] goalOwnerFirstLast = fullName.split("\\^");
    return (goalOwnerFirstLast[0] + " " + goalOwnerFirstLast[1]);


Java Source Code List