Commit db27de12ce6c74ee408e24598e094682613dbece
1 parent
e54c424ab1
Exists in
master
完成大多数界面,时间选择器,地区选择器
Showing
67 changed files
with
5511 additions
and
34 deletions
Show diff stats
PersonalCenter/.idea/gradle.xml
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 | <option value="$PROJECT_DIR$" /> |
12 | 12 | <option value="$PROJECT_DIR$/app" /> |
13 | 13 | <option value="$PROJECT_DIR$/circledialog" /> |
14 | + <option value="$PROJECT_DIR$/pickerview" /> | |
14 | 15 | </set> |
15 | 16 | </option> |
16 | 17 | <option name="resolveModulePerSourceSet" value="false" /> | ... | ... |
PersonalCenter/.idea/modules.xml
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 | <module fileurl="file://$PROJECT_DIR$/PersonalCenter.iml" filepath="$PROJECT_DIR$/PersonalCenter.iml" /> |
6 | 6 | <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> |
7 | 7 | <module fileurl="file://$PROJECT_DIR$/circledialog/circledialog.iml" filepath="$PROJECT_DIR$/circledialog/circledialog.iml" /> |
8 | + <module fileurl="file://$PROJECT_DIR$/pickerview/pickerview.iml" filepath="$PROJECT_DIR$/pickerview/pickerview.iml" /> | |
8 | 9 | </modules> |
9 | 10 | </component> |
10 | 11 | </project> |
11 | 12 | \ No newline at end of file | ... | ... |
PersonalCenter/app/build.gradle
PersonalCenter/app/src/main/AndroidManifest.xml
... | ... | @@ -61,7 +61,7 @@ |
61 | 61 | |
62 | 62 | </activity> |
63 | 63 | <activity |
64 | - android:name=".activity.ChangeEletronicCardPhone" | |
64 | + android:name=".activity.ChangeEletronicCardPhoneActivity" | |
65 | 65 | android:launchMode="singleTask" |
66 | 66 | android:screenOrientation="landscape"> |
67 | 67 | |
... | ... | @@ -78,6 +78,30 @@ |
78 | 78 | android:screenOrientation="landscape"> |
79 | 79 | |
80 | 80 | </activity> |
81 | + <activity | |
82 | + android:name=".activity.ElectronicCardEditInfoActivity" | |
83 | + android:launchMode="singleTask" | |
84 | + android:screenOrientation="landscape"> | |
85 | + | |
86 | + </activity> | |
87 | + <activity | |
88 | + android:name=".activity.ElectronicCardInfoOKActivity" | |
89 | + android:launchMode="singleTask" | |
90 | + android:screenOrientation="landscape"> | |
91 | + | |
92 | + </activity> | |
93 | + <activity | |
94 | + android:name=".activity.ElectronicCardLookInfoActivity" | |
95 | + android:launchMode="singleTask" | |
96 | + android:screenOrientation="landscape"> | |
97 | + | |
98 | + </activity> | |
99 | + <activity | |
100 | + android:name=".activity.FeedBackActivity" | |
101 | + android:launchMode="singleTask" | |
102 | + android:screenOrientation="landscape"> | |
103 | + | |
104 | + </activity> | |
81 | 105 | </application> |
82 | 106 | |
83 | 107 | </manifest> |
84 | 108 | \ No newline at end of file | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangeEletronicCardPhone.java
... | ... | @@ -1,18 +0,0 @@ |
1 | -package com.hjx.personalcenter.activity; | |
2 | - | |
3 | -import android.app.Activity; | |
4 | -import android.os.Bundle; | |
5 | - | |
6 | -import com.hjx.personalcenter.R; | |
7 | - | |
8 | -/** | |
9 | - * Created by h on 2017/8/9. | |
10 | - */ | |
11 | - | |
12 | -public class ChangeEletronicCardPhone extends Activity { | |
13 | - @Override | |
14 | - protected void onCreate(Bundle savedInstanceState) { | |
15 | - super.onCreate(savedInstanceState); | |
16 | - setContentView(R.layout.activity_electronicard_phone); | |
17 | - } | |
18 | -} |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChangeEletronicCardPhoneActivity.java
... | ... | @@ -0,0 +1,18 @@ |
1 | +package com.hjx.personalcenter.activity; | |
2 | + | |
3 | +import android.app.Activity; | |
4 | +import android.os.Bundle; | |
5 | + | |
6 | +import com.hjx.personalcenter.R; | |
7 | + | |
8 | +/** | |
9 | + * Created by h on 2017/8/9. | |
10 | + */ | |
11 | + | |
12 | +public class ChangeEletronicCardPhoneActivity extends Activity { | |
13 | + @Override | |
14 | + protected void onCreate(Bundle savedInstanceState) { | |
15 | + super.onCreate(savedInstanceState); | |
16 | + setContentView(R.layout.activity_electronicard_phone); | |
17 | + } | |
18 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardEditInfoActivity.java
... | ... | @@ -0,0 +1,95 @@ |
1 | +package com.hjx.personalcenter.activity; | |
2 | + | |
3 | +import android.app.Activity; | |
4 | +import android.graphics.Color; | |
5 | +import android.os.Bundle; | |
6 | +import android.view.View; | |
7 | +import android.widget.Button; | |
8 | +import android.widget.LinearLayout; | |
9 | +import android.widget.TextView; | |
10 | + | |
11 | +import com.bigkoo.pickerview.TimePickerView; | |
12 | +import com.hjx.personalcenter.R; | |
13 | + | |
14 | +import java.text.SimpleDateFormat; | |
15 | +import java.util.Calendar; | |
16 | +import java.util.Date; | |
17 | + | |
18 | +/**填写保卡信息 熊巍 | |
19 | + * Created by h on 2017/8/11. | |
20 | + */ | |
21 | + | |
22 | +public class ElectronicCardEditInfoActivity extends Activity implements View.OnClickListener { | |
23 | + private LinearLayout lineL_buy_time; | |
24 | + private TextView tv_buy_time; | |
25 | + private TimePickerView pvTime; | |
26 | + | |
27 | + @Override | |
28 | + protected void onCreate(Bundle savedInstanceState) { | |
29 | + super.onCreate(savedInstanceState); | |
30 | + setContentView(R.layout.activity_electroniccard_info); | |
31 | + initView(); | |
32 | + initData(); | |
33 | + initLister(); | |
34 | + initTimePicker(); | |
35 | + } | |
36 | + | |
37 | + private void initView() { | |
38 | + lineL_buy_time = (LinearLayout) findViewById(R.id.lineL_buy_time); | |
39 | + tv_buy_time = (TextView) findViewById(R.id.tv_buy_time); | |
40 | + } | |
41 | + | |
42 | + private void initData() { | |
43 | + | |
44 | + } | |
45 | + | |
46 | + private void initLister() { | |
47 | + lineL_buy_time.setOnClickListener(this); | |
48 | + | |
49 | + } | |
50 | + private void initTimePicker() { | |
51 | + //控制时间范围(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释) | |
52 | + //因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 | |
53 | + Calendar selectedDate = Calendar.getInstance(); | |
54 | + Calendar startDate = Calendar.getInstance(); | |
55 | + startDate.set(2013, 0, 23); | |
56 | + Calendar endDate = Calendar.getInstance(); | |
57 | + endDate.set(2019, 11, 28); | |
58 | + //时间选择器 | |
59 | + pvTime = new TimePickerView.Builder(this, new TimePickerView.OnTimeSelectListener() { | |
60 | + @Override | |
61 | + public void onTimeSelect(Date date, View v) {//选中事件回调 | |
62 | + // 这里回调过来的v,就是show()方法里面所添加的 View 参数,如果show的时候没有添加参数,v则为null | |
63 | + /*btn_Time.setText(getTime(date));*/ | |
64 | + Button btn = (Button) v; | |
65 | + btn.setText(getTime(date)); | |
66 | + } | |
67 | + }) | |
68 | + //年月日时分秒 的显示与否,不设置则默认全部显示 | |
69 | + .setType(new boolean[]{true, true, true, false, false, false}) | |
70 | + .setLabel("", "", "", "", "", "") | |
71 | + .isCenterLabel(false) | |
72 | + .setDividerColor(Color.DKGRAY) | |
73 | + .setContentSize(21) | |
74 | + .setDate(selectedDate) | |
75 | + .setRangDate(startDate, endDate) | |
76 | + .setBackgroundId(0x00FFFFFF) //设置外部遮罩颜色 | |
77 | + .setDecorView(null) | |
78 | + .build(); | |
79 | + } | |
80 | + private String getTime(Date date) {//可根据需要自行截取数据显示 | |
81 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
82 | + return format.format(date); | |
83 | + } | |
84 | + | |
85 | + @Override | |
86 | + public void onClick(View v) { | |
87 | + switch (v.getId()){ | |
88 | + case R.id.lineL_buy_time: | |
89 | + pvTime.show(v);//弹出时间选择器,传递参数过去,回调的时候则可以绑定此view | |
90 | + break; | |
91 | + } | |
92 | + | |
93 | + | |
94 | + } | |
95 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardInfoOKActivity.java
... | ... | @@ -0,0 +1,18 @@ |
1 | +package com.hjx.personalcenter.activity; | |
2 | + | |
3 | +import android.app.Activity; | |
4 | +import android.os.Bundle; | |
5 | + | |
6 | +import com.hjx.personalcenter.R; | |
7 | + | |
8 | +/** | |
9 | + * Created by h on 2017/8/11. | |
10 | + */ | |
11 | + | |
12 | +public class ElectronicCardInfoOKActivity extends Activity{ | |
13 | + @Override | |
14 | + protected void onCreate(Bundle savedInstanceState) { | |
15 | + super.onCreate(savedInstanceState); | |
16 | + setContentView(R.layout.activity_ok_cardinfo); | |
17 | + } | |
18 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardLookInfoActivity.java
... | ... | @@ -0,0 +1,18 @@ |
1 | +package com.hjx.personalcenter.activity; | |
2 | + | |
3 | +import android.app.Activity; | |
4 | +import android.os.Bundle; | |
5 | + | |
6 | +import com.hjx.personalcenter.R; | |
7 | + | |
8 | +/** | |
9 | + * Created by h on 2017/8/11. | |
10 | + */ | |
11 | + | |
12 | +public class ElectronicCardLookInfoActivity extends Activity{ | |
13 | + @Override | |
14 | + protected void onCreate(Bundle savedInstanceState) { | |
15 | + super.onCreate(savedInstanceState); | |
16 | + setContentView(R.layout.activity_electronic_look_cardinfo); | |
17 | + } | |
18 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/FeedBackActivity.java
... | ... | @@ -0,0 +1,18 @@ |
1 | +package com.hjx.personalcenter.activity; | |
2 | + | |
3 | +import android.app.Activity; | |
4 | +import android.os.Bundle; | |
5 | + | |
6 | +import com.hjx.personalcenter.R; | |
7 | + | |
8 | +/** | |
9 | + * Created by h on 2017/8/11. | |
10 | + */ | |
11 | + | |
12 | +public class FeedBackActivity extends Activity{ | |
13 | + @Override | |
14 | + protected void onCreate(Bundle savedInstanceState) { | |
15 | + super.onCreate(savedInstanceState); | |
16 | + setContentView(R.layout.activity_feedback); | |
17 | + } | |
18 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
... | ... | @@ -18,7 +18,7 @@ public class MainActivity extends AppCompatActivity { |
18 | 18 | ssss.setOnClickListener(new View.OnClickListener() { |
19 | 19 | @Override |
20 | 20 | public void onClick(View v) { |
21 | - Intent intent = new Intent(MainActivity.this,LoginAndRegisterActivity.class); | |
21 | + Intent intent = new Intent(MainActivity.this,RegisterInfoActivity.class); | |
22 | 22 | startActivity(intent); |
23 | 23 | } |
24 | 24 | }); | ... | ... |
PersonalCenter/app/src/main/res/drawable/corcle_blue_bg.xml
... | ... | @@ -0,0 +1,13 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<shape xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:shape="rectangle"> | |
4 | + <solid | |
5 | + android:color="@color/white"/> | |
6 | + <corners | |
7 | + android:bottomLeftRadius="20dp" | |
8 | + android:topLeftRadius="20dp" | |
9 | + android:bottomRightRadius="20dp" | |
10 | + android:topRightRadius="20dp"/> | |
11 | + <stroke android:width="1dp" | |
12 | + android:color="@color/login_text_blue"/> | |
13 | +</shape> | |
0 | 14 | \ No newline at end of file | ... | ... |
PersonalCenter/app/src/main/res/drawable/corcle_white_bg.xml
... | ... | @@ -1,13 +0,0 @@ |
1 | -<?xml version="1.0" encoding="utf-8"?> | |
2 | -<shape xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | - android:shape="rectangle"> | |
4 | - <solid | |
5 | - android:color="@color/colorAccent"/> | |
6 | - <corners | |
7 | - android:bottomLeftRadius="20dp" | |
8 | - android:topLeftRadius="20dp" | |
9 | - android:bottomRightRadius="20dp" | |
10 | - android:topRightRadius="20dp"/> | |
11 | - <stroke android:width="1dp" | |
12 | - android:color="@color/cutoff_line"/> | |
13 | -</shape> | |
14 | 0 | \ No newline at end of file |
PersonalCenter/app/src/main/res/layout/activity_electronic_look_cardinfo.xml
... | ... | @@ -0,0 +1,370 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:layout_width="match_parent" | |
4 | + android:layout_height="match_parent" | |
5 | + android:orientation="vertical"> | |
6 | + | |
7 | + <RelativeLayout | |
8 | + android:id="@+id/title" | |
9 | + android:layout_width="match_parent" | |
10 | + android:layout_height="wrap_content" | |
11 | + android:background="@color/login_text_blue" | |
12 | + android:minHeight="50dp"> | |
13 | + | |
14 | + <ImageView | |
15 | + android:id="@+id/cancel" | |
16 | + android:layout_width="wrap_content" | |
17 | + android:layout_height="wrap_content" | |
18 | + android:layout_centerVertical="true" | |
19 | + android:paddingLeft="20dp" | |
20 | + android:paddingRight="20dp" | |
21 | + android:src="@mipmap/title_back" /> | |
22 | + | |
23 | + <TextView | |
24 | + android:id="@+id/menu_title" | |
25 | + android:layout_width="wrap_content" | |
26 | + android:layout_height="wrap_content" | |
27 | + android:layout_centerInParent="true" | |
28 | + android:text="@string/string_electroniccard_info_look" | |
29 | + android:textColor="@android:color/white" | |
30 | + android:textSize="22sp" /> | |
31 | + </RelativeLayout> | |
32 | + | |
33 | + <LinearLayout | |
34 | + android:layout_width="match_parent" | |
35 | + android:layout_height="wrap_content" | |
36 | + android:layout_margin="20dp" | |
37 | + android:background="@mipmap/cardbackgrangd" | |
38 | + android:gravity="center" | |
39 | + android:orientation="vertical"> | |
40 | + | |
41 | + <LinearLayout | |
42 | + android:layout_width="match_parent" | |
43 | + android:layout_height="wrap_content" | |
44 | + android:layout_marginTop="70dp" | |
45 | + android:gravity="center_vertical" | |
46 | + android:orientation="horizontal"> | |
47 | + | |
48 | + <LinearLayout | |
49 | + android:layout_width="wrap_content" | |
50 | + android:layout_height="wrap_content" | |
51 | + android:layout_marginLeft="200dp" | |
52 | + android:gravity="center_vertical"> | |
53 | + | |
54 | + <ImageView | |
55 | + android:layout_width="wrap_content" | |
56 | + android:layout_height="wrap_content" | |
57 | + android:src="@mipmap/logo_info" /> | |
58 | + | |
59 | + <TextView | |
60 | + android:layout_width="wrap_content" | |
61 | + android:layout_height="wrap_content" | |
62 | + android:layout_marginLeft="50dp" | |
63 | + android:background="@null" | |
64 | + android:text="电子保卡" | |
65 | + android:textColor="@color/electronic_card" | |
66 | + android:textSize="22sp" /> | |
67 | + | |
68 | + </LinearLayout> | |
69 | + | |
70 | + <LinearLayout | |
71 | + android:layout_width="wrap_content" | |
72 | + android:layout_height="80dp" | |
73 | + android:layout_marginLeft="200dp" | |
74 | + android:gravity="center_vertical"> | |
75 | + | |
76 | + <TextView | |
77 | + android:layout_width="wrap_content" | |
78 | + android:layout_height="wrap_content" | |
79 | + android:text="客户姓名" | |
80 | + android:textColor="@color/btn_text_color" | |
81 | + android:textSize="22sp" /> | |
82 | + | |
83 | + <TextView | |
84 | + android:layout_width="wrap_content" | |
85 | + android:layout_height="wrap_content" | |
86 | + android:layout_marginLeft="60dp" | |
87 | + android:text="王小明" | |
88 | + android:textColor="@color/btn_text_color" | |
89 | + android:textSize="22sp" /> | |
90 | + | |
91 | + </LinearLayout> | |
92 | + | |
93 | + </LinearLayout> | |
94 | + | |
95 | + <LinearLayout | |
96 | + android:layout_width="match_parent" | |
97 | + android:layout_height="wrap_content" | |
98 | + android:gravity="center_vertical" | |
99 | + android:orientation="horizontal"> | |
100 | + | |
101 | + <LinearLayout | |
102 | + android:layout_width="wrap_content" | |
103 | + android:layout_height="60dp" | |
104 | + android:layout_marginLeft="200dp" | |
105 | + android:gravity="center_vertical"> | |
106 | + | |
107 | + <TextView | |
108 | + android:layout_width="wrap_content" | |
109 | + android:layout_height="wrap_content" | |
110 | + android:text="产品型号" | |
111 | + android:textColor="@color/btn_text_color" | |
112 | + android:textSize="22sp" /> | |
113 | + | |
114 | + <TextView | |
115 | + android:layout_width="wrap_content" | |
116 | + android:layout_height="wrap_content" | |
117 | + android:layout_marginLeft="50dp" | |
118 | + android:text="IPone888" | |
119 | + android:textSize="22sp" /> | |
120 | + | |
121 | + | |
122 | + </LinearLayout> | |
123 | + | |
124 | + <LinearLayout | |
125 | + android:layout_width="wrap_content" | |
126 | + android:layout_height="60dp" | |
127 | + android:layout_marginLeft="250dp" | |
128 | + android:gravity="center_vertical"> | |
129 | + | |
130 | + <TextView | |
131 | + android:layout_width="wrap_content" | |
132 | + android:layout_height="wrap_content" | |
133 | + android:text="客户地址" | |
134 | + android:textSize="22sp" /> | |
135 | + | |
136 | + <TextView | |
137 | + android:layout_width="wrap_content" | |
138 | + android:layout_height="wrap_content" | |
139 | + android:layout_marginLeft="98dp" | |
140 | + android:background="@null" | |
141 | + android:text="北京市昭阳区三里屯" | |
142 | + android:textSize="22sp" /> | |
143 | + <TextView | |
144 | + android:layout_width="wrap_content" | |
145 | + android:layout_height="wrap_content" | |
146 | + android:layout_marginLeft="18dp" | |
147 | + android:background="@drawable/corcle_blue_bg" | |
148 | + android:text="修改" | |
149 | + android:paddingLeft="5dp" | |
150 | + android:paddingRight="5dp" | |
151 | + android:textColor="@color/login_text_blue" | |
152 | + android:textSize="18sp" /> | |
153 | + | |
154 | + | |
155 | + </LinearLayout> | |
156 | + | |
157 | + </LinearLayout> | |
158 | + | |
159 | + <LinearLayout | |
160 | + android:layout_width="match_parent" | |
161 | + android:layout_height="wrap_content" | |
162 | + android:gravity="center_vertical" | |
163 | + android:orientation="horizontal"> | |
164 | + | |
165 | + <LinearLayout | |
166 | + android:layout_width="wrap_content" | |
167 | + android:layout_height="60dp" | |
168 | + android:layout_marginLeft="200dp" | |
169 | + android:gravity="center_vertical"> | |
170 | + | |
171 | + <TextView | |
172 | + android:layout_width="wrap_content" | |
173 | + android:layout_height="wrap_content" | |
174 | + android:text="MAC地址" | |
175 | + android:textSize="22sp" /> | |
176 | + | |
177 | + <TextView | |
178 | + android:layout_width="wrap_content" | |
179 | + android:layout_height="wrap_content" | |
180 | + android:layout_marginLeft="50dp" | |
181 | + android:background="@null" | |
182 | + android:text="237462873463278" | |
183 | + android:textSize="22sp" /> | |
184 | + | |
185 | + </LinearLayout> | |
186 | + | |
187 | + <LinearLayout | |
188 | + android:layout_width="wrap_content" | |
189 | + android:layout_height="60dp" | |
190 | + android:layout_marginLeft="210dp" | |
191 | + android:gravity="center_vertical"> | |
192 | + | |
193 | + <TextView | |
194 | + android:layout_width="wrap_content" | |
195 | + android:layout_height="wrap_content" | |
196 | + android:text="购买时间" | |
197 | + android:textColor="@color/btn_text_color" | |
198 | + android:textSize="22sp" /> | |
199 | + | |
200 | + <TextView | |
201 | + android:layout_width="wrap_content" | |
202 | + android:layout_height="wrap_content" | |
203 | + android:layout_marginLeft="25dp" | |
204 | + android:background="@null" | |
205 | + android:text="4433322-334--34" | |
206 | + android:textColor="@color/btn_text_color" | |
207 | + android:textSize="22sp" /> | |
208 | + </LinearLayout> | |
209 | + | |
210 | + </LinearLayout> | |
211 | + | |
212 | + <LinearLayout | |
213 | + android:layout_width="match_parent" | |
214 | + android:layout_height="wrap_content" | |
215 | + android:gravity="center_vertical" | |
216 | + android:orientation="horizontal"> | |
217 | + | |
218 | + <LinearLayout | |
219 | + android:layout_width="wrap_content" | |
220 | + android:layout_height="60dp" | |
221 | + android:layout_marginLeft="200dp" | |
222 | + android:gravity="center_vertical"> | |
223 | + | |
224 | + <TextView | |
225 | + android:layout_width="wrap_content" | |
226 | + android:layout_height="wrap_content" | |
227 | + android:text="机身编码" | |
228 | + android:textColor="@color/btn_text_color" | |
229 | + android:textSize="22sp" /> | |
230 | + | |
231 | + <TextView | |
232 | + android:layout_width="wrap_content" | |
233 | + android:layout_height="wrap_content" | |
234 | + android:layout_marginLeft="50dp" | |
235 | + android:hint="473463746343" | |
236 | + android:textSize="22sp" /> | |
237 | + | |
238 | + </LinearLayout> | |
239 | + | |
240 | + <LinearLayout | |
241 | + android:layout_width="wrap_content" | |
242 | + android:layout_height="60dp" | |
243 | + android:layout_marginLeft="210dp" | |
244 | + android:gravity="center_vertical"> | |
245 | + | |
246 | + <TextView | |
247 | + android:layout_width="wrap_content" | |
248 | + android:layout_height="wrap_content" | |
249 | + android:text="购买地址" | |
250 | + android:textColor="@color/btn_text_color" | |
251 | + android:textSize="22sp" /> | |
252 | + | |
253 | + <TextView | |
254 | + android:layout_width="wrap_content" | |
255 | + android:layout_height="wrap_content" | |
256 | + android:layout_marginLeft="25dp" | |
257 | + android:text="啥啥啥 专卖店" | |
258 | + android:textColor="@color/btn_text_color" | |
259 | + android:textSize="22sp" /> | |
260 | + </LinearLayout> | |
261 | + | |
262 | + </LinearLayout> | |
263 | + | |
264 | + <LinearLayout | |
265 | + android:layout_width="match_parent" | |
266 | + android:layout_height="wrap_content" | |
267 | + android:gravity="center_vertical" | |
268 | + android:orientation="horizontal"> | |
269 | + | |
270 | + <LinearLayout | |
271 | + android:layout_width="wrap_content" | |
272 | + android:layout_height="60dp" | |
273 | + android:layout_marginLeft="200dp" | |
274 | + android:gravity="center_vertical"> | |
275 | + | |
276 | + <TextView | |
277 | + android:layout_width="wrap_content" | |
278 | + android:layout_height="wrap_content" | |
279 | + android:text="手机号码" | |
280 | + android:textColor="@color/btn_text_color" | |
281 | + android:textSize="22sp" /> | |
282 | + | |
283 | + <TextView | |
284 | + android:layout_width="wrap_content" | |
285 | + android:layout_height="wrap_content" | |
286 | + android:layout_marginLeft="50dp" | |
287 | + android:text="IPone888" | |
288 | + android:textSize="22sp" /> | |
289 | + <TextView | |
290 | + android:layout_width="wrap_content" | |
291 | + android:layout_height="wrap_content" | |
292 | + android:layout_marginLeft="18dp" | |
293 | + android:background="@drawable/corcle_blue_bg" | |
294 | + android:text="修改" | |
295 | + android:paddingLeft="5dp" | |
296 | + android:paddingRight="5dp" | |
297 | + android:textColor="@color/login_text_blue" | |
298 | + android:textSize="18sp" /> | |
299 | + | |
300 | + | |
301 | + </LinearLayout> | |
302 | + | |
303 | + <LinearLayout | |
304 | + android:layout_width="wrap_content" | |
305 | + android:layout_height="60dp" | |
306 | + android:layout_marginLeft="250dp" | |
307 | + android:gravity="center_vertical"> | |
308 | + | |
309 | + <TextView | |
310 | + android:layout_width="wrap_content" | |
311 | + android:layout_height="wrap_content" | |
312 | + android:text="本地售后电话" | |
313 | + android:textSize="22sp" /> | |
314 | + | |
315 | + <TextView | |
316 | + android:layout_width="wrap_content" | |
317 | + android:layout_height="wrap_content" | |
318 | + android:layout_marginLeft="98dp" | |
319 | + android:background="@null" | |
320 | + android:text="1111111" | |
321 | + android:textSize="22sp" /> | |
322 | + | |
323 | + </LinearLayout> | |
324 | + | |
325 | + </LinearLayout> | |
326 | + </LinearLayout> | |
327 | + | |
328 | + <LinearLayout | |
329 | + android:layout_width="match_parent" | |
330 | + android:layout_height="wrap_content" | |
331 | + android:layout_marginTop="5dp" | |
332 | + android:gravity="center" | |
333 | + android:orientation="vertical"> | |
334 | + | |
335 | + <TextView | |
336 | + android:layout_width="wrap_content" | |
337 | + android:layout_height="wrap_content" | |
338 | + android:layout_marginTop="5dp" | |
339 | + android:text="@string/electronic_card" | |
340 | + android:textColor="@color/electronic_text" | |
341 | + android:textSize="18sp" /> | |
342 | + | |
343 | + | |
344 | + | |
345 | + </LinearLayout> | |
346 | + <LinearLayout | |
347 | + android:layout_width="match_parent" | |
348 | + android:layout_height="wrap_content" | |
349 | + android:layout_marginTop="30dp" | |
350 | + android:gravity="center" | |
351 | + android:orientation="horizontal"> | |
352 | + | |
353 | + <ImageView | |
354 | + android:layout_width="wrap_content" | |
355 | + android:layout_height="wrap_content" | |
356 | + android:src="@mipmap/phone"/> | |
357 | + <TextView | |
358 | + android:layout_width="wrap_content" | |
359 | + android:layout_height="wrap_content" | |
360 | + android:textSize="30sp" | |
361 | + android:layout_marginLeft="5dp" | |
362 | + android:textColor="@color/login_text_blue" | |
363 | + android:text="400-400-000"/> | |
364 | + | |
365 | + | |
366 | + </LinearLayout> | |
367 | + | |
368 | + | |
369 | + | |
370 | +</LinearLayout> | |
0 | 371 | \ No newline at end of file | ... | ... |
PersonalCenter/app/src/main/res/layout/activity_electroniccard_info.xml
... | ... | @@ -0,0 +1,364 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:layout_width="match_parent" | |
4 | + android:layout_height="match_parent" | |
5 | + android:orientation="vertical"> | |
6 | + | |
7 | + <RelativeLayout | |
8 | + android:id="@+id/title" | |
9 | + android:layout_width="match_parent" | |
10 | + android:layout_height="wrap_content" | |
11 | + android:background="@color/login_text_blue" | |
12 | + android:minHeight="50dp"> | |
13 | + | |
14 | + <ImageView | |
15 | + android:id="@+id/cancel" | |
16 | + android:layout_width="wrap_content" | |
17 | + android:layout_height="wrap_content" | |
18 | + android:layout_centerVertical="true" | |
19 | + android:paddingLeft="20dp" | |
20 | + android:paddingRight="20dp" | |
21 | + android:src="@mipmap/title_back" /> | |
22 | + | |
23 | + <TextView | |
24 | + android:id="@+id/menu_title" | |
25 | + android:layout_width="wrap_content" | |
26 | + android:layout_height="wrap_content" | |
27 | + android:layout_centerInParent="true" | |
28 | + android:text="@string/change_electroniccard_info_fill" | |
29 | + android:textColor="@android:color/white" | |
30 | + android:textSize="22sp" /> | |
31 | + </RelativeLayout> | |
32 | + | |
33 | + <ImageView | |
34 | + android:layout_width="wrap_content" | |
35 | + android:layout_height="wrap_content" | |
36 | + android:layout_gravity="center" | |
37 | + android:layout_marginTop="20dp" | |
38 | + android:src="@mipmap/change_info_icon" /> | |
39 | + <LinearLayout | |
40 | + android:layout_width="wrap_content" | |
41 | + android:layout_height="wrap_content" | |
42 | + android:layout_marginTop="20dp" | |
43 | + android:orientation="horizontal"> | |
44 | + <View | |
45 | + android:layout_width="450dp" | |
46 | + android:layout_height="0.7dp" | |
47 | + android:layout_marginLeft="150dp" | |
48 | + android:background="@color/electronic_text"> | |
49 | + | |
50 | + </View> | |
51 | + <View | |
52 | + android:layout_width="400dp" | |
53 | + android:layout_height="0.7dp" | |
54 | + android:layout_marginLeft="80dp" | |
55 | + android:background="@color/electronic_text"> | |
56 | + | |
57 | + </View> | |
58 | + | |
59 | + | |
60 | + </LinearLayout> | |
61 | + | |
62 | + <LinearLayout | |
63 | + android:layout_width="match_parent" | |
64 | + android:layout_height="wrap_content" | |
65 | + android:gravity="center_vertical" | |
66 | + android:orientation="horizontal"> | |
67 | + | |
68 | + <LinearLayout | |
69 | + android:layout_width="wrap_content" | |
70 | + android:layout_height="80dp" | |
71 | + android:layout_marginLeft="200dp" | |
72 | + android:gravity="center_vertical"> | |
73 | + | |
74 | + <TextView | |
75 | + android:layout_width="wrap_content" | |
76 | + android:layout_height="wrap_content" | |
77 | + android:text="客户姓名" | |
78 | + android:textColor="@color/btn_text_color" | |
79 | + android:textSize="22sp" /> | |
80 | + | |
81 | + <EditText | |
82 | + android:layout_width="wrap_content" | |
83 | + android:layout_height="wrap_content" | |
84 | + android:background="@null" | |
85 | + android:layout_marginLeft="50dp" | |
86 | + android:textColor="@color/electronic_text" | |
87 | + android:hint="请输入" | |
88 | + android:textSize="22sp" /> | |
89 | + | |
90 | + </LinearLayout> | |
91 | + | |
92 | + <LinearLayout | |
93 | + android:layout_width="wrap_content" | |
94 | + android:layout_height="80dp" | |
95 | + android:layout_marginLeft="300dp" | |
96 | + android:gravity="center_vertical"> | |
97 | + | |
98 | + <TextView | |
99 | + android:layout_width="wrap_content" | |
100 | + android:layout_height="wrap_content" | |
101 | + android:text="购买地址" | |
102 | + android:textColor="@color/btn_text_color" | |
103 | + android:textSize="22sp" /> | |
104 | + | |
105 | + <TextView | |
106 | + android:layout_width="wrap_content" | |
107 | + android:layout_height="wrap_content" | |
108 | + android:text="请选择地区" | |
109 | + android:layout_marginLeft="60dp" | |
110 | + android:textColor="@color/btn_text_color" | |
111 | + android:textSize="22sp" /> | |
112 | + | |
113 | + <ImageView | |
114 | + android:layout_width="wrap_content" | |
115 | + android:layout_height="wrap_content" | |
116 | + android:layout_marginLeft="50dp" | |
117 | + android:src="@mipmap/xiajiantou"> | |
118 | + | |
119 | + </ImageView> | |
120 | + </LinearLayout> | |
121 | + | |
122 | + </LinearLayout> | |
123 | + <LinearLayout | |
124 | + android:layout_width="wrap_content" | |
125 | + android:layout_height="wrap_content" | |
126 | + android:orientation="horizontal"> | |
127 | + <View | |
128 | + android:layout_width="450dp" | |
129 | + android:layout_height="0.7dp" | |
130 | + android:layout_marginLeft="150dp" | |
131 | + android:background="@color/electronic_text"> | |
132 | + | |
133 | + </View> | |
134 | + <View | |
135 | + android:layout_width="400dp" | |
136 | + android:layout_height="0.7dp" | |
137 | + android:layout_marginLeft="80dp" | |
138 | + android:background="@color/electronic_text"> | |
139 | + | |
140 | + </View> | |
141 | + | |
142 | + | |
143 | + </LinearLayout> | |
144 | + | |
145 | + <LinearLayout | |
146 | + android:layout_width="match_parent" | |
147 | + android:layout_height="wrap_content" | |
148 | + android:gravity="center_vertical" | |
149 | + android:orientation="horizontal"> | |
150 | + | |
151 | + <LinearLayout | |
152 | + android:layout_width="wrap_content" | |
153 | + android:layout_height="80dp" | |
154 | + android:layout_marginLeft="200dp" | |
155 | + android:gravity="center_vertical"> | |
156 | + | |
157 | + <TextView | |
158 | + android:layout_width="wrap_content" | |
159 | + android:layout_height="wrap_content" | |
160 | + android:text="客户地址" | |
161 | + android:textColor="@color/btn_text_color" | |
162 | + android:textSize="22sp" /> | |
163 | + | |
164 | + <TextView | |
165 | + android:layout_width="wrap_content" | |
166 | + android:layout_height="wrap_content" | |
167 | + android:text="请选择地区" | |
168 | + android:layout_marginLeft="50dp" | |
169 | + android:textSize="22sp" /> | |
170 | + | |
171 | + <ImageView | |
172 | + android:layout_width="wrap_content" | |
173 | + android:layout_height="wrap_content" | |
174 | + android:layout_marginLeft="50dp" | |
175 | + android:src="@mipmap/xiajiantou"> | |
176 | + | |
177 | + </ImageView> | |
178 | + | |
179 | + | |
180 | + </LinearLayout> | |
181 | + | |
182 | + <LinearLayout | |
183 | + android:layout_width="wrap_content" | |
184 | + android:layout_height="80dp" | |
185 | + android:layout_marginLeft="200dp" | |
186 | + android:gravity="center_vertical"> | |
187 | + <TextView | |
188 | + android:layout_width="wrap_content" | |
189 | + android:layout_height="wrap_content" | |
190 | + android:text=" " | |
191 | + android:textColor="@color/white" | |
192 | + android:textSize="22sp" /> | |
193 | + <EditText | |
194 | + android:layout_width="wrap_content" | |
195 | + android:layout_height="wrap_content" | |
196 | + android:layout_marginLeft="98dp" | |
197 | + android:background="@null" | |
198 | + android:hint="请输入商店名称" | |
199 | + android:textSize="22sp" /> | |
200 | + | |
201 | + </LinearLayout> | |
202 | + | |
203 | + </LinearLayout> | |
204 | + <LinearLayout | |
205 | + android:layout_width="wrap_content" | |
206 | + android:layout_height="wrap_content" | |
207 | + | |
208 | + android:orientation="horizontal"> | |
209 | + <View | |
210 | + android:layout_width="450dp" | |
211 | + android:layout_height="0.7dp" | |
212 | + android:layout_marginLeft="150dp" | |
213 | + android:background="@color/electronic_text"> | |
214 | + | |
215 | + </View> | |
216 | + <View | |
217 | + android:layout_width="400dp" | |
218 | + android:layout_height="0.7dp" | |
219 | + android:layout_marginLeft="80dp" | |
220 | + android:background="@color/electronic_text"> | |
221 | + | |
222 | + </View> | |
223 | + | |
224 | + | |
225 | + </LinearLayout> | |
226 | + | |
227 | + <LinearLayout | |
228 | + android:layout_width="match_parent" | |
229 | + android:layout_height="wrap_content" | |
230 | + android:gravity="center_vertical" | |
231 | + android:orientation="horizontal"> | |
232 | + | |
233 | + <LinearLayout | |
234 | + android:layout_width="wrap_content" | |
235 | + android:layout_height="80dp" | |
236 | + android:gravity="center_vertical" | |
237 | + android:layout_marginLeft="200dp"> | |
238 | + <TextView | |
239 | + android:layout_width="wrap_content" | |
240 | + android:layout_height="wrap_content" | |
241 | + android:text=" " | |
242 | + android:textColor="@color/white" | |
243 | + android:textSize="22sp" /> | |
244 | + | |
245 | + <EditText | |
246 | + android:layout_width="wrap_content" | |
247 | + android:layout_height="wrap_content" | |
248 | + android:layout_marginLeft="100dp" | |
249 | + android:background="@null" | |
250 | + android:hint="请输入详细地址" | |
251 | + android:textSize="22sp" /> | |
252 | + | |
253 | + </LinearLayout> | |
254 | + | |
255 | + <LinearLayout | |
256 | + android:layout_width="wrap_content" | |
257 | + android:layout_height="80dp" | |
258 | + android:layout_marginLeft="210dp" | |
259 | + android:gravity="center_vertical"> | |
260 | + | |
261 | + <TextView | |
262 | + android:layout_width="wrap_content" | |
263 | + android:layout_height="wrap_content" | |
264 | + android:text="本地售后电话" | |
265 | + android:textColor="@color/btn_text_color" | |
266 | + android:textSize="22sp" /> | |
267 | + | |
268 | + <EditText | |
269 | + android:layout_width="wrap_content" | |
270 | + android:layout_height="wrap_content" | |
271 | + android:hint="请输入" | |
272 | + android:background="@null" | |
273 | + android:layout_marginLeft="25dp" | |
274 | + android:textColor="@color/btn_text_color" | |
275 | + android:textSize="22sp" /> | |
276 | + </LinearLayout> | |
277 | + | |
278 | + </LinearLayout> | |
279 | + <LinearLayout | |
280 | + android:layout_width="wrap_content" | |
281 | + android:layout_height="wrap_content" | |
282 | + | |
283 | + android:orientation="horizontal"> | |
284 | + <View | |
285 | + android:layout_width="450dp" | |
286 | + android:layout_height="0.7dp" | |
287 | + android:layout_marginLeft="150dp" | |
288 | + android:background="@color/electronic_text"> | |
289 | + | |
290 | + </View> | |
291 | + <View | |
292 | + android:layout_width="400dp" | |
293 | + android:layout_height="0.7dp" | |
294 | + android:layout_marginLeft="80dp" | |
295 | + android:background="@color/electronic_text"> | |
296 | + | |
297 | + </View> | |
298 | + | |
299 | + | |
300 | + </LinearLayout> | |
301 | + | |
302 | + <LinearLayout | |
303 | + android:layout_width="match_parent" | |
304 | + android:layout_height="wrap_content" | |
305 | + android:gravity="center_vertical" | |
306 | + android:orientation="horizontal"> | |
307 | + | |
308 | + <LinearLayout | |
309 | + android:id="@+id/lineL_buy_time" | |
310 | + android:layout_width="wrap_content" | |
311 | + android:layout_height="80dp" | |
312 | + android:layout_marginLeft="200dp" | |
313 | + android:gravity="center_vertical"> | |
314 | + | |
315 | + <TextView | |
316 | + android:layout_width="wrap_content" | |
317 | + android:layout_height="wrap_content" | |
318 | + android:text="购买时间" | |
319 | + android:textColor="@color/btn_text_color" | |
320 | + android:textSize="22sp" /> | |
321 | + | |
322 | + <TextView | |
323 | + android:id="@+id/tv_buy_time" | |
324 | + android:layout_width="wrap_content" | |
325 | + android:layout_height="wrap_content" | |
326 | + android:hint="请选择时间" | |
327 | + android:layout_marginLeft="50dp" | |
328 | + android:textSize="22sp" /> | |
329 | + <ImageView | |
330 | + android:layout_width="wrap_content" | |
331 | + android:layout_height="wrap_content" | |
332 | + android:layout_marginLeft="50dp" | |
333 | + android:src="@mipmap/xiajiantou"> | |
334 | + | |
335 | + </ImageView> | |
336 | + | |
337 | + </LinearLayout> | |
338 | + | |
339 | + </LinearLayout> | |
340 | + <LinearLayout | |
341 | + android:layout_width="wrap_content" | |
342 | + android:layout_height="wrap_content" | |
343 | + | |
344 | + android:orientation="horizontal"> | |
345 | + <View | |
346 | + android:layout_width="450dp" | |
347 | + android:layout_height="0.7dp" | |
348 | + android:layout_marginLeft="150dp" | |
349 | + android:background="@color/electronic_text"> | |
350 | + | |
351 | + </View> | |
352 | + | |
353 | + | |
354 | + </LinearLayout> | |
355 | + <Button | |
356 | + android:layout_marginLeft="200dp" | |
357 | + android:layout_marginRight="200dp" | |
358 | + android:layout_marginTop="80dp" | |
359 | + android:id="@+id/btn_ok" | |
360 | + style="@style/button_login_register_style" | |
361 | + android:text="@string/string_regist_next" /> | |
362 | + | |
363 | + | |
364 | +</LinearLayout> | |
0 | 365 | \ No newline at end of file | ... | ... |
PersonalCenter/app/src/main/res/layout/activity_feedback.xml
... | ... | @@ -0,0 +1,82 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:orientation="vertical" android:layout_width="match_parent" | |
4 | + android:layout_height="match_parent" | |
5 | + android:background="@color/backgerangde_laout"> | |
6 | + <RelativeLayout | |
7 | + android:id="@+id/title" | |
8 | + android:layout_width="match_parent" | |
9 | + android:layout_height="50dp" | |
10 | + android:background="@color/login_text_blue"> | |
11 | + | |
12 | + <ImageView | |
13 | + android:id="@+id/cancel" | |
14 | + android:layout_width="wrap_content" | |
15 | + android:layout_height="match_parent" | |
16 | + android:paddingLeft="20dp" | |
17 | + android:paddingRight="20dp" | |
18 | + android:src="@mipmap/title_back" /> | |
19 | + | |
20 | + <TextView | |
21 | + android:id="@+id/menu_title" | |
22 | + android:layout_width="wrap_content" | |
23 | + android:layout_height="match_parent" | |
24 | + android:layout_centerInParent="true" | |
25 | + android:gravity="center_vertical" | |
26 | + android:text="意见反馈" | |
27 | + android:textColor="@android:color/white" | |
28 | + android:textSize="22sp" /> | |
29 | + <TextView | |
30 | + android:id="@+id/feedback_sub" | |
31 | + android:layout_width="wrap_content" | |
32 | + android:layout_height="match_parent" | |
33 | + android:paddingLeft="20dp" | |
34 | + android:paddingRight="20dp" | |
35 | + android:gravity="center_vertical" | |
36 | + android:layout_alignParentRight="true" | |
37 | + android:text="提交" | |
38 | + android:textColor="@android:color/white" | |
39 | + android:textSize="22sp" /> | |
40 | + | |
41 | + | |
42 | + </RelativeLayout> | |
43 | + <EditText | |
44 | + android:id="@+id/feedback_content" | |
45 | + android:layout_width="match_parent" | |
46 | + android:layout_height="250dp" | |
47 | + android:hint="@string/feedback" | |
48 | + android:textColor="@color/electronic_text" | |
49 | + android:textSize="18sp" | |
50 | + android:textScaleX="1" | |
51 | + android:padding="20dp" | |
52 | + android:gravity="top" | |
53 | + android:background="@color/white"/> | |
54 | + <LinearLayout | |
55 | + android:id="@+id/take_phone" | |
56 | + android:layout_width="match_parent" | |
57 | + android:layout_height="wrap_content" | |
58 | + android:background="@color/white"> | |
59 | + <ImageView | |
60 | + android:layout_margin="20dp" | |
61 | + android:layout_width="wrap_content" | |
62 | + android:layout_height="wrap_content" | |
63 | + android:src="@mipmap/feedback_take_phone"/> | |
64 | + | |
65 | + </LinearLayout> | |
66 | + <EditText | |
67 | + android:layout_width="match_parent" | |
68 | + android:layout_marginTop="20dp" | |
69 | + android:background="@color/white" | |
70 | + android:hint="@string/qq" | |
71 | + android:padding="20dp" | |
72 | + android:layout_height="60dp" /> | |
73 | + <TextView | |
74 | + android:layout_width="match_parent" | |
75 | + android:text="@string/hint" | |
76 | + android:padding="20dp" | |
77 | + android:textSize="18sp" | |
78 | + android:layout_height="60dp" /> | |
79 | + | |
80 | + | |
81 | + | |
82 | +</LinearLayout> | |
0 | 83 | \ No newline at end of file | ... | ... |
PersonalCenter/app/src/main/res/layout/activity_ok_cardinfo.xml
... | ... | @@ -0,0 +1,363 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:layout_width="match_parent" | |
4 | + android:layout_height="match_parent" | |
5 | + android:orientation="vertical"> | |
6 | + | |
7 | + <RelativeLayout | |
8 | + android:id="@+id/title" | |
9 | + android:layout_width="match_parent" | |
10 | + android:layout_height="wrap_content" | |
11 | + android:background="@color/login_text_blue" | |
12 | + android:minHeight="50dp"> | |
13 | + | |
14 | + <ImageView | |
15 | + android:id="@+id/cancel" | |
16 | + android:layout_width="wrap_content" | |
17 | + android:layout_height="wrap_content" | |
18 | + android:layout_centerVertical="true" | |
19 | + android:paddingLeft="20dp" | |
20 | + android:paddingRight="20dp" | |
21 | + android:src="@mipmap/title_back" /> | |
22 | + | |
23 | + <TextView | |
24 | + android:id="@+id/menu_title" | |
25 | + android:layout_width="wrap_content" | |
26 | + android:layout_height="wrap_content" | |
27 | + android:layout_centerInParent="true" | |
28 | + android:text="@string/string_electroniccard_info_ok" | |
29 | + android:textColor="@android:color/white" | |
30 | + android:textSize="22sp" /> | |
31 | + </RelativeLayout> | |
32 | + | |
33 | + <LinearLayout | |
34 | + android:layout_width="match_parent" | |
35 | + android:layout_height="wrap_content" | |
36 | + android:layout_margin="20dp" | |
37 | + android:background="@mipmap/cardbackgrangd" | |
38 | + android:gravity="center" | |
39 | + android:orientation="vertical"> | |
40 | + | |
41 | + <LinearLayout | |
42 | + android:layout_width="match_parent" | |
43 | + android:layout_height="wrap_content" | |
44 | + android:layout_marginTop="70dp" | |
45 | + android:gravity="center_vertical" | |
46 | + android:orientation="horizontal"> | |
47 | + | |
48 | + <LinearLayout | |
49 | + android:layout_width="wrap_content" | |
50 | + android:layout_height="wrap_content" | |
51 | + android:layout_marginLeft="200dp" | |
52 | + android:gravity="center_vertical"> | |
53 | + | |
54 | + <ImageView | |
55 | + android:layout_width="wrap_content" | |
56 | + android:layout_height="wrap_content" | |
57 | + android:src="@mipmap/logo_info" /> | |
58 | + | |
59 | + <TextView | |
60 | + android:layout_width="wrap_content" | |
61 | + android:layout_height="wrap_content" | |
62 | + android:layout_marginLeft="50dp" | |
63 | + android:background="@null" | |
64 | + android:text="电子保卡" | |
65 | + android:textColor="@color/login_text_blue" | |
66 | + android:textSize="22sp" /> | |
67 | + | |
68 | + </LinearLayout> | |
69 | + | |
70 | + <LinearLayout | |
71 | + android:layout_width="wrap_content" | |
72 | + android:layout_height="80dp" | |
73 | + android:layout_marginLeft="200dp" | |
74 | + android:gravity="center_vertical"> | |
75 | + | |
76 | + <TextView | |
77 | + android:layout_width="wrap_content" | |
78 | + android:layout_height="wrap_content" | |
79 | + android:text="客户姓名" | |
80 | + android:textColor="@color/btn_text_color" | |
81 | + android:textSize="22sp" /> | |
82 | + | |
83 | + <TextView | |
84 | + android:layout_width="wrap_content" | |
85 | + android:layout_height="wrap_content" | |
86 | + android:layout_marginLeft="60dp" | |
87 | + android:text="王小明" | |
88 | + android:textColor="@color/btn_text_color" | |
89 | + android:textSize="22sp" /> | |
90 | + | |
91 | + </LinearLayout> | |
92 | + | |
93 | + </LinearLayout> | |
94 | + | |
95 | + <LinearLayout | |
96 | + android:layout_width="match_parent" | |
97 | + android:layout_height="wrap_content" | |
98 | + android:gravity="center_vertical" | |
99 | + android:orientation="horizontal"> | |
100 | + | |
101 | + <LinearLayout | |
102 | + android:layout_width="wrap_content" | |
103 | + android:layout_height="60dp" | |
104 | + android:layout_marginLeft="200dp" | |
105 | + android:gravity="center_vertical"> | |
106 | + | |
107 | + <TextView | |
108 | + android:layout_width="wrap_content" | |
109 | + android:layout_height="wrap_content" | |
110 | + android:text="产品型号" | |
111 | + android:textColor="@color/btn_text_color" | |
112 | + android:textSize="22sp" /> | |
113 | + | |
114 | + <TextView | |
115 | + android:layout_width="wrap_content" | |
116 | + android:layout_height="wrap_content" | |
117 | + android:layout_marginLeft="50dp" | |
118 | + android:text="IPone888" | |
119 | + android:textSize="22sp" /> | |
120 | + | |
121 | + | |
122 | + </LinearLayout> | |
123 | + | |
124 | + <LinearLayout | |
125 | + android:layout_width="wrap_content" | |
126 | + android:layout_height="60dp" | |
127 | + android:layout_marginLeft="250dp" | |
128 | + android:gravity="center_vertical"> | |
129 | + | |
130 | + <TextView | |
131 | + android:layout_width="wrap_content" | |
132 | + android:layout_height="wrap_content" | |
133 | + android:text="客户地址" | |
134 | + android:textSize="22sp" /> | |
135 | + | |
136 | + <TextView | |
137 | + android:layout_width="wrap_content" | |
138 | + android:layout_height="wrap_content" | |
139 | + android:layout_marginLeft="98dp" | |
140 | + android:background="@null" | |
141 | + android:text="北京市昭阳区三里屯" | |
142 | + android:textSize="22sp" /> | |
143 | + | |
144 | + </LinearLayout> | |
145 | + | |
146 | + </LinearLayout> | |
147 | + | |
148 | + <LinearLayout | |
149 | + android:layout_width="match_parent" | |
150 | + android:layout_height="wrap_content" | |
151 | + android:gravity="center_vertical" | |
152 | + android:orientation="horizontal"> | |
153 | + | |
154 | + <LinearLayout | |
155 | + android:layout_width="wrap_content" | |
156 | + android:layout_height="60dp" | |
157 | + android:layout_marginLeft="200dp" | |
158 | + android:gravity="center_vertical"> | |
159 | + | |
160 | + <TextView | |
161 | + android:layout_width="wrap_content" | |
162 | + android:layout_height="wrap_content" | |
163 | + android:text="MAC地址" | |
164 | + android:textSize="22sp" /> | |
165 | + | |
166 | + <TextView | |
167 | + android:layout_width="wrap_content" | |
168 | + android:layout_height="wrap_content" | |
169 | + android:layout_marginLeft="50dp" | |
170 | + android:background="@null" | |
171 | + android:text="237462873463278" | |
172 | + android:textSize="22sp" /> | |
173 | + | |
174 | + </LinearLayout> | |
175 | + | |
176 | + <LinearLayout | |
177 | + android:layout_width="wrap_content" | |
178 | + android:layout_height="60dp" | |
179 | + android:layout_marginLeft="210dp" | |
180 | + android:gravity="center_vertical"> | |
181 | + | |
182 | + <TextView | |
183 | + android:layout_width="wrap_content" | |
184 | + android:layout_height="wrap_content" | |
185 | + android:text="购买时间" | |
186 | + android:textColor="@color/btn_text_color" | |
187 | + android:textSize="22sp" /> | |
188 | + | |
189 | + <TextView | |
190 | + android:layout_width="wrap_content" | |
191 | + android:layout_height="wrap_content" | |
192 | + android:layout_marginLeft="25dp" | |
193 | + android:background="@null" | |
194 | + android:text="4433322-334--34" | |
195 | + android:textColor="@color/btn_text_color" | |
196 | + android:textSize="22sp" /> | |
197 | + </LinearLayout> | |
198 | + | |
199 | + </LinearLayout> | |
200 | + | |
201 | + <LinearLayout | |
202 | + android:layout_width="match_parent" | |
203 | + android:layout_height="wrap_content" | |
204 | + android:gravity="center_vertical" | |
205 | + android:orientation="horizontal"> | |
206 | + | |
207 | + <LinearLayout | |
208 | + android:layout_width="wrap_content" | |
209 | + android:layout_height="60dp" | |
210 | + android:layout_marginLeft="200dp" | |
211 | + android:gravity="center_vertical"> | |
212 | + | |
213 | + <TextView | |
214 | + android:layout_width="wrap_content" | |
215 | + android:layout_height="wrap_content" | |
216 | + android:text="机身编码" | |
217 | + android:textColor="@color/btn_text_color" | |
218 | + android:textSize="22sp" /> | |
219 | + | |
220 | + <TextView | |
221 | + android:layout_width="wrap_content" | |
222 | + android:layout_height="wrap_content" | |
223 | + android:layout_marginLeft="50dp" | |
224 | + android:hint="473463746343" | |
225 | + android:textSize="22sp" /> | |
226 | + | |
227 | + </LinearLayout> | |
228 | + | |
229 | + <LinearLayout | |
230 | + android:layout_width="wrap_content" | |
231 | + android:layout_height="60dp" | |
232 | + android:layout_marginLeft="210dp" | |
233 | + android:gravity="center_vertical"> | |
234 | + | |
235 | + <TextView | |
236 | + android:layout_width="wrap_content" | |
237 | + android:layout_height="wrap_content" | |
238 | + android:text="购买地址" | |
239 | + android:textColor="@color/btn_text_color" | |
240 | + android:textSize="22sp" /> | |
241 | + | |
242 | + <TextView | |
243 | + android:layout_width="wrap_content" | |
244 | + android:layout_height="wrap_content" | |
245 | + android:layout_marginLeft="25dp" | |
246 | + android:text="啥啥啥 专卖店" | |
247 | + android:textColor="@color/btn_text_color" | |
248 | + android:textSize="22sp" /> | |
249 | + </LinearLayout> | |
250 | + | |
251 | + </LinearLayout> | |
252 | + | |
253 | + <LinearLayout | |
254 | + android:layout_width="match_parent" | |
255 | + android:layout_height="wrap_content" | |
256 | + android:gravity="center_vertical" | |
257 | + android:orientation="horizontal"> | |
258 | + | |
259 | + <LinearLayout | |
260 | + android:layout_width="wrap_content" | |
261 | + android:layout_height="60dp" | |
262 | + android:layout_marginLeft="200dp" | |
263 | + android:gravity="center_vertical"> | |
264 | + | |
265 | + <TextView | |
266 | + android:layout_width="wrap_content" | |
267 | + android:layout_height="wrap_content" | |
268 | + android:text="手机号码" | |
269 | + android:textColor="@color/btn_text_color" | |
270 | + android:textSize="22sp" /> | |
271 | + | |
272 | + <TextView | |
273 | + android:layout_width="wrap_content" | |
274 | + android:layout_height="wrap_content" | |
275 | + android:layout_marginLeft="50dp" | |
276 | + android:text="IPone888" | |
277 | + android:textSize="22sp" /> | |
278 | + | |
279 | + | |
280 | + </LinearLayout> | |
281 | + | |
282 | + <LinearLayout | |
283 | + android:layout_width="wrap_content" | |
284 | + android:layout_height="60dp" | |
285 | + android:layout_marginLeft="250dp" | |
286 | + android:gravity="center_vertical"> | |
287 | + | |
288 | + <TextView | |
289 | + android:layout_width="wrap_content" | |
290 | + android:layout_height="wrap_content" | |
291 | + android:text="本地售后电话" | |
292 | + android:textSize="22sp" /> | |
293 | + | |
294 | + <TextView | |
295 | + android:layout_width="wrap_content" | |
296 | + android:layout_height="wrap_content" | |
297 | + android:layout_marginLeft="98dp" | |
298 | + android:background="@null" | |
299 | + android:text="1111111" | |
300 | + android:textSize="22sp" /> | |
301 | + | |
302 | + </LinearLayout> | |
303 | + | |
304 | + </LinearLayout> | |
305 | + </LinearLayout> | |
306 | + | |
307 | + <LinearLayout | |
308 | + android:layout_width="match_parent" | |
309 | + android:layout_height="wrap_content" | |
310 | + android:layout_marginTop="5dp" | |
311 | + android:gravity="center" | |
312 | + android:orientation="vertical"> | |
313 | + | |
314 | + <TextView | |
315 | + android:layout_width="wrap_content" | |
316 | + android:layout_height="wrap_content" | |
317 | + android:layout_marginTop="5dp" | |
318 | + android:text="@string/electronic_card3" | |
319 | + android:textColor="@color/electronic_text" | |
320 | + android:textSize="18sp" /> | |
321 | + | |
322 | + <TextView | |
323 | + android:layout_width="wrap_content" | |
324 | + android:layout_height="wrap_content" | |
325 | + android:layout_marginTop="5dp" | |
326 | + android:text="@string/electronic_card4" | |
327 | + android:textColor="@color/electronic_text" | |
328 | + android:textSize="18sp" /> | |
329 | + | |
330 | + | |
331 | + </LinearLayout> | |
332 | + | |
333 | + <LinearLayout | |
334 | + android:layout_width="match_parent" | |
335 | + android:layout_height="wrap_content" | |
336 | + android:layout_marginTop="30dp" | |
337 | + android:gravity="center" | |
338 | + android:orientation="horizontal"> | |
339 | + | |
340 | + <Button | |
341 | + android:id="@+id/btn_bangding" | |
342 | + android:layout_width="300dp" | |
343 | + android:layout_height="wrap_content" | |
344 | + android:background="@drawable/selector_blue_btn_bg" | |
345 | + android:text="@string/bangding" | |
346 | + android:textColor="@color/white" | |
347 | + android:textSize="23sp" /> | |
348 | + | |
349 | + <Button | |
350 | + android:id="@+id/btn_ok" | |
351 | + android:layout_width="300dp" | |
352 | + android:layout_height="wrap_content" | |
353 | + android:layout_marginLeft="50dp" | |
354 | + android:background="@drawable/selector_blue_btn_bg" | |
355 | + android:text="@string/finish" | |
356 | + android:textColor="@color/white" | |
357 | + android:textSize="23sp" /> | |
358 | + | |
359 | + | |
360 | + </LinearLayout> | |
361 | + | |
362 | + | |
363 | +</LinearLayout> | |
0 | 364 | \ No newline at end of file | ... | ... |
PersonalCenter/app/src/main/res/mipmap-xhdpi/cardbackgrangd.png
8.88 KB
PersonalCenter/app/src/main/res/mipmap-xhdpi/change_info_icon.png
5.91 KB
PersonalCenter/app/src/main/res/mipmap-xhdpi/feedback_take_phone.png
2.85 KB
PersonalCenter/app/src/main/res/mipmap-xhdpi/logo_info.png
5.04 KB
PersonalCenter/app/src/main/res/mipmap-xhdpi/phone.png
772 Bytes
PersonalCenter/app/src/main/res/mipmap-xhdpi/pic_phone.png
1.66 KB
PersonalCenter/app/src/main/res/mipmap-xhdpi/xiajiantou.png
429 Bytes
PersonalCenter/app/src/main/res/values/colors.xml
... | ... | @@ -12,5 +12,7 @@ |
12 | 12 | <color name="login_edittext_pressed">#1cb8ff</color> |
13 | 13 | <color name="cutoff_line">#CCCCCC</color> |
14 | 14 | <color name="electronic_card">#ff480f</color> |
15 | + <color name="electronic_text">#afafaf</color> | |
16 | + <color name="backgerangde_laout">#eeeeee</color> | |
15 | 17 | |
16 | 18 | </resources> | ... | ... |
PersonalCenter/app/src/main/res/values/strings.xml
... | ... | @@ -16,14 +16,28 @@ |
16 | 16 | <string name="string_regist_school">学校</string> |
17 | 17 | <string name="string_regist_next">下一步</string> |
18 | 18 | <string name="string_start_page">开始学习体验</string> |
19 | + <string name="bangding">绑定家长控制</string> | |
20 | + <string name="finish">完成</string> | |
19 | 21 | |
20 | 22 | //电子保卡 |
21 | 23 | <string name="string_electroniccard_info_title">填写保卡信息</string> |
22 | 24 | <string name="string_electroniccard_info_fill">填写电子保卡</string> |
25 | + <string name="change_electroniccard_info_fill">修改保卡信息</string> | |
23 | 26 | <string name="string_electroniccard_info_change">修改保卡信息</string> |
27 | + <string name="string_electroniccard_info_ok">确认保卡信息</string> | |
28 | + <string name="string_electroniccard_info_look">好记星-电子报卡</string> | |
24 | 29 | <string name="string_electroniccard_change_bangding">更换绑定</string> |
30 | + <string name="electronic_card">温馨提示:若您想修改的相关信息请拨打客服电话</string> | |
25 | 31 | <string name="electronic_card1">请先填写《好记星-电子保卡》信息</string> |
26 | 32 | <string name="electronic_card2">该信息是本产品的三包证明,为维护您的合法权益,请认真填写</string> |
33 | + <string name="electronic_card3">您已填写完《好记星-电子保卡》信息</string> | |
34 | + <string name="electronic_card4">您也可以设置家长管理,用手机及时了解和管理孩子的学习情况</string> | |
35 | + | |
36 | + //意见反馈 | |
37 | + <string name="feedback">写下您对我们产品的意见吧,我们将努力完善,最多输入500字。</string> | |
38 | + <string name="qq">QQ或手机号码</string> | |
39 | + <string name="hint">留下您的联系方式,方便与您沟通。</string> | |
40 | + | |
27 | 41 | |
28 | 42 | |
29 | 43 | </resources> | ... | ... |
PersonalCenter/pickerview/.gitignore
... | ... | @@ -0,0 +1 @@ |
1 | +/build | ... | ... |
PersonalCenter/pickerview/build.gradle
... | ... | @@ -0,0 +1,49 @@ |
1 | +apply plugin: 'com.android.library' | |
2 | +apply plugin: 'maven' | |
3 | +apply plugin: 'com.novoda.bintray-release'//添加插件 | |
4 | + | |
5 | + | |
6 | + | |
7 | +android { | |
8 | + compileSdkVersion 25 | |
9 | + buildToolsVersion "25.0.2" | |
10 | + | |
11 | + defaultConfig { | |
12 | + minSdkVersion 15 | |
13 | + targetSdkVersion 25 | |
14 | + versionCode 22 | |
15 | + versionName "3.2.6" | |
16 | + } | |
17 | + buildTypes { | |
18 | + release { | |
19 | + minifyEnabled false | |
20 | + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
21 | + } | |
22 | + } | |
23 | + lintOptions { | |
24 | + abortOnError false | |
25 | + } | |
26 | +} | |
27 | + | |
28 | +allprojects { | |
29 | + tasks.withType(Javadoc) {//兼容中文字符 | |
30 | + options{ | |
31 | + encoding "UTF-8" | |
32 | + charSet 'UTF-8' | |
33 | + links "http://docs.oracle.com/javase/7/docs/api" | |
34 | + } | |
35 | + } | |
36 | +} | |
37 | +publish { | |
38 | + userOrg = 'contrarywind'//bintray.com 用户名/组织名 user/org name | |
39 | + groupId = 'com.contrarywind'//JCenter上显示的路径 path | |
40 | + artifactId = 'Android-PickerView'//项目名称 project name | |
41 | + publishVersion = '3.2.6'//版本号 version code | |
42 | + desc = 'this is a pickerview for android'//项目描述 description | |
43 | + website = 'https://github.com/Contrarywind/Android-PickerView' //项目网址链接 link | |
44 | +} | |
45 | + | |
46 | +dependencies { | |
47 | + compile fileTree(include: ['*.jar'], dir: 'libs') | |
48 | + | |
49 | +} | |
0 | 50 | \ No newline at end of file | ... | ... |
PersonalCenter/pickerview/proguard-rules.pro
... | ... | @@ -0,0 +1,17 @@ |
1 | +# Add project specific ProGuard rules here. | |
2 | +# By default, the flags in this file are appended to flags specified | |
3 | +# in /Users/Sai/Documents/software/sdk/tools/proguard/proguard-android.txt | |
4 | +# You can edit the include path and order by changing the proguardFiles | |
5 | +# directive in build.gradle. | |
6 | +# | |
7 | +# For more details, see | |
8 | +# http://developer.android.com/guide/developing/tools/proguard.html | |
9 | + | |
10 | +# Add any project specific keep options here: | |
11 | + | |
12 | +# If your project uses WebView with JS, uncomment the following | |
13 | +# and specify the fully qualified class name to the JavaScript interface | |
14 | +# class: | |
15 | +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | |
16 | +# public *; | |
17 | +#} | ... | ... |
PersonalCenter/pickerview/src/androidTest/java/com/bigkoo/pickerview/ApplicationTest.java
... | ... | @@ -0,0 +1,13 @@ |
1 | +package com.bigkoo.pickerview; | |
2 | + | |
3 | +import android.app.Application; | |
4 | +import android.test.ApplicationTestCase; | |
5 | + | |
6 | +/** | |
7 | + * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | |
8 | + */ | |
9 | +public class ApplicationTest extends ApplicationTestCase<Application> { | |
10 | + public ApplicationTest() { | |
11 | + super(Application.class); | |
12 | + } | |
13 | +} | |
0 | 14 | \ No newline at end of file | ... | ... |
PersonalCenter/pickerview/src/main/AndroidManifest.xml
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/OptionsPickerView.java
... | ... | @@ -0,0 +1,542 @@ |
1 | +package com.bigkoo.pickerview; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.graphics.Typeface; | |
5 | +import android.text.TextUtils; | |
6 | +import android.view.LayoutInflater; | |
7 | +import android.view.View; | |
8 | +import android.view.ViewGroup; | |
9 | +import android.widget.Button; | |
10 | +import android.widget.LinearLayout; | |
11 | +import android.widget.RelativeLayout; | |
12 | +import android.widget.TextView; | |
13 | + | |
14 | +import com.bigkoo.pickerview.lib.WheelView; | |
15 | +import com.bigkoo.pickerview.listener.CustomListener; | |
16 | +import com.bigkoo.pickerview.view.BasePickerView; | |
17 | +import com.bigkoo.pickerview.view.WheelOptions; | |
18 | + | |
19 | +import java.util.List; | |
20 | + | |
21 | +/** | |
22 | + * 条件选择器 | |
23 | + * Created by Sai on 15/11/22. | |
24 | + */ | |
25 | +public class OptionsPickerView<T> extends BasePickerView implements View.OnClickListener { | |
26 | + | |
27 | + WheelOptions<T> wheelOptions; | |
28 | + private int layoutRes; | |
29 | + private CustomListener customListener; | |
30 | + private Button btnSubmit, btnCancel; //确定、取消按钮 | |
31 | + private TextView tvTitle; | |
32 | + private RelativeLayout rv_top_bar; | |
33 | + | |
34 | + private static final String TAG_SUBMIT = "submit"; | |
35 | + private static final String TAG_CANCEL = "cancel"; | |
36 | + | |
37 | + private OnOptionsSelectListener optionsSelectListener; | |
38 | + | |
39 | + private String Str_Submit;//确定按钮文字 | |
40 | + private String Str_Cancel;//取消按钮文字 | |
41 | + private String Str_Title;//标题文字 | |
42 | + | |
43 | + private int Color_Submit;//确定按钮颜色 | |
44 | + private int Color_Cancel;//取消按钮颜色 | |
45 | + private int Color_Title;//标题颜色 | |
46 | + | |
47 | + private int Color_Background_Wheel;//滚轮背景颜色 | |
48 | + private int Color_Background_Title;//标题背景颜色 | |
49 | + | |
50 | + private int Size_Submit_Cancel;//确定取消按钮大小 | |
51 | + private int Size_Title;//标题文字大小 | |
52 | + private int Size_Content;//内容文字大小 | |
53 | + | |
54 | + private int textColorOut; //分割线以外的文字颜色 | |
55 | + private int textColorCenter; //分割线之间的文字颜色 | |
56 | + private int dividerColor; //分割线的颜色 | |
57 | + private int backgroundId; //显示时的外部背景色颜色,默认是灰色 | |
58 | + // 条目间距倍数 默认1.6 | |
59 | + private float lineSpacingMultiplier = 1.6F; | |
60 | + private boolean isDialog;//是否是对话框模式 | |
61 | + | |
62 | + private boolean cancelable;//是否能取消 | |
63 | + private boolean linkage;//是否联动 | |
64 | + | |
65 | + private boolean isCenterLabel ;//是否只显示中间的label | |
66 | + | |
67 | + private String label1;//单位 | |
68 | + private String label2; | |
69 | + private String label3; | |
70 | + | |
71 | + private boolean cyclic1;//是否循环 | |
72 | + private boolean cyclic2; | |
73 | + private boolean cyclic3; | |
74 | + | |
75 | + private Typeface font;//字体样式 | |
76 | + | |
77 | + private int option1;//默认选中项 | |
78 | + private int option2; | |
79 | + private int option3; | |
80 | + private WheelView.DividerType dividerType;//分隔线类型 | |
81 | + | |
82 | + //构造方法 | |
83 | + public OptionsPickerView(Builder builder) { | |
84 | + super(builder.context); | |
85 | + this.optionsSelectListener = builder.optionsSelectListener; | |
86 | + this.Str_Submit = builder.Str_Submit; | |
87 | + this.Str_Cancel = builder.Str_Cancel; | |
88 | + this.Str_Title = builder.Str_Title; | |
89 | + | |
90 | + this.Color_Submit = builder.Color_Submit; | |
91 | + this.Color_Cancel = builder.Color_Cancel; | |
92 | + this.Color_Title = builder.Color_Title; | |
93 | + this.Color_Background_Wheel = builder.Color_Background_Wheel; | |
94 | + this.Color_Background_Title = builder.Color_Background_Title; | |
95 | + | |
96 | + this.Size_Submit_Cancel = builder.Size_Submit_Cancel; | |
97 | + this.Size_Title = builder.Size_Title; | |
98 | + this.Size_Content = builder.Size_Content; | |
99 | + | |
100 | + this.cyclic1 = builder.cyclic1; | |
101 | + this.cyclic2 = builder.cyclic2; | |
102 | + this.cyclic3 = builder.cyclic3; | |
103 | + | |
104 | + this.cancelable = builder.cancelable; | |
105 | + this.linkage = builder.linkage; | |
106 | + this.isCenterLabel = builder.isCenterLabel; | |
107 | + | |
108 | + this.label1 = builder.label1; | |
109 | + this.label2 = builder.label2; | |
110 | + this.label3 = builder.label3; | |
111 | + | |
112 | + this.font = builder.font; | |
113 | + | |
114 | + | |
115 | + this.option1 = builder.option1; | |
116 | + this.option2 = builder.option2; | |
117 | + this.option3 = builder.option3; | |
118 | + this.textColorCenter = builder.textColorCenter; | |
119 | + this.textColorOut = builder.textColorOut; | |
120 | + this.dividerColor = builder.dividerColor; | |
121 | + this.lineSpacingMultiplier = builder.lineSpacingMultiplier; | |
122 | + this.customListener = builder.customListener; | |
123 | + this.layoutRes = builder.layoutRes; | |
124 | + this.isDialog = builder.isDialog; | |
125 | + this.dividerType = builder.dividerType; | |
126 | + this.backgroundId = builder.backgroundId; | |
127 | + this.decorView = builder.decorView; | |
128 | + initView(builder.context); | |
129 | + } | |
130 | + | |
131 | + | |
132 | + //建造器 | |
133 | + public static class Builder { | |
134 | + private int layoutRes = R.layout.pickerview_options; | |
135 | + private CustomListener customListener; | |
136 | + private Context context; | |
137 | + private OnOptionsSelectListener optionsSelectListener; | |
138 | + | |
139 | + private String Str_Submit;//确定按钮文字 | |
140 | + private String Str_Cancel;//取消按钮文字 | |
141 | + private String Str_Title;//标题文字 | |
142 | + | |
143 | + private int Color_Submit;//确定按钮颜色 | |
144 | + private int Color_Cancel;//取消按钮颜色 | |
145 | + private int Color_Title;//标题颜色 | |
146 | + | |
147 | + private int Color_Background_Wheel;//滚轮背景颜色 | |
148 | + private int Color_Background_Title;//标题背景颜色 | |
149 | + | |
150 | + private int Size_Submit_Cancel = 17;//确定取消按钮大小 | |
151 | + private int Size_Title = 18;//标题文字大小 | |
152 | + private int Size_Content = 18;//内容文字大小 | |
153 | + | |
154 | + private boolean cancelable = true;//是否能取消 | |
155 | + private boolean linkage = true;//是否联动 | |
156 | + private boolean isCenterLabel = true;//是否只显示中间的label | |
157 | + | |
158 | + private int textColorOut; //分割线以外的文字颜色 | |
159 | + private int textColorCenter; //分割线之间的文字颜色 | |
160 | + private int dividerColor; //分割线的颜色 | |
161 | + private int backgroundId; //显示时的外部背景色颜色,默认是灰色 | |
162 | + public ViewGroup decorView ;//显示pickerview的根View,默认是activity的根view | |
163 | + // 条目间距倍数 默认1.6 | |
164 | + private float lineSpacingMultiplier = 1.6F; | |
165 | + private boolean isDialog;//是否是对话框模式 | |
166 | + | |
167 | + private String label1; | |
168 | + private String label2; | |
169 | + private String label3; | |
170 | + | |
171 | + private boolean cyclic1 = false;//是否循环,默认否 | |
172 | + private boolean cyclic2 = false; | |
173 | + private boolean cyclic3 = false; | |
174 | + | |
175 | + private Typeface font; | |
176 | + | |
177 | + private int option1;//默认选中项 | |
178 | + private int option2; | |
179 | + private int option3; | |
180 | + | |
181 | + private WheelView.DividerType dividerType;//分隔线类型 | |
182 | + | |
183 | + //Required | |
184 | + public Builder(Context context, OnOptionsSelectListener listener) { | |
185 | + this.context = context; | |
186 | + this.optionsSelectListener = listener; | |
187 | + } | |
188 | + | |
189 | + //Option | |
190 | + | |
191 | + public Builder setSubmitText(String Str_Cancel) { | |
192 | + this.Str_Submit = Str_Cancel; | |
193 | + return this; | |
194 | + } | |
195 | + | |
196 | + public Builder setCancelText(String Str_Cancel) { | |
197 | + this.Str_Cancel = Str_Cancel; | |
198 | + return this; | |
199 | + } | |
200 | + | |
201 | + public Builder setTitleText(String Str_Title) { | |
202 | + this.Str_Title = Str_Title; | |
203 | + return this; | |
204 | + } | |
205 | + | |
206 | + public Builder isDialog(boolean isDialog) { | |
207 | + this.isDialog = isDialog; | |
208 | + return this; | |
209 | + } | |
210 | + | |
211 | + public Builder setSubmitColor(int Color_Submit) { | |
212 | + this.Color_Submit = Color_Submit; | |
213 | + return this; | |
214 | + } | |
215 | + | |
216 | + public Builder setCancelColor(int Color_Cancel) { | |
217 | + this.Color_Cancel = Color_Cancel; | |
218 | + return this; | |
219 | + } | |
220 | + | |
221 | + /** | |
222 | + * 显示时的外部背景色颜色,默认是灰色 | |
223 | + * @param backgroundId | |
224 | + * @return | |
225 | + */ | |
226 | + public Builder setBackgroundId(int backgroundId) { | |
227 | + this.backgroundId = backgroundId; | |
228 | + return this; | |
229 | + } | |
230 | + /** | |
231 | + * 必须是viewgroup | |
232 | + * 设置要将pickerview显示到的容器 | |
233 | + * @param decorView | |
234 | + * @return | |
235 | + */ | |
236 | + public Builder setDecorView(ViewGroup decorView) { | |
237 | + this.decorView = decorView; | |
238 | + return this; | |
239 | + } | |
240 | + | |
241 | + | |
242 | + | |
243 | + | |
244 | + public Builder setLayoutRes(int res, CustomListener listener) { | |
245 | + this.layoutRes = res; | |
246 | + this.customListener = listener; | |
247 | + return this; | |
248 | + } | |
249 | + | |
250 | + public Builder setBgColor(int Color_Background_Wheel) { | |
251 | + this.Color_Background_Wheel = Color_Background_Wheel; | |
252 | + return this; | |
253 | + } | |
254 | + | |
255 | + public Builder setTitleBgColor(int Color_Background_Title) { | |
256 | + this.Color_Background_Title = Color_Background_Title; | |
257 | + return this; | |
258 | + } | |
259 | + | |
260 | + public Builder setTitleColor(int Color_Title) { | |
261 | + this.Color_Title = Color_Title; | |
262 | + return this; | |
263 | + } | |
264 | + | |
265 | + public Builder setSubCalSize(int Size_Submit_Cancel) { | |
266 | + this.Size_Submit_Cancel = Size_Submit_Cancel; | |
267 | + return this; | |
268 | + } | |
269 | + | |
270 | + public Builder setTitleSize(int Size_Title) { | |
271 | + this.Size_Title = Size_Title; | |
272 | + return this; | |
273 | + } | |
274 | + | |
275 | + public Builder setContentTextSize(int Size_Content) { | |
276 | + this.Size_Content = Size_Content; | |
277 | + return this; | |
278 | + } | |
279 | + | |
280 | + | |
281 | + public Builder setOutSideCancelable(boolean cancelable) { | |
282 | + this.cancelable = cancelable; | |
283 | + return this; | |
284 | + } | |
285 | + | |
286 | + /** | |
287 | + * 此方法已废弃 | |
288 | + * 不联动的情况下,请调用 setNPicker 方法。 | |
289 | + * */ | |
290 | + @Deprecated | |
291 | + public Builder setLinkage(boolean linkage) { | |
292 | + this.linkage = linkage; | |
293 | + return this; | |
294 | + } | |
295 | + | |
296 | + public Builder setLabels(String label1, String label2, String label3) { | |
297 | + this.label1 = label1; | |
298 | + this.label2 = label2; | |
299 | + this.label3 = label3; | |
300 | + return this; | |
301 | + } | |
302 | + | |
303 | + /** | |
304 | + * 设置间距倍数,但是只能在1.2-2.0f之间 | |
305 | + * | |
306 | + * @param lineSpacingMultiplier | |
307 | + */ | |
308 | + public Builder setLineSpacingMultiplier(float lineSpacingMultiplier) { | |
309 | + this.lineSpacingMultiplier = lineSpacingMultiplier; | |
310 | + return this; | |
311 | + } | |
312 | + | |
313 | + /** | |
314 | + * 设置分割线的颜色 | |
315 | + * | |
316 | + * @param dividerColor | |
317 | + */ | |
318 | + public Builder setDividerColor(int dividerColor) { | |
319 | + this.dividerColor = dividerColor; | |
320 | + return this; | |
321 | + } | |
322 | + | |
323 | + /** | |
324 | + * 设置分割线的类型 | |
325 | + * | |
326 | + * @param dividerType | |
327 | + */ | |
328 | + public Builder setDividerType(WheelView.DividerType dividerType) { | |
329 | + this.dividerType = dividerType; | |
330 | + return this; | |
331 | + } | |
332 | + | |
333 | + /** | |
334 | + * 设置分割线之间的文字的颜色 | |
335 | + * | |
336 | + * @param textColorCenter | |
337 | + */ | |
338 | + public Builder setTextColorCenter(int textColorCenter) { | |
339 | + this.textColorCenter = textColorCenter; | |
340 | + return this; | |
341 | + } | |
342 | + | |
343 | + /** | |
344 | + * 设置分割线以外文字的颜色 | |
345 | + * | |
346 | + * @param textColorOut | |
347 | + */ | |
348 | + public Builder setTextColorOut(int textColorOut) { | |
349 | + this.textColorOut = textColorOut; | |
350 | + return this; | |
351 | + } | |
352 | + | |
353 | + public Builder setTypeface(Typeface font) { | |
354 | + this.font = font; | |
355 | + return this; | |
356 | + } | |
357 | + | |
358 | + public Builder setCyclic(boolean cyclic1, boolean cyclic2, boolean cyclic3) { | |
359 | + this.cyclic1 = cyclic1; | |
360 | + this.cyclic2 = cyclic2; | |
361 | + this.cyclic3 = cyclic3; | |
362 | + return this; | |
363 | + } | |
364 | + | |
365 | + public Builder setSelectOptions(int option1) { | |
366 | + this.option1 = option1; | |
367 | + return this; | |
368 | + } | |
369 | + | |
370 | + public Builder setSelectOptions(int option1, int option2) { | |
371 | + this.option1 = option1; | |
372 | + this.option2 = option2; | |
373 | + return this; | |
374 | + } | |
375 | + | |
376 | + public Builder setSelectOptions(int option1, int option2, int option3) { | |
377 | + this.option1 = option1; | |
378 | + this.option2 = option2; | |
379 | + this.option3 = option3; | |
380 | + return this; | |
381 | + } | |
382 | + | |
383 | + public Builder isCenterLabel(boolean isCenterLabel) { | |
384 | + this.isCenterLabel = isCenterLabel; | |
385 | + return this; | |
386 | + } | |
387 | + | |
388 | + public OptionsPickerView build() { | |
389 | + return new OptionsPickerView(this); | |
390 | + } | |
391 | + } | |
392 | + | |
393 | + | |
394 | + private void initView(Context context) { | |
395 | + setDialogOutSideCancelable(cancelable); | |
396 | + initViews(backgroundId); | |
397 | + init(); | |
398 | + initEvents(); | |
399 | + if (customListener == null) { | |
400 | + LayoutInflater.from(context).inflate(layoutRes, contentContainer); | |
401 | + | |
402 | + //顶部标题 | |
403 | + tvTitle = (TextView) findViewById(R.id.tvTitle); | |
404 | + rv_top_bar = (RelativeLayout)findViewById(R.id.rv_topbar); | |
405 | + | |
406 | + //确定和取消按钮 | |
407 | + btnSubmit = (Button) findViewById(R.id.btnSubmit); | |
408 | + btnCancel = (Button) findViewById(R.id.btnCancel); | |
409 | + | |
410 | + btnSubmit.setTag(TAG_SUBMIT); | |
411 | + btnCancel.setTag(TAG_CANCEL); | |
412 | + btnSubmit.setOnClickListener(this); | |
413 | + btnCancel.setOnClickListener(this); | |
414 | + | |
415 | + //设置文字 | |
416 | + btnSubmit.setText(TextUtils.isEmpty(Str_Submit) ? context.getResources().getString(R.string.pickerview_submit) : Str_Submit); | |
417 | + btnCancel.setText(TextUtils.isEmpty(Str_Cancel) ? context.getResources().getString(R.string.pickerview_cancel) : Str_Cancel); | |
418 | + tvTitle.setText(TextUtils.isEmpty(Str_Title) ? "" : Str_Title);//默认为空 | |
419 | + | |
420 | + //设置color | |
421 | + btnSubmit.setTextColor(Color_Submit == 0 ? pickerview_timebtn_nor : Color_Submit); | |
422 | + btnCancel.setTextColor(Color_Cancel == 0 ? pickerview_timebtn_nor : Color_Cancel); | |
423 | + tvTitle.setTextColor(Color_Title == 0 ? pickerview_topbar_title : Color_Title); | |
424 | + rv_top_bar.setBackgroundColor(Color_Background_Title == 0 ? pickerview_bg_topbar : Color_Background_Title); | |
425 | + | |
426 | + //设置文字大小 | |
427 | + btnSubmit.setTextSize(Size_Submit_Cancel); | |
428 | + btnCancel.setTextSize(Size_Submit_Cancel); | |
429 | + tvTitle.setTextSize(Size_Title); | |
430 | + tvTitle.setText(Str_Title); | |
431 | + } else { | |
432 | + customListener.customLayout(LayoutInflater.from(context).inflate(layoutRes, contentContainer)); | |
433 | + } | |
434 | + | |
435 | + // ----滚轮布局 | |
436 | + final LinearLayout optionsPicker = (LinearLayout) findViewById(R.id.optionspicker); | |
437 | + optionsPicker.setBackgroundColor(Color_Background_Wheel == 0 ? bgColor_default : Color_Background_Wheel); | |
438 | + | |
439 | + wheelOptions = new WheelOptions(optionsPicker, linkage); | |
440 | + wheelOptions.setTextContentSize(Size_Content); | |
441 | + wheelOptions.setLabels(label1, label2, label3); | |
442 | + wheelOptions.setCyclic(cyclic1, cyclic2, cyclic3); | |
443 | + wheelOptions.setTypeface(font); | |
444 | + | |
445 | + setOutSideCancelable(cancelable); | |
446 | + | |
447 | + if (tvTitle!= null){ | |
448 | + tvTitle.setText(Str_Title); | |
449 | + } | |
450 | + | |
451 | + wheelOptions.setDividerColor(dividerColor); | |
452 | + wheelOptions.setDividerType(dividerType); | |
453 | + wheelOptions.setLineSpacingMultiplier(lineSpacingMultiplier); | |
454 | + wheelOptions.setTextColorOut(textColorOut); | |
455 | + wheelOptions.setTextColorCenter(textColorCenter); | |
456 | + wheelOptions.isCenterLabel(isCenterLabel); | |
457 | + | |
458 | + } | |
459 | + | |
460 | + | |
461 | + /** | |
462 | + * 设置默认选中项 | |
463 | + * | |
464 | + * @param option1 | |
465 | + */ | |
466 | + public void setSelectOptions(int option1) { | |
467 | + this.option1 = option1; | |
468 | + SetCurrentItems(); | |
469 | + } | |
470 | + | |
471 | + | |
472 | + public void setSelectOptions(int option1, int option2) { | |
473 | + this.option1 = option1; | |
474 | + this.option2 = option2; | |
475 | + SetCurrentItems(); | |
476 | + } | |
477 | + | |
478 | + public void setSelectOptions(int option1, int option2, int option3) { | |
479 | + this.option1 = option1; | |
480 | + this.option2 = option2; | |
481 | + this.option3 = option3; | |
482 | + SetCurrentItems(); | |
483 | + } | |
484 | + | |
485 | + private void SetCurrentItems() { | |
486 | + if(wheelOptions!=null){ | |
487 | + wheelOptions.setCurrentItems(option1, option2, option3); | |
488 | + } | |
489 | + } | |
490 | + | |
491 | + public void setPicker(List<T> optionsItems) { | |
492 | + this.setPicker(optionsItems, null, null); | |
493 | + } | |
494 | + | |
495 | + public void setPicker(List<T> options1Items, List<List<T>> options2Items) { | |
496 | + this.setPicker(options1Items, options2Items, null); | |
497 | + } | |
498 | + | |
499 | + public void setPicker(List<T> options1Items, | |
500 | + List<List<T>> options2Items, | |
501 | + List<List<List<T>>> options3Items) { | |
502 | + | |
503 | + wheelOptions.setPicker(options1Items, options2Items, options3Items); | |
504 | + SetCurrentItems(); | |
505 | + } | |
506 | + | |
507 | + | |
508 | + //不联动情况下调用 | |
509 | + public void setNPicker(List<T> options1Items, | |
510 | + List<T> options2Items, | |
511 | + List<T> options3Items) { | |
512 | + | |
513 | + wheelOptions.setNPicker(options1Items, options2Items, options3Items); | |
514 | + SetCurrentItems(); | |
515 | + } | |
516 | + | |
517 | + @Override | |
518 | + public void onClick(View v) { | |
519 | + String tag = (String) v.getTag(); | |
520 | + if (tag.equals(TAG_SUBMIT)) { | |
521 | + returnData(); | |
522 | + } | |
523 | + dismiss(); | |
524 | + } | |
525 | + | |
526 | + //抽离接口回调的方法 | |
527 | + public void returnData() { | |
528 | + if (optionsSelectListener != null) { | |
529 | + int[] optionsCurrentItems = wheelOptions.getCurrentItems(); | |
530 | + optionsSelectListener.onOptionsSelect(optionsCurrentItems[0], optionsCurrentItems[1], optionsCurrentItems[2], clickView); | |
531 | + } | |
532 | + } | |
533 | + | |
534 | + public interface OnOptionsSelectListener { | |
535 | + void onOptionsSelect(int options1, int options2, int options3, View v); | |
536 | + } | |
537 | + | |
538 | + @Override | |
539 | + public boolean isDialog() { | |
540 | + return isDialog; | |
541 | + } | |
542 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/TimePickerView.java
... | ... | @@ -0,0 +1,555 @@ |
1 | +package com.bigkoo.pickerview; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.text.TextUtils; | |
5 | +import android.view.Gravity; | |
6 | +import android.view.LayoutInflater; | |
7 | +import android.view.View; | |
8 | +import android.view.ViewGroup; | |
9 | +import android.widget.Button; | |
10 | +import android.widget.LinearLayout; | |
11 | +import android.widget.RelativeLayout; | |
12 | +import android.widget.TextView; | |
13 | + | |
14 | +import com.bigkoo.pickerview.lib.WheelView; | |
15 | +import com.bigkoo.pickerview.listener.CustomListener; | |
16 | +import com.bigkoo.pickerview.view.BasePickerView; | |
17 | +import com.bigkoo.pickerview.view.WheelTime; | |
18 | + | |
19 | +import java.text.ParseException; | |
20 | +import java.util.Calendar; | |
21 | +import java.util.Date; | |
22 | + | |
23 | +/** | |
24 | + * 时间选择器 | |
25 | + * Created by Sai on 15/11/22. | |
26 | + * Updated by XiaoSong on 2017-2-22. | |
27 | + */ | |
28 | +public class TimePickerView extends BasePickerView implements View.OnClickListener { | |
29 | + private int layoutRes; | |
30 | + private CustomListener customListener; | |
31 | + | |
32 | + WheelTime wheelTime; //自定义控件 | |
33 | + private Button btnSubmit, btnCancel; //确定、取消按钮 | |
34 | + private TextView tvTitle;//标题 | |
35 | + private OnTimeSelectListener timeSelectListener;//回调接口 | |
36 | + private int gravity = Gravity.CENTER;//内容显示位置 默认居中 | |
37 | + private boolean[] type;// 显示类型 | |
38 | + | |
39 | + private String Str_Submit;//确定按钮字符串 | |
40 | + private String Str_Cancel;//取消按钮字符串 | |
41 | + private String Str_Title;//标题字符串 | |
42 | + | |
43 | + private int Color_Submit;//确定按钮颜色 | |
44 | + private int Color_Cancel;//取消按钮颜色 | |
45 | + private int Color_Title;//标题颜色 | |
46 | + | |
47 | + private int Color_Background_Wheel;//滚轮背景颜色 | |
48 | + private int Color_Background_Title;//标题背景颜色 | |
49 | + | |
50 | + private int Size_Submit_Cancel;//确定取消按钮大小 | |
51 | + private int Size_Title;//标题字体大小 | |
52 | + private int Size_Content;//内容字体大小 | |
53 | + | |
54 | + private Calendar date;//当前选中时间 | |
55 | + private Calendar startDate;//开始时间 | |
56 | + private Calendar endDate;//终止时间 | |
57 | + private int startYear;//开始年份 | |
58 | + private int endYear;//结尾年份 | |
59 | + | |
60 | + private boolean cyclic;//是否循环 | |
61 | + private boolean cancelable;//是否能取消 | |
62 | + private boolean isCenterLabel;//是否只显示中间的label | |
63 | + | |
64 | + private int textColorOut; //分割线以外的文字颜色 | |
65 | + private int textColorCenter; //分割线之间的文字颜色 | |
66 | + private int dividerColor; //分割线的颜色 | |
67 | + private int backgroundId; //显示时的外部背景色颜色,默认是灰色 | |
68 | + | |
69 | + // 条目间距倍数 默认1.6 | |
70 | + private float lineSpacingMultiplier = 1.6F; | |
71 | + private boolean isDialog;//是否是对话框模式 | |
72 | + private String label_year, label_month, label_day, label_hours, label_mins, label_seconds; | |
73 | + private WheelView.DividerType dividerType;//分隔线类型 | |
74 | + | |
75 | + private static final String TAG_SUBMIT = "submit"; | |
76 | + private static final String TAG_CANCEL = "cancel"; | |
77 | + | |
78 | + //构造方法 | |
79 | + public TimePickerView(Builder builder) { | |
80 | + super(builder.context); | |
81 | + this.timeSelectListener = builder.timeSelectListener; | |
82 | + this.gravity = builder.gravity; | |
83 | + this.type = builder.type; | |
84 | + this.Str_Submit = builder.Str_Submit; | |
85 | + this.Str_Cancel = builder.Str_Cancel; | |
86 | + this.Str_Title = builder.Str_Title; | |
87 | + this.Color_Submit = builder.Color_Submit; | |
88 | + this.Color_Cancel = builder.Color_Cancel; | |
89 | + this.Color_Title = builder.Color_Title; | |
90 | + this.Color_Background_Wheel = builder.Color_Background_Wheel; | |
91 | + this.Color_Background_Title = builder.Color_Background_Title; | |
92 | + this.Size_Submit_Cancel = builder.Size_Submit_Cancel; | |
93 | + this.Size_Title = builder.Size_Title; | |
94 | + this.Size_Content = builder.Size_Content; | |
95 | + this.startYear = builder.startYear; | |
96 | + this.endYear = builder.endYear; | |
97 | + this.startDate = builder.startDate; | |
98 | + this.endDate = builder.endDate; | |
99 | + this.date = builder.date; | |
100 | + this.cyclic = builder.cyclic; | |
101 | + this.isCenterLabel = builder.isCenterLabel; | |
102 | + this.cancelable = builder.cancelable; | |
103 | + this.label_year = builder.label_year; | |
104 | + this.label_month = builder.label_month; | |
105 | + this.label_day = builder.label_day; | |
106 | + this.label_hours = builder.label_hours; | |
107 | + this.label_mins = builder.label_mins; | |
108 | + this.label_seconds = builder.label_seconds; | |
109 | + this.textColorCenter = builder.textColorCenter; | |
110 | + this.textColorOut = builder.textColorOut; | |
111 | + this.dividerColor = builder.dividerColor; | |
112 | + this.customListener = builder.customListener; | |
113 | + this.layoutRes = builder.layoutRes; | |
114 | + this.lineSpacingMultiplier = builder.lineSpacingMultiplier; | |
115 | + this.isDialog = builder.isDialog; | |
116 | + this.dividerType = builder.dividerType; | |
117 | + this.backgroundId = builder.backgroundId; | |
118 | + this.decorView = builder.decorView; | |
119 | + initView(builder.context); | |
120 | + } | |
121 | + | |
122 | + | |
123 | + //建造器 | |
124 | + public static class Builder { | |
125 | + private int layoutRes = R.layout.pickerview_time; | |
126 | + private CustomListener customListener; | |
127 | + private Context context; | |
128 | + private OnTimeSelectListener timeSelectListener; | |
129 | + private boolean[] type = new boolean[]{true, true, true, true, true, true};//显示类型 默认全部显示 | |
130 | + private int gravity = Gravity.CENTER;//内容显示位置 默认居中 | |
131 | + | |
132 | + private String Str_Submit;//确定按钮文字 | |
133 | + private String Str_Cancel;//取消按钮文字 | |
134 | + private String Str_Title;//标题文字 | |
135 | + | |
136 | + private int Color_Submit;//确定按钮颜色 | |
137 | + private int Color_Cancel;//取消按钮颜色 | |
138 | + private int Color_Title;//标题颜色 | |
139 | + | |
140 | + private int Color_Background_Wheel;//滚轮背景颜色 | |
141 | + private int Color_Background_Title;//标题背景颜色 | |
142 | + | |
143 | + private int Size_Submit_Cancel = 17;//确定取消按钮大小 | |
144 | + private int Size_Title = 18;//标题字体大小 | |
145 | + private int Size_Content = 18;//内容字体大小 | |
146 | + private Calendar date;//当前选中时间 | |
147 | + private Calendar startDate;//开始时间 | |
148 | + private Calendar endDate;//终止时间 | |
149 | + private int startYear;//开始年份 | |
150 | + private int endYear;//结尾年份 | |
151 | + | |
152 | + private boolean cyclic = false;//是否循环 | |
153 | + private boolean cancelable = true;//是否能取消 | |
154 | + | |
155 | + private boolean isCenterLabel = true ;//是否只显示中间的label | |
156 | + public ViewGroup decorView ;//显示pickerview的根View,默认是activity的根view | |
157 | + | |
158 | + private int textColorOut; //分割线以外的文字颜色 | |
159 | + private int textColorCenter; //分割线之间的文字颜色 | |
160 | + private int dividerColor; //分割线的颜色 | |
161 | + private int backgroundId; //显示时的外部背景色颜色,默认是灰色 | |
162 | + private WheelView.DividerType dividerType;//分隔线类型 | |
163 | + // 条目间距倍数 默认1.6 | |
164 | + private float lineSpacingMultiplier = 1.6F; | |
165 | + | |
166 | + private boolean isDialog;//是否是对话框模式 | |
167 | + | |
168 | + private String label_year, label_month, label_day, label_hours, label_mins, label_seconds;//单位 | |
169 | + | |
170 | + //Required | |
171 | + public Builder(Context context, OnTimeSelectListener listener) { | |
172 | + this.context = context; | |
173 | + this.timeSelectListener = listener; | |
174 | + } | |
175 | + | |
176 | + //Option | |
177 | + public Builder setType(boolean[] type) { | |
178 | + this.type = type; | |
179 | + return this; | |
180 | + } | |
181 | + | |
182 | + public Builder gravity(int gravity) { | |
183 | + this.gravity = gravity; | |
184 | + return this; | |
185 | + } | |
186 | + | |
187 | + public Builder setSubmitText(String Str_Submit) { | |
188 | + this.Str_Submit = Str_Submit; | |
189 | + return this; | |
190 | + } | |
191 | + | |
192 | + public Builder isDialog(boolean isDialog) { | |
193 | + this.isDialog = isDialog; | |
194 | + return this; | |
195 | + } | |
196 | + | |
197 | + public Builder setCancelText(String Str_Cancel) { | |
198 | + this.Str_Cancel = Str_Cancel; | |
199 | + return this; | |
200 | + } | |
201 | + | |
202 | + public Builder setTitleText(String Str_Title) { | |
203 | + this.Str_Title = Str_Title; | |
204 | + return this; | |
205 | + } | |
206 | + | |
207 | + public Builder setSubmitColor(int Color_Submit) { | |
208 | + this.Color_Submit = Color_Submit; | |
209 | + return this; | |
210 | + } | |
211 | + | |
212 | + public Builder setCancelColor(int Color_Cancel) { | |
213 | + this.Color_Cancel = Color_Cancel; | |
214 | + return this; | |
215 | + } | |
216 | + /** | |
217 | + * 必须是viewgroup | |
218 | + * 设置要将pickerview显示到的容器id | |
219 | + * @param decorView | |
220 | + * @return | |
221 | + */ | |
222 | + public Builder setDecorView(ViewGroup decorView) { | |
223 | + this.decorView = decorView; | |
224 | + return this; | |
225 | + } | |
226 | + | |
227 | + public Builder setBgColor(int Color_Background_Wheel) { | |
228 | + this.Color_Background_Wheel = Color_Background_Wheel; | |
229 | + return this; | |
230 | + } | |
231 | + | |
232 | + public Builder setTitleBgColor(int Color_Background_Title) { | |
233 | + this.Color_Background_Title = Color_Background_Title; | |
234 | + return this; | |
235 | + } | |
236 | + | |
237 | + public Builder setTitleColor(int Color_Title) { | |
238 | + this.Color_Title = Color_Title; | |
239 | + return this; | |
240 | + } | |
241 | + | |
242 | + public Builder setSubCalSize(int Size_Submit_Cancel) { | |
243 | + this.Size_Submit_Cancel = Size_Submit_Cancel; | |
244 | + return this; | |
245 | + } | |
246 | + | |
247 | + public Builder setTitleSize(int Size_Title) { | |
248 | + this.Size_Title = Size_Title; | |
249 | + return this; | |
250 | + } | |
251 | + | |
252 | + public Builder setContentSize(int Size_Content) { | |
253 | + this.Size_Content = Size_Content; | |
254 | + return this; | |
255 | + } | |
256 | + | |
257 | + /** | |
258 | + * 因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 | |
259 | + * | |
260 | + * @param date | |
261 | + * @return | |
262 | + */ | |
263 | + public Builder setDate(Calendar date) { | |
264 | + this.date = date; | |
265 | + return this; | |
266 | + } | |
267 | + | |
268 | + public Builder setLayoutRes(int res, CustomListener customListener) { | |
269 | + this.layoutRes = res; | |
270 | + this.customListener = customListener; | |
271 | + return this; | |
272 | + } | |
273 | + | |
274 | + public Builder setRange(int startYear, int endYear) { | |
275 | + this.startYear = startYear; | |
276 | + this.endYear = endYear; | |
277 | + return this; | |
278 | + } | |
279 | + | |
280 | + /** | |
281 | + * 设置起始时间 | |
282 | + * 因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 | |
283 | + * | |
284 | + * @return | |
285 | + */ | |
286 | + | |
287 | + public Builder setRangDate(Calendar startDate, Calendar endDate) { | |
288 | + this.startDate = startDate; | |
289 | + this.endDate = endDate; | |
290 | + return this; | |
291 | + } | |
292 | + | |
293 | + | |
294 | + /** | |
295 | + * 设置间距倍数,但是只能在1.2-2.0f之间 | |
296 | + * | |
297 | + * @param lineSpacingMultiplier | |
298 | + */ | |
299 | + public Builder setLineSpacingMultiplier(float lineSpacingMultiplier) { | |
300 | + this.lineSpacingMultiplier = lineSpacingMultiplier; | |
301 | + return this; | |
302 | + } | |
303 | + | |
304 | + /** | |
305 | + * 设置分割线的颜色 | |
306 | + * | |
307 | + * @param dividerColor | |
308 | + */ | |
309 | + public Builder setDividerColor(int dividerColor) { | |
310 | + this.dividerColor = dividerColor; | |
311 | + return this; | |
312 | + } | |
313 | + | |
314 | + /** | |
315 | + * 设置分割线的类型 | |
316 | + * | |
317 | + * @param dividerType | |
318 | + */ | |
319 | + public Builder setDividerType(WheelView.DividerType dividerType) { | |
320 | + this.dividerType = dividerType; | |
321 | + return this; | |
322 | + } | |
323 | + | |
324 | + /** | |
325 | + * //显示时的外部背景色颜色,默认是灰色 | |
326 | + * @param backgroundId | |
327 | + */ | |
328 | + | |
329 | + public Builder setBackgroundId(int backgroundId) { | |
330 | + this.backgroundId = backgroundId; | |
331 | + return this; | |
332 | + } | |
333 | + | |
334 | + /** | |
335 | + * 设置分割线之间的文字的颜色 | |
336 | + * | |
337 | + * @param textColorCenter | |
338 | + */ | |
339 | + public Builder setTextColorCenter(int textColorCenter) { | |
340 | + this.textColorCenter = textColorCenter; | |
341 | + return this; | |
342 | + } | |
343 | + | |
344 | + /** | |
345 | + * 设置分割线以外文字的颜色 | |
346 | + * | |
347 | + * @param textColorOut | |
348 | + */ | |
349 | + public Builder setTextColorOut(int textColorOut) { | |
350 | + this.textColorOut = textColorOut; | |
351 | + return this; | |
352 | + } | |
353 | + | |
354 | + public Builder isCyclic(boolean cyclic) { | |
355 | + this.cyclic = cyclic; | |
356 | + return this; | |
357 | + } | |
358 | + | |
359 | + public Builder setOutSideCancelable(boolean cancelable) { | |
360 | + this.cancelable = cancelable; | |
361 | + return this; | |
362 | + } | |
363 | + | |
364 | + public Builder setLabel(String label_year, String label_month, String label_day, String label_hours, String label_mins, String label_seconds) { | |
365 | + this.label_year = label_year; | |
366 | + this.label_month = label_month; | |
367 | + this.label_day = label_day; | |
368 | + this.label_hours = label_hours; | |
369 | + this.label_mins = label_mins; | |
370 | + this.label_seconds = label_seconds; | |
371 | + return this; | |
372 | + } | |
373 | + | |
374 | + public Builder isCenterLabel(boolean isCenterLabel) { | |
375 | + this.isCenterLabel = isCenterLabel; | |
376 | + return this; | |
377 | + } | |
378 | + | |
379 | + | |
380 | + public TimePickerView build() { | |
381 | + return new TimePickerView(this); | |
382 | + } | |
383 | + } | |
384 | + | |
385 | + | |
386 | + private void initView(Context context) { | |
387 | + setDialogOutSideCancelable(cancelable); | |
388 | + initViews(backgroundId); | |
389 | + init(); | |
390 | + initEvents(); | |
391 | + if (customListener == null) { | |
392 | + LayoutInflater.from(context).inflate(R.layout.pickerview_time, contentContainer); | |
393 | + | |
394 | + //顶部标题 | |
395 | + tvTitle = (TextView) findViewById(R.id.tvTitle); | |
396 | + | |
397 | + //确定和取消按钮 | |
398 | + btnSubmit = (Button) findViewById(R.id.btnSubmit); | |
399 | + btnCancel = (Button) findViewById(R.id.btnCancel); | |
400 | + | |
401 | + btnSubmit.setTag(TAG_SUBMIT); | |
402 | + btnCancel.setTag(TAG_CANCEL); | |
403 | + | |
404 | + btnSubmit.setOnClickListener(this); | |
405 | + btnCancel.setOnClickListener(this); | |
406 | + | |
407 | + //设置文字 | |
408 | + btnSubmit.setText(TextUtils.isEmpty(Str_Submit) ? context.getResources().getString(R.string.pickerview_submit) : Str_Submit); | |
409 | + btnCancel.setText(TextUtils.isEmpty(Str_Cancel) ? context.getResources().getString(R.string.pickerview_cancel) : Str_Cancel); | |
410 | + tvTitle.setText(TextUtils.isEmpty(Str_Title) ? "" : Str_Title);//默认为空 | |
411 | + | |
412 | + //设置文字颜色 | |
413 | + btnSubmit.setTextColor(Color_Submit == 0 ? pickerview_timebtn_nor : Color_Submit); | |
414 | + btnCancel.setTextColor(Color_Cancel == 0 ? pickerview_timebtn_nor : Color_Cancel); | |
415 | + tvTitle.setTextColor(Color_Title == 0 ? pickerview_topbar_title : Color_Title); | |
416 | + | |
417 | + //设置文字大小 | |
418 | + btnSubmit.setTextSize(Size_Submit_Cancel); | |
419 | + btnCancel.setTextSize(Size_Submit_Cancel); | |
420 | + tvTitle.setTextSize(Size_Title); | |
421 | + RelativeLayout rv_top_bar = (RelativeLayout) findViewById(R.id.rv_topbar); | |
422 | + rv_top_bar.setBackgroundColor(Color_Background_Title == 0 ? pickerview_bg_topbar : Color_Background_Title); | |
423 | + } else { | |
424 | + customListener.customLayout(LayoutInflater.from(context).inflate(layoutRes, contentContainer)); | |
425 | + } | |
426 | + // 时间转轮 自定义控件 | |
427 | + LinearLayout timePickerView = (LinearLayout) findViewById(R.id.timepicker); | |
428 | + | |
429 | + timePickerView.setBackgroundColor(Color_Background_Wheel == 0 ? bgColor_default : Color_Background_Wheel); | |
430 | + | |
431 | + wheelTime = new WheelTime(timePickerView, type, gravity, Size_Content); | |
432 | + | |
433 | + if (startYear != 0 && endYear != 0 && startYear <= endYear) { | |
434 | + setRange(); | |
435 | + } | |
436 | + | |
437 | + if (startDate != null && endDate != null) { | |
438 | + if (startDate.getTimeInMillis() <= endDate.getTimeInMillis()) { | |
439 | + setRangDate(); | |
440 | + } | |
441 | + } else if (startDate != null && endDate == null) { | |
442 | + setRangDate(); | |
443 | + } else if (startDate == null && endDate != null) { | |
444 | + setRangDate(); | |
445 | + } | |
446 | + | |
447 | + setTime(); | |
448 | + wheelTime.setLabels(label_year, label_month, label_day, label_hours, label_mins, label_seconds); | |
449 | + | |
450 | + setOutSideCancelable(cancelable); | |
451 | + wheelTime.setCyclic(cyclic); | |
452 | + wheelTime.setDividerColor(dividerColor); | |
453 | + wheelTime.setDividerType(dividerType); | |
454 | + wheelTime.setLineSpacingMultiplier(lineSpacingMultiplier); | |
455 | + wheelTime.setTextColorOut(textColorOut); | |
456 | + wheelTime.setTextColorCenter(textColorCenter); | |
457 | + wheelTime.isCenterLabel(isCenterLabel); | |
458 | + } | |
459 | + | |
460 | + | |
461 | + /** | |
462 | + * 设置默认时间 | |
463 | + */ | |
464 | + public void setDate(Calendar date) { | |
465 | + this.date = date; | |
466 | + setTime(); | |
467 | + } | |
468 | + | |
469 | + /** | |
470 | + * 设置可以选择的时间范围, 要在setTime之前调用才有效果 | |
471 | + */ | |
472 | + private void setRange() { | |
473 | + wheelTime.setStartYear(startYear); | |
474 | + wheelTime.setEndYear(endYear); | |
475 | + | |
476 | + } | |
477 | + | |
478 | + /** | |
479 | + * 设置可以选择的时间范围, 要在setTime之前调用才有效果 | |
480 | + */ | |
481 | + private void setRangDate() { | |
482 | + wheelTime.setRangDate(startDate, endDate); | |
483 | + //如果设置了时间范围 | |
484 | + if (startDate != null && endDate != null) { | |
485 | + //判断一下默认时间是否设置了,或者是否在起始终止时间范围内 | |
486 | + if (date == null || date.getTimeInMillis() < startDate.getTimeInMillis() | |
487 | + || date.getTimeInMillis() > endDate.getTimeInMillis()) { | |
488 | + date = startDate; | |
489 | + } | |
490 | + } else if (startDate != null) { | |
491 | + //没有设置默认选中时间,那就拿开始时间当默认时间 | |
492 | + date = startDate; | |
493 | + } else if (endDate != null) { | |
494 | + date = endDate; | |
495 | + } | |
496 | + } | |
497 | + | |
498 | + /** | |
499 | + * 设置选中时间,默认选中当前时间 | |
500 | + */ | |
501 | + private void setTime() { | |
502 | + int year, month, day, hours, minute, seconds; | |
503 | + | |
504 | + Calendar calendar = Calendar.getInstance(); | |
505 | + if (date == null) { | |
506 | + calendar.setTimeInMillis(System.currentTimeMillis()); | |
507 | + year = calendar.get(Calendar.YEAR); | |
508 | + month = calendar.get(Calendar.MONTH); | |
509 | + day = calendar.get(Calendar.DAY_OF_MONTH); | |
510 | + hours = calendar.get(Calendar.HOUR_OF_DAY); | |
511 | + minute = calendar.get(Calendar.MINUTE); | |
512 | + seconds = calendar.get(Calendar.SECOND); | |
513 | + } else { | |
514 | + year = date.get(Calendar.YEAR); | |
515 | + month = date.get(Calendar.MONTH); | |
516 | + day = date.get(Calendar.DAY_OF_MONTH); | |
517 | + hours = date.get(Calendar.HOUR_OF_DAY); | |
518 | + minute = date.get(Calendar.MINUTE); | |
519 | + seconds = date.get(Calendar.SECOND); | |
520 | + } | |
521 | + | |
522 | + | |
523 | + wheelTime.setPicker(year, month, day, hours, minute, seconds); | |
524 | + } | |
525 | + | |
526 | + | |
527 | + @Override | |
528 | + public void onClick(View v) { | |
529 | + String tag = (String) v.getTag(); | |
530 | + if (tag.equals(TAG_SUBMIT)) { | |
531 | + returnData(); | |
532 | + } | |
533 | + dismiss(); | |
534 | + } | |
535 | + | |
536 | + public void returnData() { | |
537 | + if (timeSelectListener != null) { | |
538 | + try { | |
539 | + Date date = WheelTime.dateFormat.parse(wheelTime.getTime()); | |
540 | + timeSelectListener.onTimeSelect(date, clickView); | |
541 | + } catch (ParseException e) { | |
542 | + e.printStackTrace(); | |
543 | + } | |
544 | + } | |
545 | + } | |
546 | + | |
547 | + public interface OnTimeSelectListener { | |
548 | + void onTimeSelect(Date date, View v); | |
549 | + } | |
550 | + | |
551 | + @Override | |
552 | + public boolean isDialog() { | |
553 | + return isDialog; | |
554 | + } | |
555 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/adapter/ArrayWheelAdapter.java
... | ... | @@ -0,0 +1,55 @@ |
1 | +package com.bigkoo.pickerview.adapter; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +/** | |
6 | + * The simple Array wheel adapter | |
7 | + * @param <T> the element type | |
8 | + */ | |
9 | +public class ArrayWheelAdapter<T> implements WheelAdapter { | |
10 | + | |
11 | + /** The default items length */ | |
12 | + public static final int DEFAULT_LENGTH = 4; | |
13 | + | |
14 | + // items | |
15 | + private List<T> items; | |
16 | + // length | |
17 | + private int length; | |
18 | + | |
19 | + /** | |
20 | + * Constructor | |
21 | + * @param items the items | |
22 | + * @param length the max items length | |
23 | + */ | |
24 | + public ArrayWheelAdapter(List<T> items, int length) { | |
25 | + this.items = items; | |
26 | + this.length = length; | |
27 | + } | |
28 | + | |
29 | + /** | |
30 | + * Contructor | |
31 | + * @param items the items | |
32 | + */ | |
33 | + public ArrayWheelAdapter(List<T> items) { | |
34 | + this(items, DEFAULT_LENGTH); | |
35 | + } | |
36 | + | |
37 | + @Override | |
38 | + public Object getItem(int index) { | |
39 | + if (index >= 0 && index < items.size()) { | |
40 | + return items.get(index); | |
41 | + } | |
42 | + return ""; | |
43 | + } | |
44 | + | |
45 | + @Override | |
46 | + public int getItemsCount() { | |
47 | + return items.size(); | |
48 | + } | |
49 | + | |
50 | + @Override | |
51 | + public int indexOf(Object o){ | |
52 | + return items.indexOf(o); | |
53 | + } | |
54 | + | |
55 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/adapter/NumericWheelAdapter.java
... | ... | @@ -0,0 +1,59 @@ |
1 | +package com.bigkoo.pickerview.adapter; | |
2 | + | |
3 | + | |
4 | +/** | |
5 | + * Numeric Wheel adapter. | |
6 | + */ | |
7 | +public class NumericWheelAdapter implements WheelAdapter { | |
8 | + | |
9 | + /** The default min value */ | |
10 | + public static final int DEFAULT_MAX_VALUE = 9; | |
11 | + | |
12 | + /** The default max value */ | |
13 | + private static final int DEFAULT_MIN_VALUE = 0; | |
14 | + | |
15 | + // Values | |
16 | + private int minValue; | |
17 | + private int maxValue; | |
18 | + | |
19 | + /** | |
20 | + * Default constructor | |
21 | + */ | |
22 | + public NumericWheelAdapter() { | |
23 | + this(DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE); | |
24 | + } | |
25 | + | |
26 | + /** | |
27 | + * Constructor | |
28 | + * @param minValue the wheel min value | |
29 | + * @param maxValue the wheel max value | |
30 | + */ | |
31 | + public NumericWheelAdapter(int minValue, int maxValue) { | |
32 | + this.minValue = minValue; | |
33 | + this.maxValue = maxValue; | |
34 | + } | |
35 | + | |
36 | + @Override | |
37 | + public Object getItem(int index) { | |
38 | + if (index >= 0 && index < getItemsCount()) { | |
39 | + int value = minValue + index; | |
40 | + return value; | |
41 | + } | |
42 | + return 0; | |
43 | + } | |
44 | + | |
45 | + @Override | |
46 | + public int getItemsCount() { | |
47 | + return maxValue - minValue + 1; | |
48 | + } | |
49 | + | |
50 | + @Override | |
51 | + public int indexOf(Object o){ | |
52 | + try { | |
53 | + return (int)o - minValue; | |
54 | + } catch (Exception e) { | |
55 | + return -1; | |
56 | + } | |
57 | + | |
58 | + } | |
59 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/adapter/WheelAdapter.java
... | ... | @@ -0,0 +1,24 @@ |
1 | +package com.bigkoo.pickerview.adapter; | |
2 | + | |
3 | +public interface WheelAdapter<T> { | |
4 | + /** | |
5 | + * Gets items count | |
6 | + * @return the count of wheel items | |
7 | + */ | |
8 | + int getItemsCount(); | |
9 | + | |
10 | + /** | |
11 | + * Gets a wheel item by index. | |
12 | + * @param index the item index | |
13 | + * @return the wheel item text or null | |
14 | + */ | |
15 | + T getItem(int index); | |
16 | + | |
17 | + /** | |
18 | + * Gets maximum item length. It is used to determine the wheel width. | |
19 | + * If -1 is returned there will be used the default wheel width. | |
20 | + * @param o | |
21 | + * @return the maximum item length or -1 | |
22 | + */ | |
23 | + int indexOf(T o); | |
24 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/lib/InertiaTimerTask.java
... | ... | @@ -0,0 +1,68 @@ |
1 | +package com.bigkoo.pickerview.lib; | |
2 | + | |
3 | +import java.util.TimerTask; | |
4 | +/** | |
5 | + * @TODO<滚动惯性的实现> | |
6 | + * @author 小嵩 | |
7 | + */ | |
8 | +final class InertiaTimerTask extends TimerTask { | |
9 | + | |
10 | + float a; | |
11 | + final float velocityY; | |
12 | + final WheelView loopView; | |
13 | + | |
14 | + InertiaTimerTask(WheelView loopview, float velocityY) { | |
15 | + super(); | |
16 | + loopView = loopview; | |
17 | + this.velocityY = velocityY; | |
18 | + a = Integer.MAX_VALUE; | |
19 | + } | |
20 | + | |
21 | + @Override | |
22 | + public final void run() { | |
23 | + if (a == Integer.MAX_VALUE) { | |
24 | + if (Math.abs(velocityY) > 2000F) { | |
25 | + if (velocityY > 0.0F) { | |
26 | + a = 2000F; | |
27 | + } else { | |
28 | + a = -2000F; | |
29 | + } | |
30 | + } else { | |
31 | + a = velocityY; | |
32 | + } | |
33 | + } | |
34 | + if (Math.abs(a) >= 0.0F && Math.abs(a) <= 20F) { | |
35 | + loopView.cancelFuture(); | |
36 | + loopView.handler.sendEmptyMessage(MessageHandler.WHAT_SMOOTH_SCROLL); | |
37 | + return; | |
38 | + } | |
39 | + int i = (int) ((a * 10F) / 1000F); | |
40 | + loopView.totalScrollY = loopView.totalScrollY - i; | |
41 | + if (!loopView.isLoop) { | |
42 | + float itemHeight = loopView.itemHeight; | |
43 | + float top = (-loopView.initPosition) * itemHeight; | |
44 | + float bottom = (loopView.getItemsCount() - 1 - loopView.initPosition) * itemHeight; | |
45 | + if(loopView.totalScrollY - itemHeight*0.25 < top){ | |
46 | + top = loopView.totalScrollY + i; | |
47 | + } | |
48 | + else if(loopView.totalScrollY + itemHeight*0.25 > bottom){ | |
49 | + bottom = loopView.totalScrollY + i; | |
50 | + } | |
51 | + | |
52 | + if (loopView.totalScrollY <= top){ | |
53 | + a = 40F; | |
54 | + loopView.totalScrollY = (int)top; | |
55 | + } else if (loopView.totalScrollY >= bottom) { | |
56 | + loopView.totalScrollY = (int)bottom; | |
57 | + a = -40F; | |
58 | + } | |
59 | + } | |
60 | + if (a < 0.0F) { | |
61 | + a = a + 20F; | |
62 | + } else { | |
63 | + a = a - 20F; | |
64 | + } | |
65 | + loopView.handler.sendEmptyMessage(MessageHandler.WHAT_INVALIDATE_LOOP_VIEW); | |
66 | + } | |
67 | + | |
68 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/lib/LoopViewGestureListener.java
... | ... | @@ -0,0 +1,18 @@ |
1 | +package com.bigkoo.pickerview.lib; | |
2 | + | |
3 | +import android.view.MotionEvent; | |
4 | + | |
5 | +final class LoopViewGestureListener extends android.view.GestureDetector.SimpleOnGestureListener { | |
6 | + | |
7 | + final WheelView loopView; | |
8 | + | |
9 | + LoopViewGestureListener(WheelView loopview) { | |
10 | + loopView = loopview; | |
11 | + } | |
12 | + | |
13 | + @Override | |
14 | + public final boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { | |
15 | + loopView.scrollBy(velocityY); | |
16 | + return true; | |
17 | + } | |
18 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/lib/MessageHandler.java
... | ... | @@ -0,0 +1,34 @@ |
1 | +package com.bigkoo.pickerview.lib; | |
2 | + | |
3 | +import android.os.Handler; | |
4 | +import android.os.Message; | |
5 | + | |
6 | +final class MessageHandler extends Handler { | |
7 | + public static final int WHAT_INVALIDATE_LOOP_VIEW = 1000; | |
8 | + public static final int WHAT_SMOOTH_SCROLL = 2000; | |
9 | + public static final int WHAT_ITEM_SELECTED = 3000; | |
10 | + | |
11 | + final WheelView loopview; | |
12 | + | |
13 | + MessageHandler(WheelView loopview) { | |
14 | + this.loopview = loopview; | |
15 | + } | |
16 | + | |
17 | + @Override | |
18 | + public final void handleMessage(Message msg) { | |
19 | + switch (msg.what) { | |
20 | + case WHAT_INVALIDATE_LOOP_VIEW: | |
21 | + loopview.invalidate(); | |
22 | + break; | |
23 | + | |
24 | + case WHAT_SMOOTH_SCROLL: | |
25 | + loopview.smoothScroll(WheelView.ACTION.FLING); | |
26 | + break; | |
27 | + | |
28 | + case WHAT_ITEM_SELECTED: | |
29 | + loopview.onItemSelected(); | |
30 | + break; | |
31 | + } | |
32 | + } | |
33 | + | |
34 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/lib/OnItemSelectedRunnable.java
... | ... | @@ -0,0 +1,14 @@ |
1 | +package com.bigkoo.pickerview.lib; | |
2 | + | |
3 | +final class OnItemSelectedRunnable implements Runnable { | |
4 | + final WheelView loopView; | |
5 | + | |
6 | + OnItemSelectedRunnable(WheelView loopview) { | |
7 | + loopView = loopview; | |
8 | + } | |
9 | + | |
10 | + @Override | |
11 | + public final void run() { | |
12 | + loopView.onItemSelectedListener.onItemSelected(loopView.getCurrentItem()); | |
13 | + } | |
14 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/lib/SmoothScrollTimerTask.java
... | ... | @@ -0,0 +1,61 @@ |
1 | +package com.bigkoo.pickerview.lib; | |
2 | + | |
3 | +import java.util.TimerTask; | |
4 | + | |
5 | +/** | |
6 | + * @TODO<平滑滚动的实现> | |
7 | + * @author 小嵩 | |
8 | + */ | |
9 | +final class SmoothScrollTimerTask extends TimerTask { | |
10 | + | |
11 | + int realTotalOffset; | |
12 | + int realOffset; | |
13 | + int offset; | |
14 | + final WheelView loopView; | |
15 | + | |
16 | + SmoothScrollTimerTask(WheelView loopview, int offset) { | |
17 | + this.loopView = loopview; | |
18 | + this.offset = offset; | |
19 | + realTotalOffset = Integer.MAX_VALUE; | |
20 | + realOffset = 0; | |
21 | + } | |
22 | + | |
23 | + @Override | |
24 | + public final void run() { | |
25 | + if (realTotalOffset == Integer.MAX_VALUE) { | |
26 | + realTotalOffset = offset; | |
27 | + } | |
28 | + //把要滚动的范围细分成10小份,按10小份单位来重绘 | |
29 | + realOffset = (int) ((float) realTotalOffset * 0.1F); | |
30 | + | |
31 | + if (realOffset == 0) { | |
32 | + if (realTotalOffset < 0) { | |
33 | + realOffset = -1; | |
34 | + } else { | |
35 | + realOffset = 1; | |
36 | + } | |
37 | + } | |
38 | + | |
39 | + if (Math.abs(realTotalOffset) <= 1) { | |
40 | + loopView.cancelFuture(); | |
41 | + loopView.handler.sendEmptyMessage(MessageHandler.WHAT_ITEM_SELECTED); | |
42 | + } else { | |
43 | + loopView.totalScrollY = loopView.totalScrollY + realOffset; | |
44 | + | |
45 | + //这里如果不是循环模式,则点击空白位置需要回滚,不然就会出现选到-1 item的 情况 | |
46 | + if (!loopView.isLoop) { | |
47 | + float itemHeight = loopView.itemHeight; | |
48 | + float top = (float) (-loopView.initPosition) * itemHeight; | |
49 | + float bottom = (float) (loopView.getItemsCount() - 1 - loopView.initPosition) * itemHeight; | |
50 | + if (loopView.totalScrollY <= top||loopView.totalScrollY >= bottom) { | |
51 | + loopView.totalScrollY = loopView.totalScrollY - realOffset; | |
52 | + loopView.cancelFuture(); | |
53 | + loopView.handler.sendEmptyMessage(MessageHandler.WHAT_ITEM_SELECTED); | |
54 | + return; | |
55 | + } | |
56 | + } | |
57 | + loopView.handler.sendEmptyMessage(MessageHandler.WHAT_INVALIDATE_LOOP_VIEW); | |
58 | + realTotalOffset = realTotalOffset - realOffset; | |
59 | + } | |
60 | + } | |
61 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/lib/WheelView.java
... | ... | @@ -0,0 +1,779 @@ |
1 | +package com.bigkoo.pickerview.lib; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.content.res.TypedArray; | |
5 | +import android.graphics.Canvas; | |
6 | +import android.graphics.Paint; | |
7 | +import android.graphics.Rect; | |
8 | +import android.graphics.Typeface; | |
9 | +import android.os.Handler; | |
10 | +import android.text.TextUtils; | |
11 | +import android.util.AttributeSet; | |
12 | +import android.util.DisplayMetrics; | |
13 | +import android.util.Log; | |
14 | +import android.view.GestureDetector; | |
15 | +import android.view.Gravity; | |
16 | +import android.view.MotionEvent; | |
17 | +import android.view.View; | |
18 | + | |
19 | +import com.bigkoo.pickerview.R; | |
20 | +import com.bigkoo.pickerview.adapter.WheelAdapter; | |
21 | +import com.bigkoo.pickerview.listener.OnItemSelectedListener; | |
22 | +import com.bigkoo.pickerview.model.IPickerViewData; | |
23 | + | |
24 | +import java.util.Locale; | |
25 | +import java.util.concurrent.Executors; | |
26 | +import java.util.concurrent.ScheduledExecutorService; | |
27 | +import java.util.concurrent.ScheduledFuture; | |
28 | +import java.util.concurrent.TimeUnit; | |
29 | + | |
30 | +/** | |
31 | + * 3d滚轮控件 | |
32 | + */ | |
33 | +public class WheelView extends View { | |
34 | + | |
35 | + public enum ACTION { // 点击,滑翔(滑到尽头),拖拽事件 | |
36 | + CLICK, FLING, DAGGLE | |
37 | + } | |
38 | + public enum DividerType { // 分隔线类型 | |
39 | + FILL, WRAP | |
40 | + } | |
41 | + | |
42 | + private DividerType dividerType;//分隔线类型 | |
43 | + | |
44 | + Context context; | |
45 | + | |
46 | + Handler handler; | |
47 | + private GestureDetector gestureDetector; | |
48 | + OnItemSelectedListener onItemSelectedListener; | |
49 | + | |
50 | + private boolean isOptions = false; | |
51 | + private boolean isCenterLabel = true; | |
52 | + | |
53 | + // Timer mTimer; | |
54 | + ScheduledExecutorService mExecutor = Executors.newSingleThreadScheduledExecutor(); | |
55 | + private ScheduledFuture<?> mFuture; | |
56 | + | |
57 | + Paint paintOuterText; | |
58 | + Paint paintCenterText; | |
59 | + Paint paintIndicator; | |
60 | + | |
61 | + WheelAdapter adapter; | |
62 | + | |
63 | + private String label;//附加单位 | |
64 | + int textSize;//选项的文字大小 | |
65 | + int maxTextWidth; | |
66 | + int maxTextHeight; | |
67 | + float itemHeight;//每行高度 | |
68 | + | |
69 | + Typeface typeface = Typeface.MONOSPACE;//字体样式,默认是等宽字体 | |
70 | + | |
71 | + int textColorOut = 0xFFa8a8a8; | |
72 | + int textColorCenter = 0xFF2a2a2a; | |
73 | + int dividerColor = 0xFFd5d5d5; | |
74 | + | |
75 | + // 条目间距倍数 | |
76 | + float lineSpacingMultiplier = 1.6F; | |
77 | + boolean isLoop; | |
78 | + | |
79 | + // 第一条线Y坐标值 | |
80 | + float firstLineY; | |
81 | + //第二条线Y坐标 | |
82 | + float secondLineY; | |
83 | + //中间label绘制的Y坐标 | |
84 | + float centerY; | |
85 | + | |
86 | + //滚动总高度y值 | |
87 | + float totalScrollY; | |
88 | + //初始化默认选中项 | |
89 | + int initPosition; | |
90 | + //选中的Item是第几个 | |
91 | + private int selectedItem; | |
92 | + int preCurrentIndex; | |
93 | + //滚动偏移值,用于记录滚动了多少个item | |
94 | + int change; | |
95 | + | |
96 | + // 绘制几个条目,实际上第一项和最后一项Y轴压缩成0%了,所以可见的数目实际为9 | |
97 | + int itemsVisible = 11; | |
98 | + | |
99 | + int measuredHeight;// WheelView 控件高度 | |
100 | + int measuredWidth;// WheelView 控件宽度 | |
101 | + | |
102 | + // 半圆周长 | |
103 | + int halfCircumference; | |
104 | + // 半径 | |
105 | + int radius; | |
106 | + | |
107 | + private int mOffset = 0; | |
108 | + private float previousY = 0; | |
109 | + long startTime = 0; | |
110 | + | |
111 | + // 修改这个值可以改变滑行速度 | |
112 | + private static final int VELOCITYFLING = 5; | |
113 | + int widthMeasureSpec; | |
114 | + | |
115 | + private int mGravity = Gravity.CENTER; | |
116 | + private int drawCenterContentStart = 0;//中间选中文字开始绘制位置 | |
117 | + private int drawOutContentStart = 0;//非中间文字开始绘制位置 | |
118 | + private static final float SCALECONTENT = 0.8F;//非中间文字则用此控制高度,压扁形成3d错觉 | |
119 | + private float CENTERCONTENTOFFSET ;//偏移量 | |
120 | + | |
121 | + public WheelView(Context context) { | |
122 | + this(context, null); | |
123 | + } | |
124 | + | |
125 | + public WheelView(Context context, AttributeSet attrs) { | |
126 | + super(context, attrs); | |
127 | + /* textColorOut = getResources().getColor(R.color.pickerview_wheelview_textcolor_out); | |
128 | + textColorCenter =getResources().getColor(R.color.pickerview_wheelview_textcolor_center); | |
129 | + dividerColor = getResources().getColor(R.color.pickerview_wheelview_textcolor_out);*/ | |
130 | + | |
131 | + textSize = getResources().getDimensionPixelSize(R.dimen.pickerview_textsize);//默认大小 | |
132 | + | |
133 | + DisplayMetrics dm = getResources().getDisplayMetrics(); | |
134 | + float density = dm.density; // 屏幕密度(0.75/1.0/1.5/2.0/3.0) | |
135 | + | |
136 | + if (density<1){//根据密度不同进行适配 | |
137 | + CENTERCONTENTOFFSET=2.4F; | |
138 | + }else if (1<=density&&density<2){ | |
139 | + CENTERCONTENTOFFSET = 3.6F; | |
140 | + }else if (1<=density&&density<2){ | |
141 | + CENTERCONTENTOFFSET = 4.5F; | |
142 | + }else if (2<=density&&density<3){ | |
143 | + CENTERCONTENTOFFSET = 6.0F; | |
144 | + }else if (density>=3){ | |
145 | + CENTERCONTENTOFFSET= density * 2.5F; | |
146 | + } | |
147 | + | |
148 | + | |
149 | + if (attrs != null) { | |
150 | + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.pickerview, 0, 0); | |
151 | + mGravity = a.getInt(R.styleable.pickerview_pickerview_gravity, Gravity.CENTER); | |
152 | + textColorOut = a.getColor(R.styleable.pickerview_pickerview_textColorOut, textColorOut); | |
153 | + textColorCenter = a.getColor(R.styleable.pickerview_pickerview_textColorCenter, textColorCenter); | |
154 | + dividerColor = a.getColor(R.styleable.pickerview_pickerview_dividerColor, dividerColor); | |
155 | + textSize = a.getDimensionPixelOffset(R.styleable.pickerview_pickerview_textSize, textSize); | |
156 | + lineSpacingMultiplier = a.getFloat(R.styleable.pickerview_pickerview_lineSpacingMultiplier, lineSpacingMultiplier); | |
157 | + a.recycle();//回收内存 | |
158 | + } | |
159 | + | |
160 | + judgeLineSpae(); | |
161 | + | |
162 | + initLoopView(context); | |
163 | + } | |
164 | + | |
165 | + /** | |
166 | + * 判断间距是否在1.0-2.0之间 | |
167 | + */ | |
168 | + private void judgeLineSpae() { | |
169 | + if (lineSpacingMultiplier < 1.2f) { | |
170 | + lineSpacingMultiplier = 1.2f; | |
171 | + } else if (lineSpacingMultiplier > 2.0f) { | |
172 | + lineSpacingMultiplier = 2.0f; | |
173 | + } | |
174 | + } | |
175 | + | |
176 | + private void initLoopView(Context context) { | |
177 | + this.context = context; | |
178 | + handler = new MessageHandler(this); | |
179 | + gestureDetector = new GestureDetector(context, new LoopViewGestureListener(this)); | |
180 | + gestureDetector.setIsLongpressEnabled(false); | |
181 | + | |
182 | + isLoop = true; | |
183 | + | |
184 | + totalScrollY = 0; | |
185 | + initPosition = -1; | |
186 | + | |
187 | + initPaints(); | |
188 | + | |
189 | + } | |
190 | + | |
191 | + private void initPaints() { | |
192 | + paintOuterText = new Paint(); | |
193 | + paintOuterText.setColor(textColorOut); | |
194 | + paintOuterText.setAntiAlias(true); | |
195 | + paintOuterText.setTypeface(typeface); | |
196 | + paintOuterText.setTextSize(textSize); | |
197 | + | |
198 | + paintCenterText = new Paint(); | |
199 | + paintCenterText.setColor(textColorCenter); | |
200 | + paintCenterText.setAntiAlias(true); | |
201 | + paintCenterText.setTextScaleX(1.1F); | |
202 | + paintCenterText.setTypeface(typeface); | |
203 | + paintCenterText.setTextSize(textSize); | |
204 | + | |
205 | + | |
206 | + paintIndicator = new Paint(); | |
207 | + paintIndicator.setColor(dividerColor); | |
208 | + paintIndicator.setAntiAlias(true); | |
209 | + | |
210 | + if (android.os.Build.VERSION.SDK_INT >= 11) { | |
211 | + setLayerType(LAYER_TYPE_SOFTWARE, null); | |
212 | + } | |
213 | + } | |
214 | + | |
215 | + private void remeasure() {//重新测量 | |
216 | + if (adapter == null) { | |
217 | + return; | |
218 | + } | |
219 | + | |
220 | + measureTextWidthHeight(); | |
221 | + | |
222 | + //半圆的周长 = item高度乘以item数目-1 | |
223 | + halfCircumference = (int) (itemHeight * (itemsVisible - 1)); | |
224 | + //整个圆的周长除以PI得到直径,这个直径用作控件的总高度 | |
225 | + measuredHeight = (int) ((halfCircumference * 2) / Math.PI); | |
226 | + //求出半径 | |
227 | + radius = (int) (halfCircumference / Math.PI); | |
228 | + //控件宽度,这里支持weight | |
229 | + measuredWidth = MeasureSpec.getSize(widthMeasureSpec); | |
230 | + //计算两条横线 和 选中项画笔的基线Y位置 | |
231 | + firstLineY = (measuredHeight - itemHeight) / 2.0F; | |
232 | + secondLineY = (measuredHeight + itemHeight) / 2.0F; | |
233 | + centerY = secondLineY - (itemHeight-maxTextHeight)/2.0f - CENTERCONTENTOFFSET; | |
234 | + | |
235 | + //初始化显示的item的position | |
236 | + if (initPosition == -1) { | |
237 | + if (isLoop) { | |
238 | + initPosition = (adapter.getItemsCount() + 1) / 2; | |
239 | + } else { | |
240 | + initPosition = 0; | |
241 | + } | |
242 | + } | |
243 | + preCurrentIndex = initPosition; | |
244 | + } | |
245 | + | |
246 | + /** | |
247 | + * 计算最大length的Text的宽高度 | |
248 | + */ | |
249 | + private void measureTextWidthHeight() { | |
250 | + Rect rect = new Rect(); | |
251 | + for (int i = 0; i < adapter.getItemsCount(); i++) { | |
252 | + String s1 = getContentText(adapter.getItem(i)); | |
253 | + paintCenterText.getTextBounds(s1, 0, s1.length(), rect); | |
254 | + | |
255 | + int textWidth = rect.width(); | |
256 | + | |
257 | + if (textWidth > maxTextWidth) { | |
258 | + maxTextWidth = textWidth; | |
259 | + } | |
260 | + paintCenterText.getTextBounds("\u661F\u671F", 0, 2, rect); // 星期的字符编码(以它为标准高度) | |
261 | + | |
262 | + maxTextHeight = rect.height() + 2; | |
263 | + | |
264 | + } | |
265 | + itemHeight = lineSpacingMultiplier * maxTextHeight; | |
266 | + } | |
267 | + | |
268 | + void smoothScroll(ACTION action) {//平滑滚动的实现 | |
269 | + cancelFuture(); | |
270 | + if (action == ACTION.FLING || action == ACTION.DAGGLE) { | |
271 | + mOffset = (int) ((totalScrollY % itemHeight + itemHeight) % itemHeight); | |
272 | + if ((float) mOffset > itemHeight / 2.0F) {//如果超过Item高度的一半,滚动到下一个Item去 | |
273 | + mOffset = (int) (itemHeight - (float) mOffset); | |
274 | + } else { | |
275 | + mOffset = -mOffset; | |
276 | + } | |
277 | + } | |
278 | + //停止的时候,位置有偏移,不是全部都能正确停止到中间位置的,这里把文字位置挪回中间去 | |
279 | + mFuture = mExecutor.scheduleWithFixedDelay(new SmoothScrollTimerTask(this, mOffset), 0, 10, TimeUnit.MILLISECONDS); | |
280 | + } | |
281 | + | |
282 | + protected final void scrollBy(float velocityY) {//滚动惯性的实现 | |
283 | + cancelFuture(); | |
284 | + mFuture = mExecutor.scheduleWithFixedDelay(new InertiaTimerTask(this, velocityY), 0, VELOCITYFLING, TimeUnit.MILLISECONDS); | |
285 | + } | |
286 | + | |
287 | + public void cancelFuture() { | |
288 | + if (mFuture != null && !mFuture.isCancelled()) { | |
289 | + mFuture.cancel(true); | |
290 | + mFuture = null; | |
291 | + } | |
292 | + } | |
293 | + | |
294 | + /** | |
295 | + * 设置是否循环滚动 | |
296 | + * | |
297 | + * @param cyclic 是否循环 | |
298 | + */ | |
299 | + public final void setCyclic(boolean cyclic) { | |
300 | + isLoop = cyclic; | |
301 | + } | |
302 | + | |
303 | + public final void setTypeface(Typeface font) { | |
304 | + typeface = font; | |
305 | + paintOuterText.setTypeface(typeface); | |
306 | + paintCenterText.setTypeface(typeface); | |
307 | + } | |
308 | + | |
309 | + public final void setTextSize(float size) { | |
310 | + if (size > 0.0F ) { | |
311 | + textSize = (int) (context.getResources().getDisplayMetrics().density * size); | |
312 | + paintOuterText.setTextSize(textSize); | |
313 | + paintCenterText.setTextSize(textSize); | |
314 | + } | |
315 | + } | |
316 | + | |
317 | + public final void setCurrentItem(int currentItem) { | |
318 | + //不添加这句,当这个wheelview不可见时,默认都是0,会导致获取到的时间错误 | |
319 | + this.selectedItem = currentItem; | |
320 | + this.initPosition = currentItem; | |
321 | + totalScrollY = 0;//回归顶部,不然重设setCurrentItem的话位置会偏移的,就会显示出不对位置的数据 | |
322 | + invalidate(); | |
323 | + } | |
324 | + | |
325 | + public final void setOnItemSelectedListener(OnItemSelectedListener OnItemSelectedListener) { | |
326 | + this.onItemSelectedListener = OnItemSelectedListener; | |
327 | + } | |
328 | + | |
329 | + public final void setAdapter(WheelAdapter adapter) { | |
330 | + this.adapter = adapter; | |
331 | + remeasure(); | |
332 | + invalidate(); | |
333 | + } | |
334 | + | |
335 | + public final WheelAdapter getAdapter() { | |
336 | + return adapter; | |
337 | + } | |
338 | + | |
339 | + public final int getCurrentItem() { | |
340 | + return selectedItem; | |
341 | + } | |
342 | + | |
343 | + protected final void onItemSelected() { | |
344 | + if (onItemSelectedListener != null) { | |
345 | + postDelayed(new OnItemSelectedRunnable(this), 200L); | |
346 | + } | |
347 | + } | |
348 | + | |
349 | + @Override | |
350 | + protected void onDraw(Canvas canvas) { | |
351 | + if (adapter == null) { | |
352 | + return; | |
353 | + } | |
354 | + //initPosition越界会造成preCurrentIndex的值不正确 | |
355 | + if(initPosition<0) | |
356 | + { | |
357 | + initPosition = 0; | |
358 | + } | |
359 | + if(initPosition>=adapter.getItemsCount()) | |
360 | + { | |
361 | + initPosition = adapter.getItemsCount()-1; | |
362 | + } | |
363 | + //可见的item数组 | |
364 | + Object visibles[] = new Object[itemsVisible]; | |
365 | + //滚动的Y值高度除去每行Item的高度,得到滚动了多少个item,即change数 | |
366 | + change = (int)(totalScrollY / itemHeight); | |
367 | + | |
368 | + try { | |
369 | + //滚动中实际的预选中的item(即经过了中间位置的item) = 滑动前的位置 + 滑动相对位置 | |
370 | + preCurrentIndex = initPosition + change % adapter.getItemsCount(); | |
371 | + | |
372 | + } catch (ArithmeticException e) { | |
373 | + Log.e("WheelView","出错了!adapter.getItemsCount() == 0,联动数据不匹配"); | |
374 | + } | |
375 | + if (!isLoop) {//不循环的情况 | |
376 | + if (preCurrentIndex < 0) { | |
377 | + preCurrentIndex = 0; | |
378 | + } | |
379 | + if (preCurrentIndex > adapter.getItemsCount() - 1) { | |
380 | + preCurrentIndex = adapter.getItemsCount() - 1; | |
381 | + } | |
382 | + } else {//循环 | |
383 | + if (preCurrentIndex < 0) {//举个例子:如果总数是5,preCurrentIndex = -1,那么preCurrentIndex按循环来说,其实是0的上面,也就是4的位置 | |
384 | + preCurrentIndex = adapter.getItemsCount() + preCurrentIndex; | |
385 | + } | |
386 | + if (preCurrentIndex > adapter.getItemsCount() - 1) {//同理上面,自己脑补一下 | |
387 | + preCurrentIndex = preCurrentIndex - adapter.getItemsCount(); | |
388 | + } | |
389 | + } | |
390 | + //跟滚动流畅度有关,总滑动距离与每个item高度取余,即并不是一格格的滚动,每个item不一定滚到对应Rect里的,这个item对应格子的偏移值 | |
391 | + float itemHeightOffset = (totalScrollY % itemHeight); | |
392 | + | |
393 | + // 设置数组中每个元素的值 | |
394 | + int counter = 0; | |
395 | + while (counter < itemsVisible) { | |
396 | + int index = preCurrentIndex - (itemsVisible / 2 - counter);//索引值,即当前在控件中间的item看作数据源的中间,计算出相对源数据源的index值 | |
397 | + //判断是否循环,如果是循环数据源也使用相对循环的position获取对应的item值,如果不是循环则超出数据源范围使用""空白字符串填充,在界面上形成空白无数据的item项 | |
398 | + if (isLoop) { | |
399 | + index = getLoopMappingIndex(index); | |
400 | + visibles[counter] = adapter.getItem(index); | |
401 | + } else if (index < 0) { | |
402 | + visibles[counter] = ""; | |
403 | + } else if (index > adapter.getItemsCount() - 1) { | |
404 | + visibles[counter] = ""; | |
405 | + } else { | |
406 | + visibles[counter] = adapter.getItem(index); | |
407 | + } | |
408 | + | |
409 | + counter++; | |
410 | + | |
411 | + } | |
412 | + | |
413 | + //绘制中间两条横线 | |
414 | + if (dividerType == DividerType.WRAP){//横线长度仅包裹内容 | |
415 | + float startX; | |
416 | + float endX; | |
417 | + | |
418 | + if (TextUtils.isEmpty(label)){//隐藏Label的情况 | |
419 | + startX = (measuredWidth - maxTextWidth)/2 - 12; | |
420 | + }else { | |
421 | + startX = (measuredWidth - maxTextWidth)/4 - 12; | |
422 | + } | |
423 | + | |
424 | + if (startX<=0){//如果超过了WheelView的边缘 | |
425 | + startX = 10; | |
426 | + } | |
427 | + endX = measuredWidth - startX; | |
428 | + canvas.drawLine(startX, firstLineY, endX, firstLineY, paintIndicator); | |
429 | + canvas.drawLine(startX, secondLineY, endX, secondLineY, paintIndicator); | |
430 | + }else { | |
431 | + canvas.drawLine(0.0F, firstLineY, measuredWidth, firstLineY, paintIndicator); | |
432 | + canvas.drawLine(0.0F, secondLineY, measuredWidth, secondLineY, paintIndicator); | |
433 | + } | |
434 | + | |
435 | + //只显示选中项Label文字的模式,并且Label文字不为空,则进行绘制 | |
436 | + if (!TextUtils.isEmpty(label)&& isCenterLabel) { | |
437 | + //绘制文字,靠右并留出空隙 | |
438 | + int drawRightContentStart = measuredWidth - getTextWidth(paintCenterText, label); | |
439 | + canvas.drawText(label, drawRightContentStart - CENTERCONTENTOFFSET, centerY, paintCenterText); | |
440 | + } | |
441 | + | |
442 | + counter = 0; | |
443 | + while (counter < itemsVisible) { | |
444 | + canvas.save(); | |
445 | + // 弧长 L = itemHeight * counter - itemHeightOffset | |
446 | + // 求弧度 α = L / r (弧长/半径) [0,π] | |
447 | + double radian = ((itemHeight * counter - itemHeightOffset)) / radius; | |
448 | + // 弧度转换成角度(把半圆以Y轴为轴心向右转90度,使其处于第一象限及第四象限 | |
449 | + // angle [-90°,90°] | |
450 | + float angle = (float) (90D - (radian / Math.PI) * 180D);//item第一项,从90度开始,逐渐递减到 -90度 | |
451 | + | |
452 | + // 计算取值可能有细微偏差,保证负90°到90°以外的不绘制 | |
453 | + if (angle >= 90F || angle <= -90F) { | |
454 | + canvas.restore(); | |
455 | + } else { | |
456 | + //获取内容文字 | |
457 | + String contentText; | |
458 | + | |
459 | + //如果是label每项都显示的模式,并且item内容不为空、label 也不为空 | |
460 | + if(!isCenterLabel&&!TextUtils.isEmpty(label) &&!TextUtils.isEmpty(getContentText(visibles[counter]))){ | |
461 | + contentText = getContentText(visibles[counter])+label; | |
462 | + }else { | |
463 | + contentText = getContentText(visibles[counter]); | |
464 | + } | |
465 | + | |
466 | + reMeasureTextSize(contentText); | |
467 | + //计算开始绘制的位置 | |
468 | + measuredCenterContentStart(contentText); | |
469 | + measuredOutContentStart(contentText); | |
470 | + float translateY = (float) (radius - Math.cos(radian) * radius - (Math.sin(radian) * maxTextHeight) / 2D); | |
471 | + //根据Math.sin(radian)来更改canvas坐标系原点,然后缩放画布,使得文字高度进行缩放,形成弧形3d视觉差 | |
472 | + canvas.translate(0.0F, translateY); | |
473 | + canvas.scale(1.0F, (float) Math.sin(radian)); | |
474 | + if (translateY <= firstLineY && maxTextHeight + translateY >= firstLineY) { | |
475 | + // 条目经过第一条线 | |
476 | + canvas.save(); | |
477 | + canvas.clipRect(0, 0, measuredWidth, firstLineY - translateY); | |
478 | + canvas.scale(1.0F, (float) Math.sin(radian) * SCALECONTENT); | |
479 | + canvas.drawText(contentText, drawOutContentStart, maxTextHeight, paintOuterText); | |
480 | + canvas.restore(); | |
481 | + canvas.save(); | |
482 | + canvas.clipRect(0, firstLineY - translateY, measuredWidth, (int) (itemHeight)); | |
483 | + canvas.scale(1.0F, (float) Math.sin(radian) * 1.0F); | |
484 | + canvas.drawText(contentText, drawCenterContentStart, maxTextHeight - CENTERCONTENTOFFSET, paintCenterText); | |
485 | + canvas.restore(); | |
486 | + } else if (translateY <= secondLineY && maxTextHeight + translateY >= secondLineY) { | |
487 | + // 条目经过第二条线 | |
488 | + canvas.save(); | |
489 | + canvas.clipRect(0, 0, measuredWidth, secondLineY - translateY); | |
490 | + canvas.scale(1.0F, (float) Math.sin(radian) * 1.0F); | |
491 | + canvas.drawText(contentText, drawCenterContentStart, maxTextHeight - CENTERCONTENTOFFSET, paintCenterText); | |
492 | + canvas.restore(); | |
493 | + canvas.save(); | |
494 | + canvas.clipRect(0, secondLineY - translateY, measuredWidth, (int) (itemHeight)); | |
495 | + canvas.scale(1.0F, (float) Math.sin(radian) * SCALECONTENT); | |
496 | + canvas.drawText(contentText, drawOutContentStart, maxTextHeight, paintOuterText); | |
497 | + canvas.restore(); | |
498 | + } else if (translateY >= firstLineY && maxTextHeight + translateY <= secondLineY) { | |
499 | + // 中间条目 | |
500 | + //canvas.clipRect(0, 0, measuredWidth, maxTextHeight); | |
501 | + //让文字居中 | |
502 | + float Y = maxTextHeight - CENTERCONTENTOFFSET;//因为圆弧角换算的向下取值,导致角度稍微有点偏差,加上画笔的基线会偏上,因此需要偏移量修正一下 | |
503 | + canvas.drawText(contentText, drawCenterContentStart, Y, paintCenterText); | |
504 | + | |
505 | + int preSelectedItem = adapter.indexOf(visibles[counter]); | |
506 | + | |
507 | + selectedItem = preSelectedItem; | |
508 | + | |
509 | + } else { | |
510 | + // 其他条目 | |
511 | + canvas.save(); | |
512 | + canvas.clipRect(0, 0, measuredWidth, (int) (itemHeight)); | |
513 | + canvas.scale(1.0F, (float) Math.sin(radian) * SCALECONTENT); | |
514 | + canvas.drawText(contentText, drawOutContentStart, maxTextHeight, paintOuterText); | |
515 | + canvas.restore(); | |
516 | + } | |
517 | + canvas.restore(); | |
518 | + paintCenterText.setTextSize(textSize); | |
519 | + } | |
520 | + counter++; | |
521 | + } | |
522 | + } | |
523 | + | |
524 | + /** | |
525 | + * 根据文字的长度 重新设置文字的大小 让其能完全显示 | |
526 | + * @param contentText | |
527 | + */ | |
528 | + private void reMeasureTextSize(String contentText) { | |
529 | + Rect rect = new Rect(); | |
530 | + paintCenterText.getTextBounds(contentText, 0, contentText.length(), rect); | |
531 | + int width = rect.width(); | |
532 | + int size = textSize; | |
533 | + while (width > measuredWidth) { | |
534 | + size--; | |
535 | + //设置2条横线中间的文字大小 | |
536 | + paintCenterText.setTextSize(size); | |
537 | + paintCenterText.getTextBounds(contentText, 0, contentText.length(), rect); | |
538 | + width = rect.width(); | |
539 | + } | |
540 | + //设置2条横线外面的文字大小 | |
541 | + paintOuterText.setTextSize(size); | |
542 | + } | |
543 | + | |
544 | + | |
545 | + //递归计算出对应的index | |
546 | + private int getLoopMappingIndex(int index) { | |
547 | + if (index < 0) { | |
548 | + index = index + adapter.getItemsCount(); | |
549 | + index = getLoopMappingIndex(index); | |
550 | + } else if (index > adapter.getItemsCount() - 1) { | |
551 | + index = index - adapter.getItemsCount(); | |
552 | + index = getLoopMappingIndex(index); | |
553 | + } | |
554 | + return index; | |
555 | + } | |
556 | + | |
557 | + /** | |
558 | + * 根据传进来的对象获取getPickerViewText()方法,来获取需要显示的值 | |
559 | + * | |
560 | + * @param item 数据源的item | |
561 | + * @return 对应显示的字符串 | |
562 | + */ | |
563 | + private String getContentText(Object item) { | |
564 | + if (item == null) { | |
565 | + return ""; | |
566 | + } else if (item instanceof IPickerViewData) { | |
567 | + return ((IPickerViewData) item).getPickerViewText(); | |
568 | + } else if (item instanceof Integer) { | |
569 | + //如果为整形则最少保留两位数. | |
570 | + return String.format(Locale.getDefault(), "%02d", (int) item); | |
571 | + } | |
572 | + return item.toString(); | |
573 | + } | |
574 | + | |
575 | + private void measuredCenterContentStart(String content) { | |
576 | + Rect rect = new Rect(); | |
577 | + paintCenterText.getTextBounds(content, 0, content.length(), rect); | |
578 | + switch (mGravity) { | |
579 | + case Gravity.CENTER://显示内容居中 | |
580 | + if (isOptions||label == null|| label.equals("")||!isCenterLabel) { | |
581 | + drawCenterContentStart = (int) ((measuredWidth - rect.width()) * 0.5); | |
582 | + } else {//只显示中间label时,时间选择器内容偏左一点,留出空间绘制单位标签 | |
583 | + drawCenterContentStart = (int) ((measuredWidth - rect.width()) * 0.25); | |
584 | + } | |
585 | + break; | |
586 | + case Gravity.LEFT: | |
587 | + drawCenterContentStart = 0; | |
588 | + break; | |
589 | + case Gravity.RIGHT://添加偏移量 | |
590 | + drawCenterContentStart = measuredWidth - rect.width() -(int)CENTERCONTENTOFFSET; | |
591 | + break; | |
592 | + } | |
593 | + } | |
594 | + | |
595 | + private void measuredOutContentStart(String content) { | |
596 | + Rect rect = new Rect(); | |
597 | + paintOuterText.getTextBounds(content, 0, content.length(), rect); | |
598 | + switch (mGravity) { | |
599 | + case Gravity.CENTER: | |
600 | + if (isOptions||label == null|| label.equals("")||!isCenterLabel) { | |
601 | + drawOutContentStart = (int) ((measuredWidth - rect.width()) * 0.5); | |
602 | + } else {//只显示中间label时,时间选择器内容偏左一点,留出空间绘制单位标签 | |
603 | + drawOutContentStart = (int) ((measuredWidth - rect.width()) * 0.25); | |
604 | + } | |
605 | + break; | |
606 | + case Gravity.LEFT: | |
607 | + drawOutContentStart = 0; | |
608 | + break; | |
609 | + case Gravity.RIGHT: | |
610 | + drawOutContentStart = measuredWidth - rect.width()-(int)CENTERCONTENTOFFSET; | |
611 | + break; | |
612 | + } | |
613 | + } | |
614 | + | |
615 | + @Override | |
616 | + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |
617 | + this.widthMeasureSpec = widthMeasureSpec; | |
618 | + remeasure(); | |
619 | + setMeasuredDimension(measuredWidth, measuredHeight); | |
620 | + } | |
621 | + | |
622 | + @Override | |
623 | + public boolean onTouchEvent(MotionEvent event) { | |
624 | + boolean eventConsumed = gestureDetector.onTouchEvent(event); | |
625 | + switch (event.getAction()) { | |
626 | + //按下 | |
627 | + case MotionEvent.ACTION_DOWN: | |
628 | + startTime = System.currentTimeMillis(); | |
629 | + cancelFuture(); | |
630 | + previousY = event.getRawY(); | |
631 | + break; | |
632 | + //滑动中 | |
633 | + case MotionEvent.ACTION_MOVE: | |
634 | + | |
635 | + float dy = previousY - event.getRawY(); | |
636 | + previousY = event.getRawY(); | |
637 | + totalScrollY = totalScrollY + dy; | |
638 | + | |
639 | + // 边界处理。 | |
640 | + if (!isLoop) { | |
641 | + float top = -initPosition * itemHeight; | |
642 | + float bottom = (adapter.getItemsCount() - 1 - initPosition) * itemHeight; | |
643 | + | |
644 | + | |
645 | + if (totalScrollY - itemHeight * 0.25 < top) { | |
646 | + top = totalScrollY - dy; | |
647 | + } else if (totalScrollY + itemHeight * 0.25 > bottom) { | |
648 | + bottom = totalScrollY - dy; | |
649 | + } | |
650 | + | |
651 | + if (totalScrollY < top) { | |
652 | + totalScrollY = (int) top; | |
653 | + } else if (totalScrollY > bottom) { | |
654 | + totalScrollY = (int) bottom; | |
655 | + } | |
656 | + } | |
657 | + break; | |
658 | + //完成滑动,手指离开屏幕 | |
659 | + case MotionEvent.ACTION_UP: | |
660 | + | |
661 | + default: | |
662 | + if (!eventConsumed) {//未消费掉事件 | |
663 | + | |
664 | + /** | |
665 | + * TODO<关于弧长的计算> | |
666 | + * | |
667 | + * 弧长公式: L = α*R | |
668 | + * 反余弦公式:arccos(cosα) = α | |
669 | + * 由于之前是有顺时针偏移90度, | |
670 | + * 所以实际弧度范围α2的值 :α2 = π/2-α (α=[0,π] α2 = [-π/2,π/2]) | |
671 | + * 根据正弦余弦转换公式 cosα = sin(π/2-α) | |
672 | + * 代入,得: cosα = sin(π/2-α) = sinα2 = (R - y) / R | |
673 | + * 所以弧长 L = arccos(cosα)*R = arccos((R - y) / R)*R | |
674 | + */ | |
675 | + | |
676 | + float y = event.getY(); | |
677 | + double L = Math.acos((radius - y) / radius) * radius; | |
678 | + //item0 有一半是在不可见区域,所以需要加上 itemHeight / 2 | |
679 | + int circlePosition = (int) ((L + itemHeight / 2) / itemHeight); | |
680 | + float extraOffset = (totalScrollY % itemHeight + itemHeight) % itemHeight; | |
681 | + //已滑动的弧长值 | |
682 | + mOffset = (int) ((circlePosition - itemsVisible / 2) * itemHeight - extraOffset); | |
683 | + | |
684 | + if ((System.currentTimeMillis() - startTime) > 120) { | |
685 | + // 处理拖拽事件 | |
686 | + smoothScroll(ACTION.DAGGLE); | |
687 | + } else { | |
688 | + // 处理条目点击事件 | |
689 | + smoothScroll(ACTION.CLICK); | |
690 | + } | |
691 | + } | |
692 | + break; | |
693 | + } | |
694 | + | |
695 | + invalidate(); | |
696 | + return true; | |
697 | + } | |
698 | + | |
699 | + /** | |
700 | + * 获取Item个数 | |
701 | + * | |
702 | + * @return item个数 | |
703 | + */ | |
704 | + public int getItemsCount() { | |
705 | + return adapter != null ? adapter.getItemsCount() : 0; | |
706 | + } | |
707 | + | |
708 | + /** | |
709 | + * 附加在右边的单位字符串 | |
710 | + * | |
711 | + * @param label 单位 | |
712 | + */ | |
713 | + public void setLabel(String label) { | |
714 | + this.label = label; | |
715 | + } | |
716 | + | |
717 | + public void isCenterLabel(Boolean isCenterLabel) { | |
718 | + this.isCenterLabel = isCenterLabel; | |
719 | + } | |
720 | + | |
721 | + public void setGravity(int gravity) { | |
722 | + this.mGravity = gravity; | |
723 | + } | |
724 | + | |
725 | + public int getTextWidth(Paint paint, String str) {//计算文字宽度 | |
726 | + int iRet = 0; | |
727 | + if (str != null && str.length() > 0) { | |
728 | + int len = str.length(); | |
729 | + float[] widths = new float[len]; | |
730 | + paint.getTextWidths(str, widths); | |
731 | + for (int j = 0; j < len; j++) { | |
732 | + iRet += (int) Math.ceil(widths[j]); | |
733 | + } | |
734 | + } | |
735 | + return iRet; | |
736 | + } | |
737 | + | |
738 | + public void setIsOptions(boolean options) { | |
739 | + isOptions = options; | |
740 | + } | |
741 | + | |
742 | + | |
743 | + public void setTextColorOut(int textColorOut) { | |
744 | + if (textColorOut != 0) { | |
745 | + this.textColorOut = textColorOut; | |
746 | + paintOuterText.setColor(this.textColorOut); | |
747 | + } | |
748 | + } | |
749 | + | |
750 | + public void setTextColorCenter(int textColorCenter) { | |
751 | + if (textColorCenter != 0) { | |
752 | + | |
753 | + this.textColorCenter = textColorCenter; | |
754 | + paintCenterText.setColor(this.textColorCenter); | |
755 | + } | |
756 | + } | |
757 | + | |
758 | + public void setDividerColor(int dividerColor) { | |
759 | + if (dividerColor != 0) { | |
760 | + this.dividerColor = dividerColor; | |
761 | + paintIndicator.setColor(this.dividerColor); | |
762 | + } | |
763 | + } | |
764 | + public void setDividerType(DividerType dividerType) { | |
765 | + this.dividerType = dividerType; | |
766 | + } | |
767 | + | |
768 | + public void setLineSpacingMultiplier(float lineSpacingMultiplier) { | |
769 | + if (lineSpacingMultiplier != 0) { | |
770 | + | |
771 | + | |
772 | + this.lineSpacingMultiplier = lineSpacingMultiplier; | |
773 | + judgeLineSpae(); | |
774 | + | |
775 | + } | |
776 | + } | |
777 | + | |
778 | + | |
779 | +} | |
0 | 780 | \ No newline at end of file | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/listener/CustomListener.java
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/listener/OnDismissListener.java
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/listener/OnItemSelectedListener.java
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/model/IPickerViewData.java
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/utils/PickerViewAnimateUtil.java
... | ... | @@ -0,0 +1,26 @@ |
1 | +package com.bigkoo.pickerview.utils; | |
2 | + | |
3 | +import android.view.Gravity; | |
4 | + | |
5 | +import com.bigkoo.pickerview.R; | |
6 | + | |
7 | +/** | |
8 | + * Created by Sai on 15/8/9. | |
9 | + */ | |
10 | +public class PickerViewAnimateUtil { | |
11 | + private static final int INVALID = -1; | |
12 | + /** | |
13 | + * Get default animation resource when not defined by the user | |
14 | + * | |
15 | + * @param gravity the gravity of the dialog | |
16 | + * @param isInAnimation determine if is in or out animation. true when is is | |
17 | + * @return the id of the animation resource | |
18 | + */ | |
19 | + public static int getAnimationResource(int gravity, boolean isInAnimation) { | |
20 | + switch (gravity) { | |
21 | + case Gravity.BOTTOM: | |
22 | + return isInAnimation ? R.anim.pickerview_slide_in_bottom : R.anim.pickerview_slide_out_bottom; | |
23 | + } | |
24 | + return INVALID; | |
25 | + } | |
26 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/view/BasePickerView.java
... | ... | @@ -0,0 +1,358 @@ |
1 | +package com.bigkoo.pickerview.view; | |
2 | + | |
3 | +import android.app.Activity; | |
4 | +import android.app.Dialog; | |
5 | +import android.content.Context; | |
6 | +import android.content.DialogInterface; | |
7 | +import android.graphics.Color; | |
8 | +import android.view.Gravity; | |
9 | +import android.view.KeyEvent; | |
10 | +import android.view.LayoutInflater; | |
11 | +import android.view.MotionEvent; | |
12 | +import android.view.View; | |
13 | +import android.view.ViewGroup; | |
14 | +import android.view.animation.Animation; | |
15 | +import android.view.animation.AnimationUtils; | |
16 | +import android.widget.FrameLayout; | |
17 | + | |
18 | +import com.bigkoo.pickerview.R; | |
19 | +import com.bigkoo.pickerview.listener.OnDismissListener; | |
20 | +import com.bigkoo.pickerview.utils.PickerViewAnimateUtil; | |
21 | + | |
22 | +/** | |
23 | + * Created by Sai on 15/11/22. | |
24 | + * 精仿iOSPickerViewController控件 | |
25 | + */ | |
26 | +public class BasePickerView { | |
27 | + private final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( | |
28 | + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | |
29 | + ); | |
30 | + | |
31 | + private Context context; | |
32 | + protected ViewGroup contentContainer; | |
33 | + public ViewGroup decorView;//显示pickerview的根View,默认是activity的根view | |
34 | + private ViewGroup rootView;//附加View 的 根View | |
35 | + private ViewGroup dialogView;//附加Dialog 的 根View | |
36 | + | |
37 | + protected int pickerview_timebtn_nor = 0xFF057dff; | |
38 | + protected int pickerview_timebtn_pre = 0xFFc2daf5; | |
39 | + protected int pickerview_bg_topbar = 0xFFf5f5f5; | |
40 | + protected int pickerview_topbar_title = 0xFF000000; | |
41 | + protected int bgColor_default = 0xFFFFFFFF; | |
42 | + | |
43 | + private OnDismissListener onDismissListener; | |
44 | + private boolean dismissing; | |
45 | + | |
46 | + private Animation outAnim; | |
47 | + private Animation inAnim; | |
48 | + private boolean isShowing; | |
49 | + private int gravity = Gravity.BOTTOM; | |
50 | + | |
51 | + | |
52 | + private Dialog mDialog; | |
53 | + private boolean cancelable;//是否能取消 | |
54 | + | |
55 | + protected View clickView;//是通过哪个View弹出的 | |
56 | + | |
57 | + private boolean isAnim = true; | |
58 | + public BasePickerView(Context context) { | |
59 | + this.context = context; | |
60 | + | |
61 | + /*initViews(); | |
62 | + init(); | |
63 | + initEvents();*/ | |
64 | + } | |
65 | + | |
66 | + protected void initViews(int backgroudId) { | |
67 | + LayoutInflater layoutInflater = LayoutInflater.from(context); | |
68 | + if (isDialog()) { | |
69 | + //如果是对话框模式 | |
70 | + dialogView = (ViewGroup) layoutInflater.inflate(R.layout.layout_basepickerview, null, false); | |
71 | + //设置界面的背景为透明 | |
72 | + dialogView.setBackgroundColor(Color.TRANSPARENT); | |
73 | + //这个是真正要加载时间选取器的父布局 | |
74 | + contentContainer = (ViewGroup) dialogView.findViewById(R.id.content_container); | |
75 | + //设置对话框 左右间距屏幕30 | |
76 | + this.params.leftMargin = 30; | |
77 | + this.params.rightMargin = 30; | |
78 | + contentContainer.setLayoutParams(this.params); | |
79 | + //创建对话框 | |
80 | + createDialog(); | |
81 | + //给背景设置点击事件,这样当点击内容以外的地方会关闭界面 | |
82 | + dialogView.setOnClickListener(new View.OnClickListener() { | |
83 | + @Override | |
84 | + public void onClick(View view) { | |
85 | + dismiss(); | |
86 | + } | |
87 | + }); | |
88 | + } else { | |
89 | + //如果只是要显示在屏幕的下方 | |
90 | + //decorView是activity的根View | |
91 | + if (decorView == null) { | |
92 | + decorView = (ViewGroup) ((Activity) context).getWindow().getDecorView().findViewById(android.R.id.content); | |
93 | + } | |
94 | + //将控件添加到decorView中 | |
95 | + rootView = (ViewGroup) layoutInflater.inflate(R.layout.layout_basepickerview, decorView, false); | |
96 | + rootView.setLayoutParams(new FrameLayout.LayoutParams( | |
97 | + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT | |
98 | + )); | |
99 | + if (backgroudId != 0) { | |
100 | + rootView.setBackgroundColor(backgroudId); | |
101 | + } | |
102 | + // rootView.setBackgroundColor(ContextCompat.getColor(context,backgroudId)); | |
103 | + //这个是真正要加载时间选取器的父布局 | |
104 | + contentContainer = (ViewGroup) rootView.findViewById(R.id.content_container); | |
105 | + contentContainer.setLayoutParams(params); | |
106 | + } | |
107 | + setKeyBackCancelable(true); | |
108 | + } | |
109 | + | |
110 | + protected void init() { | |
111 | + inAnim = getInAnimation(); | |
112 | + outAnim = getOutAnimation(); | |
113 | + } | |
114 | + | |
115 | + protected void initEvents() { | |
116 | + } | |
117 | + | |
118 | + | |
119 | + /** | |
120 | + * @param v (是通过哪个View弹出的) | |
121 | + * @param isAnim 是否显示动画效果 | |
122 | + */ | |
123 | + public void show(View v, boolean isAnim) { | |
124 | + this.clickView = v; | |
125 | + this.isAnim = isAnim; | |
126 | + show(); | |
127 | + } | |
128 | + | |
129 | + public void show(boolean isAnim) { | |
130 | + this.isAnim = isAnim; | |
131 | + show(); | |
132 | + } | |
133 | + | |
134 | + public void show(View v) { | |
135 | + this.clickView = v; | |
136 | + show(); | |
137 | + } | |
138 | + | |
139 | + | |
140 | + /** | |
141 | + * 添加View到根视图 | |
142 | + */ | |
143 | + public void show() { | |
144 | + if (isDialog()) { | |
145 | + showDialog(); | |
146 | + } else { | |
147 | + if (isShowing()) { | |
148 | + return; | |
149 | + } | |
150 | + isShowing = true; | |
151 | + onAttached(rootView); | |
152 | + rootView.requestFocus(); | |
153 | + } | |
154 | + } | |
155 | + | |
156 | + | |
157 | + /** | |
158 | + * show的时候调用 | |
159 | + * | |
160 | + * @param view 这个View | |
161 | + */ | |
162 | + private void onAttached(View view) { | |
163 | + decorView.addView(view); | |
164 | + if(isAnim){ | |
165 | + contentContainer.startAnimation(inAnim); | |
166 | + } | |
167 | + } | |
168 | + | |
169 | + | |
170 | + /** | |
171 | + * 检测该View是不是已经添加到根视图 | |
172 | + * | |
173 | + * @return 如果视图已经存在该View返回true | |
174 | + */ | |
175 | + public boolean isShowing() { | |
176 | + if (isDialog()) { | |
177 | + return false; | |
178 | + } else { | |
179 | + return rootView.getParent() != null || isShowing; | |
180 | + } | |
181 | + | |
182 | + } | |
183 | + | |
184 | + public void dismiss() { | |
185 | + if (isDialog()) { | |
186 | + dismissDialog(); | |
187 | + } else { | |
188 | + if (dismissing) { | |
189 | + return; | |
190 | + } | |
191 | + | |
192 | + if (isAnim){ | |
193 | + //消失动画 | |
194 | + outAnim.setAnimationListener(new Animation.AnimationListener() { | |
195 | + @Override | |
196 | + public void onAnimationStart(Animation animation) { | |
197 | + | |
198 | + } | |
199 | + | |
200 | + @Override | |
201 | + public void onAnimationEnd(Animation animation) { | |
202 | + dismissImmediately(); | |
203 | + } | |
204 | + | |
205 | + @Override | |
206 | + public void onAnimationRepeat(Animation animation) { | |
207 | + | |
208 | + } | |
209 | + }); | |
210 | + contentContainer.startAnimation(outAnim); | |
211 | + } else { | |
212 | + dismissImmediately(); | |
213 | + } | |
214 | + dismissing = true; | |
215 | + } | |
216 | + | |
217 | + | |
218 | + } | |
219 | + | |
220 | + public void dismissImmediately() { | |
221 | + | |
222 | + decorView.post(new Runnable() { | |
223 | + @Override | |
224 | + public void run() { | |
225 | + //从根视图移除 | |
226 | + decorView.removeView(rootView); | |
227 | + isShowing = false; | |
228 | + dismissing = false; | |
229 | + if (onDismissListener != null) { | |
230 | + onDismissListener.onDismiss(BasePickerView.this); | |
231 | + } | |
232 | + } | |
233 | + }); | |
234 | + | |
235 | + | |
236 | + } | |
237 | + | |
238 | + public Animation getInAnimation() { | |
239 | + int res = PickerViewAnimateUtil.getAnimationResource(this.gravity, true); | |
240 | + return AnimationUtils.loadAnimation(context, res); | |
241 | + } | |
242 | + | |
243 | + public Animation getOutAnimation() { | |
244 | + int res = PickerViewAnimateUtil.getAnimationResource(this.gravity, false); | |
245 | + return AnimationUtils.loadAnimation(context, res); | |
246 | + } | |
247 | + | |
248 | + public BasePickerView setOnDismissListener(OnDismissListener onDismissListener) { | |
249 | + this.onDismissListener = onDismissListener; | |
250 | + return this; | |
251 | + } | |
252 | + | |
253 | + public void setKeyBackCancelable(boolean isCancelable) { | |
254 | + | |
255 | + ViewGroup View; | |
256 | + if (isDialog()) { | |
257 | + View = dialogView; | |
258 | + } else { | |
259 | + View = rootView; | |
260 | + } | |
261 | + | |
262 | + View.setFocusable(isCancelable); | |
263 | + View.setFocusableInTouchMode(isCancelable); | |
264 | + if (isCancelable) { | |
265 | + View.setOnKeyListener(onKeyBackListener); | |
266 | + } else { | |
267 | + View.setOnKeyListener(null); | |
268 | + } | |
269 | + } | |
270 | + | |
271 | + private View.OnKeyListener onKeyBackListener = new View.OnKeyListener() { | |
272 | + @Override | |
273 | + public boolean onKey(View v, int keyCode, KeyEvent event) { | |
274 | + if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == MotionEvent.ACTION_DOWN | |
275 | + && isShowing()) { | |
276 | + dismiss(); | |
277 | + return true; | |
278 | + } | |
279 | + return false; | |
280 | + } | |
281 | + }; | |
282 | + | |
283 | + protected BasePickerView setOutSideCancelable(boolean isCancelable) { | |
284 | + if (rootView != null) { | |
285 | + View view = rootView.findViewById(R.id.outmost_container); | |
286 | + | |
287 | + if (isCancelable) { | |
288 | + view.setOnTouchListener(onCancelableTouchListener); | |
289 | + } else { | |
290 | + view.setOnTouchListener(null); | |
291 | + } | |
292 | + } | |
293 | + | |
294 | + return this; | |
295 | + } | |
296 | + | |
297 | + /** | |
298 | + * 设置对话框模式是否可以点击外部取消 | |
299 | + * | |
300 | + * @param cancelable | |
301 | + */ | |
302 | + public void setDialogOutSideCancelable(boolean cancelable) { | |
303 | + this.cancelable = cancelable; | |
304 | + } | |
305 | + | |
306 | + | |
307 | + /** | |
308 | + * Called when the user touch on black overlay in order to dismiss the dialog | |
309 | + */ | |
310 | + private final View.OnTouchListener onCancelableTouchListener = new View.OnTouchListener() { | |
311 | + @Override | |
312 | + public boolean onTouch(View v, MotionEvent event) { | |
313 | + if (event.getAction() == MotionEvent.ACTION_DOWN) { | |
314 | + dismiss(); | |
315 | + } | |
316 | + return false; | |
317 | + } | |
318 | + }; | |
319 | + | |
320 | + public View findViewById(int id) { | |
321 | + return contentContainer.findViewById(id); | |
322 | + } | |
323 | + | |
324 | + public void createDialog() { | |
325 | + if (dialogView != null) { | |
326 | + mDialog = new Dialog(context, R.style.custom_dialog2); | |
327 | + mDialog.setCancelable(cancelable);//不能点外面取消,也不 能点back取消 | |
328 | + mDialog.setContentView(dialogView); | |
329 | + | |
330 | + mDialog.getWindow().setWindowAnimations(R.style.pickerview_dialogAnim); | |
331 | + mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { | |
332 | + @Override | |
333 | + public void onDismiss(DialogInterface dialog) { | |
334 | + if (onDismissListener != null) { | |
335 | + onDismissListener.onDismiss(BasePickerView.this); | |
336 | + } | |
337 | + } | |
338 | + }); | |
339 | + } | |
340 | + | |
341 | + } | |
342 | + | |
343 | + public void showDialog() { | |
344 | + if (mDialog != null) { | |
345 | + mDialog.show(); | |
346 | + } | |
347 | + } | |
348 | + | |
349 | + public void dismissDialog() { | |
350 | + if (mDialog != null) { | |
351 | + mDialog.dismiss(); | |
352 | + } | |
353 | + } | |
354 | + | |
355 | + public boolean isDialog() { | |
356 | + return false; | |
357 | + } | |
358 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/view/WheelOptions.java
... | ... | @@ -0,0 +1,378 @@ |
1 | +package com.bigkoo.pickerview.view; | |
2 | + | |
3 | +import android.graphics.Typeface; | |
4 | +import android.view.View; | |
5 | + | |
6 | +import com.bigkoo.pickerview.R; | |
7 | +import com.bigkoo.pickerview.adapter.ArrayWheelAdapter; | |
8 | +import com.bigkoo.pickerview.lib.WheelView; | |
9 | +import com.bigkoo.pickerview.listener.OnItemSelectedListener; | |
10 | + | |
11 | +import java.util.List; | |
12 | + | |
13 | +public class WheelOptions<T> { | |
14 | + private View view; | |
15 | + private WheelView wv_option1; | |
16 | + private WheelView wv_option2; | |
17 | + private WheelView wv_option3; | |
18 | + | |
19 | + private List<T> mOptions1Items; | |
20 | + private List<List<T>> mOptions2Items; | |
21 | + private List<T> N_mOptions2Items; | |
22 | + private List<List<List<T>>> mOptions3Items; | |
23 | + private List<T> N_mOptions3Items; | |
24 | + private boolean linkage; | |
25 | + private OnItemSelectedListener wheelListener_option1; | |
26 | + private OnItemSelectedListener wheelListener_option2; | |
27 | + | |
28 | + //文字的颜色和分割线的颜色 | |
29 | + int textColorOut; | |
30 | + int textColorCenter; | |
31 | + int dividerColor; | |
32 | + | |
33 | + private WheelView.DividerType dividerType; | |
34 | + | |
35 | + // 条目间距倍数 | |
36 | + float lineSpacingMultiplier = 1.6F; | |
37 | + | |
38 | + public View getView() { | |
39 | + return view; | |
40 | + } | |
41 | + | |
42 | + public void setView(View view) { | |
43 | + this.view = view; | |
44 | + } | |
45 | + | |
46 | + public WheelOptions(View view, Boolean linkage) { | |
47 | + super(); | |
48 | + this.linkage = linkage; | |
49 | + this.view = view; | |
50 | + wv_option1 = (WheelView) view.findViewById(R.id.options1);// 初始化时显示的数据 | |
51 | + wv_option2 = (WheelView) view.findViewById(R.id.options2); | |
52 | + wv_option3 = (WheelView) view.findViewById(R.id.options3); | |
53 | + } | |
54 | + | |
55 | + | |
56 | + public void setPicker(List<T> options1Items, | |
57 | + List<List<T>> options2Items, | |
58 | + List<List<List<T>>> options3Items) { | |
59 | + this.mOptions1Items = options1Items; | |
60 | + this.mOptions2Items = options2Items; | |
61 | + this.mOptions3Items = options3Items; | |
62 | + int len = ArrayWheelAdapter.DEFAULT_LENGTH; | |
63 | + if (this.mOptions3Items == null) | |
64 | + len = 8; | |
65 | + if (this.mOptions2Items == null) | |
66 | + len = 12; | |
67 | + // 选项1 | |
68 | + wv_option1.setAdapter(new ArrayWheelAdapter(mOptions1Items, len));// 设置显示数据 | |
69 | + wv_option1.setCurrentItem(0);// 初始化时显示的数据 | |
70 | + // 选项2 | |
71 | + if (mOptions2Items != null) | |
72 | + wv_option2.setAdapter(new ArrayWheelAdapter(mOptions2Items.get(0)));// 设置显示数据 | |
73 | + wv_option2.setCurrentItem(wv_option1.getCurrentItem());// 初始化时显示的数据 | |
74 | + // 选项3 | |
75 | + if (mOptions3Items != null) | |
76 | + wv_option3.setAdapter(new ArrayWheelAdapter(mOptions3Items.get(0).get(0)));// 设置显示数据 | |
77 | + wv_option3.setCurrentItem(wv_option3.getCurrentItem()); | |
78 | + wv_option1.setIsOptions(true); | |
79 | + wv_option2.setIsOptions(true); | |
80 | + wv_option3.setIsOptions(true); | |
81 | + | |
82 | + if (this.mOptions2Items == null) { | |
83 | + wv_option2.setVisibility(View.GONE); | |
84 | + } else { | |
85 | + wv_option2.setVisibility(View.VISIBLE); | |
86 | + } | |
87 | + if (this.mOptions3Items == null) { | |
88 | + wv_option3.setVisibility(View.GONE); | |
89 | + } else { | |
90 | + wv_option3.setVisibility(View.VISIBLE); | |
91 | + } | |
92 | + | |
93 | + // 联动监听器 | |
94 | + wheelListener_option1 = new OnItemSelectedListener() { | |
95 | + | |
96 | + @Override | |
97 | + public void onItemSelected(int index) { | |
98 | + int opt2Select = 0; | |
99 | + if (mOptions2Items != null) { | |
100 | + opt2Select = wv_option2.getCurrentItem();//上一个opt2的选中位置 | |
101 | + //新opt2的位置,判断如果旧位置没有超过数据范围,则沿用旧位置,否则选中最后一项 | |
102 | + opt2Select = opt2Select >= mOptions2Items.get(index).size() - 1 ? mOptions2Items.get(index).size() - 1 : opt2Select; | |
103 | + | |
104 | + wv_option2.setAdapter(new ArrayWheelAdapter(mOptions2Items.get(index))); | |
105 | + wv_option2.setCurrentItem(opt2Select); | |
106 | + } | |
107 | + if (mOptions3Items != null) { | |
108 | + wheelListener_option2.onItemSelected(opt2Select); | |
109 | + } | |
110 | + } | |
111 | + }; | |
112 | + wheelListener_option2 = new OnItemSelectedListener() { | |
113 | + | |
114 | + @Override | |
115 | + public void onItemSelected(int index) { | |
116 | + if (mOptions3Items != null) { | |
117 | + int opt1Select = wv_option1.getCurrentItem(); | |
118 | + opt1Select = opt1Select >= mOptions3Items.size() - 1 ? mOptions3Items.size() - 1 : opt1Select; | |
119 | + index = index >= mOptions2Items.get(opt1Select).size() - 1 ? mOptions2Items.get(opt1Select).size() - 1 : index; | |
120 | + int opt3 = wv_option3.getCurrentItem();//上一个opt3的选中位置 | |
121 | + //新opt3的位置,判断如果旧位置没有超过数据范围,则沿用旧位置,否则选中最后一项 | |
122 | + opt3 = opt3 >= mOptions3Items.get(opt1Select).get(index).size() - 1 ? mOptions3Items.get(opt1Select).get(index).size() - 1 : opt3; | |
123 | + | |
124 | + wv_option3.setAdapter(new ArrayWheelAdapter(mOptions3Items | |
125 | + .get(wv_option1.getCurrentItem()).get(index))); | |
126 | + wv_option3.setCurrentItem(opt3); | |
127 | + | |
128 | + } | |
129 | + } | |
130 | + }; | |
131 | + | |
132 | + // 添加联动监听 | |
133 | + if (options2Items != null && linkage) | |
134 | + wv_option1.setOnItemSelectedListener(wheelListener_option1); | |
135 | + if (options3Items != null && linkage) | |
136 | + wv_option2.setOnItemSelectedListener(wheelListener_option2); | |
137 | + } | |
138 | + | |
139 | + | |
140 | + //不联动情况下 | |
141 | + public void setNPicker(List<T> options1Items, | |
142 | + List<T> options2Items, | |
143 | + List<T> options3Items) { | |
144 | + this.mOptions1Items = options1Items; | |
145 | + this.N_mOptions2Items = options2Items; | |
146 | + this.N_mOptions3Items = options3Items; | |
147 | + int len = ArrayWheelAdapter.DEFAULT_LENGTH; | |
148 | + if (this.N_mOptions3Items == null) | |
149 | + len = 8; | |
150 | + if (this.N_mOptions2Items == null) | |
151 | + len = 12; | |
152 | + // 选项1 | |
153 | + wv_option1.setAdapter(new ArrayWheelAdapter(mOptions1Items, len));// 设置显示数据 | |
154 | + wv_option1.setCurrentItem(0);// 初始化时显示的数据 | |
155 | + // 选项2 | |
156 | + if (N_mOptions2Items != null) | |
157 | + wv_option2.setAdapter(new ArrayWheelAdapter(N_mOptions2Items));// 设置显示数据 | |
158 | + wv_option2.setCurrentItem(wv_option1.getCurrentItem());// 初始化时显示的数据 | |
159 | + // 选项3 | |
160 | + if (N_mOptions3Items != null) | |
161 | + wv_option3.setAdapter(new ArrayWheelAdapter(N_mOptions3Items));// 设置显示数据 | |
162 | + wv_option3.setCurrentItem(wv_option3.getCurrentItem()); | |
163 | + wv_option1.setIsOptions(true); | |
164 | + wv_option2.setIsOptions(true); | |
165 | + wv_option3.setIsOptions(true); | |
166 | + | |
167 | + if (this.N_mOptions2Items == null) { | |
168 | + wv_option2.setVisibility(View.GONE); | |
169 | + } else { | |
170 | + wv_option2.setVisibility(View.VISIBLE); | |
171 | + } | |
172 | + if (this.N_mOptions3Items == null) { | |
173 | + wv_option3.setVisibility(View.GONE); | |
174 | + } else { | |
175 | + wv_option3.setVisibility(View.VISIBLE); | |
176 | + } | |
177 | + } | |
178 | + | |
179 | + | |
180 | + public void setTextContentSize(int textSize) { | |
181 | + wv_option1.setTextSize(textSize); | |
182 | + wv_option2.setTextSize(textSize); | |
183 | + wv_option3.setTextSize(textSize); | |
184 | + } | |
185 | + | |
186 | + private void setTextColorOut() { | |
187 | + wv_option1.setTextColorOut(textColorOut); | |
188 | + wv_option2.setTextColorOut(textColorOut); | |
189 | + wv_option3.setTextColorOut(textColorOut); | |
190 | + | |
191 | + } | |
192 | + | |
193 | + private void setTextColorCenter() { | |
194 | + wv_option1.setTextColorCenter(textColorCenter); | |
195 | + wv_option2.setTextColorCenter(textColorCenter); | |
196 | + wv_option3.setTextColorCenter(textColorCenter); | |
197 | + | |
198 | + } | |
199 | + | |
200 | + private void setDividerColor() { | |
201 | + wv_option1.setDividerColor(dividerColor); | |
202 | + wv_option2.setDividerColor(dividerColor); | |
203 | + wv_option3.setDividerColor(dividerColor); | |
204 | + } | |
205 | + | |
206 | + private void setDividerType() { | |
207 | + wv_option1.setDividerType(dividerType); | |
208 | + wv_option2.setDividerType(dividerType); | |
209 | + wv_option3.setDividerType(dividerType); | |
210 | + } | |
211 | + | |
212 | + private void setLineSpacingMultiplier() { | |
213 | + wv_option1.setLineSpacingMultiplier(lineSpacingMultiplier); | |
214 | + wv_option2.setLineSpacingMultiplier(lineSpacingMultiplier); | |
215 | + wv_option3.setLineSpacingMultiplier(lineSpacingMultiplier); | |
216 | + | |
217 | + } | |
218 | + | |
219 | + /** | |
220 | + * 设置选项的单位 | |
221 | + * | |
222 | + * @param label1 单位 | |
223 | + * @param label2 单位 | |
224 | + * @param label3 单位 | |
225 | + */ | |
226 | + public void setLabels(String label1, String label2, String label3) { | |
227 | + if (label1 != null) | |
228 | + wv_option1.setLabel(label1); | |
229 | + if (label2 != null) | |
230 | + wv_option2.setLabel(label2); | |
231 | + if (label3 != null) | |
232 | + wv_option3.setLabel(label3); | |
233 | + } | |
234 | + | |
235 | + /** | |
236 | + * 设置是否循环滚动 | |
237 | + * | |
238 | + * @param cyclic 是否循环 | |
239 | + */ | |
240 | + public void setCyclic(boolean cyclic) { | |
241 | + wv_option1.setCyclic(cyclic); | |
242 | + wv_option2.setCyclic(cyclic); | |
243 | + wv_option3.setCyclic(cyclic); | |
244 | + } | |
245 | + | |
246 | + /** | |
247 | + * 设置字体样式 | |
248 | + * | |
249 | + * @param font 系统提供的几种样式 | |
250 | + */ | |
251 | + public void setTypeface (Typeface font) { | |
252 | + wv_option1.setTypeface(font); | |
253 | + wv_option2.setTypeface(font); | |
254 | + wv_option3.setTypeface(font); | |
255 | + } | |
256 | + | |
257 | + /** | |
258 | + * 分别设置第一二三级是否循环滚动 | |
259 | + * | |
260 | + * @param cyclic1,cyclic2,cyclic3 是否循环 | |
261 | + */ | |
262 | + public void setCyclic(boolean cyclic1, boolean cyclic2, boolean cyclic3) { | |
263 | + wv_option1.setCyclic(cyclic1); | |
264 | + wv_option2.setCyclic(cyclic2); | |
265 | + wv_option3.setCyclic(cyclic3); | |
266 | + } | |
267 | + | |
268 | + | |
269 | + | |
270 | + /** | |
271 | + * 返回当前选中的结果对应的位置数组 因为支持三级联动效果,分三个级别索引,0,1,2。 | |
272 | + * 在快速滑动未停止时,点击确定按钮,会进行判断,如果匹配数据越界,则设为0,防止index出错导致崩溃。 | |
273 | + * | |
274 | + * @return 索引数组 | |
275 | + */ | |
276 | + public int[] getCurrentItems() { | |
277 | + int[] currentItems = new int[3]; | |
278 | + currentItems[0] = wv_option1.getCurrentItem(); | |
279 | + | |
280 | + if (mOptions2Items!=null&&mOptions2Items.size()>0){//非空判断 | |
281 | + currentItems[1] = wv_option2.getCurrentItem()>(mOptions2Items.get(currentItems[0]).size()-1)?0:wv_option2.getCurrentItem(); | |
282 | + }else { | |
283 | + currentItems[1] = wv_option2.getCurrentItem(); | |
284 | + } | |
285 | + | |
286 | + if (mOptions3Items!=null&&mOptions3Items.size()>0){//非空判断 | |
287 | + currentItems[2] = wv_option3.getCurrentItem()>(mOptions3Items.get(currentItems[0]).get(currentItems[1]).size()-1)?0:wv_option3.getCurrentItem(); | |
288 | + }else { | |
289 | + currentItems[2] = wv_option3.getCurrentItem(); | |
290 | + } | |
291 | + | |
292 | + return currentItems; | |
293 | + } | |
294 | + | |
295 | + public void setCurrentItems(int option1, int option2, int option3) { | |
296 | + if (linkage) { | |
297 | + itemSelected(option1, option2, option3); | |
298 | + } | |
299 | + wv_option1.setCurrentItem(option1); | |
300 | + wv_option2.setCurrentItem(option2); | |
301 | + wv_option3.setCurrentItem(option3); | |
302 | + } | |
303 | + | |
304 | + private void itemSelected(int opt1Select, int opt2Select, int opt3Select) { | |
305 | + if (mOptions2Items != null) { | |
306 | + wv_option2.setAdapter(new ArrayWheelAdapter(mOptions2Items | |
307 | + .get(opt1Select))); | |
308 | + wv_option2.setCurrentItem(opt2Select); | |
309 | + } | |
310 | + if (mOptions3Items != null) { | |
311 | + wv_option3.setAdapter(new ArrayWheelAdapter(mOptions3Items | |
312 | + .get(opt1Select).get( | |
313 | + opt2Select))); | |
314 | + wv_option3.setCurrentItem(opt3Select); | |
315 | + } | |
316 | + } | |
317 | + /** | |
318 | + * 设置间距倍数,但是只能在1.2-2.0f之间 | |
319 | + * | |
320 | + * @param lineSpacingMultiplier | |
321 | + */ | |
322 | + public void setLineSpacingMultiplier(float lineSpacingMultiplier) { | |
323 | + this.lineSpacingMultiplier = lineSpacingMultiplier; | |
324 | + setLineSpacingMultiplier(); | |
325 | + } | |
326 | + | |
327 | + /** | |
328 | + * 设置分割线的颜色 | |
329 | + * | |
330 | + * @param dividerColor | |
331 | + */ | |
332 | + public void setDividerColor(int dividerColor) { | |
333 | + this.dividerColor = dividerColor; | |
334 | + setDividerColor(); | |
335 | + } | |
336 | + | |
337 | + /** | |
338 | + * 设置分割线的类型 | |
339 | + * | |
340 | + * @param dividerType | |
341 | + */ | |
342 | + public void setDividerType(WheelView.DividerType dividerType) { | |
343 | + this.dividerType = dividerType; | |
344 | + setDividerType(); | |
345 | + } | |
346 | + /** | |
347 | + * 设置分割线之间的文字的颜色 | |
348 | + * | |
349 | + * @param textColorCenter | |
350 | + */ | |
351 | + public void setTextColorCenter(int textColorCenter) { | |
352 | + this.textColorCenter = textColorCenter; | |
353 | + setTextColorCenter(); | |
354 | + } | |
355 | + | |
356 | + /** | |
357 | + * 设置分割线以外文字的颜色 | |
358 | + * | |
359 | + * @param textColorOut | |
360 | + */ | |
361 | + public void setTextColorOut(int textColorOut) { | |
362 | + this.textColorOut = textColorOut; | |
363 | + setTextColorOut(); | |
364 | + } | |
365 | + | |
366 | + /** | |
367 | + * Label 是否只显示中间选中项的 | |
368 | + * | |
369 | + * @param isCenterLabel | |
370 | + */ | |
371 | + | |
372 | + public void isCenterLabel(Boolean isCenterLabel) { | |
373 | + wv_option1.isCenterLabel(isCenterLabel); | |
374 | + wv_option2.isCenterLabel(isCenterLabel); | |
375 | + wv_option3.isCenterLabel(isCenterLabel); | |
376 | + } | |
377 | + | |
378 | +} | ... | ... |
PersonalCenter/pickerview/src/main/java/com/bigkoo/pickerview/view/WheelTime.java
... | ... | @@ -0,0 +1,700 @@ |
1 | +package com.bigkoo.pickerview.view; | |
2 | + | |
3 | +import android.view.View; | |
4 | + | |
5 | +import com.bigkoo.pickerview.R; | |
6 | +import com.bigkoo.pickerview.adapter.NumericWheelAdapter; | |
7 | +import com.bigkoo.pickerview.lib.WheelView; | |
8 | +import com.bigkoo.pickerview.listener.OnItemSelectedListener; | |
9 | + | |
10 | +import java.text.DateFormat; | |
11 | +import java.text.SimpleDateFormat; | |
12 | +import java.util.Arrays; | |
13 | +import java.util.Calendar; | |
14 | +import java.util.List; | |
15 | + | |
16 | + | |
17 | +public class WheelTime { | |
18 | + public static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
19 | + private View view; | |
20 | + private WheelView wv_year; | |
21 | + private WheelView wv_month; | |
22 | + private WheelView wv_day; | |
23 | + private WheelView wv_hours; | |
24 | + private WheelView wv_mins; | |
25 | + private WheelView wv_seconds; | |
26 | + private int gravity; | |
27 | + | |
28 | + private boolean[] type; | |
29 | + private static final int DEFAULT_START_YEAR = 1900; | |
30 | + private static final int DEFAULT_END_YEAR = 2100; | |
31 | + private static final int DEFAULT_START_MONTH = 1; | |
32 | + private static final int DEFAULT_END_MONTH = 12; | |
33 | + private static final int DEFAULT_START_DAY = 1; | |
34 | + private static final int DEFAULT_END_DAY = 31; | |
35 | + | |
36 | + private int startYear = DEFAULT_START_YEAR; | |
37 | + private int endYear = DEFAULT_END_YEAR; | |
38 | + private int startMonth = DEFAULT_START_MONTH; | |
39 | + private int endMonth = DEFAULT_END_MONTH; | |
40 | + private int startDay = DEFAULT_START_DAY; | |
41 | + private int endDay = DEFAULT_END_DAY; //表示31天的 | |
42 | + private int currentYear; | |
43 | + | |
44 | + | |
45 | + // 根据屏幕密度来指定选择器字体的大小(不同屏幕可能不同) | |
46 | + private int textSize = 18; | |
47 | + //文字的颜色和分割线的颜色 | |
48 | + int textColorOut; | |
49 | + int textColorCenter; | |
50 | + int dividerColor; | |
51 | + // 条目间距倍数 | |
52 | + float lineSpacingMultiplier = 1.6F; | |
53 | + | |
54 | + private WheelView.DividerType dividerType; | |
55 | + | |
56 | + public WheelTime(View view) { | |
57 | + super(); | |
58 | + this.view = view; | |
59 | + type = new boolean[]{true, true, true, true, true, true}; | |
60 | + setView(view); | |
61 | + } | |
62 | + | |
63 | + public WheelTime(View view, boolean[] type, int gravity, int textSize) { | |
64 | + super(); | |
65 | + this.view = view; | |
66 | + this.type = type; | |
67 | + this.gravity = gravity; | |
68 | + this.textSize = textSize; | |
69 | + setView(view); | |
70 | + } | |
71 | + | |
72 | + public void setPicker(int year, int month, int day) { | |
73 | + this.setPicker(year, month, day, 0, 0, 0); | |
74 | + } | |
75 | + | |
76 | + public void setPicker(int year, final int month, int day, int h, int m, int s) { | |
77 | + // 添加大小月月份并将其转换为list,方便之后的判断 | |
78 | + String[] months_big = {"1", "3", "5", "7", "8", "10", "12"}; | |
79 | + String[] months_little = {"4", "6", "9", "11"}; | |
80 | + | |
81 | + final List<String> list_big = Arrays.asList(months_big); | |
82 | + final List<String> list_little = Arrays.asList(months_little); | |
83 | + | |
84 | + /* final Context context = view.getContext();*/ | |
85 | + currentYear = year; | |
86 | + // 年 | |
87 | + wv_year = (WheelView) view.findViewById(R.id.year); | |
88 | + wv_year.setAdapter(new NumericWheelAdapter(startYear, endYear));// 设置"年"的显示数据 | |
89 | + /*wv_year.setLabel(context.getString(R.string.pickerview_year));// 添加文字*/ | |
90 | + wv_year.setCurrentItem(year - startYear);// 初始化时显示的数据 | |
91 | + wv_year.setGravity(gravity); | |
92 | + // 月 | |
93 | + wv_month = (WheelView) view.findViewById(R.id.month); | |
94 | + if (startYear == endYear) {//开始年等于终止年 | |
95 | + wv_month.setAdapter(new NumericWheelAdapter(startMonth, endMonth)); | |
96 | + wv_month.setCurrentItem(month + 1 - startMonth); | |
97 | + } else if (year == startYear) { | |
98 | + //起始日期的月份控制 | |
99 | + wv_month.setAdapter(new NumericWheelAdapter(startMonth, 12)); | |
100 | + wv_month.setCurrentItem(month + 1 - startMonth); | |
101 | + } else if (year == endYear) { | |
102 | + //终止日期的月份控制 | |
103 | + wv_month.setAdapter(new NumericWheelAdapter(1, endMonth)); | |
104 | + wv_month.setCurrentItem(month); | |
105 | + } else { | |
106 | + wv_month.setAdapter(new NumericWheelAdapter(1, 12)); | |
107 | + wv_month.setCurrentItem(month); | |
108 | + } | |
109 | + /* wv_month.setLabel(context.getString(R.string.pickerview_month));*/ | |
110 | + | |
111 | + wv_month.setGravity(gravity); | |
112 | + // 日 | |
113 | + wv_day = (WheelView) view.findViewById(R.id.day); | |
114 | + | |
115 | + if (startYear == endYear && startMonth == endMonth) { | |
116 | + if (list_big.contains(String.valueOf(month + 1))) { | |
117 | + if (endDay > 31) { | |
118 | + endDay = 31; | |
119 | + } | |
120 | + wv_day.setAdapter(new NumericWheelAdapter(startDay, endDay)); | |
121 | + } else if (list_little.contains(String.valueOf(month + 1))) { | |
122 | + if (endDay > 30) { | |
123 | + endDay = 30; | |
124 | + } | |
125 | + wv_day.setAdapter(new NumericWheelAdapter(startDay, endDay)); | |
126 | + } else { | |
127 | + // 闰年 | |
128 | + if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { | |
129 | + if (endDay > 29) { | |
130 | + endDay = 29; | |
131 | + } | |
132 | + wv_day.setAdapter(new NumericWheelAdapter(startDay, endDay)); | |
133 | + } else { | |
134 | + if (endDay > 28) { | |
135 | + endDay = 28; | |
136 | + } | |
137 | + wv_day.setAdapter(new NumericWheelAdapter(startDay, endDay)); | |
138 | + } | |
139 | + } | |
140 | + wv_day.setCurrentItem(day - startDay); | |
141 | + } else if (year == startYear && month + 1 == startMonth) { | |
142 | + // 起始日期的天数控制 | |
143 | + if (list_big.contains(String.valueOf(month + 1))) { | |
144 | + | |
145 | + wv_day.setAdapter(new NumericWheelAdapter(startDay, 31)); | |
146 | + } else if (list_little.contains(String.valueOf(month + 1))) { | |
147 | + | |
148 | + wv_day.setAdapter(new NumericWheelAdapter(startDay, 30)); | |
149 | + } else { | |
150 | + // 闰年 | |
151 | + if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { | |
152 | + | |
153 | + wv_day.setAdapter(new NumericWheelAdapter(startDay, 29)); | |
154 | + } else { | |
155 | + | |
156 | + wv_day.setAdapter(new NumericWheelAdapter(startDay, 28)); | |
157 | + } | |
158 | + } | |
159 | + wv_day.setCurrentItem(day - startDay); | |
160 | + } else if (year == endYear && month + 1 == endMonth) { | |
161 | + // 终止日期的天数控制 | |
162 | + if (list_big.contains(String.valueOf(month + 1))) { | |
163 | + if (endDay > 31) { | |
164 | + endDay = 31; | |
165 | + } | |
166 | + wv_day.setAdapter(new NumericWheelAdapter(1, endDay)); | |
167 | + } else if (list_little.contains(String.valueOf(month + 1))) { | |
168 | + if (endDay > 30) { | |
169 | + endDay = 30; | |
170 | + } | |
171 | + wv_day.setAdapter(new NumericWheelAdapter(1, endDay)); | |
172 | + } else { | |
173 | + // 闰年 | |
174 | + if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { | |
175 | + if (endDay > 29) { | |
176 | + endDay = 29; | |
177 | + } | |
178 | + wv_day.setAdapter(new NumericWheelAdapter(1, endDay)); | |
179 | + } else { | |
180 | + if (endDay > 28) { | |
181 | + endDay = 28; | |
182 | + } | |
183 | + wv_day.setAdapter(new NumericWheelAdapter(1, endDay)); | |
184 | + } | |
185 | + } | |
186 | + wv_day.setCurrentItem(day - 1); | |
187 | + } else { | |
188 | + // 判断大小月及是否闰年,用来确定"日"的数据 | |
189 | + if (list_big.contains(String.valueOf(month + 1))) { | |
190 | + | |
191 | + wv_day.setAdapter(new NumericWheelAdapter(1, 31)); | |
192 | + } else if (list_little.contains(String.valueOf(month + 1))) { | |
193 | + | |
194 | + wv_day.setAdapter(new NumericWheelAdapter(1, 30)); | |
195 | + } else { | |
196 | + // 闰年 | |
197 | + if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { | |
198 | + | |
199 | + wv_day.setAdapter(new NumericWheelAdapter(1, 29)); | |
200 | + } else { | |
201 | + | |
202 | + wv_day.setAdapter(new NumericWheelAdapter(1, 28)); | |
203 | + } | |
204 | + } | |
205 | + wv_day.setCurrentItem(day - 1); | |
206 | + } | |
207 | + | |
208 | + /* wv_day.setLabel(context.getString(R.string.pickerview_day));*/ | |
209 | + | |
210 | + wv_day.setGravity(gravity); | |
211 | + //时 | |
212 | + wv_hours = (WheelView) view.findViewById(R.id.hour); | |
213 | + wv_hours.setAdapter(new NumericWheelAdapter(0, 23)); | |
214 | + /* wv_hours.setLabel(context.getString(R.string.pickerview_hours));// 添加文字*/ | |
215 | + wv_hours.setCurrentItem(h); | |
216 | + wv_hours.setGravity(gravity); | |
217 | + //分 | |
218 | + wv_mins = (WheelView) view.findViewById(R.id.min); | |
219 | + wv_mins.setAdapter(new NumericWheelAdapter(0, 59)); | |
220 | + /* wv_mins.setLabel(context.getString(R.string.pickerview_minutes));// 添加文字*/ | |
221 | + wv_mins.setCurrentItem(m); | |
222 | + wv_mins.setGravity(gravity); | |
223 | + //秒 | |
224 | + wv_seconds = (WheelView) view.findViewById(R.id.second); | |
225 | + wv_seconds.setAdapter(new NumericWheelAdapter(0, 59)); | |
226 | + /* wv_seconds.setLabel(context.getString(R.string.pickerview_seconds));// 添加文字*/ | |
227 | + wv_seconds.setCurrentItem(s); | |
228 | + wv_seconds.setGravity(gravity); | |
229 | + | |
230 | + // 添加"年"监听 | |
231 | + OnItemSelectedListener wheelListener_year = new OnItemSelectedListener() { | |
232 | + @Override | |
233 | + public void onItemSelected(int index) { | |
234 | + int year_num = index + startYear; | |
235 | + currentYear = year_num; | |
236 | + int currentMonthItem = wv_month.getCurrentItem();//记录上一次的item位置 | |
237 | + // 判断大小月及是否闰年,用来确定"日"的数据 | |
238 | + if (startYear == endYear) { | |
239 | + //重新设置月份 | |
240 | + wv_month.setAdapter(new NumericWheelAdapter(startMonth, endMonth)); | |
241 | + | |
242 | + if (currentMonthItem > wv_month.getAdapter().getItemsCount() - 1) { | |
243 | + currentMonthItem = wv_month.getAdapter().getItemsCount() - 1; | |
244 | + wv_month.setCurrentItem(currentMonthItem); | |
245 | + } | |
246 | + | |
247 | + int monthNum = currentMonthItem + startMonth; | |
248 | + | |
249 | + if (startMonth == endMonth) { | |
250 | + //重新设置日 | |
251 | + setReDay(year_num, monthNum, startDay, endDay, list_big, list_little); | |
252 | + } else if (monthNum == startMonth) { | |
253 | + //重新设置日 | |
254 | + setReDay(year_num, monthNum, startDay, 31, list_big, list_little); | |
255 | + } else { | |
256 | + //重新设置日 | |
257 | + setReDay(year_num, monthNum, 1, 31, list_big, list_little); | |
258 | + } | |
259 | + } else if (year_num == startYear) {//等于开始的年 | |
260 | + //重新设置月份 | |
261 | + wv_month.setAdapter(new NumericWheelAdapter(startMonth, 12)); | |
262 | + | |
263 | + if (currentMonthItem > wv_month.getAdapter().getItemsCount() - 1) { | |
264 | + currentMonthItem = wv_month.getAdapter().getItemsCount() - 1; | |
265 | + wv_month.setCurrentItem(currentMonthItem); | |
266 | + } | |
267 | + | |
268 | + int month = currentMonthItem + startMonth; | |
269 | + if (month == startMonth) { | |
270 | + | |
271 | + //重新设置日 | |
272 | + setReDay(year_num, month, startDay, 31, list_big, list_little); | |
273 | + } else { | |
274 | + //重新设置日 | |
275 | + | |
276 | + setReDay(year_num, month, 1, 31, list_big, list_little); | |
277 | + } | |
278 | + | |
279 | + } else if (year_num == endYear) { | |
280 | + //重新设置月份 | |
281 | + wv_month.setAdapter(new NumericWheelAdapter(1, endMonth)); | |
282 | + if (currentMonthItem > wv_month.getAdapter().getItemsCount() - 1) { | |
283 | + currentMonthItem = wv_month.getAdapter().getItemsCount() - 1; | |
284 | + wv_month.setCurrentItem(currentMonthItem); | |
285 | + } | |
286 | + int monthNum = currentMonthItem + 1; | |
287 | + | |
288 | + if (monthNum == endMonth) { | |
289 | + //重新设置日 | |
290 | + setReDay(year_num, monthNum, 1, endDay, list_big, list_little); | |
291 | + } else { | |
292 | + //重新设置日 | |
293 | + setReDay(year_num, monthNum, 1, 31, list_big, list_little); | |
294 | + } | |
295 | + | |
296 | + } else { | |
297 | + //重新设置月份 | |
298 | + wv_month.setAdapter(new NumericWheelAdapter(1, 12)); | |
299 | + //重新设置日 | |
300 | + setReDay(year_num, wv_month.getCurrentItem() + 1, 1, 31, list_big, list_little); | |
301 | + | |
302 | + } | |
303 | + | |
304 | + } | |
305 | + }; | |
306 | + // 添加"月"监听 | |
307 | + OnItemSelectedListener wheelListener_month = new OnItemSelectedListener() { | |
308 | + @Override | |
309 | + public void onItemSelected(int index) { | |
310 | + int month_num = index + 1; | |
311 | + | |
312 | + if (startYear == endYear) { | |
313 | + month_num = month_num + startMonth - 1; | |
314 | + if (startMonth == endMonth) { | |
315 | + //重新设置日 | |
316 | + setReDay(currentYear, month_num, startDay, endDay, list_big, list_little); | |
317 | + } else if (startMonth == month_num) { | |
318 | + | |
319 | + //重新设置日 | |
320 | + setReDay(currentYear, month_num, startDay, 31, list_big, list_little); | |
321 | + } else if (endMonth == month_num) { | |
322 | + setReDay(currentYear, month_num, 1, endDay, list_big, list_little); | |
323 | + } else { | |
324 | + setReDay(currentYear, month_num, 1, 31, list_big, list_little); | |
325 | + } | |
326 | + } else if (currentYear == startYear) { | |
327 | + month_num = month_num + startMonth - 1; | |
328 | + if (month_num == startMonth) { | |
329 | + //重新设置日 | |
330 | + setReDay(currentYear, month_num, startDay, 31, list_big, list_little); | |
331 | + } else { | |
332 | + //重新设置日 | |
333 | + setReDay(currentYear, month_num, 1, 31, list_big, list_little); | |
334 | + } | |
335 | + | |
336 | + } else if (currentYear == endYear) { | |
337 | + if (month_num == endMonth) { | |
338 | + //重新设置日 | |
339 | + setReDay(currentYear, wv_month.getCurrentItem() + 1, 1, endDay, list_big, list_little); | |
340 | + } else { | |
341 | + setReDay(currentYear, wv_month.getCurrentItem() + 1, 1, 31, list_big, list_little); | |
342 | + } | |
343 | + | |
344 | + } else { | |
345 | + //重新设置日 | |
346 | + setReDay(currentYear, month_num, 1, 31, list_big, list_little); | |
347 | + | |
348 | + } | |
349 | + | |
350 | + | |
351 | + } | |
352 | + }; | |
353 | + wv_year.setOnItemSelectedListener(wheelListener_year); | |
354 | + wv_month.setOnItemSelectedListener(wheelListener_month); | |
355 | + if (type.length != 6) { | |
356 | + throw new RuntimeException("type[] length is not 6"); | |
357 | + } | |
358 | + wv_year.setVisibility(type[0] ? View.VISIBLE : View.GONE); | |
359 | + wv_month.setVisibility(type[1] ? View.VISIBLE : View.GONE); | |
360 | + wv_day.setVisibility(type[2] ? View.VISIBLE : View.GONE); | |
361 | + wv_hours.setVisibility(type[3] ? View.VISIBLE : View.GONE); | |
362 | + wv_mins.setVisibility(type[4] ? View.VISIBLE : View.GONE); | |
363 | + wv_seconds.setVisibility(type[5] ? View.VISIBLE : View.GONE); | |
364 | + setContentTextSize(); | |
365 | + } | |
366 | + | |
367 | + | |
368 | + private void setReDay(int year_num, int monthNum, int startD, int endD, List<String> list_big, List<String> list_little) { | |
369 | + int currentItem = wv_day.getCurrentItem(); | |
370 | + | |
371 | + int maxItem; | |
372 | + if (list_big | |
373 | + .contains(String.valueOf(monthNum))) { | |
374 | + if (endD > 31) { | |
375 | + endD = 31; | |
376 | + } | |
377 | + wv_day.setAdapter(new NumericWheelAdapter(startD, endD)); | |
378 | + maxItem = endD; | |
379 | + } else if (list_little.contains(String.valueOf(monthNum))) { | |
380 | + if (endD > 30) { | |
381 | + endD = 30; | |
382 | + } | |
383 | + wv_day.setAdapter(new NumericWheelAdapter(startD, endD)); | |
384 | + maxItem = endD; | |
385 | + } else { | |
386 | + if ((year_num % 4 == 0 && year_num % 100 != 0) | |
387 | + || year_num % 400 == 0) { | |
388 | + if (endD > 29) { | |
389 | + endD = 29; | |
390 | + } | |
391 | + wv_day.setAdapter(new NumericWheelAdapter(startD, endD)); | |
392 | + maxItem = endD; | |
393 | + } else { | |
394 | + if (endD > 28) { | |
395 | + endD = 28; | |
396 | + } | |
397 | + wv_day.setAdapter(new NumericWheelAdapter(startD, endD)); | |
398 | + maxItem = endD; | |
399 | + } | |
400 | + } | |
401 | + | |
402 | + if (currentItem > wv_day.getAdapter().getItemsCount() - 1) { | |
403 | + currentItem = wv_day.getAdapter().getItemsCount() - 1; | |
404 | + wv_day.setCurrentItem(currentItem); | |
405 | + } | |
406 | + | |
407 | + } | |
408 | + | |
409 | + | |
410 | + private void setContentTextSize() { | |
411 | + wv_day.setTextSize(textSize); | |
412 | + wv_month.setTextSize(textSize); | |
413 | + wv_year.setTextSize(textSize); | |
414 | + wv_hours.setTextSize(textSize); | |
415 | + wv_mins.setTextSize(textSize); | |
416 | + wv_seconds.setTextSize(textSize); | |
417 | + } | |
418 | + | |
419 | + private void setTextColorOut() { | |
420 | + wv_day.setTextColorOut(textColorOut); | |
421 | + wv_month.setTextColorOut(textColorOut); | |
422 | + wv_year.setTextColorOut(textColorOut); | |
423 | + wv_hours.setTextColorOut(textColorOut); | |
424 | + wv_mins.setTextColorOut(textColorOut); | |
425 | + wv_seconds.setTextColorOut(textColorOut); | |
426 | + } | |
427 | + | |
428 | + private void setTextColorCenter() { | |
429 | + wv_day.setTextColorCenter(textColorCenter); | |
430 | + wv_month.setTextColorCenter(textColorCenter); | |
431 | + wv_year.setTextColorCenter(textColorCenter); | |
432 | + wv_hours.setTextColorCenter(textColorCenter); | |
433 | + wv_mins.setTextColorCenter(textColorCenter); | |
434 | + wv_seconds.setTextColorCenter(textColorCenter); | |
435 | + } | |
436 | + | |
437 | + private void setDividerColor() { | |
438 | + wv_day.setDividerColor(dividerColor); | |
439 | + wv_month.setDividerColor(dividerColor); | |
440 | + wv_year.setDividerColor(dividerColor); | |
441 | + wv_hours.setDividerColor(dividerColor); | |
442 | + wv_mins.setDividerColor(dividerColor); | |
443 | + wv_seconds.setDividerColor(dividerColor); | |
444 | + } | |
445 | + | |
446 | + private void setDividerType() { | |
447 | + | |
448 | + wv_day.setDividerType(dividerType); | |
449 | + wv_month.setDividerType(dividerType); | |
450 | + wv_year.setDividerType(dividerType); | |
451 | + wv_hours.setDividerType(dividerType); | |
452 | + wv_mins.setDividerType(dividerType); | |
453 | + wv_seconds.setDividerType(dividerType); | |
454 | + | |
455 | + } | |
456 | + | |
457 | + private void setLineSpacingMultiplier() { | |
458 | + wv_day.setLineSpacingMultiplier(lineSpacingMultiplier); | |
459 | + wv_month.setLineSpacingMultiplier(lineSpacingMultiplier); | |
460 | + wv_year.setLineSpacingMultiplier(lineSpacingMultiplier); | |
461 | + wv_hours.setLineSpacingMultiplier(lineSpacingMultiplier); | |
462 | + wv_mins.setLineSpacingMultiplier(lineSpacingMultiplier); | |
463 | + wv_seconds.setLineSpacingMultiplier(lineSpacingMultiplier); | |
464 | + } | |
465 | + | |
466 | + public void setLabels(String label_year, String label_month, String label_day, String label_hours, String label_mins, String label_seconds) { | |
467 | + if (label_year != null) { | |
468 | + wv_year.setLabel(label_year); | |
469 | + } else { | |
470 | + wv_year.setLabel(view.getContext().getString(R.string.pickerview_year)); | |
471 | + } | |
472 | + if (label_month != null) { | |
473 | + wv_month.setLabel(label_month); | |
474 | + } else { | |
475 | + wv_month.setLabel(view.getContext().getString(R.string.pickerview_month)); | |
476 | + } | |
477 | + if (label_day != null) { | |
478 | + wv_day.setLabel(label_day); | |
479 | + } else { | |
480 | + wv_day.setLabel(view.getContext().getString(R.string.pickerview_day)); | |
481 | + } | |
482 | + if (label_hours != null) { | |
483 | + wv_hours.setLabel(label_hours); | |
484 | + } else { | |
485 | + wv_hours.setLabel(view.getContext().getString(R.string.pickerview_hours)); | |
486 | + } | |
487 | + if (label_mins != null) { | |
488 | + wv_mins.setLabel(label_mins); | |
489 | + } else { | |
490 | + wv_mins.setLabel(view.getContext().getString(R.string.pickerview_minutes)); | |
491 | + } | |
492 | + if (label_seconds != null) { | |
493 | + wv_seconds.setLabel(label_seconds); | |
494 | + } else { | |
495 | + wv_seconds.setLabel(view.getContext().getString(R.string.pickerview_seconds)); | |
496 | + } | |
497 | + | |
498 | + } | |
499 | + | |
500 | + | |
501 | + /** | |
502 | + * 设置是否循环滚动 | |
503 | + * | |
504 | + * @param cyclic | |
505 | + */ | |
506 | + public void setCyclic(boolean cyclic) { | |
507 | + wv_year.setCyclic(cyclic); | |
508 | + wv_month.setCyclic(cyclic); | |
509 | + wv_day.setCyclic(cyclic); | |
510 | + wv_hours.setCyclic(cyclic); | |
511 | + wv_mins.setCyclic(cyclic); | |
512 | + wv_seconds.setCyclic(cyclic); | |
513 | + } | |
514 | + | |
515 | + public String getTime() { | |
516 | + StringBuffer sb = new StringBuffer(); | |
517 | + if (currentYear == startYear) { | |
518 | + /* int i = wv_month.getCurrentItem() + startMonth; | |
519 | + System.out.println("i:" + i);*/ | |
520 | + if ((wv_month.getCurrentItem() + startMonth) == startMonth) { | |
521 | + sb.append((wv_year.getCurrentItem() + startYear)).append("-") | |
522 | + .append((wv_month.getCurrentItem() + startMonth)).append("-") | |
523 | + .append((wv_day.getCurrentItem() + startDay)).append(" ") | |
524 | + .append(wv_hours.getCurrentItem()).append(":") | |
525 | + .append(wv_mins.getCurrentItem()).append(":") | |
526 | + .append(wv_seconds.getCurrentItem()); | |
527 | + } else { | |
528 | + sb.append((wv_year.getCurrentItem() + startYear)).append("-") | |
529 | + .append((wv_month.getCurrentItem() + startMonth)).append("-") | |
530 | + .append((wv_day.getCurrentItem() + 1)).append(" ") | |
531 | + .append(wv_hours.getCurrentItem()).append(":") | |
532 | + .append(wv_mins.getCurrentItem()).append(":") | |
533 | + .append(wv_seconds.getCurrentItem()); | |
534 | + } | |
535 | + | |
536 | + | |
537 | + } else { | |
538 | + sb.append((wv_year.getCurrentItem() + startYear)).append("-") | |
539 | + .append((wv_month.getCurrentItem() + 1)).append("-") | |
540 | + .append((wv_day.getCurrentItem() + 1)).append(" ") | |
541 | + .append(wv_hours.getCurrentItem()).append(":") | |
542 | + .append(wv_mins.getCurrentItem()).append(":") | |
543 | + .append(wv_seconds.getCurrentItem()); | |
544 | + } | |
545 | + | |
546 | + return sb.toString(); | |
547 | + } | |
548 | + | |
549 | + public View getView() { | |
550 | + return view; | |
551 | + } | |
552 | + | |
553 | + public void setView(View view) { | |
554 | + this.view = view; | |
555 | + } | |
556 | + | |
557 | + public int getStartYear() { | |
558 | + return startYear; | |
559 | + } | |
560 | + | |
561 | + public void setStartYear(int startYear) { | |
562 | + this.startYear = startYear; | |
563 | + } | |
564 | + | |
565 | + public int getEndYear() { | |
566 | + return endYear; | |
567 | + } | |
568 | + | |
569 | + public void setEndYear(int endYear) { | |
570 | + this.endYear = endYear; | |
571 | + } | |
572 | + | |
573 | + | |
574 | + public void setRangDate(Calendar startDate, Calendar endDate) { | |
575 | + | |
576 | + if (startDate == null && endDate != null) { | |
577 | + int year = endDate.get(Calendar.YEAR); | |
578 | + int month = endDate.get(Calendar.MONTH) + 1; | |
579 | + int day = endDate.get(Calendar.DAY_OF_MONTH); | |
580 | + if (year > startYear) { | |
581 | + this.endYear = year; | |
582 | + this.endMonth = month; | |
583 | + this.endDay = day; | |
584 | + } else if (year == startYear) { | |
585 | + if (month > startMonth) { | |
586 | + this.endYear = year; | |
587 | + this.endMonth = month; | |
588 | + this.endDay = day; | |
589 | + } else if (month == startMonth) { | |
590 | + if (month > startDay) { | |
591 | + this.endYear = year; | |
592 | + this.endMonth = month; | |
593 | + this.endDay = day; | |
594 | + } | |
595 | + } | |
596 | + } | |
597 | + | |
598 | + } else if (startDate != null && endDate == null) { | |
599 | + int year = startDate.get(Calendar.YEAR); | |
600 | + int month = startDate.get(Calendar.MONTH) + 1; | |
601 | + int day = startDate.get(Calendar.DAY_OF_MONTH); | |
602 | + if (year < endYear) { | |
603 | + this.startMonth = month; | |
604 | + this.startDay = day; | |
605 | + this.startYear = year; | |
606 | + } else if (year == endYear) { | |
607 | + if (month < endMonth) { | |
608 | + this.startMonth = month; | |
609 | + this.startDay = day; | |
610 | + this.startYear = year; | |
611 | + } else if (month == endMonth) { | |
612 | + if (day < endDay) { | |
613 | + this.startMonth = month; | |
614 | + this.startDay = day; | |
615 | + this.startYear = year; | |
616 | + } | |
617 | + } | |
618 | + } | |
619 | + | |
620 | + } else if (startDate != null && endDate != null) { | |
621 | + this.startYear = startDate.get(Calendar.YEAR); | |
622 | + this.endYear = endDate.get(Calendar.YEAR); | |
623 | + this.startMonth = startDate.get(Calendar.MONTH) + 1; | |
624 | + this.endMonth = endDate.get(Calendar.MONTH) + 1; | |
625 | + this.startDay = startDate.get(Calendar.DAY_OF_MONTH); | |
626 | + this.endDay = endDate.get(Calendar.DAY_OF_MONTH); | |
627 | + | |
628 | + | |
629 | + } | |
630 | + | |
631 | + | |
632 | + } | |
633 | + | |
634 | + | |
635 | + /** | |
636 | + * 设置间距倍数,但是只能在1.0-2.0f之间 | |
637 | + * | |
638 | + * @param lineSpacingMultiplier | |
639 | + */ | |
640 | + public void setLineSpacingMultiplier(float lineSpacingMultiplier) { | |
641 | + this.lineSpacingMultiplier = lineSpacingMultiplier; | |
642 | + setLineSpacingMultiplier(); | |
643 | + } | |
644 | + | |
645 | + /** | |
646 | + * 设置分割线的颜色 | |
647 | + * | |
648 | + * @param dividerColor | |
649 | + */ | |
650 | + public void setDividerColor(int dividerColor) { | |
651 | + this.dividerColor = dividerColor; | |
652 | + setDividerColor(); | |
653 | + } | |
654 | + | |
655 | + /** | |
656 | + * 设置分割线的类型 | |
657 | + * | |
658 | + * @param dividerType | |
659 | + */ | |
660 | + public void setDividerType(WheelView.DividerType dividerType) { | |
661 | + this.dividerType = dividerType; | |
662 | + setDividerType(); | |
663 | + } | |
664 | + | |
665 | + /** | |
666 | + * 设置分割线之间的文字的颜色 | |
667 | + * | |
668 | + * @param textColorCenter | |
669 | + */ | |
670 | + public void setTextColorCenter(int textColorCenter) { | |
671 | + this.textColorCenter = textColorCenter; | |
672 | + setTextColorCenter(); | |
673 | + } | |
674 | + | |
675 | + /** | |
676 | + * 设置分割线以外文字的颜色 | |
677 | + * | |
678 | + * @param textColorOut | |
679 | + */ | |
680 | + public void setTextColorOut(int textColorOut) { | |
681 | + this.textColorOut = textColorOut; | |
682 | + setTextColorOut(); | |
683 | + } | |
684 | + | |
685 | + /** | |
686 | + * Label 是否只显示中间选中项的 | |
687 | + * | |
688 | + * @param isCenterLabel | |
689 | + */ | |
690 | + | |
691 | + public void isCenterLabel(Boolean isCenterLabel) { | |
692 | + | |
693 | + wv_day.isCenterLabel(isCenterLabel); | |
694 | + wv_month.isCenterLabel(isCenterLabel); | |
695 | + wv_year.isCenterLabel(isCenterLabel); | |
696 | + wv_hours.isCenterLabel(isCenterLabel); | |
697 | + wv_mins.isCenterLabel(isCenterLabel); | |
698 | + wv_seconds.isCenterLabel(isCenterLabel); | |
699 | + } | |
700 | +} | ... | ... |
PersonalCenter/pickerview/src/main/res/anim/pickerview_dialog_scale_in.xml
... | ... | @@ -0,0 +1,19 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<set xmlns:android="http://schemas.android.com/apk/res/android"> | |
3 | + | |
4 | + | |
5 | + <alpha | |
6 | + android:duration="@integer/animation_default_duration" | |
7 | + android:fromAlpha="0.0" | |
8 | + android:toAlpha="1.0" /> | |
9 | + | |
10 | + <scale | |
11 | + android:duration="@integer/animation_default_duration" | |
12 | + android:fromXScale="0.0" | |
13 | + android:toXScale="1.0" | |
14 | + android:fromYScale="0.0" | |
15 | + android:toYScale="1.0" | |
16 | + android:pivotX="50%" | |
17 | + android:pivotY="50%"/> | |
18 | + | |
19 | +</set> | |
0 | 20 | \ No newline at end of file | ... | ... |
PersonalCenter/pickerview/src/main/res/anim/pickerview_dialog_scale_out.xml
... | ... | @@ -0,0 +1,18 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<set xmlns:android="http://schemas.android.com/apk/res/android"> | |
3 | + | |
4 | + | |
5 | + <alpha | |
6 | + android:duration="@integer/animation_default_duration" | |
7 | + android:fromAlpha="1.0" | |
8 | + android:toAlpha="0.3" /> | |
9 | + | |
10 | + <scale | |
11 | + android:duration="@integer/animation_default_duration" | |
12 | + android:fromXScale="1.0" | |
13 | + android:toXScale="0.0" | |
14 | + android:fromYScale="1.0" | |
15 | + android:toYScale="0.0" | |
16 | + android:pivotX="50%" | |
17 | + android:pivotY="50%"/> | |
18 | +</set> | |
0 | 19 | \ No newline at end of file | ... | ... |
PersonalCenter/pickerview/src/main/res/anim/pickerview_slide_in_bottom.xml
... | ... | @@ -0,0 +1,11 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<set xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:shareInterpolator="false"> | |
4 | + | |
5 | + <translate | |
6 | + android:duration="@integer/animation_default_duration" | |
7 | + android:fromXDelta="0%" | |
8 | + android:toXDelta="0%" | |
9 | + android:fromYDelta="100%" | |
10 | + android:toYDelta="0%"/> | |
11 | +</set> | |
0 | 12 | \ No newline at end of file | ... | ... |
PersonalCenter/pickerview/src/main/res/anim/pickerview_slide_out_bottom.xml
... | ... | @@ -0,0 +1,11 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<set xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:shareInterpolator="false"> | |
4 | + | |
5 | + <translate | |
6 | + android:duration="@integer/animation_default_duration" | |
7 | + android:fromXDelta="0%" | |
8 | + android:toXDelta="0%" | |
9 | + android:fromYDelta="0%" | |
10 | + android:toYDelta="100%"/> | |
11 | +</set> | |
0 | 12 | \ No newline at end of file | ... | ... |
PersonalCenter/pickerview/src/main/res/drawable/selector_pickerview_btn.xml
... | ... | @@ -0,0 +1,6 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<selector | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android"> | |
4 | + <item android:state_pressed="true" android:color="@color/pickerview_timebtn_pre" /> | |
5 | + <item android:color="@color/pickerview_timebtn_nor" /> | |
6 | +</selector> | ... | ... |
PersonalCenter/pickerview/src/main/res/layout/include_pickerview_topbar.xml
... | ... | @@ -0,0 +1,42 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:id="@+id/rv_topbar" | |
4 | + android:layout_width="match_parent" | |
5 | + android:layout_height="match_parent"> | |
6 | + | |
7 | + <Button | |
8 | + android:id="@+id/btnCancel" | |
9 | + android:layout_width="wrap_content" | |
10 | + android:layout_height="match_parent" | |
11 | + android:background="@android:color/transparent" | |
12 | + android:gravity="left|center_vertical" | |
13 | + android:paddingLeft="@dimen/pickerview_topbar_padding" | |
14 | + android:text="@string/pickerview_cancel" | |
15 | + android:layout_marginLeft="20dp" | |
16 | + android:textColor="@drawable/selector_pickerview_btn" | |
17 | + android:textSize="@dimen/pickerview_topbar_btn_textsize" /> | |
18 | + | |
19 | + <TextView | |
20 | + android:id="@+id/tvTitle" | |
21 | + android:layout_width="match_parent" | |
22 | + android:gravity="center" | |
23 | + android:layout_height="wrap_content" | |
24 | + android:layout_centerVertical="true" | |
25 | + android:layout_toLeftOf="@+id/btnSubmit" | |
26 | + android:layout_toRightOf="@+id/btnCancel" | |
27 | + android:textColor="@color/pickerview_topbar_title" | |
28 | + android:textSize="@dimen/pickerview_topbar_title_textsize" /> | |
29 | + | |
30 | + <Button | |
31 | + android:id="@id/btnSubmit" | |
32 | + android:layout_width="wrap_content" | |
33 | + android:layout_height="match_parent" | |
34 | + android:layout_alignParentRight="true" | |
35 | + android:background="@android:color/transparent" | |
36 | + android:gravity="right|center_vertical" | |
37 | + android:paddingRight="@dimen/pickerview_topbar_padding" | |
38 | + android:text="@string/pickerview_submit" | |
39 | + android:layout_marginRight="20dp" | |
40 | + android:textColor="@drawable/selector_pickerview_btn" | |
41 | + android:textSize="@dimen/pickerview_topbar_btn_textsize" /> | |
42 | +</RelativeLayout> | ... | ... |
PersonalCenter/pickerview/src/main/res/layout/layout_basepickerview.xml
... | ... | @@ -0,0 +1,16 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<FrameLayout | |
3 | + android:id="@+id/outmost_container" | |
4 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
5 | + android:layout_width="match_parent" | |
6 | + android:layout_height="match_parent" | |
7 | + android:clickable="true" | |
8 | + android:background="@color/pickerview_bgColor_overlay"> | |
9 | + | |
10 | + <FrameLayout | |
11 | + android:id="@+id/content_container" | |
12 | + android:layout_width="wrap_content" | |
13 | + android:layout_height="wrap_content"> | |
14 | + </FrameLayout> | |
15 | + | |
16 | +</FrameLayout> | |
0 | 17 | \ No newline at end of file | ... | ... |
PersonalCenter/pickerview/src/main/res/layout/pickerview_options.xml
... | ... | @@ -0,0 +1,39 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:layout_width="wrap_content" | |
4 | + android:layout_height="wrap_content" | |
5 | + android:orientation="vertical"> | |
6 | + | |
7 | + <include | |
8 | + layout="@layout/include_pickerview_topbar" | |
9 | + android:layout_width="match_parent" | |
10 | + android:layout_height="@dimen/pickerview_topbar_height" /> | |
11 | + | |
12 | + <LinearLayout | |
13 | + android:id="@+id/optionspicker" | |
14 | + android:layout_width="match_parent" | |
15 | + android:layout_height="wrap_content" | |
16 | + android:background="@android:color/white" | |
17 | + android:orientation="horizontal"> | |
18 | + | |
19 | + <com.bigkoo.pickerview.lib.WheelView | |
20 | + android:id="@+id/options1" | |
21 | + android:layout_width="match_parent" | |
22 | + android:layout_height="wrap_content" | |
23 | + android:layout_weight="1" /> | |
24 | + | |
25 | + <com.bigkoo.pickerview.lib.WheelView | |
26 | + android:id="@+id/options2" | |
27 | + android:layout_width="match_parent" | |
28 | + android:layout_height="wrap_content" | |
29 | + android:layout_weight="1" /> | |
30 | + | |
31 | + <com.bigkoo.pickerview.lib.WheelView | |
32 | + android:id="@+id/options3" | |
33 | + android:layout_width="match_parent" | |
34 | + android:layout_height="wrap_content" | |
35 | + android:layout_weight="1" /> | |
36 | + </LinearLayout> | |
37 | + | |
38 | + | |
39 | +</LinearLayout> | |
0 | 40 | \ No newline at end of file | ... | ... |
PersonalCenter/pickerview/src/main/res/layout/pickerview_time.xml
... | ... | @@ -0,0 +1,59 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:layout_width="wrap_content" | |
4 | + android:layout_height="wrap_content" | |
5 | + android:background="@color/pickerview_bgColor_default" | |
6 | + android:orientation="vertical"> | |
7 | + | |
8 | + | |
9 | + <LinearLayout | |
10 | + android:id="@+id/timepicker" | |
11 | + android:layout_width="match_parent" | |
12 | + android:layout_height="wrap_content" | |
13 | + android:background="@android:color/white" | |
14 | + android:orientation="horizontal"> | |
15 | + | |
16 | + <com.bigkoo.pickerview.lib.WheelView | |
17 | + android:id="@+id/year" | |
18 | + android:layout_width="match_parent" | |
19 | + android:layout_height="wrap_content" | |
20 | + android:layout_weight="0.96" /> | |
21 | + | |
22 | + <com.bigkoo.pickerview.lib.WheelView | |
23 | + | |
24 | + android:id="@+id/month" | |
25 | + android:layout_width="match_parent" | |
26 | + android:layout_height="wrap_content" | |
27 | + android:layout_weight="1" /> | |
28 | + | |
29 | + <com.bigkoo.pickerview.lib.WheelView | |
30 | + android:id="@+id/day" | |
31 | + android:layout_width="match_parent" | |
32 | + android:layout_height="wrap_content" | |
33 | + android:layout_weight="1" /> | |
34 | + | |
35 | + <com.bigkoo.pickerview.lib.WheelView | |
36 | + android:id="@+id/hour" | |
37 | + android:layout_width="match_parent" | |
38 | + android:layout_height="wrap_content" | |
39 | + android:layout_weight="1" /> | |
40 | + | |
41 | + <com.bigkoo.pickerview.lib.WheelView | |
42 | + android:id="@+id/min" | |
43 | + android:layout_width="match_parent" | |
44 | + android:layout_height="wrap_content" | |
45 | + android:layout_weight="1" /> | |
46 | + | |
47 | + <com.bigkoo.pickerview.lib.WheelView | |
48 | + android:id="@+id/second" | |
49 | + android:layout_width="match_parent" | |
50 | + android:layout_height="wrap_content" | |
51 | + android:layout_weight="1" /> | |
52 | + </LinearLayout> | |
53 | + <include | |
54 | + layout="@layout/include_pickerview_topbar" | |
55 | + android:layout_width="match_parent" | |
56 | + android:layout_height="@dimen/pickerview_topbar_height" /> | |
57 | + | |
58 | + | |
59 | +</LinearLayout> | |
0 | 60 | \ No newline at end of file | ... | ... |
PersonalCenter/pickerview/src/main/res/values-en/strings.xml
... | ... | @@ -0,0 +1,11 @@ |
1 | +<resources> | |
2 | + | |
3 | + <string name="pickerview_cancel">Cancel</string> | |
4 | + <string name="pickerview_submit">Confirm</string> | |
5 | + <string name="pickerview_year"> </string> | |
6 | + <string name="pickerview_month"> </string> | |
7 | + <string name="pickerview_day"> </string> | |
8 | + <string name="pickerview_hours"> </string> | |
9 | + <string name="pickerview_minutes"> </string> | |
10 | + <string name="pickerview_seconds"> </string> | |
11 | +</resources> | ... | ... |
PersonalCenter/pickerview/src/main/res/values/attrs.xml
... | ... | @@ -0,0 +1,15 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<resources> | |
3 | + <declare-styleable name="pickerview"> | |
4 | + <attr name="pickerview_gravity"> | |
5 | + <enum name="center" value="17"/> | |
6 | + <enum name="left" value="3"/> | |
7 | + <enum name="right" value="5"/> | |
8 | + </attr> | |
9 | + <attr name="pickerview_textSize" format="dimension"/> | |
10 | + <attr name="pickerview_textColorOut" format="color"/> | |
11 | + <attr name="pickerview_textColorCenter" format="color"/> | |
12 | + <attr name="pickerview_dividerColor" format="color"/> | |
13 | + <attr name="pickerview_lineSpacingMultiplier" format="float"/> | |
14 | + </declare-styleable> | |
15 | +</resources> | |
0 | 16 | \ No newline at end of file | ... | ... |
PersonalCenter/pickerview/src/main/res/values/colors.xml
... | ... | @@ -0,0 +1,14 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<resources> | |
3 | + <color name="pickerview_timebtn_nor">#057dff</color> | |
4 | + <color name="pickerview_timebtn_pre">#c2daf5</color> | |
5 | + <color name="pickerview_bg_topbar">#f5f5f5</color> | |
6 | + | |
7 | + <color name="pickerview_topbar_title">#000000</color> | |
8 | + <color name="pickerview_wheelview_textcolor_out">#a8a8a8</color> | |
9 | + <color name="pickerview_wheelview_textcolor_center">#2a2a2a</color> | |
10 | + <color name="pickerview_wheelview_textcolor_divider">#d5d5d5</color> | |
11 | + <color name="pickerview_bgColor_overlay">#60000000</color> | |
12 | + <color name="pickerview_bgColor_default">#FFFFFFFF</color> | |
13 | + | |
14 | +</resources> | ... | ... |
PersonalCenter/pickerview/src/main/res/values/dimens.xml
... | ... | @@ -0,0 +1,13 @@ |
1 | +<resources> | |
2 | + <!-- 顶部按钮栏高度 --> | |
3 | + <dimen name="pickerview_topbar_height">44dp</dimen> | |
4 | + | |
5 | + <!-- 顶部按钮padding --> | |
6 | + <dimen name="pickerview_topbar_padding">20dp</dimen> | |
7 | + | |
8 | + <!-- 顶部按钮文字大小 --> | |
9 | + <dimen name="pickerview_topbar_btn_textsize">17sp</dimen> | |
10 | + <dimen name="pickerview_topbar_title_textsize">18sp</dimen> | |
11 | + <!-- 选项文字大小 --> | |
12 | + <dimen name="pickerview_textsize">20sp</dimen> | |
13 | +</resources> | ... | ... |
PersonalCenter/pickerview/src/main/res/values/integers.xml
PersonalCenter/pickerview/src/main/res/values/strings.xml
... | ... | @@ -0,0 +1,11 @@ |
1 | +<resources> | |
2 | + | |
3 | + <string name="pickerview_cancel">取消</string> | |
4 | + <string name="pickerview_submit">确定</string> | |
5 | + <string name="pickerview_year">年</string> | |
6 | + <string name="pickerview_month">月</string> | |
7 | + <string name="pickerview_day">日</string> | |
8 | + <string name="pickerview_hours">时</string> | |
9 | + <string name="pickerview_minutes">分</string> | |
10 | + <string name="pickerview_seconds">秒</string> | |
11 | +</resources> | ... | ... |
PersonalCenter/pickerview/src/main/res/values/styles.xml
... | ... | @@ -0,0 +1,25 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<resources> | |
3 | + <style name="custom_dialog2" parent="@android:style/Theme.Dialog"> | |
4 | + <item name="android:windowFrame">@null</item> | |
5 | + <!-- Dialog的windowFrame框为无 --> | |
6 | + <item name="android:windowIsFloating">true</item> | |
7 | + <!-- 是否漂现在activity上 --> | |
8 | + <item name="android:windowIsTranslucent">true</item> | |
9 | + <!-- 是否半透明 --> | |
10 | + <item name="android:windowNoTitle">true</item> | |
11 | + <item name="android:background">@null</item> | |
12 | + <item name="android:windowBackground">@android:color/transparent</item> | |
13 | + <item name="android:windowContentOverlay">@null</item> | |
14 | + <!-- 去除黑色边框的关键设置项 --> | |
15 | + <item name="android:backgroundDimEnabled">true</item> | |
16 | + <!-- 屏幕背景是否变暗 --> | |
17 | + <item name="android:backgroundDimAmount">0.3</item> | |
18 | + </style> | |
19 | + | |
20 | + <style name="pickerview_dialogAnim" mce_bogus="1" parent="android:Animation"> | |
21 | + <item name="android:windowEnterAnimation">@anim/pickerview_dialog_scale_in</item> | |
22 | + <item name="android:windowExitAnimation">@anim/pickerview_dialog_scale_out</item> | |
23 | + </style> | |
24 | + | |
25 | +</resources> | ... | ... |
PersonalCenter/settings.gradle