Android Open Source - GroupGoal View Attendees Activity






From Project

Back to project page GroupGoal.

License

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.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
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;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_attendees);
      getActionBar().setDisplayShowTitleEnabled(false);
    
    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);
      
      attendeesAdapter.addAll(userProfiles.values());
      
    attendeeView = (ListView) findViewById(R.id.attendee_list_view);
    attendeeView.setAdapter(attendeesAdapter);
    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,
            UserProfileActivity.class)
          .putExtra("userId", userId);
      
        startActivity(intent);
      }
    });
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent = new Intent(ViewAttendeesActivity.this, ViewGoal.class)
      .putExtra("goal_id", parseId)
      .putExtra("goal_owner", ownerName);
  
    startActivity(intent);
    return true;
  }
  
  private String adaptFullName(String fullName) {
    String[] goalOwnerFirstLast = fullName.split("\\^");
    return (goalOwnerFirstLast[0] + " " + goalOwnerFirstLast[1]);
  }


}




Java Source Code List

android.UnusedStub.java
com.cs121.groupgoal.Application.java
com.cs121.groupgoal.CommentActivity.java
com.cs121.groupgoal.Comment.java
com.cs121.groupgoal.ConfigHelper.java
com.cs121.groupgoal.DatePickerDialogFragment.java
com.cs121.groupgoal.DispatchActivity.java
com.cs121.groupgoal.GoalAdapter.java
com.cs121.groupgoal.GoalPost.java
com.cs121.groupgoal.InviteActivity.java
com.cs121.groupgoal.LoginActivity.java
com.cs121.groupgoal.MainActivity.java
com.cs121.groupgoal.MyFriendsActivity.java
com.cs121.groupgoal.NotificationsActivity.java
com.cs121.groupgoal.PostActivity.java
com.cs121.groupgoal.SignUpActivity.java
com.cs121.groupgoal.StartGuideActivity.java
com.cs121.groupgoal.TimePickerDialogFragment.java
com.cs121.groupgoal.UpcomingGoalsActivity.java
com.cs121.groupgoal.UserProfileActivity.java
com.cs121.groupgoal.ViewAttendeesActivity.java
com.cs121.groupgoal.ViewGoal.java
com.cs121.groupgoal.WelcomeActivity.java