Skip to content

Commit

Permalink
README.md
Browse files Browse the repository at this point in the history
README.md
  • Loading branch information
RmondJone committed Dec 14, 2017
1 parent e2ef556 commit 7e225ea
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 6 deletions.
2 changes: 1 addition & 1 deletion LockTableViewProject/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions LockTableViewProject/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ dependencies {
})
compile 'com.android.support:appcompat-v7:25.0.0'
testCompile 'junit:junit:4.12'
// compile project(':locktableview')
compile 'com.github.RmondJone:LockTableView:1.0.6'
compile project(':locktableview')
// compile 'com.github.RmondJone:LockTableView:1.0.6'
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;

import com.rmondjone.locktableview.DisplayUtil;
Expand Down Expand Up @@ -61,7 +62,18 @@ protected void onCreate(Bundle savedInstanceState) {
public void onTableViewScrollChange(int x, int y) {
Log.e("滚动值","["+x+"]"+"["+y+"]");
}
})//设置滚动回调监听
})//设置横向滚动回调监听
.setTableViewRangeListener(new LockTableView.OnTableViewRangeListener() {
@Override
public void onLeft(HorizontalScrollView view) {
Log.e("滚动边界","滚动到最左边");
}

@Override
public void onRight(HorizontalScrollView view) {
Log.e("滚动边界","滚动到最右边");
}
})//设置横向滚动边界监听
.setOnLoadingListener(new LockTableView.OnLoadingListener() {
@Override
public void onRefresh(final XRecyclerView mXRecyclerView, final ArrayList<ArrayList<String>> mTableDatas) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.HorizontalScrollView;

/**
Expand All @@ -26,7 +27,47 @@ public CustomHorizontalScrollView(Context context, AttributeSet attrs, int defSt
}

public interface onScrollChangeListener{
/**
* 滚动监听
* @param scrollView
* @param x
* @param y
*/
void onScrollChanged(HorizontalScrollView scrollView,int x,int y);
/**
* 滑动到最左侧
* @param scrollView
*/
void onScrollFarLeft(HorizontalScrollView scrollView);

/**
*滑动到最右侧
* @param scrollView
*/
void onScrollFarRight(HorizontalScrollView scrollView);
}

@Override
public boolean onTouchEvent(MotionEvent ev) {
switch (ev.getAction()){
case MotionEvent.ACTION_UP:
if(computeHorizontalScrollOffset()==0){
//滑动最左边
if(onScrollChangeListener!=null){
onScrollChangeListener.onScrollFarLeft(this);
}
}else if(computeHorizontalScrollRange()-computeHorizontalScrollOffset()
==computeHorizontalScrollExtent()){
//滑动最右边
if(onScrollChangeListener!=null){
onScrollChangeListener.onScrollFarRight(this);
}
}
break;
default:
break;
}
return super.onTouchEvent(ev);
}

/**
Expand All @@ -37,6 +78,7 @@ public void setOnScrollChangeListener(CustomHorizontalScrollView.onScrollChangeL
this.onScrollChangeListener = onScrollChangeListener;
}


@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ public class LockTableView {
*/
private OnTableViewListener mTableViewListener;

/**
* 表格横向滚动到边界监听事件
*/
private OnTableViewRangeListener mTableViewRangeListener;

/**
* 表格上拉刷新、下拉加载监听事件
*/
Expand Down Expand Up @@ -394,6 +399,21 @@ public void onTableViewScrollChange(int x, int y) {
changeAllScrollView(x, y);
}
});
mTableViewAdapter.setTableViewRangeListener(new OnTableViewRangeListener() {
@Override
public void onLeft(HorizontalScrollView view) {
if (mTableViewRangeListener!=null){
mTableViewRangeListener.onLeft(view);
}
}

@Override
public void onRight(HorizontalScrollView view) {
if (mTableViewRangeListener!=null){
mTableViewRangeListener.onRight(view);
}
}
});
mTableViewAdapter.setOnTableViewCreatedListener(new TableViewAdapter.OnTableViewCreatedListener() {
@Override
public void onTableViewCreatedCompleted(CustomHorizontalScrollView mScrollView) {
Expand Down Expand Up @@ -440,6 +460,20 @@ private void creatHeadView() {
public void onScrollChanged(HorizontalScrollView scrollView, int x, int y) {
changeAllScrollView(x, y);
}

@Override
public void onScrollFarLeft(HorizontalScrollView scrollView) {
if(mTableViewRangeListener!=null){
mTableViewRangeListener.onLeft(scrollView);
}
}

@Override
public void onScrollFarRight(HorizontalScrollView scrollView) {
if(mTableViewRangeListener!=null){
mTableViewRangeListener.onRight(scrollView);
}
}
});
} else {
createScollview(mUnLockScrollView, mTableFristData, true);
Expand All @@ -449,6 +483,20 @@ public void onScrollChanged(HorizontalScrollView scrollView, int x, int y) {
public void onScrollChanged(HorizontalScrollView scrollView, int x, int y) {
changeAllScrollView(x, y);
}

@Override
public void onScrollFarLeft(HorizontalScrollView scrollView) {
if(mTableViewRangeListener!=null){
mTableViewRangeListener.onLeft(scrollView);
}
}

@Override
public void onScrollFarRight(HorizontalScrollView scrollView) {
if(mTableViewRangeListener!=null){
mTableViewRangeListener.onRight(scrollView);
}
}
});
}
}
Expand Down Expand Up @@ -674,6 +722,11 @@ public LockTableView setOnLoadingListener(OnLoadingListener mOnLoadingListener)
return this;
}

