/* the onClick listener will validate all of the event data fields * and then will pass on the data to the submitEvent method */ @Override public void onClick(View v) { switch (v.getId()) { case R.id.submitNewEvent: /* TODO: add validation for event form * */ int messageResId = 0; // will be used to make toast User currentUser = userLocalStore.getLoggedInUser(); // For event table, we need: host email, host event count, event name, location, time, // description String hostEmail = currentUser.email; int eventCount = currentUser.eventCount + 1; User user = new User(currentUser.fullName, currentUser.email, currentUser.password, eventCount); ArrayList<Friend> invitedFriends = dropdownListAdapter.getSelectedFriends(); String eventName = new_event_name.getText().toString(); // String eventLocation = mAutocompleteView.getText().toString(); if (invitedFriends.size() == 0 || eventName == "" || eventLocation == null || !isEventTimeSet()) { messageResId = R.string.missing_event_field; } if (messageResId == 0) { /*TODO: Parse invitedFriends into eventGuestList *TODO: get email to friends class */ Intent currentIntent = this.getIntent(); hostEmail = currentIntent.getStringExtra("currentUserEmail"); int hostEventCounter = currentIntent.getIntExtra("currentUserEventCount", 0); Event event = new Event( hostEmail, hostEventCounter, eventName, eventLocation.toString(), eventTime.toString(), ""); submitEvent(event); } else { Toast.makeText(this, messageResId, Toast.LENGTH_SHORT).show(); } break; default: break; } }
private void displayListView() { userLocalStore = new UserLocalStore(this); User user = userLocalStore.getLoggedInUser(); // ((AppDelegate)this.getApplication()).yourFriends; friends = ((AppDelegate) this.getApplication()).yourFriends; groups = ((AppDelegate) this.getApplication()).getGroups(); Log.d("JJK", "number of friends: " + String.valueOf(friends.size())); dataAdapter = new FriendSendAdapter(sendRendezvous.this, friends); adapter = new GroupAdapter(sendRendezvous.this, groups); ListView listView = (ListView) findViewById(R.id.listView1); ListView listView2 = (ListView) findViewById(R.id.listView2); // Assign adapter to ListView listView.setAdapter(dataAdapter); listView2.setAdapter(adapter); dataAdapter.notifyDataSetChanged(); adapter.notifyDataSetChanged(); listView.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // When clicked, show a toast with the TextView text Friend friend = (Friend) parent.getItemAtPosition(position); Toast.makeText( getApplicationContext(), "Clicked on Row: " + friend.getShowname(), Toast.LENGTH_LONG) .show(); } }); listView2.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // When clicked, show a toast with the TextView text Group friend = (Group) parent.getItemAtPosition(position); Toast.makeText( getApplicationContext(), "Clicked on Row: " + friend.groupname, Toast.LENGTH_LONG) .show(); } }); }
private void returnSendlist() { User user = userLocalStore.getLoggedInUser(); ArrayList<Friend> friendlistsend = dataAdapter.friendList; for (int i = 0; i < friendlistsend.size(); i++) { Friend friend = friendlistsend.get(i); if (friend.isSelected()) { Friend friendsend = new Friend(friend.username, friend.friendname, null, null, -1); sendingFriendlist.add(friendsend); if (((AppDelegate) this.getApplication()).isTheFriendInTheWoz(friend.username)) { // if you send a rendez and your friends chat is allocated, need to append. // else the first instance will be able to retrieve this SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT")); String time = dateFormatGmt.format(new Date()).toString(); RendezStatus tem = new RendezStatus( user.username, statusTitle, details, location, null, timefor, type, -1, friend.username); rendezChatDictionary temp = ((AppDelegate) this.getApplication()).getRendezDictionary(friend.username); temp.allDeesRendez.add(0, tem); // ((AppDelegate) this.getApplication()).putItInTheWoz(friend.username, temp); } } } for (int i = 0; i < groups.size(); i++) { if (groups.get(i).isSelected()) { Friend friendsend = new Friend(groups.get(i).groupname, groups.get(i).groupdetail, null, null, -1); sendingFriendlist.add(friendsend); /* * need to figure out the emits for this... * */ if (((AppDelegate) this.getApplication()).isTheFriendInTheWoz(groups.get(i).groupname)) { SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT")); String time = dateFormatGmt.format(new Date()).toString(); RendezStatus tem = new RendezStatus( user.username, statusTitle, details, location, null, timefor, type, -1, groups.get(i).groupname); rendezChatDictionary temp = ((AppDelegate) this.getApplication()).getRendezDictionary(groups.get(i).groupname); temp.allDeesRendez.add(0, tem); // ((AppDelegate) this.getApplication()).putItInTheWoz(groups.get(i).groupname, temp); } } } RendezStatus status = new RendezStatus( user.username, statusTitle, details, location, null, timefor, type, -1, null); ServerRequests serverRequests = new ServerRequests(this); serverRequests.sendToFriendsInBackground( user, sendingFriendlist, status, new SendRendezStatusCallback() { @Override public void done(ArrayList status) { ArrayList<RendezStatus> rs = status; for (int i = 0; i < status.size(); i++) { ((AppDelegate) getApplication()) .putItInTheWozRendezStatus(rs.get(i).username, rs.get(i)); ((AppDelegate) getApplication()) .emitRendez( rs.get(i).id, sendingFriendlist.get(i).username, statusTitle, details, location, timefor, type, 0); } } }); Intent returnIntent = new Intent(); returnIntent.putExtra("result", 1); setResult(RESULT_OK, returnIntent); finish(); }