mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-12-28 22:48:59 +00:00
Can get older conversation message
This commit is contained in:
parent
e579891f73
commit
2a202f1308
@ -182,7 +182,7 @@ public class ConversationMessageAdapter extends RecyclerView.Adapter {
|
||||
mUserName.setText(info.getDisplayFullName());
|
||||
}
|
||||
|
||||
if(pos < 2)
|
||||
if(pos < 1)
|
||||
setUserInfoVisibility(true);
|
||||
else
|
||||
setUserInfoVisibility(
|
||||
|
@ -38,6 +38,7 @@ import org.communiquons.android.comunic.client.ui.adapters.ConversationMessageAd
|
||||
import org.communiquons.android.comunic.client.ui.listeners.OnScrollChangeDetectListener;
|
||||
import org.communiquons.android.comunic.client.ui.utils.BitmapUtils;
|
||||
import org.communiquons.android.comunic.client.ui.utils.UiUtils;
|
||||
import org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
@ -110,7 +111,7 @@ public class ConversationFragment extends Fragment
|
||||
/**
|
||||
* Conversation message listView
|
||||
*/
|
||||
private RecyclerView convMessRecyclerView;
|
||||
private ScrollRecyclerView convMessRecyclerView;
|
||||
|
||||
/**
|
||||
* Conversation messages layout manager
|
||||
@ -291,7 +292,7 @@ public class ConversationFragment extends Fragment
|
||||
|
||||
|
||||
//Set a listener to detect when the user reaches the top of the conversation
|
||||
//TODO : add reach top listener
|
||||
convMessRecyclerView.setOnScrollChangeDetectListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ package org.communiquons.android.comunic.client.ui.listeners;
|
||||
* On Scroll change listener
|
||||
*
|
||||
* This listener works with {@link org.communiquons.android.comunic.client.ui.views.ScrollListView}
|
||||
* and {@link org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView}
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
* Created by pierre on 4/28/18.
|
||||
|
@ -0,0 +1,71 @@
|
||||
package org.communiquons.android.comunic.client.ui.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.AbsListView;
|
||||
|
||||
import org.communiquons.android.comunic.client.ui.listeners.OnScrollChangeDetectListener;
|
||||
|
||||
/**
|
||||
* A view that extends RecyclerView in order to add a listener to detect when
|
||||
* the user scrolll the view
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
public class ScrollRecyclerView extends RecyclerView {
|
||||
|
||||
private OnScrollChangeDetectListener mOnScrollChangeDetectListener = null;
|
||||
|
||||
public ScrollRecyclerView(@NonNull Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public ScrollRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public ScrollRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init();
|
||||
}
|
||||
|
||||
public void setOnScrollChangeDetectListener(OnScrollChangeDetectListener onScrollChangeDetectListener) {
|
||||
this.mOnScrollChangeDetectListener = onScrollChangeDetectListener;
|
||||
}
|
||||
|
||||
public OnScrollChangeDetectListener getOnScrollChangeDetectListener() {
|
||||
return mOnScrollChangeDetectListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the view
|
||||
*/
|
||||
private void init(){
|
||||
addOnScrollListener(new PrivateScrollListener());
|
||||
}
|
||||
|
||||
/**
|
||||
* Private class to handle scroll events
|
||||
*/
|
||||
private class PrivateScrollListener extends OnScrollListener {
|
||||
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
|
||||
if(mOnScrollChangeDetectListener == null)
|
||||
return;
|
||||
|
||||
if(!canScrollVertically(1))
|
||||
mOnScrollChangeDetectListener.onReachBottom();
|
||||
|
||||
else if(!canScrollVertically(-1))
|
||||
mOnScrollChangeDetectListener.onReachTop();
|
||||
}
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- Messages -->
|
||||
<android.support.v7.widget.RecyclerView
|
||||
<org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView
|
||||
android:id="@+id/fragment_conversation_messageslist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
Loading…
Reference in New Issue
Block a user