Witam, problem jak na filmiku:
main:
public void onViewCreated(View view, Bundle savedInstanceState) {
TextView name = (TextView) view.findViewById(R.id.chatContactName);
TextView motd = (TextView) view.findViewById(R.id.chatContactMotd);
name.setText(contact.name);
motd.setText(contact.motd);
final RecyclerView list = (RecyclerView)view.findViewById(R.id.messageList);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this.getContext());
list.setLayoutManager(mLayoutManager);
list.setItemAnimator(new DefaultItemAnimator());
list.setAdapter(new chatMessagesAdapter(core.user.getMessages(windowID), core));
if(msgs.size() > 0) list.scrollToPosition(core.user.getMessages(windowID).size()-1);
handler = new Handler(Looper.getMainLooper());
runnable = new Runnable() {
@Override
public void run() {
View view = getView();
RecyclerView list = (RecyclerView)view.findViewById(R.id.messageList);
list.getAdapter().notifyDataSetChanged();
list.scrollToPosition(core.user.getMessages(windowID).size()-1);
handler.postDelayed(this, 1000);
}
};
handler.postDelayed(runnable, 1000);
}
adapter:
public class MyViewHolder extends RecyclerView.ViewHolder {
public TextView message, author, msgtime;
public MyViewHolder(View view) {
super(view);
message = (TextView)view.findViewById(R.id.msgText);
author = (TextView)view.findViewById(R.id.msgAuthor);
msgtime = (TextView)view.findViewById(R.id.msgTime);
cloud = (LinearLayout)view.findViewById(R.id.msgCloud);
}
@TargetApi(Build.VERSION_CODES.M)
public void bindViews(message xd) {
message.setText(xd.msg);
if(xd.owner == core.user.ID) {
author.setText("Ty");
cloud.setBackground(core.getResources().getDrawable( R.drawable.message));
}else{
author.setText(core.user.getContact(xd.owner).name);
cloud.setBackground(core.getResources().getDrawable( R.drawable.message_from));
}
msgtime.setText(CONST.timeDiff(xd.time));
}
}
niby wszystko poprawnie, poza tłem