Exemplo n.º 1
0
  private void bookmarkAdapter(
      FriendData friendData, ArrayList<FriendData> friendDataList, RelativeLayout recyclerLayout) {

    RecyclerView bookmarkRecyclerView =
        (RecyclerView) recyclerLayout.findViewById(R.id.friend_recycler_view);

    LinearLayoutManager bookmarkLayoutManager =
        new LinearLayoutManager(recyclerLayout.getContext());
    bookmarkLayoutManager.setOrientation(RecyclerView.VERTICAL);
    bookmarkRecyclerView.setLayoutManager(bookmarkLayoutManager);

    FriendListMain.getFriendListDB().updateFriendData(friendData);

    ArrayList<FriendData> tempList = friendDataList;
    ArrayList<FriendData> bookmarkedList = new ArrayList<>();

    Collections.sort(
        tempList,
        new Comparator<FriendData>() {
          @Override
          public int compare(FriendData lhs, FriendData rhs) {
            return (lhs.getName().compareToIgnoreCase(rhs.getName()));
          }
        });

    for (int i = 0; i < tempList.size(); i++)
      if (tempList.get(i).getBookMark() == 1) bookmarkedList.add(tempList.get(i));
      else if (i == tempList.size() - 1)
        for (int j = 0; j < tempList.size(); j++)
          if (tempList.get(j).getBookMark() == 0) bookmarkedList.add(tempList.get(j));

    FriendListAdapter friendListAdapter =
        new FriendListAdapter(bookmarkedList, recyclerLayout.getContext(), recyclerLayout, false);
    bookmarkRecyclerView.setAdapter(friendListAdapter);
    friendListAdapter.notifyDataSetChanged();
    FriendListMain.getFriendListDB().close();
  }
Exemplo n.º 2
0
  private void bookmarkFunc(FriendData friendData) {

    FriendListMain.getFriendListDB().updateFriendData(friendData);
    FriendListMain.getFriendListDB().close();
  }