diff --git a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/interfaces/ILoadMoreFooter.java b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/interfaces/ILoadMoreFooter.java
index b814d49..58821a7 100644
--- a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/interfaces/ILoadMoreFooter.java
+++ b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/interfaces/ILoadMoreFooter.java
@@ -30,4 +30,16 @@ public interface ILoadMoreFooter {
* 加载更多的View
*/
View getFootView();
+
+ void setNetworkErrorViewClickListener(OnNetWorkErrorListener listener);
+
+ void setOnClickLoadMoreListener(final OnLoadMoreListener listener);
+
+ enum State {
+ Normal/**正常*/
+ , ManualLoadMore/**手动点击加载*/
+ , NoMore/**加载到最底了*/
+ , Loading/**加载中..*/
+ , NetWorkError/**网络异常*/
+ }
}
diff --git a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LRecyclerView.java b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LRecyclerView.java
index f528e2a..83c9603 100644
--- a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LRecyclerView.java
+++ b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LRecyclerView.java
@@ -567,17 +567,16 @@ public void setOnLoadMoreListener(OnLoadMoreListener listener) {
}
public void setOnNetWorkErrorListener(final OnNetWorkErrorListener listener) {
- final LoadingFooter loadingFooter = ((LoadingFooter) mFootView);
- loadingFooter.setState(LoadingFooter.State.NetWorkError);
- loadingFooter.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mLoadMoreFooter.onLoading();
- listener.reload();
- }
- });
+ mLoadMoreFooter.setNetworkErrorViewClickListener(listener);
}
+ /**
+ * 请使用自定义LoadingFooter的方式实现
+ * @param loading
+ * @param noMore
+ * @param noNetWork
+ */
+ @Deprecated
public void setFooterViewHint(String loading, String noMore, String noNetWork) {
if (mLoadMoreFooter instanceof LoadingFooter) {
LoadingFooter loadingFooter = ((LoadingFooter) mLoadMoreFooter);
@@ -588,11 +587,13 @@ public void setFooterViewHint(String loading, String noMore, String noNetWork) {
}
/**
+ * 本方法不再推荐使用,请使用自定义LoadingFooter的方式实现
* 设置Footer文字颜色
* @param indicatorColor
* @param hintColor
* @param backgroundColor
*/
+ @Deprecated
public void setFooterViewColor(int indicatorColor, int hintColor, int backgroundColor) {
if (mLoadMoreFooter instanceof LoadingFooter) {
LoadingFooter loadingFooter = ((LoadingFooter) mLoadMoreFooter);
diff --git a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LuRecyclerView.java b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LuRecyclerView.java
index fbc129f..c6ab041 100644
--- a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LuRecyclerView.java
+++ b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LuRecyclerView.java
@@ -9,6 +9,7 @@
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
@@ -26,6 +27,8 @@
*/
public class LuRecyclerView extends RecyclerView {
private boolean mLoadMoreEnabled = true;
+ /** 是否手动点击加载更多 */
+ private boolean mIsManualLoadMore = false;
private boolean mRefreshing = false;//是否正在下拉刷新
private boolean mLoadingData = false;//是否正在加载数据
private boolean flag = false;//标记是否setAdapter
@@ -221,6 +224,7 @@ public void setRefreshing(boolean refreshing) {
* @param pageSize 一页加载的数量
*/
public void refreshComplete(int pageSize) {
+ Log.e("lzx","refreshComplete pageSize " + pageSize );
this.mPageSize = pageSize;
if (mRefreshing) {
isNoMore = false;
@@ -314,8 +318,31 @@ public void setNoMore(boolean noMore){
mLoadingData = false;
isNoMore = noMore;
if(isNoMore) {
- mLoadMoreFooter.onNoMore();
mFootView.setVisibility(VISIBLE);
+ mLoadMoreFooter.onNoMore();
+ Log.e("lzx","setNoMore true ");
+ } else {
+ mLoadMoreFooter.onComplete();
+ }
+ }
+
+ /**
+ * 设置是否已加载全部
+ * @param noMore
+ * @param isShowFootView
+ */
+ public void setNoMore(boolean noMore, boolean isShowFootView){
+ mLoadingData = false;
+ isNoMore = noMore;
+ if(isNoMore) {
+ if (isShowFootView) {
+ mFootView.setVisibility(VISIBLE);
+ } else {
+ mFootView.setVisibility(GONE);
+ mWrapAdapter.removeFooterView();
+ }
+ mLoadMoreFooter.onNoMore();
+ Log.e("lzx","setNoMore true ");
} else {
mLoadMoreFooter.onComplete();
}
@@ -365,6 +392,17 @@ public void setLoadMoreEnabled(boolean enabled) {
}
}
+ /**
+ * 滑动到底手动点击加载
+ */
+ public void setManualLoadMore(boolean enabled) {
+ if(mWrapAdapter == null){
+ throw new NullPointerException("mWrapAdapter cannot be null, please make sure the variable mWrapAdapter have been initialized.");
+ }
+ mIsManualLoadMore = enabled;
+
+ }
+
public void setLoadingMoreProgressStyle(int style) {
if (mLoadMoreFooter instanceof LoadingFooter) {
((LoadingFooter) mLoadMoreFooter).setProgressStyle(style);
@@ -377,15 +415,7 @@ public void setOnLoadMoreListener(OnLoadMoreListener listener) {
}
public void setOnNetWorkErrorListener(final OnNetWorkErrorListener listener) {
- final LoadingFooter loadingFooter = ((LoadingFooter) mFootView);
- loadingFooter.setState(LoadingFooter.State.NetWorkError);
- loadingFooter.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mLoadMoreFooter.onLoading();
- listener.reload();
- }
- });
+ mLoadMoreFooter.setNetworkErrorViewClickListener(listener);
}
public void setFooterViewHint(String loading, String noMore, String noNetWork) {
@@ -488,25 +518,36 @@ public void onScrolled(int dx, int dy) {
mLScrollListener.onScrolled(mScrolledXDistance, mScrolledYDistance);
}
- if (mLoadMoreListener != null && mLoadMoreEnabled) {
- int visibleItemCount = layoutManager.getChildCount();
- int totalItemCount = layoutManager.getItemCount();
- if (visibleItemCount > 0
- && lastVisibleItemPosition >= totalItemCount - 1
- && (isCritical ? totalItemCount >= visibleItemCount : totalItemCount > visibleItemCount)
- && !isNoMore
- && !mRefreshing) {
-
- mFootView.setVisibility(View.VISIBLE);
- if (!mLoadingData) {
- mLoadingData = true;
- mLoadMoreFooter.onLoading();
- mLoadMoreListener.onLoadMore();
+ //如果想要滑动到底部自动加载更多,mIsManualLoadMore必须为false
+ if (mIsManualLoadMore) {
+ if (!isNoMore) {
+ Log.e("lzx","onScrooo set visible");
+ mLoadingData = true;
+ mLoadMoreFooter.setOnClickLoadMoreListener(mLoadMoreListener);
+ }
+
+ } else {
+ if (mLoadMoreListener != null && mLoadMoreEnabled) {
+ int visibleItemCount = layoutManager.getChildCount();
+ int totalItemCount = layoutManager.getItemCount();
+ if (visibleItemCount > 0
+ && lastVisibleItemPosition >= totalItemCount - 1
+ && (isCritical ? totalItemCount >= visibleItemCount : totalItemCount > visibleItemCount)
+ && !isNoMore
+ && !mRefreshing) {
+
+ mFootView.setVisibility(View.VISIBLE);
+ if (!mLoadingData) {
+ mLoadingData = true;
+ mLoadMoreFooter.onLoading();
+ mLoadMoreListener.onLoadMore();
+ }
+
}
}
-
}
+
}
@Override
diff --git a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/view/LoadingFooter.java b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/view/LoadingFooter.java
index d5f2904..cba097f 100644
--- a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/view/LoadingFooter.java
+++ b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/view/LoadingFooter.java
@@ -14,6 +14,8 @@
import com.github.jdsjlzx.R;
import com.github.jdsjlzx.interfaces.ILoadMoreFooter;
+import com.github.jdsjlzx.interfaces.OnLoadMoreListener;
+import com.github.jdsjlzx.interfaces.OnNetWorkErrorListener;
import com.github.jdsjlzx.progressindicator.AVLoadingIndicatorView;
import com.github.jdsjlzx.recyclerview.ProgressStyle;
@@ -133,6 +135,29 @@ public View getFootView() {
return this;
}
+ @Override
+ public void setNetworkErrorViewClickListener(final OnNetWorkErrorListener listener) {
+ setState(State.NetWorkError);
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ setState(State.Loading);
+ listener.reload();
+ }
+ });
+ }
+
+ @Override
+ public void setOnClickLoadMoreListener(final OnLoadMoreListener listener) {
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ setState(State.Loading);
+ listener.onLoadMore();
+ }
+ });
+ }
+
/**
* 设置状态
*
@@ -239,10 +264,5 @@ public void setState(State status, boolean showView) {
}
- public enum State {
- Normal/**正常*/
- , NoMore/**加载到最底了*/
- , Loading/**加载中..*/
- , NetWorkError/**网络异常*/
- }
+
}
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index ec025a4..3f4ce76 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -5,7 +5,7 @@ android {
defaultConfig {
applicationId "com.lzx.demo"
- minSdkVersion 14
+ minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 956d542..7942e78 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -58,6 +58,7 @@
+
\ No newline at end of file
diff --git a/app/src/main/java/com/lzx/demo/MainActivity.java b/app/src/main/java/com/lzx/demo/MainActivity.java
index 72ddd2b..bf6d1fb 100644
--- a/app/src/main/java/com/lzx/demo/MainActivity.java
+++ b/app/src/main/java/com/lzx/demo/MainActivity.java
@@ -1,5 +1,8 @@
package com.lzx.demo;
+import android.content.Intent;
+import android.os.Bundle;
+
import com.lzx.demo.base.BaseMainActivity;
import com.lzx.demo.multitype.MultiTypeActivity;
import com.lzx.demo.ui.CommonActivity;
@@ -22,4 +25,9 @@ public Class>[] getActivitys() {
public String[] getTitles() {
return TITLE;
}
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
}
diff --git a/app/src/main/java/com/lzx/demo/adapter/CategoryAdapter.java b/app/src/main/java/com/lzx/demo/adapter/CategoryAdapter.java
new file mode 100644
index 0000000..8090e12
--- /dev/null
+++ b/app/src/main/java/com/lzx/demo/adapter/CategoryAdapter.java
@@ -0,0 +1,218 @@
+package com.lzx.demo.adapter;
+
+import android.content.Context;
+import android.util.Log;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.github.jdsjlzx.interfaces.OnLoadMoreListener;
+import com.github.jdsjlzx.recyclerview.LuRecyclerView;
+import com.lzx.demo.R;
+import com.lzx.demo.base.BaseMultiAdapter;
+import com.lzx.demo.base.SuperViewHolder;
+import com.lzx.demo.bean.MultipleItem;
+import com.lzx.demo.view.ClickLoadingFooter;
+
+import java.util.List;
+
+/**
+ * Created by Lzx on 2016/12/30.
+ */
+
+public class CategoryAdapter extends BaseMultiAdapter {
+
+ public CategoryAdapter(Context context) {
+ super(context);
+ addItemType(MultipleItem.TEXT, R.layout.list_item_category);
+ addItemType(MultipleItem.LIST, R.layout.list_item_list);
+ addItemType(MultipleItem.FOOT, R.layout.list_item_foot);
+ }
+
+ @Override
+ public void onBindItemHolder(SuperViewHolder holder, int position) {
+ MultipleItem item = getDataList().get(position);
+ switch (item.getItemType()) {
+ case MultipleItem.TEXT:
+ bindTextItem(holder,item);
+ break;
+ case MultipleItem.LIST:
+ bindListItem(holder,item);
+ break;
+ case MultipleItem.FOOT:
+ bindFootItem(holder,item);
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ private void bindTextItem(SuperViewHolder holder, MultipleItem item) {
+ TextView textView = holder.getView(R.id.info_text);
+ textView.setText(item.getTitle());
+ }
+
+ private void bindListItem(SuperViewHolder holder, MultipleItem item) {
+ TextView textView = holder.getView(R.id.content);
+ textView.setText(item.getTitle());
+ }
+
+ private void bindFootItem(SuperViewHolder holder, final MultipleItem item) {
+ ClickLoadingFooter footer = holder.getView(R.id.footer);
+ footer.setOnClickLoadMoreListener(new OnLoadMoreListener() {
+ @Override
+ public void onLoadMore() {
+ Log.e("lzx","CategoryAdapter onLoadMore getFootCategory() " + item.getFootCategory());
+ loadMoreListener.loadMore(item.getFootCategory());
+ }
+ });
+ }
+
+ public void removeItem(int footCategory,int index) {
+ if (footCategory == MultipleItem.FOOT_MY_GROUP) {
+ getDataList().remove(index);
+ size_first_list--;
+ } else if (footCategory == MultipleItem.FOOT_PUBLIC_GROUP) {
+ getDataList().remove(index);
+ size_second_list--;
+ }
+ }
+
+
+ public int getSize_first_list() {
+ return size_first_list;
+ }
+
+ public int getSize_second_list() {
+ return size_second_list;
+ }
+
+ public int getFootViewIndex(int footCategory) {
+ Log.e("lzx","getFootViewIndex getDataList().size() " + getDataList().size()
+ + " size_first_list " + size_first_list + " size_second_list " + size_second_list);
+ int index = 0;
+ if (footCategory == MultipleItem.FOOT_MY_GROUP) {
+ if (size_first_list > 0) {
+ index = this.size_first_list - 1;
+ }
+ } else if (footCategory == MultipleItem.FOOT_PUBLIC_GROUP) {
+ if (getDataList().size() > 0) {
+ index = getDataList().size() - 1;
+ }
+ }
+ return index;
+ }
+
+ public void addData(List list,int footCategory) {
+ Log.e("lzx","addData getDataList().size() " + getDataList().size()
+ + " size_first_list " + size_first_list + " size_second_list " + size_second_list);
+ if (footCategory == MultipleItem.FOOT_MY_GROUP) {
+
+ //第一次添加
+ if (size_first_list == 0) {
+ //添加头部标题
+ MultipleItem item = new MultipleItem(MultipleItem.TEXT);
+ item.setTitle("我的群组");
+ getDataList().add(item);
+
+ //添加尾部加载更多view
+ item = new MultipleItem(MultipleItem.FOOT);
+ item.setFootCategory(MultipleItem.FOOT_MY_GROUP);
+ getDataList().add(item);
+
+ int insertIndex = this.mDataList.size() - 1;
+ if (this.mDataList.addAll(insertIndex, list)) {
+ notifyItemRangeInserted(insertIndex, list.size());
+ size_first_list += list.size();
+ }
+ } else {
+ int insertIndex = size_first_list + 1;
+ if (this.mDataList.addAll(insertIndex, list)) {
+ notifyItemRangeInserted(insertIndex, list.size());
+ size_first_list += list.size();
+ }
+ if (size_first_list >= totalFirstList) {
+ int footIndex = size_first_list + 1;
+ Log.e("lzx","footIndex " + footIndex);
+ getDataList().remove(footIndex);
+ }
+ }
+
+ /*if (size_first_list > 0 && size_first_list - 2 < totalFirstList) {
+ int footIndex = size_first_list - 1;
+ Log.e("lzx","footIndex " + footIndex);
+ getDataList().remove(footIndex);
+ size_first_list--;
+ }
+ Log.e("lzx","insert size_first_list " + size_first_list + " new list.size " + list.size());
+ getDataList().addAll(this.size_first_list,list);
+ this.size_first_list += list.size();
+ //减去1是为了减去顶部的标题
+ if (size_first_list - 1 < totalFirstList) {
+ MultipleItem item = new MultipleItem(MultipleItem.FOOT);
+ item.setFootCategory(MultipleItem.FOOT_MY_GROUP);
+ getDataList().add(this.size_first_list,item);
+ }*/
+
+ } else if (footCategory == MultipleItem.FOOT_PUBLIC_GROUP) {
+ //第一次添加
+ if (size_second_list == 0) {
+ //添加头部标题
+ MultipleItem item = new MultipleItem(MultipleItem.TEXT);
+ item.setTitle("公开群组");
+ getDataList().add(item);
+
+ //添加尾部加载更多view
+ item = new MultipleItem(MultipleItem.FOOT);
+ item.setFootCategory(MultipleItem.FOOT_PUBLIC_GROUP);
+ getDataList().add(item);
+
+ int insertIndex = this.mDataList.size() - 1;
+ if (this.mDataList.addAll(insertIndex, list)) {
+ notifyItemRangeInserted(insertIndex, list.size());
+ size_second_list += list.size();
+ }
+ } else {
+ int insertIndex = getDataList().size() - 1;
+ if (this.mDataList.addAll(insertIndex, list)) {
+ notifyItemRangeInserted(insertIndex, list.size());
+ size_second_list += list.size();
+ }
+ if (size_second_list >= totalSecondList) {
+ int footIndex = getDataList().size() - 1;
+ Log.e("lzx","footIndex " + footIndex);
+ getDataList().remove(footIndex);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * 真实数据统计(不包括头部和尾部)
+ */
+ private int size_first_list = 0;
+ private int size_second_list = 0;
+ private int totalFirstList = 0;
+
+ public void setTotalFirstList(int total) {
+ this.totalFirstList = total;
+ }
+
+ public void setTotalSecondList(int total) {
+ this.totalSecondList = total;
+ }
+
+ private int totalSecondList = 0;
+
+ public interface LoadMoreListener {
+ void loadMore(int footCategory);
+ }
+
+ private LoadMoreListener loadMoreListener;
+
+ public void setLoadMoreListener(LoadMoreListener listener) {
+ this.loadMoreListener = listener;
+ }
+
+}
diff --git a/app/src/main/java/com/lzx/demo/adapter/DataAdapter.java b/app/src/main/java/com/lzx/demo/adapter/DataAdapter.java
index adc2b71..eab87a3 100644
--- a/app/src/main/java/com/lzx/demo/adapter/DataAdapter.java
+++ b/app/src/main/java/com/lzx/demo/adapter/DataAdapter.java
@@ -34,9 +34,4 @@ public void onBindItemHolder(SuperViewHolder holder, int position) {
titleText.setText(item.title);
}
- @Override
- public void onViewRecycled(SuperViewHolder holder) {
- super.onViewRecycled(holder);
- }
-
}
diff --git a/app/src/main/java/com/lzx/demo/base/BaseMultiAdapter.java b/app/src/main/java/com/lzx/demo/base/BaseMultiAdapter.java
index 2f7fea5..2d6c683 100644
--- a/app/src/main/java/com/lzx/demo/base/BaseMultiAdapter.java
+++ b/app/src/main/java/com/lzx/demo/base/BaseMultiAdapter.java
@@ -11,7 +11,6 @@
import android.view.ViewGroup;
import com.lzx.demo.bean.MultiItemEntity;
-import com.lzx.demo.bean.Person;
import com.lzx.demo.interfaces.IExpandable;
import java.util.ArrayList;
diff --git a/app/src/main/java/com/lzx/demo/bean/MultipleItem.java b/app/src/main/java/com/lzx/demo/bean/MultipleItem.java
index 154886e..e29ca6d 100644
--- a/app/src/main/java/com/lzx/demo/bean/MultipleItem.java
+++ b/app/src/main/java/com/lzx/demo/bean/MultipleItem.java
@@ -4,11 +4,17 @@ public class MultipleItem implements MultiItemEntity {
public static final int TEXT = 1;
public static final int IMG = 2;
public static final int LIST = 3;
+ public static final int FOOT = 4;
public static final int TEXT_SPAN_SIZE = 1;
public static final int IMG_SPAN_SIZE = 3;
private int itemType;
private int spanSize;
+ public static final int FOOT_MY_GROUP = 100;
+ public static final int FOOT_PUBLIC_GROUP= 101;
+
+
+
public MultipleItem(int itemType) {
this.itemType = itemType;
}
@@ -32,6 +38,7 @@ public int getItemType() {
}
private String title;
+ private int footCategory;
public String getTitle() {
return title;
@@ -40,4 +47,13 @@ public String getTitle() {
public void setTitle(String title) {
this.title = title;
}
+
+ public int getFootCategory() {
+ return footCategory;
+ }
+
+ public void setFootCategory(int footCategory) {
+ this.footCategory = footCategory;
+ }
+
}
diff --git a/app/src/main/java/com/lzx/demo/ui/ClickLoadingFootActivity.java b/app/src/main/java/com/lzx/demo/ui/ClickLoadingFootActivity.java
new file mode 100644
index 0000000..970e9c1
--- /dev/null
+++ b/app/src/main/java/com/lzx/demo/ui/ClickLoadingFootActivity.java
@@ -0,0 +1,224 @@
+package com.lzx.demo.ui;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+
+import com.github.jdsjlzx.recyclerview.LuRecyclerView;
+import com.github.jdsjlzx.recyclerview.LuRecyclerViewAdapter;
+import com.lzx.demo.R;
+import com.lzx.demo.adapter.CategoryAdapter;
+import com.lzx.demo.bean.MultipleItem;
+import com.lzx.demo.util.NetworkUtils;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+
+/**
+ * 手动加载示例
+ */
+public class ClickLoadingFootActivity extends AppCompatActivity{
+ private static final String TAG = "lzx";
+
+ /**服务器端一共多少条数据*/
+ private static final int TOTAL_COUNTER = 64;
+
+ /**每一页展示多少条数据*/
+ private static final int REQUEST_COUNT = 10;
+
+ /**已经获取到多少条数据了*/
+ private static int mCurrentCounter = 0;
+
+ private LuRecyclerView mRecyclerView = null;
+
+ private CategoryAdapter mMultipleItemAdapter = null;
+
+ private PreviewHandler mHandler = new PreviewHandler(this);
+ private LuRecyclerViewAdapter mLRecyclerViewAdapter = null;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_multi_click_loading);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ mRecyclerView = findViewById(R.id.list);
+
+ mMultipleItemAdapter = new CategoryAdapter(this);
+ mLRecyclerViewAdapter = new LuRecyclerViewAdapter(mMultipleItemAdapter);
+ mRecyclerView.setAdapter(mLRecyclerViewAdapter);
+
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
+
+ mMultipleItemAdapter.setLoadMoreListener(new CategoryAdapter.LoadMoreListener() {
+ @Override
+ public void loadMore(int footCategory) {
+ requestData(footCategory);
+ }
+ });
+
+ /*mRecyclerView.setOnLoadMoreListener(new OnLoadMoreListener() {
+ @Override
+ public void onLoadMore() {
+ if (mCurrentCounter < TOTAL_COUNTER) {
+ // loading more
+ requestData();
+ } else {
+ //the end
+ mRecyclerView.setNoMore(true);
+ }
+ }
+ });*/
+
+ requestData(MultipleItem.FOOT_MY_GROUP);
+ mRecyclerView.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ requestData(MultipleItem.FOOT_PUBLIC_GROUP);
+ }
+ },1000);
+
+ }
+
+ private void notifyDataSetChanged() {
+ mLRecyclerViewAdapter.notifyDataSetChanged();
+ }
+
+ private void addItems(ArrayList list, int category) {
+ mMultipleItemAdapter.addData(list,category);
+ }
+
+ private class PreviewHandler extends Handler {
+
+ private WeakReference ref;
+
+ PreviewHandler(ClickLoadingFootActivity activity) {
+ ref = new WeakReference<>(activity);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ final ClickLoadingFootActivity activity = ref.get();
+ if (activity == null || activity.isFinishing()) {
+ return;
+ }
+ switch (msg.what) {
+
+ case -1:
+ int category = (int) msg.obj;
+ int currentSize = 0;
+
+ if (category == MultipleItem.FOOT_MY_GROUP) {
+ currentSize = activity.mMultipleItemAdapter.getSize_first_list();
+ } else if (category == MultipleItem.FOOT_PUBLIC_GROUP) {
+ currentSize = activity.mMultipleItemAdapter.getSize_second_list();
+ }
+ //模拟组装10个数据
+ ArrayList newList = new ArrayList<>();
+ MultipleItem item ;
+
+ if (currentSize == 0) {
+
+ if (category == MultipleItem.FOOT_MY_GROUP) {
+ activity.mMultipleItemAdapter.setTotalFirstList(33);
+ } else if (category == MultipleItem.FOOT_PUBLIC_GROUP) {
+ //item.setTitle("公开群组");
+ activity.mMultipleItemAdapter.setTotalSecondList(33);
+ }
+ }
+
+ for (int i = 0; i < 10; i++) {
+ item = new MultipleItem(MultipleItem.LIST);
+ if (category == MultipleItem.FOOT_MY_GROUP) {
+ item.setTitle("我的item"+(currentSize+i));
+ } else if (category == MultipleItem.FOOT_PUBLIC_GROUP) {
+ item.setTitle("公开item"+(currentSize+i));
+ }
+ newList.add(item);
+ }
+
+ /*if (currentSize == 0) {
+ item = new MultipleItem(MultipleItem.FOOT);
+ item.setFootCategory(category);
+ newList.add(item);
+ } else {
+ if (category == MultipleItem.FOOT_MY_GROUP) {
+ int lastFootIndex = mMultipleItemAdapter.getFootViewIndex(MultipleItem.FOOT_MY_GROUP);
+ Log.e("lzx","FOOT_MY_GROUP lastFootIndex " + lastFootIndex);
+ mMultipleItemAdapter.removeItem(MultipleItem.FOOT_MY_GROUP, lastFootIndex);
+ Log.e("lzx","FOOT_MY_GROUP getSize_first_list() " + mMultipleItemAdapter.getSize_first_list());
+
+ } else if (category == MultipleItem.FOOT_PUBLIC_GROUP) {
+ int lastFootIndex = mMultipleItemAdapter.getFootViewIndex(MultipleItem.FOOT_PUBLIC_GROUP);
+ Log.e("lzx","FOOT_PUBLIC_GROUP lastFootIndex " + lastFootIndex);
+ mMultipleItemAdapter.removeItem(MultipleItem.FOOT_PUBLIC_GROUP, lastFootIndex);
+ if (mMultipleItemAdapter.getSize_second_list() + newList.size() < 33) {
+ item = new MultipleItem(MultipleItem.FOOT);
+ item.setFootCategory(MultipleItem.FOOT_PUBLIC_GROUP);
+ newList.add(item);
+ }
+ }
+
+ }*/
+
+ activity.addItems(newList,category);
+
+ activity.mRecyclerView.refreshComplete(REQUEST_COUNT);
+ activity.notifyDataSetChanged();
+ break;
+ case -2:
+ activity.notifyDataSetChanged();
+ break;
+ case -3:
+ /*activity.mRecyclerView.refreshComplete(REQUEST_COUNT);
+ activity.notifyDataSetChanged();
+ activity.mRecyclerView.setOnNetWorkErrorListener(new OnNetWorkErrorListener() {
+ @Override
+ public void reload() {
+ requestData();
+ }
+ });*/
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * 模拟请求网络
+ */
+ private void requestData(final int footCategory) {
+ Log.d(TAG, "requestData footCategory " + footCategory);
+ new Thread() {
+
+ @Override
+ public void run() {
+ super.run();
+
+ try {
+ Thread.sleep(800);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+
+
+ //模拟一下网络请求失败的情况
+ if(NetworkUtils.isNetAvailable(ClickLoadingFootActivity.this)) {
+ mHandler.obtainMessage(-1, footCategory).sendToTarget();
+ } else {
+ mHandler.obtainMessage(-3, footCategory).sendToTarget();
+ }
+ }
+ }.start();
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/lzx/demo/ui/CommonActivity.java b/app/src/main/java/com/lzx/demo/ui/CommonActivity.java
index e09247f..7a757a3 100644
--- a/app/src/main/java/com/lzx/demo/ui/CommonActivity.java
+++ b/app/src/main/java/com/lzx/demo/ui/CommonActivity.java
@@ -22,7 +22,8 @@ public class CommonActivity extends BaseMainActivity {
BannerHeaderLayoutActivity.class,
QzoneHeaderActivity.class,
MomentsHeaderActivity.class,
- CustomLoadingFootActivity.class};
+ CustomLoadingFootActivity.class,
+ ClickLoadingFootActivity.class};
private static final String[] TITLE = {
"LinearLayoutSample",
@@ -41,7 +42,8 @@ public class CommonActivity extends BaseMainActivity {
"BannerHeaderLayoutActivity",
"QzoneHeaderActivity",
"MomentsHeaderActivity",
- "CustomLoadingFootActivity"};
+ "CustomLoadingFootActivity",
+ "ClickLoadingFootActivity"};
public Class>[] getActivitys() {
return ACTIVITY;
diff --git a/app/src/main/java/com/lzx/demo/view/AnchorView.java b/app/src/main/java/com/lzx/demo/view/AnchorView.java
new file mode 100755
index 0000000..615e597
--- /dev/null
+++ b/app/src/main/java/com/lzx/demo/view/AnchorView.java
@@ -0,0 +1,136 @@
+package com.lzx.demo.view;
+
+import android.content.Context;
+import android.support.annotation.Nullable;
+import android.support.v7.widget.LinearLayoutManager;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.github.jdsjlzx.interfaces.OnItemClickListener;
+import com.github.jdsjlzx.interfaces.OnLoadMoreListener;
+import com.github.jdsjlzx.recyclerview.LuRecyclerView;
+import com.github.jdsjlzx.recyclerview.LuRecyclerViewAdapter;
+import com.github.jdsjlzx.recyclerview.ProgressStyle;
+import com.lzx.demo.R;
+import com.lzx.demo.adapter.DataAdapter;
+import com.lzx.demo.bean.ItemModel;
+import com.lzx.demo.util.AppToast;
+
+import java.util.Collection;
+
+public class AnchorView extends LinearLayout {
+
+ /**服务器端一共多少条数据*/
+ private static final int TOTAL_COUNTER = 34;//如果服务器没有返回总数据或者总页数,这里设置为最大值比如10000,什么时候没有数据了根据接口返回判断
+
+ /**每一页展示多少条数据*/
+ private static final int REQUEST_COUNT = 10;
+
+ /**已经获取到多少条数据了*/
+ private static int mCurrentCounter = 0;
+
+ private TextView tvAnchor;
+ private LuRecyclerView mRecyclerView = null;
+ private DataAdapter mDataAdapter = null;
+ private LuRecyclerViewAdapter mLRecyclerViewAdapter = null;
+
+ public AnchorView(Context context) {
+ this(context, null);
+ }
+
+ public AnchorView(Context context, @Nullable AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public AnchorView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(context);
+ }
+
+ private void init(Context context) {
+ View view = LayoutInflater.from(context).inflate(R.layout.view_anchor, this, true);
+ tvAnchor = view.findViewById(R.id.tv_anchor);
+
+ mRecyclerView = findViewById(R.id.list);
+
+ mRecyclerView.setNestedScrollingEnabled(false);
+
+ mDataAdapter = new DataAdapter(context);
+ mLRecyclerViewAdapter = new LuRecyclerViewAdapter(mDataAdapter);
+ mRecyclerView.setAdapter(mLRecyclerViewAdapter);
+
+ LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
+ linearLayoutManager.setAutoMeasureEnabled(true);
+ mRecyclerView.setLayoutManager(linearLayoutManager);
+
+ //是否禁用自动加载更多功能,false为禁用, 默认开启自动加载更多功能
+ mRecyclerView.setLoadMoreEnabled(true);
+ mRecyclerView.setManualLoadMore(true);
+
+
+ ClickLoadingFooter custLoadingFooter = new ClickLoadingFooter(context);
+ custLoadingFooter.setProgressStyle(ProgressStyle.SysProgress);
+ mRecyclerView.setLoadMoreFooter(custLoadingFooter,true);
+
+ mRecyclerView.setOnLoadMoreListener(new OnLoadMoreListener() {
+ @Override
+ public void onLoadMore() {
+ if (mCurrentCounter < TOTAL_COUNTER) {
+ // loading more
+ Log.e("lzx","load more");
+ loadMoreListener.onLoadMore();
+ }
+ }
+ });
+
+ mLRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(View view, int position) {
+ if (mDataAdapter.getDataList().size() > position) {
+ ItemModel item = mDataAdapter.getDataList().get(position);
+ AppToast.showShortText(getContext().getApplicationContext(), item.title);
+ }
+
+ }
+
+ });
+
+
+ }
+
+ public void setAnchorTxt(String txt) {
+ tvAnchor.setText(txt);
+ }
+
+ public void addAll(Collection list) {
+ mDataAdapter.addAll(list);
+ mRecyclerView.refreshComplete(REQUEST_COUNT);
+ Log.e("lzx","addAll " + mDataAdapter.getDataList().size());
+ //mLRecyclerViewAdapter.notifyDataSetChanged();
+ //requestLayout();
+ if (mDataAdapter.getDataList().size() >= TOTAL_COUNTER) {
+ mRecyclerView.setNoMore(true,false);
+ } else {
+ mRecyclerView.refreshComplete(REQUEST_COUNT);
+ }
+
+ }
+
+ public int getItemCount() {
+ return mDataAdapter.getItemCount();
+ }
+
+ LoadMoreListener loadMoreListener;
+
+ public void setLoadMoreListener(LoadMoreListener listener) {
+ this.loadMoreListener = listener;
+ }
+
+ public interface LoadMoreListener {
+ void onLoadMore();
+ }
+}
diff --git a/app/src/main/java/com/lzx/demo/view/ClickLoadingFooter.java b/app/src/main/java/com/lzx/demo/view/ClickLoadingFooter.java
new file mode 100644
index 0000000..53c85cd
--- /dev/null
+++ b/app/src/main/java/com/lzx/demo/view/ClickLoadingFooter.java
@@ -0,0 +1,301 @@
+package com.lzx.demo.view;
+
+import android.content.Context;
+import android.support.v4.content.ContextCompat;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewStub;
+import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.github.jdsjlzx.interfaces.ILoadMoreFooter;
+import com.github.jdsjlzx.interfaces.OnLoadMoreListener;
+import com.github.jdsjlzx.interfaces.OnNetWorkErrorListener;
+import com.github.jdsjlzx.progressindicator.AVLoadingIndicatorView;
+import com.github.jdsjlzx.recyclerview.ProgressStyle;
+import com.github.jdsjlzx.view.SimpleViewSwitcher;
+import com.lzx.demo.R;
+
+/**
+ * 手动点击加载更多
+ */
+public class ClickLoadingFooter extends RelativeLayout implements ILoadMoreFooter {
+
+ protected State mState = State.Normal;
+ private View mLoadingView;
+ private View mNetworkErrorView;
+ private View mTheEndView;
+ private View mManualView;
+ private SimpleViewSwitcher mProgressView;
+ private TextView mLoadingText;
+ private TextView mNoMoreText;
+ private TextView mNoNetWorkText;
+ private String loadingHint;
+ private String noMoreHint;
+ private String noNetWorkHint;
+ private int style;
+ private int indicatorColor;
+ private int hintColor = R.color.colorAccent;
+
+ public ClickLoadingFooter(Context context) {
+ super(context);
+ init();
+ }
+
+ public ClickLoadingFooter(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ public ClickLoadingFooter(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init();
+ }
+
+ public void init() {
+
+ inflate(getContext(), R.layout.view_manual_recyclerview_footer, this);
+ setOnClickListener(null);
+
+ onReset();//初始为隐藏状态
+
+ indicatorColor = ContextCompat.getColor(getContext(), R.color.colorAccent);
+ style = ProgressStyle.SysProgress;
+ }
+
+ public void setLoadingHint(String hint) {
+ this.loadingHint = hint;
+ }
+
+ public void setNoMoreHint(String hint) {
+ this.noMoreHint = hint;
+ }
+
+ public void setNoNetWorkHint(String hint) {
+ this.noNetWorkHint = hint;
+ }
+
+ public void setIndicatorColor(int color) {
+ this.indicatorColor = color;
+ }
+
+ public void setHintTextColor(int color) {
+ this.hintColor = color;
+ }
+
+ public void setViewBackgroundColor(int color) {
+ this.setBackgroundColor(ContextCompat.getColor(getContext(), color));
+ }
+
+ public void setProgressStyle(int style) {
+ this.style = style;
+ }
+
+ public State getState() {
+ return mState;
+ }
+
+ public void setState(State status) {
+ setState(status, true);
+ }
+
+ private View initIndicatorView(int style) {
+ if (style == ProgressStyle.SysProgress) {
+ return new ProgressBar(getContext(), null, android.R.attr.progressBarStyle);
+ } else {
+ AVLoadingIndicatorView progressView = (AVLoadingIndicatorView) LayoutInflater.from(getContext()).inflate(R.layout.layout_indicator_view, null);
+ progressView.setIndicatorId(style);
+ progressView.setIndicatorColor(indicatorColor);
+ return progressView;
+ }
+
+ }
+
+ @Override
+ public void onReset() {
+ onComplete();
+ }
+
+ @Override
+ public void onLoading() {
+ setState(State.Loading);
+ }
+
+ @Override
+ public void onComplete() {
+ Log.e("lzx","onComplete 111");
+ setState(State.ManualLoadMore);
+ }
+
+ @Override
+ public void onNoMore() {
+ //setState(State.NoMore);
+ setState(State.Normal);
+ setVisibility(GONE);
+ }
+
+ @Override
+ public View getFootView() {
+ return this;
+ }
+
+ @Override
+ public void setNetworkErrorViewClickListener(final OnNetWorkErrorListener listener) {
+ setState(State.NetWorkError);
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ setState(State.Loading);
+ listener.reload();
+ }
+ });
+ }
+
+ @Override
+ public void setOnClickLoadMoreListener(final OnLoadMoreListener listener) {
+ setVisibility(VISIBLE);
+ setState(State.ManualLoadMore);
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ setState(State.Loading);
+ listener.onLoadMore();
+ }
+ });
+ }
+
+ /**
+ * 设置状态
+ *
+ * @param status
+ * @param showView 是否展示当前View
+ */
+ public void setState(State status, boolean showView) {
+ if (mState == status) {
+ return;
+ }
+ mState = status;
+
+ switch (status) {
+ case Normal:
+ setOnClickListener(null);
+ if (mLoadingView != null) {
+ mLoadingView.setVisibility(GONE);
+ }
+
+ if (mTheEndView != null) {
+ mTheEndView.setVisibility(GONE);
+ }
+
+ if (mNetworkErrorView != null) {
+ mNetworkErrorView.setVisibility(GONE);
+ }
+
+ if (mManualView != null) {
+ mManualView.setVisibility(GONE);
+ }
+
+ break;
+ case Loading:
+ setOnClickListener(null);
+ if (mTheEndView != null) {
+ mTheEndView.setVisibility(GONE);
+ }
+
+ if (mNetworkErrorView != null) {
+ mNetworkErrorView.setVisibility(GONE);
+ }
+
+ if (mManualView != null) {
+ mManualView.setVisibility(GONE);
+ }
+
+ if (mLoadingView == null) {
+ ViewStub viewStub = (ViewStub) findViewById(R.id.loading_viewstub);
+ mLoadingView = viewStub.inflate();
+
+ mProgressView = (SimpleViewSwitcher) mLoadingView.findViewById(R.id.loading_progressbar);
+ mLoadingText = (TextView) mLoadingView.findViewById(R.id.loading_text);
+ }
+
+ mLoadingView.setVisibility(showView ? VISIBLE : GONE);
+
+ mProgressView.setVisibility(View.VISIBLE);
+ mProgressView.removeAllViews();
+ mProgressView.addView(initIndicatorView(style));
+
+ mLoadingText.setText(TextUtils.isEmpty(loadingHint) ? getResources().getString(R.string.list_footer_loading) : loadingHint);
+ mLoadingText.setTextColor(ContextCompat.getColor(getContext(), hintColor));
+
+ break;
+ case NoMore:
+ setOnClickListener(null);
+ if (mLoadingView != null) {
+ mLoadingView.setVisibility(GONE);
+ }
+
+ if (mNetworkErrorView != null) {
+ mNetworkErrorView.setVisibility(GONE);
+ }
+
+ if (mManualView != null) {
+ mManualView.setVisibility(GONE);
+ }
+
+ break;
+ case NetWorkError:
+ if (mLoadingView != null) {
+ mLoadingView.setVisibility(GONE);
+ }
+
+ if (mTheEndView != null) {
+ mTheEndView.setVisibility(GONE);
+ }
+
+ if (mManualView != null) {
+ mManualView.setVisibility(GONE);
+ }
+
+ if (mNetworkErrorView == null) {
+ ViewStub viewStub = (ViewStub) findViewById(R.id.network_error_viewstub);
+ mNetworkErrorView = viewStub.inflate();
+ mNoNetWorkText = (TextView) mNetworkErrorView.findViewById(R.id.network_error_text);
+ } else {
+ mNetworkErrorView.setVisibility(VISIBLE);
+ }
+
+ mNetworkErrorView.setVisibility(showView ? VISIBLE : GONE);
+ mNoNetWorkText.setText(TextUtils.isEmpty(noNetWorkHint) ? getResources().getString(R.string.list_footer_network_error) : noNetWorkHint);
+ mNoNetWorkText.setTextColor(ContextCompat.getColor(getContext(), hintColor));
+ break;
+ case ManualLoadMore:
+ if (mLoadingView != null) {
+ mLoadingView.setVisibility(GONE);
+ }
+
+ if (mTheEndView != null) {
+ mTheEndView.setVisibility(GONE);
+ }
+
+ if (mNetworkErrorView != null) {
+ mNetworkErrorView.setVisibility(GONE);
+ }
+
+ if (mManualView == null) {
+ ViewStub viewStub = (ViewStub) findViewById(R.id.manual_load_viewstub);
+ mManualView = viewStub.inflate();
+ } else {
+ mManualView.setVisibility(VISIBLE);
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/lzx/demo/view/CustLoadingFooter.java b/app/src/main/java/com/lzx/demo/view/CustLoadingFooter.java
index e9d48ab..4793c28 100644
--- a/app/src/main/java/com/lzx/demo/view/CustLoadingFooter.java
+++ b/app/src/main/java/com/lzx/demo/view/CustLoadingFooter.java
@@ -12,6 +12,8 @@
import android.widget.TextView;
import com.github.jdsjlzx.interfaces.ILoadMoreFooter;
+import com.github.jdsjlzx.interfaces.OnLoadMoreListener;
+import com.github.jdsjlzx.interfaces.OnNetWorkErrorListener;
import com.github.jdsjlzx.progressindicator.AVLoadingIndicatorView;
import com.github.jdsjlzx.recyclerview.ProgressStyle;
import com.github.jdsjlzx.view.SimpleViewSwitcher;
@@ -133,6 +135,29 @@ public View getFootView() {
return this;
}
+ @Override
+ public void setNetworkErrorViewClickListener(final OnNetWorkErrorListener listener) {
+ setState(ILoadMoreFooter.State.NetWorkError);
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ setState(ILoadMoreFooter.State.Loading);
+ listener.reload();
+ }
+ });
+ }
+
+ @Override
+ public void setOnClickLoadMoreListener(final OnLoadMoreListener listener) {
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ setState(State.Loading);
+ listener.onLoadMore();
+ }
+ });
+ }
+
/**
* 设置状态
*
@@ -238,11 +263,4 @@ public void setState(State status, boolean showView) {
}
}
-
- public enum State {
- Normal/**正常*/
- , NoMore/**加载到最底了*/
- , Loading/**加载中..*/
- , NetWorkError/**网络异常*/
- }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/lzx/demo/view/CustomScrollView.java b/app/src/main/java/com/lzx/demo/view/CustomScrollView.java
new file mode 100755
index 0000000..d4b5473
--- /dev/null
+++ b/app/src/main/java/com/lzx/demo/view/CustomScrollView.java
@@ -0,0 +1,76 @@
+package com.lzx.demo.view;
+
+import android.content.Context;
+import android.support.v4.widget.NestedScrollView;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.ViewConfiguration;
+import android.widget.ScrollView;
+
+public class CustomScrollView extends ScrollView {
+ private int slop;
+ private int touch;
+
+ public Callbacks mCallbacks;
+
+ public CustomScrollView(Context context) {
+ super(context);
+ setSlop(context);
+ }
+
+ public CustomScrollView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setSlop(context);
+ }
+
+ public CustomScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ setSlop(context);
+ }
+
+ public void setCallbacks(Callbacks callbacks) {
+ this.mCallbacks = callbacks;
+ }
+
+ @Override
+ protected void onScrollChanged(int l, int t, int oldl, int oldt) {
+ super.onScrollChanged(l, t, oldl, oldt);
+ if (mCallbacks != null) {
+ mCallbacks.onScrollChanged(l, t, oldl, oldt);
+ }
+ }
+ //定义接口用于回调
+ public interface Callbacks {
+ void onScrollChanged(int x, int y, int oldx, int oldy);
+ }
+
+ /*@Override
+ public boolean onInterceptTouchEvent(MotionEvent ev) {
+ switch (ev.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ //保存当前touch的纵坐标值
+ touch = (int) ev.getRawY();
+ break;
+ case MotionEvent.ACTION_MOVE:
+ //保存当前touch的纵坐标值
+ touch = (int) ev.getRawY();
+ // 滑动距离大于slop值时,返回true
+ if (Math.abs((int) ev.getRawY() - touch) > slop) {
+ return true;
+ }
+ break;
+ default:
+ break;
+ }
+ return super.onInterceptTouchEvent(ev);
+ }*/
+
+
+ /**
+ * 获取相应context的touch slop值(即在用户滑动之前,能够滑动的以像素为单位的距离)
+ * @param context ScrollView对应的context
+ */
+ private void setSlop(Context context) {
+ slop = ViewConfiguration.get(context).getScaledTouchSlop();
+ }
+}
diff --git a/app/src/main/res/layout/activity_multi_click_loading.xml b/app/src/main/res/layout/activity_multi_click_loading.xml
new file mode 100644
index 0000000..701bb35
--- /dev/null
+++ b/app/src/main/res/layout/activity_multi_click_loading.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/list_item_category.xml b/app/src/main/res/layout/list_item_category.xml
new file mode 100644
index 0000000..015cf59
--- /dev/null
+++ b/app/src/main/res/layout/list_item_category.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/list_item_foot.xml b/app/src/main/res/layout/list_item_foot.xml
new file mode 100644
index 0000000..e136d1f
--- /dev/null
+++ b/app/src/main/res/layout/list_item_foot.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/list_item_list.xml b/app/src/main/res/layout/list_item_list.xml
new file mode 100644
index 0000000..30ec8bf
--- /dev/null
+++ b/app/src/main/res/layout/list_item_list.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/view_anchor.xml b/app/src/main/res/layout/view_anchor.xml
new file mode 100755
index 0000000..d14e1ef
--- /dev/null
+++ b/app/src/main/res/layout/view_anchor.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/view_manual_recyclerview_footer.xml b/app/src/main/res/layout/view_manual_recyclerview_footer.xml
new file mode 100644
index 0000000..cc2a5a8
--- /dev/null
+++ b/app/src/main/res/layout/view_manual_recyclerview_footer.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/view_recyclerview_footer_view_manual.xml b/app/src/main/res/layout/view_recyclerview_footer_view_manual.xml
new file mode 100644
index 0000000..4bf6dc8
--- /dev/null
+++ b/app/src/main/res/layout/view_recyclerview_footer_view_manual.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
\ No newline at end of file