public LockTableView setTableViewRangeListener(OnTableViewRangeListener mTableViewRangeListener) {
this.mTableViewRangeListener = mTableViewRangeListener;
return this;
}

//值获取
public ArrayList<Integer> getColumnMaxWidths() {
return mColumnMaxWidths;
Expand Down Expand Up @@ -730,6 +783,30 @@ public interface OnTableViewListener {
void onTableViewScrollChange(int x, int y);
}


/**
* 横向滚动视图滑动到边界的监听
*/
public interface OnTableViewRangeListener{

/**
* 说明 最左侧
* 作者 郭翰林
* 创建时间 2017/12/14 下午4:45
* @param view
*/
void onLeft(HorizontalScrollView view);

/**
* 说明 最右侧
* 作者 郭翰林
* 创建时间 2017/12/14 下午4:45
* @param view
*/
void onRight(HorizontalScrollView view);

}

/**
* 上拉刷新,下拉加载
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public class TableViewAdapter extends RecyclerView.Adapter<TableViewAdapter.Tabl
*/
private LockTableView.OnTableViewListener mTableViewListener;

/**
* 表格横向滚动到边界监听事件
*/
private LockTableView.OnTableViewRangeListener mTableViewRangeListener;

/**
* 表格视图加载完成监听事件
*/
Expand Down Expand Up @@ -187,7 +192,23 @@ public TableViewHolder(View itemView) {
mScrollView.setOnScrollChangeListener(new CustomHorizontalScrollView.onScrollChangeListener() {
@Override
public void onScrollChanged(HorizontalScrollView scrollView, int x, int y) {
mTableViewListener.onTableViewScrollChange(x,y);
if(mTableViewListener!=null){
mTableViewListener.onTableViewScrollChange(x,y);
}
}

@Override
public void onScrollFarLeft(HorizontalScrollView scrollView) {
if(mTableViewRangeListener!=null){
mTableViewRangeListener.onLeft(scrollView);
}
}

@Override
public void onScrollFarRight(HorizontalScrollView scrollView) {
if(mTableViewRangeListener!=null){
mTableViewRangeListener.onRight(scrollView);
}
}
});
}
Expand Down Expand Up @@ -235,4 +256,8 @@ public void setHorizontalScrollView(LockTableView.OnTableViewListener mTableView
public void setOnTableViewCreatedListener(OnTableViewCreatedListener mOnTableViewCreatedListener) {
this.mOnTableViewCreatedListener = mOnTableViewCreatedListener;
}

public void setTableViewRangeListener(LockTableView.OnTableViewRangeListener mTableViewRangeListener) {
this.mTableViewRangeListener = mTableViewRangeListener;
}
}
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ mLockTableView.setLockFristColumn(true) //是否锁定第一列
Log.e("滚动值","["+x+"]"+"["+y+"]");
}
})//设置滚动回调监听
.setTableViewRangeListener(new LockTableView.OnTableViewRangeListener() {
@Override
public void onLeft(HorizontalScrollView view) {
Log.e("滚动边界","滚动到最左边");
}

@Override
public void onRight(HorizontalScrollView view) {
Log.e("滚动边界","滚动到最右边");
}
})//设置横向滚动边界监听
.setOnLoadingListener(new LockTableView.OnLoadingListener() {//下拉刷新、上拉加载监听
@Override
public void onRefresh(final XRecyclerView mXRecyclerView, final ArrayList<ArrayList<String>> mTableDatas) {
Expand Down Expand Up @@ -184,14 +195,19 @@ private int mTableHeadTextColor;
*/
private int mTableContentTextColor;
/**
* 表格监听事件
* 表格横向滚动监听事件
*/
private OnTableViewListener mTableViewListener;
/**
* 表格横向滚动到边界监听事件
*/
private OnTableViewRangeListener mTableViewRangeListener;
/**
* 表格上拉刷新、下拉加载监听事件
*/
private OnLoadingListener mOnLoadingListener;


```

## 问题反馈
Expand Down

0 comments on commit 7e225ea

Please sign in to comment.