Example #1
0
  @GET
  @Path("{userId}/friends")
  public Response getFriends(
      @PathParam("userId") String userId, @QueryParam(LOGGED_IN_USER_QPARAM) String currentUser) {
    List<User> friends = userDao.getFriends(userId, currentUser);
    List<com.campusconnect.neo4j.types.web.User> returnFriends = new ArrayList<>();
    for (User friend : friends) {
      returnFriends.add(Neo4jToWebMapper.mapUserNeo4jToWeb(friend));
    }
    FriendsPage friendsPage = new FriendsPage(0, returnFriends.size(), returnFriends);

    Friends allFriends = new Friends();
    allFriends.setFriends(friendsPage);

    if (currentUser != null && !currentUser.equals(userId)) {
      List<User> mutualFriends = userDao.getMutualFriends(currentUser, userId);
      List<com.campusconnect.neo4j.types.web.User> returnMutualFriends = new ArrayList<>();
      for (User friend : mutualFriends) {
        returnMutualFriends.add(Neo4jToWebMapper.mapUserNeo4jToWeb(friend));
      }
      FriendsPage mutualFriendsPage =
          new FriendsPage(0, returnMutualFriends.size(), returnMutualFriends);
      allFriends.setMutualFriends(mutualFriendsPage);
    }
    return Response.ok().entity(allFriends).build();
  }
Example #2
0
 @Subscribe
 public void onP2PConnectionEvent(P2PConnectionEvent e) {
   if (e.isConnected()) {
     // resend invites
     Friends friends = model.getFriends();
     ArrayList<String> pendingInvites = new ArrayList<String>(model.getPendingInvites());
     for (String email : pendingInvites) {
       log.info("Resending pending invite to {}", email);
       Friend friend = friends.get(email);
       xmppHandler.sendInvite(friend, true);
     }
   }
 }
Example #3
0
  public void initializeListView(View view) {
    Friends[] myFriends = Friends.friendsList;
    int arrLength = myFriends.length;

    ListView lv = (ListView) view.findViewById(R.id.friends_listView);

    // Instanciating an array list (you don't need to do this,
    // you already have yours).
    List<String> your_array_list = new ArrayList<String>();
    Log.v("arrLength = ", Integer.toString(arrLength));
    for (int i = 0; i < arrLength; i++) {
      Friends currentFriend = myFriends[i];
      Log.v("Friend Name = ", currentFriend.getFriendName());
      your_array_list.add(currentFriend.getFriendName());
    }
    Log.v("Alert", "Print from List<String>");
    for (int i = 0; i < your_array_list.size(); i++) {
      System.out.println(your_array_list.get(i));
    }

    // This is the array adapter, it takes the context of the activity as a
    // first parameter, the type of list view as a second parameter and your
    // array as a third parameter.
    ArrayAdapter<Friends> arrayAdapter =
        new ArrayAdapter<Friends>(
            view.getContext(), android.R.layout.simple_list_item_1, myFriends);

    lv.setAdapter(arrayAdapter);

    // Create an OnItemClickListener
    AdapterView.OnItemClickListener itemClickListener =
        new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> listView, View v, int position, long id) {

            Intent intent = new Intent(getActivity(), FriendTop3.class);
            intent.putExtra(FriendTop3.EXTRA_FRIENDNO, (int) id);
            startActivity(intent);
          }
        };
    // Add the listener to the list view

    lv.setOnItemClickListener(itemClickListener);
  }
 public Set<Contact> getFriendList(Contact contact) {
   Set<Contact> friendSet = new HashSet<>();
   Map<String, Friends> friendsMap = contactDao.getFriendshipMap();
   ArrayList<Friends> friendsList = (ArrayList<Friends>) friendsMap.values();
   for (Friends friends : friendsList) {
     if (friends.getFriendFrom().equals(contact)) {
       friendSet.add(friends.getFriendTo());
     }
     if (friends.getFriendTo().equals(contact)) {
       friendSet.add(friends.getFriendFrom());
     }
     if (!friends.getFriendFrom().equals(contact) && !friends.getFriendTo().equals(contact)) {
       System.out.println("I'm alone(Teach-In)");
     }
   }
   return friendSet;
 }