Recycler view showing single item
<p>I am facing a strange error where recyclerview is showing only a single item. Below is code for my recyclerview adapter :</p>

<pre><code>public class ChatAdapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; {


List&lt;chat&gt; chats;
String username;
final int My=0,Their=1;

public ChatAdapter(List&lt;chat&gt; chats) {
    this.chats = chats;
    this.username = PushApp.getApp().getSPF().getStringData(Constants.ANAME);
}


@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    RecyclerView.ViewHolder viewHolder;
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());

    switch (viewType) {
        case My:
            View v1 = inflater.inflate(R.layout.my_chat_child, parent, false);
            viewHolder = new MyChatHolder(v1);
            break;
        case Their:
            View v2 = inflater.inflate(R.layout.their_chat_child, parent, false);
            viewHolder = new TheirMessageHolder(v2);
            break;
        default:
            View v = inflater.inflate(R.layout.my_chat_child, parent, false);
            viewHolder = new MyChatHolder(v);
            break;
    }

    return viewHolder;

}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case My:
            MyChatHolder myChatHolder = (MyChatHolder) holder;
            myChatHolder.setMyMessage(chats.get(position).getMessage());
            break;

        case Their:
            TheirMessageHolder theirMessageHolder = (TheirMessageHolder) holder;
            theirMessageHolder.setTheirChat(chats.get(position).getFrom(), chats.get(position).getMessage());
            break;
    }
}

@Override
public int getItemViewType(int position) {
    if(username.equalsIgnoreCase(chats.get(position).getFrom()))
        return My;
    return Their;
}

@Override
public int getItemCount() {
    return chats.size();
}}
</code></pre>

<p>I have already used this code in other app and its working perfectly. I have checked the chats data which is also perfect.</p>

<p>Here's link to git repo layout files:
<a href="https://github.com/revic1993/androidchat/tree/master/app/src/main/res/layout" rel="noreferrer">layout files</a></p>