Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7905399

Browse files
committedOct 30, 2016
// recyclerview的touch事件.
1 parent 80199ad commit 7905399

File tree

13 files changed

+655
-7
lines changed

13 files changed

+655
-7
lines changed
 

‎app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ android {
2222
dependencies {
2323
compile fileTree(include: ['*.jar'], dir: 'libs')
2424
testCompile 'junit:junit:4.12'
25-
compile 'com.android.support:appcompat-v7:23.1.1'
25+
compile 'com.android.support:appcompat-v7:23.4.0'
26+
compile 'com.android.support:design:23.4.0'
2627
compile 'org.greenrobot:eventbus:3.0.0'
2728
compile 'com.commit451:PhotoView:1.2.5'
2829
compile 'com.github.razerdp:BasePopup:v1.1.9'

‎app/src/main/java/razerdp/friendcircle/config/MomentsType.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@
77
*/
88

99
public interface MomentsType {
10+
//空内容,容错用
1011
int EMPTY_CONTENT = 0;
12+
//纯文字
1113
int TEXT_ONLY = 1;
14+
//多图
1215
int MULTI_IMAGES = 2;
16+
//单图
1317
int SINGLE_IMAGE = 3;
18+
//网页
1419
int WEB = 4;
20+
// TODO: 2016/10/29 增加视频类型,广告类型等
1521
}

‎app/src/main/java/razerdp/friendcircle/ui/FriendCircleDemoActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
2525
super.onCreate(savedInstanceState);
2626
setContentView(R.layout.activity_main);
2727

28-
MomentsRequest momentsRequest=new MomentsRequest();
28+
/* MomentsRequest momentsRequest=new MomentsRequest();
2929
momentsRequest.setOnResponseListener(new OnResponseListener<List<MomentsInfo>>() {
3030
@Override
3131
public void onStart(int requestType) {
@@ -44,7 +44,7 @@ public void onError(BmobException e, int requestType) {
4444
4545
}
4646
});
47-
momentsRequest.execute();
47+
momentsRequest.execute();*/
4848

4949
//添加动态
5050
/* final BmobInitHelper helper=new BmobInitHelper();
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package razerdp.friendcircle.widget.pullrecyclerview;
2+
3+
import android.content.Context;
4+
import android.util.AttributeSet;
5+
import android.view.View;
6+
import android.view.ViewTreeObserver;
7+
import android.widget.FrameLayout;
8+
9+
import razerdp.friendcircle.R;
10+
import razerdp.friendcircle.widget.pullrecyclerview.interfaces.CirclePtrRefreshView;
11+
import razerdp.friendcircle.widget.pullrecyclerview.interfaces.PtrState;
12+
13+
/**
14+
* Created by 大灯泡 on 2016/10/29.
15+
* <p>
16+
* 朋友圈下拉头部
17+
*/
18+
19+
public class CirclePtrFooterView extends FrameLayout implements CirclePtrRefreshView {
20+
private onRecyclerPullListener onRecyclerPullListener;
21+
22+
public CirclePtrFooterView(Context context) {
23+
this(context, null);
24+
}
25+
26+
public CirclePtrFooterView(Context context, AttributeSet attrs) {
27+
this(context, attrs, 0);
28+
}
29+
30+
public CirclePtrFooterView(Context context, AttributeSet attrs, int defStyleAttr) {
31+
super(context, attrs, defStyleAttr);
32+
initView(context);
33+
}
34+
35+
private void initView(Context context) {
36+
View.inflate(context, R.layout.view_ptr_header, this);
37+
}
38+
39+
public razerdp.friendcircle.widget.pullrecyclerview.onRecyclerPullListener getOnRecyclerPullListener() {
40+
return onRecyclerPullListener;
41+
}
42+
43+
public void setOnRecyclerPullListener(razerdp.friendcircle.widget.pullrecyclerview.onRecyclerPullListener onRecyclerPullListener) {
44+
this.onRecyclerPullListener = onRecyclerPullListener;
45+
}
46+
47+
48+
@Override
49+
public void onRefreshing() {
50+
51+
}
52+
53+
@Override
54+
public void onCompelete() {
55+
56+
}
57+
58+
@Override
59+
public void onStart(PtrState state, int positionForRefresh) {
60+
61+
}
62+
63+
@Override
64+
public void onMoved(PtrState state, int positionForRefresh, int offsetY) {
65+
66+
}
67+
68+
@Override
69+
public void onRelease(PtrState state, int positionForRefresh, int offsetY) {
70+
71+
}
72+
73+
@Override
74+
public void onReset(PtrState state, int positionForRefresh) {
75+
76+
}
77+
78+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package razerdp.friendcircle.widget.pullrecyclerview;
2+
3+
import android.content.Context;
4+
import android.util.AttributeSet;
5+
import android.util.Log;
6+
import android.view.View;
7+
import android.view.ViewTreeObserver;
8+
import android.widget.FrameLayout;
9+
10+
import razerdp.friendcircle.R;
11+
import razerdp.friendcircle.widget.pullrecyclerview.interfaces.CirclePtrRefreshView;
12+
import razerdp.friendcircle.widget.pullrecyclerview.interfaces.PtrState;
13+
14+
/**
15+
* Created by 大灯泡 on 2016/10/29.
16+
* <p>
17+
* 朋友圈下拉头部
18+
*/
19+
20+
public class CirclePtrHeaderView extends FrameLayout implements CirclePtrRefreshView {
21+
private static final String TAG = "CirclePtrHeaderView";
22+
23+
private onRecyclerPullListener onRecyclerPullListener;
24+
25+
public CirclePtrHeaderView(Context context) {
26+
this(context, null);
27+
}
28+
29+
public CirclePtrHeaderView(Context context, AttributeSet attrs) {
30+
this(context, attrs, 0);
31+
}
32+
33+
public CirclePtrHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
34+
super(context, attrs, defStyleAttr);
35+
initView(context);
36+
}
37+
38+
private void initView(Context context) {
39+
View.inflate(context, R.layout.view_ptr_header, this);
40+
}
41+
42+
public razerdp.friendcircle.widget.pullrecyclerview.onRecyclerPullListener getOnRecyclerPullListener() {
43+
return onRecyclerPullListener;
44+
}
45+
46+
public void setOnRecyclerPullListener(razerdp.friendcircle.widget.pullrecyclerview.onRecyclerPullListener onRecyclerPullListener) {
47+
this.onRecyclerPullListener = onRecyclerPullListener;
48+
}
49+
50+
51+
@Override
52+
public void onRefreshing() {
53+
54+
}
55+
56+
@Override
57+
public void onCompelete() {
58+
59+
}
60+
61+
@Override
62+
public void onStart(PtrState state, int positionForRefresh) {
63+
64+
}
65+
66+
@Override
67+
public void onMoved(PtrState state, int positionForRefresh, int offsetY) {
68+
Log.d(TAG, "onMoved() called with: state = [" + state + "], positionForRefresh = [" + positionForRefresh + "], offsetY = [" + offsetY + "]");
69+
}
70+
71+
@Override
72+
public void onRelease(PtrState state, int positionForRefresh, int offsetY) {
73+
74+
}
75+
76+
@Override
77+
public void onReset(PtrState state, int positionForRefresh) {
78+
79+
}
80+
}
Lines changed: 399 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,399 @@
1+
package razerdp.friendcircle.widget.pullrecyclerview;
2+
3+
import android.content.Context;
4+
import android.graphics.Color;
5+
import android.graphics.Point;
6+
import android.graphics.PointF;
7+
import android.support.annotation.IntDef;
8+
import android.support.v7.widget.LinearLayoutManager;
9+
import android.support.v7.widget.RecyclerView;
10+
import android.util.AttributeSet;
11+
import android.util.Log;
12+
import android.view.MotionEvent;
13+
import android.view.View;
14+
import android.view.ViewConfiguration;
15+
import android.widget.LinearLayout;
16+
17+
import com.socks.library.KLog;
18+
19+
import java.lang.annotation.Retention;
20+
import java.lang.annotation.RetentionPolicy;
21+
22+
import razerdp.friendcircle.widget.pullrecyclerview.interfaces.CirclePtrRefreshView;
23+
import razerdp.friendcircle.widget.pullrecyclerview.interfaces.OnRefreshListener2;
24+
import razerdp.friendcircle.widget.pullrecyclerview.interfaces.PtrState;
25+
26+
import static razerdp.friendcircle.widget.pullrecyclerview.CircleRecyclerView.Status.*;
27+
28+
29+
/**
30+
* Created by 大灯泡 on 2016/10/29.
31+
* <p>
32+
* 专为朋友圈项目定制的下拉recyclerview
33+
* 原因在于:
34+
* 1 - 目前而言,git上大多数的rv都是用的swiperefreshlayout
35+
* 2 - 大多数rv都不支持下拉后收回下拉头部的
36+
* 3 - 因为大多数的rv都支持太多功能了,显得有点重,并且有些想要的回调我们都没法拿到
37+
* <p>
38+
* 综上所述,干脆自己弄一个算了。。。。
39+
* <p>
40+
* 目标:
41+
* 【基本要求】因为相当于定制,只为本项目服务,因此不考虑通用性,更多考虑扩展性
42+
* <p>
43+
* 1 - 下拉和上拉支持回调
44+
* 2 - 跟iOS朋友圈下拉头部一样,支持头部在刷新时的回弹
45+
* 3 - 滑动到底部自动加载更多
46+
* 4 - addHeaderView。
47+
*/
48+
49+
public class CircleRecyclerView extends LinearLayout {
50+
public static boolean DEBUG = true;
51+
private static final String TAG = "CircleRecyclerView";
52+
53+
@Retention(RetentionPolicy.SOURCE)
54+
@IntDef({DEFAULT, PULL_TO_REFRESH, REFRESHING})
55+
@interface Status {
56+
int DEFAULT = 0;
57+
int PULL_TO_REFRESH = 1;
58+
int REFRESHING = 2;
59+
}
60+
61+
@Status
62+
private int currentStatus;
63+
64+
//observer
65+
private InnerRefreshViewObserver refreshViewObserver;
66+
private InnerMotionEventObserver motionEventObserver;
67+
68+
//callback
69+
private OnRefreshListener2 onRefreshListener;
70+
71+
//view
72+
private CirclePtrRefreshView mPtrHeaderView;
73+
private CirclePtrRefreshView mPtrFooterView;
74+
private RecyclerView recyclerView;
75+
76+
//options
77+
private int positionForRefresh;
78+
private boolean canPull = true;
79+
80+
81+
public CircleRecyclerView(Context context) {
82+
this(context, null);
83+
}
84+
85+
public CircleRecyclerView(Context context, AttributeSet attrs) {
86+
this(context, attrs, 0);
87+
}
88+
89+
public CircleRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
90+
super(context, attrs, defStyleAttr);
91+
init(context);
92+
}
93+
94+
private void init(Context context) {
95+
setOrientation(VERTICAL);
96+
setBackgroundColor(Color.TRANSPARENT);
97+
98+
refreshViewObserver = new InnerRefreshViewObserver();
99+
motionEventObserver = new InnerMotionEventObserver(context);
100+
101+
if (mPtrHeaderView == null) {
102+
mPtrHeaderView = new CirclePtrHeaderView(context);
103+
}
104+
if (mPtrFooterView == null) {
105+
mPtrFooterView = new CirclePtrFooterView(context);
106+
}
107+
if (recyclerView == null) {
108+
recyclerView = new RecyclerView(context);
109+
recyclerView.setLayoutManager(new LinearLayoutManager(context, VERTICAL, false));
110+
}
111+
addView((View) mPtrHeaderView);
112+
addView(recyclerView);
113+
}
114+
115+
@Override
116+
protected void onFinishInflate() {
117+
if (getChildCount() > 2) {
118+
throw new IllegalStateException("超过了两个子view哦");
119+
}
120+
super.onFinishInflate();
121+
}
122+
123+
@Override
124+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
125+
checkRefreshViewValided();
126+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
127+
128+
if (mPtrHeaderView != null) {
129+
measureChildWithMargins((View) mPtrHeaderView, widthMeasureSpec, 0, heightMeasureSpec, 0);
130+
MarginLayoutParams ptrHeaderLayoutParams = (MarginLayoutParams) ((View) mPtrHeaderView).getLayoutParams();
131+
int ptrHeaderWidth = ((View) mPtrHeaderView).getMeasuredWidth() + ptrHeaderLayoutParams.leftMargin + ptrHeaderLayoutParams.rightMargin;
132+
int ptrHeaderHeight = ((View) mPtrHeaderView).getMeasuredHeight() + ptrHeaderLayoutParams.topMargin + ptrHeaderLayoutParams.bottomMargin;
133+
refreshViewObserver.setPtrHeaderWidth(ptrHeaderWidth);
134+
refreshViewObserver.setPtrHeaderHeight(ptrHeaderHeight);
135+
}
136+
137+
/* if (mPtrFooterView != null) {
138+
measureChildWithMargins((View) mPtrFooterView, widthMeasureSpec, 0, heightMeasureSpec, 0);
139+
MarginLayoutParams ptrFooterLayoutParams = (MarginLayoutParams) ((View) mPtrFooterView).getLayoutParams();
140+
int ptrFooterWidth = ((View) mPtrFooterView).getMeasuredWidth() + ptrFooterLayoutParams.leftMargin + ptrFooterLayoutParams.rightMargin;
141+
int ptrFooterHeight = ((View) mPtrFooterView).getMeasuredHeight() + ptrFooterLayoutParams.topMargin + ptrFooterLayoutParams.bottomMargin;
142+
refreshViewObserver.setPtrFooterWidth(ptrFooterWidth);
143+
refreshViewObserver.setPtrFooterHeight(ptrFooterHeight);
144+
}*/
145+
}
146+
147+
@Override
148+
protected void onLayout(boolean changed, int l, int t, int r, int b) {
149+
if (mPtrHeaderView != null) {
150+
final int left = 0;
151+
final int top = -refreshViewObserver.getPtrHeaderHeight() + motionEventObserver.getCurrentY();
152+
final int right = left + refreshViewObserver.getPtrHeaderWidth();
153+
final int bottom = top + refreshViewObserver.getPtrHeaderHeight();
154+
//摆放header的位置,受滑动距离影响,设为负值让其隐藏
155+
((View) mPtrHeaderView).layout(left, top, right, bottom);
156+
}
157+
super.onLayout(changed, l, t, r, b);
158+
159+
}
160+
161+
private void setCurrentStatus(@Status int status) {
162+
this.currentStatus = status;
163+
164+
}
165+
166+
private void checkRefreshViewValided() {
167+
if (mPtrHeaderView != null && !(mPtrHeaderView instanceof View)) {
168+
throw new IllegalStateException("诶多。。。那个。。。接口都有个View字哦,请给一个View来-V-");
169+
}
170+
if (mPtrFooterView != null && !(mPtrFooterView instanceof View)) {
171+
throw new IllegalStateException("诶多。。。那个。。。接口都有个View字哦,请给一个View来-V-");
172+
}
173+
}
174+
175+
@Override
176+
public boolean dispatchTouchEvent(MotionEvent ev) {
177+
if (!isCanPull()) {
178+
return super.dispatchTouchEvent(ev);
179+
} else {
180+
switch (ev.getAction()) {
181+
case MotionEvent.ACTION_DOWN:
182+
motionEventObserver.catchTouchDown(ev.getX(), ev.getY());
183+
super.dispatchTouchEvent(ev);
184+
return true;
185+
case MotionEvent.ACTION_MOVE:
186+
motionEventObserver.catchTouchMove(ev.getX(), ev.getY());
187+
float offsetX = motionEventObserver.getOffsetX();
188+
float offsetY = motionEventObserver.getOffsetY();
189+
//横向移动比纵向大,则传递下去
190+
if (Math.abs(offsetX) > Math.abs(offsetY * 2)) {
191+
if (DEBUG) {
192+
Log.d(TAG, "横向移动,取消事件");
193+
}
194+
return super.dispatchTouchEvent(ev);
195+
}
196+
197+
if (motionEventObserver.isDrag()) {
198+
if (motionEventObserver.isValidTouchSlop(offsetY)) {
199+
doMove(ev);
200+
return true;
201+
}
202+
}
203+
break;
204+
}
205+
}
206+
return super.dispatchTouchEvent(ev);
207+
}
208+
209+
/**
210+
* 处理移动事件
211+
*/
212+
private void doMove(MotionEvent ev) {
213+
214+
//如果是下拉
215+
if (motionEventObserver.isFromTop()) {
216+
mPtrHeaderView.onStart(PtrState.START_TO_PULL, positionForRefresh);
217+
}
218+
//刷新位置
219+
int currentY = (int) (motionEventObserver.getCurrentY() + motionEventObserver.getOffsetY());
220+
Log.i(TAG, ">>>isPullDown: " + motionEventObserver.isPullDown() + "<<< currentY = " + currentY);
221+
motionEventObserver.setCurrentY(currentY);
222+
if (currentY < positionForRefresh) {
223+
mPtrHeaderView.onMoved(PtrState.PULL_TO_REFRESH, positionForRefresh, (int) motionEventObserver.getOffsetY());
224+
} else {
225+
mPtrHeaderView.onMoved(PtrState.RELEASE_TO_REFRESH, positionForRefresh, (int) motionEventObserver.getOffsetY());
226+
}
227+
((View) mPtrHeaderView).offsetTopAndBottom((int) motionEventObserver.getOffsetY());
228+
recyclerView.offsetTopAndBottom((int) motionEventObserver.getOffsetY());
229+
230+
}
231+
232+
//------------------------------------------get/set-----------------------------------------------
233+
234+
public OnRefreshListener2 getOnRefreshListener() {
235+
return onRefreshListener;
236+
}
237+
238+
public void setOnRefreshListener(OnRefreshListener2 onRefreshListener) {
239+
this.onRefreshListener = onRefreshListener;
240+
}
241+
242+
public boolean isCanPull() {
243+
return canPull;
244+
}
245+
246+
public void setCanPull(boolean canPull) {
247+
this.canPull = canPull;
248+
}
249+
250+
/**
251+
* ============分割线===============
252+
* 各种状态的观察
253+
* ============分割线===============
254+
*/
255+
256+
/**
257+
* 刷新View的观察者
258+
*/
259+
private static class InnerRefreshViewObserver {
260+
private static final String INNERTAG = "InnerRefreshViewObserve";
261+
private int ptrHeaderWidth;
262+
private int ptrHeaderHeight;
263+
private int ptrFooterWidth;
264+
private int ptrFooterHeight;
265+
266+
InnerRefreshViewObserver() {
267+
}
268+
269+
int getPtrHeaderWidth() {
270+
return ptrHeaderWidth;
271+
}
272+
273+
void setPtrHeaderWidth(int ptrHeaderWidth) {
274+
this.ptrHeaderWidth = ptrHeaderWidth;
275+
if (DEBUG) {
276+
Log.i(INNERTAG, "ptrHeaderWidth >>> " + ptrHeaderWidth);
277+
}
278+
}
279+
280+
int getPtrHeaderHeight() {
281+
return ptrHeaderHeight;
282+
}
283+
284+
void setPtrHeaderHeight(int ptrHeaderHeight) {
285+
this.ptrHeaderHeight = ptrHeaderHeight;
286+
if (DEBUG) {
287+
Log.i(INNERTAG, "ptrHeaderHeight >>> " + ptrHeaderWidth);
288+
}
289+
}
290+
291+
int getPtrFooterWidth() {
292+
return ptrFooterWidth;
293+
}
294+
295+
void setPtrFooterWidth(int ptrFooterWidth) {
296+
this.ptrFooterWidth = ptrFooterWidth;
297+
if (DEBUG) {
298+
Log.i(INNERTAG, "ptrFooterWidth >>> " + ptrHeaderWidth);
299+
}
300+
}
301+
302+
int getPtrFooterHeight() {
303+
return ptrFooterHeight;
304+
}
305+
306+
void setPtrFooterHeight(int ptrFooterHeight) {
307+
this.ptrFooterHeight = ptrFooterHeight;
308+
if (DEBUG) {
309+
Log.i(INNERTAG, "ptrFooterHeight >>> " + ptrHeaderWidth);
310+
}
311+
}
312+
}
313+
314+
/**
315+
* 手势动作的观察者
316+
*/
317+
private static class InnerMotionEventObserver {
318+
//是否正在拖动拖动
319+
private boolean isDrag;
320+
//是否从初始状态拖动
321+
private boolean isFirstDrag;
322+
//是否到达顶部
323+
private boolean returnToTop;
324+
//上一次的位置
325+
private PointF lastPos;
326+
327+
private int currentY;
328+
329+
//位移量
330+
private float offsetX;
331+
private float offsetY;
332+
333+
//最小滑动判定值
334+
private int minTouchSlop;
335+
336+
InnerMotionEventObserver(Context context) {
337+
lastPos = new PointF();
338+
ViewConfiguration conf = ViewConfiguration.get(context);
339+
minTouchSlop = conf.getScaledTouchSlop();
340+
}
341+
342+
void catchTouchDown(float x, float y) {
343+
isDrag = true;
344+
lastPos.set(x, y);
345+
}
346+
347+
void catchTouchMove(float x, float y) {
348+
this.offsetX = x - lastPos.x;
349+
//阻尼1.2
350+
this.offsetY = (y - lastPos.y) / 1.2f;
351+
lastPos.set(x, y);
352+
}
353+
354+
boolean isDrag() {
355+
return isDrag;
356+
}
357+
358+
void setDrag(boolean drag) {
359+
isDrag = drag;
360+
}
361+
362+
boolean isFirstDrag() {
363+
return isFirstDrag;
364+
}
365+
366+
void setFirstDrag(boolean firstDrag) {
367+
isFirstDrag = firstDrag;
368+
}
369+
370+
float getOffsetX() {
371+
return offsetX;
372+
}
373+
374+
float getOffsetY() {
375+
return offsetY;
376+
}
377+
378+
int getCurrentY() {
379+
return currentY < 0 ? 0 : currentY;
380+
}
381+
382+
void setCurrentY(int currentY) {
383+
this.currentY = currentY;
384+
returnToTop = currentY <= 0;
385+
}
386+
387+
boolean isValidTouchSlop(float offset) {
388+
return Math.abs(offset) >= minTouchSlop;
389+
}
390+
391+
boolean isPullDown() {
392+
return offsetY > 0;
393+
}
394+
395+
boolean isFromTop() {
396+
return currentY == 0;
397+
}
398+
}
399+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package razerdp.friendcircle.widget.pullrecyclerview.interfaces;
2+
3+
/**
4+
* Created by 大灯泡 on 2016/10/29.
5+
* <p>
6+
* 刷新view
7+
*/
8+
9+
public interface CirclePtrRefreshView {
10+
11+
void onRefreshing();
12+
13+
void onCompelete();
14+
/**
15+
* 开始下拉
16+
*/
17+
void onStart(PtrState state, int positionForRefresh);
18+
19+
/**
20+
* 移动中
21+
*
22+
* @param state 当前状态
23+
* @param positionForRefresh 刷新位置
24+
* @param offsetY 移动距离
25+
*/
26+
void onMoved(PtrState state, int positionForRefresh, int offsetY);
27+
28+
/**
29+
* 释放时
30+
*/
31+
void onRelease(PtrState state, int positionForRefresh, int offsetY);
32+
33+
/**
34+
* 回到原来的位置
35+
*/
36+
void onReset(PtrState state, int positionForRefresh);
37+
38+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package razerdp.friendcircle.widget.pullrecyclerview.interfaces;
2+
3+
/**
4+
* Created by 大灯泡 on 2016/10/29.
5+
* <p>
6+
* 状态
7+
*/
8+
9+
public enum PtrState {
10+
START_TO_PULL,
11+
PULL_TO_REFRESH,
12+
RELEASE_TO_REFRESH,
13+
ON_RESET
14+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package razerdp.friendcircle.widget.pullrecyclerview.interfaces;
2+
3+
/**
4+
* Created by 大灯泡 on 2016/10/29.
5+
*
6+
* 下拉和上拉的回调
7+
*/
8+
9+
public interface OnRefreshListener2 {
10+
void onRefresh();
11+
void onLoadMore();
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package razerdp.friendcircle.widget.pullrecyclerview;
2+
3+
/**
4+
* Created by 大灯泡 on 2016/10/29.
5+
*
6+
* 下拉回调
7+
*/
8+
9+
public interface onRecyclerPullListener {
10+
void onStart();
11+
void onMove(int offsetPos);
12+
void onFinish();
13+
}

‎app/src/main/res/layout/activity_main.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
android:orientation="vertical"
77
tools:context=".ui.FriendCircleDemoActivity">
88

9-
<TextView
9+
<razerdp.friendcircle.widget.pullrecyclerview.CircleRecyclerView
1010
android:layout_width="match_parent"
11-
android:layout_height="match_parent"
12-
android:gravity="center"
13-
android:text="111"/>
11+
android:layout_height="match_parent"/>
1412
</LinearLayout>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="@dimen/ptr_header_height"
5+
android:background="@color/ptr_header_bg"
6+
android:orientation="vertical">
7+
8+
</FrameLayout>

‎build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ allprojects {
1616
repositories {
1717
jcenter()
1818
maven { url "https://jitpack.io" }
19+
1920
maven { url "https://raw.github.com/bmob/bmob-android-sdk/master" }
2021
}
2122
}

0 commit comments

Comments
 (0)
Please sign in to comment.