Search in sources :

Example 1 with ChatMsgComparator

use of br.ufrj.caronae.comparators.ChatMsgComparator in project caronae-android by caronae.

the class ChatAct method configureActivityWithChatAssets.

private void configureActivityWithChatAssets(ChatAssets chatAssets) {
    context = this;
    color = chatAssets.getColor();
    int colorPressed = Util.getPressedColorbyNormalColor(color);
    lay1.setBackgroundColor(color);
    toolbar.setBackgroundColor(color);
    int bgRes = chatAssets.getBgRes();
    // send_bt.setBackgroundResource(bgRes);
    send_bt.setColorNormal(color);
    send_bt.setColorPressed(colorPressed);
    String neighborhood = chatAssets.getLocation();
    // neighborhood_tv.setText(neighborhood);
    String date = chatAssets.getDate();
    // date_tv.setText(date);
    String time = chatAssets.getTime();
    // time_tv.setText(time);
    headerText.setText(neighborhood + " - " + date + " - " + time);
    chatMsgsList = ChatMessageReceived.find(ChatMessageReceived.class, "ride_id = ?", rideId);
    Collections.sort(chatMsgsList, new ChatMsgComparator());
    chatMsgsAdapter = new ChatMsgsAdapter(chatMsgsList, color);
    chatMsgs_rv.setAdapter(chatMsgsAdapter);
    chatMsgs_rv.setLayoutManager(new LinearLayoutManager(context));
    chatMsgsAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {

        @Override
        public void onChanged() {
            super.onChanged();
            Util.toast("mudou");
        }
    });
    if (!chatMsgsList.isEmpty())
        chatMsgs_rv.scrollToPosition(chatMsgsList.size() - 1);
}
Also used : ChatMsgComparator(br.ufrj.caronae.comparators.ChatMsgComparator) ChatMsgsAdapter(br.ufrj.caronae.adapters.ChatMsgsAdapter) ChatMessageReceived(br.ufrj.caronae.models.ChatMessageReceived) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ChatMsgsAdapter (br.ufrj.caronae.adapters.ChatMsgsAdapter)1 ChatMsgComparator (br.ufrj.caronae.comparators.ChatMsgComparator)1 ChatMessageReceived (br.ufrj.caronae.models.ChatMessageReceived)1