Search in sources :

Example 1 with Device

use of com.romainpiel.model.Device in project meatspace-android by RomainPiel.

the class ChatFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState != null) {
        listViewState = savedInstanceState.getParcelable(STATE_LISTVIEW);
        listPosition = savedInstanceState.getInt(POSITION_LIST);
        itemPosition = savedInstanceState.getInt(POSITION_ITEM);
    }
    if (adapter == null) {
        adapter = new ChatAdapter(getActivity());
        adapter.setOnMuteClickListener(new OnMenuClickListener<Chat>() {

            @Override
            public void onMenuClick(Chat item) {
                BusManager.get().getChatBus().post(new MuteEvent(true, item.getValue().getFingerprint()));
            }
        });
    }
    if (device == null) {
        device = new Device(getActivity());
    }
    listView.setAdapter(adapter);
}
Also used : Device(com.romainpiel.model.Device) Chat(com.romainpiel.model.Chat) ChatAdapter(com.romainpiel.lib.ui.adapter.ChatAdapter) MuteEvent(com.romainpiel.lib.bus.MuteEvent)

Example 2 with Device

use of com.romainpiel.model.Device in project meatspace-android by RomainPiel.

the class ChatService method syncChatList.

/**
 * synchronize the chat list:
 * - with the muted users list
 * - init isFromMe variable
 *
 * @param chatList chat list to sync
 */
private void syncChatList(ChatList chatList) {
    String myFingerprint = new Device(this).getId();
    Collection<Chat> list = chatList.get();
    Chat.Value chatValue;
    String fingerprint;
    for (Chat chat : list) {
        chatValue = chat.getValue();
        fingerprint = chatValue.getFingerprint();
        chatValue.setMuted(mutedUsers.contains(fingerprint));
        chatValue.setFromMe(fingerprint.equals(myFingerprint));
    }
}
Also used : Device(com.romainpiel.model.Device) Chat(com.romainpiel.model.Chat)

Aggregations

Chat (com.romainpiel.model.Chat)2 Device (com.romainpiel.model.Device)2 MuteEvent (com.romainpiel.lib.bus.MuteEvent)1 ChatAdapter (com.romainpiel.lib.ui.adapter.ChatAdapter)1