|
|
@@ -4,6 +4,7 @@ import android.app.Activity;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
@@ -117,18 +118,41 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
|
|
|
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
|
|
super.onScrollStateChanged(recyclerView, newState);
|
|
|
|
|
|
- if (newState == RecyclerView.SCROLL_STATE_IDLE) {//滑动到了底部
|
|
|
- if(ListUtil.size(list) >= per_page*page){
|
|
|
+ RecyclerView.LayoutManager layoutManager = view_list.getLayoutManager();
|
|
|
|
|
|
- refreshLayout.autoLoadMore();
|
|
|
- }
|
|
|
+ if(layoutManager instanceof LinearLayoutManager){
|
|
|
+ LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
|
|
|
+ //获取最后一个view 位置
|
|
|
+ int lastItemPosition = linearLayoutManager.findLastVisibleItemPosition();
|
|
|
+
|
|
|
+ View childView = recyclerView.getChildAt(list.size() - 1);
|
|
|
+ //底部bottom
|
|
|
+// int bottom = childView.getBottom();
|
|
|
+ //正常来说RecycleView的顶部坐标应该是0,但是严格来考虑,当RecycleView设置了paddingTop时,所有子view的绘制将以paddingTop的位置为起始位置,所以实际的顶部应该是paddingTop的高度的数值.
|
|
|
+ int topEdge=recyclerView.getPaddingBottom();
|
|
|
+
|
|
|
+ //获取最后一个完全显示的item的position
|
|
|
+ int lastVisibleItem = linearLayoutManager.findLastCompletelyVisibleItemPosition();
|
|
|
+ int totalCount = linearLayoutManager.getItemCount();
|
|
|
+ Log.e("lastvisi_item_-----", lastVisibleItem+","+totalCount);
|
|
|
+
|
|
|
+ if(newState == RecyclerView.SCROLL_STATE_IDLE && lastVisibleItem == totalCount -1){//滑动到了底部
|
|
|
+ if(ListUtil.size(list) >= per_page*page){
|
|
|
|
|
|
+ refreshLayout.autoLoadMore();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// bottomLine = ViewUtil.setBottomLine(refreshLayout, getNoMoreCallBack());
|
|
|
- view_list.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
+
|
|
|
+ LinearLayoutManager hotManager = new LinearLayoutManager(SheepApp.getInstance(), LinearLayoutManager.VERTICAL, false);
|
|
|
+ view_list.setHasFixedSize(true);
|
|
|
+ view_list.setNestedScrollingEnabled(false);
|
|
|
+ view_list.setLayoutManager(hotManager);
|
|
|
view_list.setAdapter(getAdapter());
|
|
|
|
|
|
}
|