/
LoadMoreView.java
93 lines (77 loc) · 2.28 KB
/
LoadMoreView.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package com.jwenfeng.library.pulltorefresh.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.jwenfeng.library.R;
/**
* 当前类注释:
* 作者:jinwenfeng on 2016/12/8 10:47
* 邮箱:823546371@qq.com
* QQ: 823546371
* 公司:南京穆尊信息科技有限公司
* © 2016 jinwenfeng
* © 版权所有,未经允许不得传播
*/
public class LoadMoreView extends FrameLayout implements FooterView {
private TextView tv;
private ImageView arrow;
private ProgressBar progressBar;
public LoadMoreView(Context context) {
this(context,null);
}
public LoadMoreView(Context context, AttributeSet attrs) {
this(context, attrs,0);
}
public LoadMoreView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.layout_header,null);
addView(view);
tv = (TextView) view.findViewById(R.id.header_tv);
arrow = (ImageView) view.findViewById(R.id.header_arrow);
progressBar = (ProgressBar) view.findViewById(R.id.header_progress);
}
@Override
public void begin() {
}
@Override
public void progress(float progress, float all) {
float s = progress / all;
if (s >= 0.9f){
arrow.setRotation(0);
}else{
arrow.setRotation(180);
}
if (progress >= all-10){
tv.setText("松开加载更多");
}else{
tv.setText("上拉加载");
}
}
@Override
public void finishing(float progress, float all) {
}
@Override
public void loading() {
arrow.setVisibility(GONE);
progressBar.setVisibility(VISIBLE);
tv.setText("加载中...");
}
@Override
public void normal() {
arrow.setVisibility(VISIBLE);
progressBar.setVisibility(GONE);
tv.setText("上拉加载");
}
@Override
public View getView() {
return this;
}
}