Basically, whenever I load data into my recyclerView it automatically scrolls to the bottom of the recyclerView
here what my function looks like :
mMessagesDBRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
final String key = getIntent().getStringExtra("key");
final String currentUid = FirebaseAuth.getInstance().getCurrentUser().getUid();
if (dataSnapshot.child(key).child(currentUid).exists() && !dataSnapshot.child(currentUid).child(key).exists()) {
mMessagesDBRef.child(key).child(currentUid).limitToLast(TOTAL_ITEMS_TO_LOAD* mCurrentPage).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
mMessagesList.clear();
for (DataSnapshot snap : dataSnapshot.getChildren()) {
ChatMessage chatMessage = snap.getValue(ChatMessage.class);
mMessagesList.add(chatMessage);
populateMessagesRecyclerView();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
private void populateMessagesRecyclerView() {
adapter = new messageAdapter(mMessagesList, this);
mChatsRecyclerView.setAdapter(adapter);
}
And this some of my xml file:
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refreshLayout"
android:layout_below="@id/imageView11"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_above="@id/imageView14">
<android.support.v7.widget.RecyclerView
android:background="#f9f9f9"
android:id="@+id/messagesRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.SwipeRefreshLayout>
Is there any way I can deactivate the automatic scrolling. And thanks