|
@@ -1,17 +1,12 @@
|
|
|
package com.xplora.xpchat.fragment;
|
|
|
|
|
|
-import android.os.Handler;
|
|
|
-import android.os.Message;
|
|
|
import android.content.Context;
|
|
|
import android.util.AttributeSet;
|
|
|
import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
-import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
import android.widget.AbsListView;
|
|
|
-import android.widget.Button;
|
|
|
import android.widget.FrameLayout;
|
|
|
-import android.widget.LinearLayout;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
@@ -23,14 +18,11 @@ import com.xplora.xpchat.adapter.ChatListAdapter;
|
|
|
import com.xplora.xpchat.manager.DataManager;
|
|
|
import com.xplora.xpchat.model.MessageBean;
|
|
|
import com.xplora.xpchat.observer.Listener;
|
|
|
-import com.xplora.xpchat.utils.Constant;
|
|
|
import com.xplora.xpchat.utils.ResUtils;
|
|
|
import com.xplora.xpchat.view.ChatItem;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Timer;
|
|
|
-import java.util.TimerTask;
|
|
|
|
|
|
public class ChatListFragment extends FrameLayout implements SwipeRefreshLayout.OnRefreshListener, AbsListView.OnScrollListener {
|
|
|
public String TAG = "losion / xpchat :" + getClass().getSimpleName();
|
|
@@ -39,6 +31,7 @@ public class ChatListFragment extends FrameLayout implements SwipeRefreshLayout.
|
|
|
private ChatListAdapter mChatAdapter = null;
|
|
|
private SwipeRefreshLayout mSwipeRefreshLayout = null;
|
|
|
private Context mContext = null;
|
|
|
+ private ArrayList<Integer> mReadItemIdArray = new ArrayList<>();
|
|
|
|
|
|
public ChatListFragment(Context context, @Nullable AttributeSet attrs) {
|
|
|
super(context, attrs);
|
|
@@ -161,13 +154,35 @@ public class ChatListFragment extends FrameLayout implements SwipeRefreshLayout.
|
|
|
|
|
|
@Override
|
|
|
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
|
|
-
|
|
|
+ Log.d(TAG, "onScrollStateChanged: " + scrollState);
|
|
|
+ switch (scrollState) {
|
|
|
+ case 1:
|
|
|
+ //开始滚动
|
|
|
+ mReadItemIdArray.clear();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ //滚动中
|
|
|
+ break;
|
|
|
+ case 0:
|
|
|
+ //滚动停止
|
|
|
+ if (mReadItemIdArray.size() <= 0)
|
|
|
+ return;
|
|
|
+ Listener.ListViewListener listener = (Listener.ListViewListener)mContext;
|
|
|
+ listener.onScrollVisibleItem(mReadItemIdArray);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
|
|
- Log.d(TAG, "onScroll: " + firstVisibleItem + " vis:" + visibleItemCount + " total:" +totalItemCount );
|
|
|
- Listener.ListViewListener listener = (Listener.ListViewListener)mContext;
|
|
|
- listener.onScrollVisibleItem(firstVisibleItem, visibleItemCount);
|
|
|
+ Log.d(TAG, "onScroll: " + firstVisibleItem + " vis:" + visibleItemCount + " total:" + totalItemCount );
|
|
|
+ for (int i = firstVisibleItem; i < firstVisibleItem + visibleItemCount; i++) {
|
|
|
+ boolean isContains = mReadItemIdArray.contains(i);
|
|
|
+ if (!isContains) {
|
|
|
+ mReadItemIdArray.add(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|