package com.nbusy.app;

import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * A fragment representing a single Chat detail screen.
 * This fragment is either contained in a {@link ChatListActivity}
 * in two-pane mode (on tablets) or a {@link ChatDetailActivity}
 * on handsets.
 */
public class ChatDetailFragment extends Fragment {
    /**
     * The fragment argument representing the item ID that this fragment
     * represents.
     */
    public static final String ARG_ITEM_ID = "item_id";

    /**
     * The dummy content this fragment is presenting.
     */
    private List<Message> messages;

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public ChatDetailFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (getArguments().containsKey(ARG_ITEM_ID)) {
            // Load the dummy content specified by the fragment
            // arguments. In a real-world scenario, use a Loader
            // to load content from a content provider.
            messages = new ArrayList<>();
            Message m = new Message();
            m.from = "Teoman Soygul";
            m.message = "Lorem ip sum my message...";
            m.sent = "8:50";
            messages.add(m);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_chat_detail, container, false);

        // Show the dummy content as text in a TextView.
        if (messages != null) {
            ((TextView) rootView.findViewById(R.id.chat_detail)).setText("wow");
        }

        return rootView;
    }
}

@@ -1102,26 +1102,64 @@
     
-if (getArguments()
+Bundle arguments = getArguments();%0A        if (arguments
 .con
@@ -1406,24 +1406,25 @@
 ayList%3C%3E();%0A
+%0A
             
@@ -1432,16 +1432,17 @@
 essage m
+1
  = new M
@@ -1464,16 +1464,17 @@
        m
+1
 .from = 
@@ -1503,16 +1503,17 @@
        m
+1
 .message
@@ -1558,16 +1558,17 @@
        m
+1
 .sent = 
@@ -1601,16 +1601,225 @@
 es.add(m
+1);%0A%0A            Message m2 = new Message();%0A            m2.from = %22User ID: %22 + arguments.get(ARG_ITEM_ID);%0A            m2.message = %22Test test.%22;%0A            m2.sent = %22Just now%22;%0A            messages.add(m2
 );%0A     

add extra dummy message for testing