@@ -0,0 +1,2272 @@
+package com.bigndesign.light.adapters.Adapters;%0A%0Aimport android.app.Activity;%0Aimport android.util.Pair;%0Aimport android.view.LayoutInflater;%0Aimport android.view.View;%0Aimport android.view.ViewGroup;%0Aimport android.widget.BaseAdapter;%0Aimport android.widget.TextView;%0A%0Aimport com.bigndesign.light.R;%0Aimport com.sinch.android.rtc.messaging.WritableMessage;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Created by Greg on 1/7/2017.%0A */%0A%0Apublic class MessageAdapter extends BaseAdapter %7B%0A%0A    public static final int DIRECTION_INCOMING = 0;%0A    public static final int DIRECTION_OUTGOING = 1;%0A%0A    private List%3CPair%3CWritableMessage, Integer%3E%3E messages;%0A    private LayoutInflater layoutInflater;%0A%0A    public MessageAdapter(Activity activity) %7B%0A        layoutInflater = activity.getLayoutInflater();%0A        messages = new ArrayList%3CPair%3CWritableMessage, Integer%3E%3E();%0A    %7D%0A%0A    public void addMessage(WritableMessage message, int direction) %7B%0A        messages.add(new Pair(message, direction));%0A        notifyDataSetChanged();%0A    %7D%0A%0A    @Override%0A    public int getCount() %7B%0A        return messages.size();%0A    %7D%0A%0A    @Override%0A    public Object getItem(int i) %7B%0A        return messages.get(i);%0A    %7D%0A%0A    @Override%0A    public long getItemId(int i) %7B%0A        return i;%0A    %7D%0A%0A    @Override%0A    public int getViewTypeCount() %7B%0A        return 2;%0A    %7D%0A%0A    @Override%0A    public int getItemViewType(int i) %7B%0A        return messages.get(i).second;%0A    %7D%0A%0A    @Override%0A    public View getView(int i, View convertView, ViewGroup viewGroup) %7B%0A        int direction = getItemViewType(i);%0A%0A        //show message on left or right, depending on if%0A        //it's incoming or outgoing%0A        if (convertView == null) %7B%0A            int res = 0;%0A            if (direction == DIRECTION_INCOMING) %7B%0A                res = R.layout.message_right;%0A            %7D else if (direction == DIRECTION_OUTGOING) %7B%0A                res = R.layout.message_left;%0A            %7D%0A            convertView = layoutInflater.inflate(res, viewGroup, false);%0A        %7D%0A%0A        WritableMessage message = messages.get(i).first;%0A%0A        TextView txtMessage = (TextView) convertView.findViewById(R.id.txtMessage);%0A        txtMessage.setText(message.getTextBody());%0A%0A        return convertView;%0A    %7D%0A%7D%0A

Add MessageAdapter to display messages