Guys, the question is as follows. Is it possible to somehow dynamically change the markup properties? I will explain: There is a correspondence between 2 users, and there is 1 markup for the messages themselves. Here is the method for initializing and configuring the adapter:
mFBAdapter = new FirebaseRecyclerAdapter<ChatMessage, FirechatMsgViewHolder>( ChatMessage.class, // chat_message собственно сама разметка текстового сообщения R.layout.chat_message, FirechatMsgViewHolder.class, mDatabaseReference.child(romName) ) { @Override protected void populateViewHolder(FirechatMsgViewHolder firechatMsgViewHolder, ChatMessage chatMessage, int i) { mProgressBar.setVisibility(ProgressBar.INVISIBLE); firechatMsgViewHolder.msgText.setText(chatMessage.getText()) firechatMsgViewHolder.userText.setText(chatMessage.getName()); if (mFirebaseUser.getPhotoUrl() == null) { firechatMsgViewHolder.userImage.setImageDrawable( ContextCompat.getDrawable(context, R.drawable.ic_account_circle_black_36dp)); } else { mUsername = mFirebaseUser.getDisplayName(); mPhotoUrl = mFirebaseUser.getPhotoUrl().toString(); Glide.with(ChatFragment.this). load(chatMessage.getPhotoUrl()).into(firechatMsgViewHolder.userImage); } } }; mFBAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { @Override public void onItemRangeInserted(int positionStart, int itemCount) { super.onItemRangeInserted(positionStart, itemCount); int chatMsgCount = mFBAdapter.getItemCount(); int lastVisiblePosition = mLayoutManager.findLastCompletelyVisibleItemPosition(); if (lastVisiblePosition == -1 || (positionStart >= (chatMsgCount - 1) && lastVisiblePosition == (positionStart - 1))) { mMsgRecyclerView.scrollToPosition(positionStart); } } }); mMsgRecyclerView.setLayoutManager(mLayoutManager); mMsgRecyclerView.setAdapter(mFBAdapter); mUsername = mFirebaseUser.getDisplayName().toString(); I have the names of both participants, and I wanted somehow with their help to make it so that the messages sent by the user were displayed on his right and the received ones on the left. There are Gravity.LEFT and Gravity.RIGHT constants that can be used to control the position from the code, but how to tighten it. there was a type option
if(mFirebaseAuth.getCurrentUser().getDisplayName().equals(mUsername)){ // gravity right... } else { // gravity lef..... } but it didn't work. Any thoughts, can anyone come across?