Search in sources :

Example 11 with ChatMessageHelper

use of ingage.ingage.helpers.ChatMessageHelper in project iNGAGE by davis123123.

the class ChatFragment method appendChatConversation.

private void appendChatConversation(DataSnapshot dataSnapshot) {
    Iterator i = dataSnapshot.getChildren().iterator();
    Log.d("STATE", "pageData2 : " + dataSnapshot);
    while (i.hasNext()) {
        chat_id = dataSnapshot.getKey();
        Log.d("STATE", "result : " + chat_id);
        chat_msg = (String) ((DataSnapshot) i.next()).getValue();
        chat_side = (String) ((DataSnapshot) i.next()).getValue();
        chat_timestamp = (String) ((DataSnapshot) i.next()).getValue();
        chat_username = (String) ((DataSnapshot) i.next()).getValue();
        chat_downvote = (Long) ((DataSnapshot) i.next()).getValue();
        chat_upvote = (Long) ((DataSnapshot) i.next()).getValue();
        String chat_userVote;
        chat_userVote = userVotes.get(chat_id);
        Log.d("CHATVOTE", "result : " + chat_userVote);
        ChatMessageHelper msg = new ChatMessageHelper(chat_id, chat_side, chat_msg, chat_username, chat_upvote, chat_downvote, chat_timestamp, chat_userVote);
        chatAdapter.add(msg);
    }
    chatAdapter.notifyDataSetChanged();
    recyclerView.scrollToPosition(chatAdapter.getItemCount() - 1);
}
Also used : ChatMessageHelper(ingage.ingage.helpers.ChatMessageHelper) Iterator(java.util.Iterator) DataSnapshot(com.google.firebase.database.DataSnapshot)

Aggregations

ChatMessageHelper (ingage.ingage.helpers.ChatMessageHelper)11 DataSnapshot (com.google.firebase.database.DataSnapshot)6 DatabaseError (com.google.firebase.database.DatabaseError)4 DatabaseReference (com.google.firebase.database.DatabaseReference)4 MutableData (com.google.firebase.database.MutableData)4 Transaction (com.google.firebase.database.Transaction)4 ChatFeaturesHandler (ingage.ingage.handlers.ChatFeaturesHandler)2 Iterator (java.util.Iterator)2 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 SessionManager (ingage.ingage.managers.SessionManager)1 ExecutionException (java.util.concurrent.ExecutionException)1