Commit 4512e826b56e13e1f2be228db4bc0646a831a074
1 parent
bcafe53a
Exists in
yxb_dev
and in
2 other branches
no message
Showing
15 changed files
with
816 additions
and
2 deletions
Show diff stats
app/src/main/AndroidManifest.xml
... | ... | @@ -53,7 +53,13 @@ |
53 | 53 | </intent-filter> |
54 | 54 | </activity> |
55 | 55 | <!--<activity android:name=".ui.activity.LoginAndRegistActivity" />--> |
56 | - <activity android:name=".ui.activity.StartActivity"></activity> | |
56 | + <activity android:name=".ui.activity.StartActivity" | |
57 | + android:screenOrientation="portrait" | |
58 | + ></activity> | |
59 | + <activity android:name=".ui.activity.binding.SelectSchoolActivity" | |
60 | + android:screenOrientation="portrait" | |
61 | + android:windowSoftInputMode="adjustPan|stateHidden" | |
62 | + ></activity> | |
57 | 63 | <activity android:name=".ui.activity.LoginAndRegistActivity" |
58 | 64 | android:screenOrientation="portrait" |
59 | 65 | /> | ... | ... |
app/src/main/java/com/shunzhi/parent/adapter/SchoolListAdapter.java
0 → 100644
... | ... | @@ -0,0 +1,96 @@ |
1 | +package com.shunzhi.parent.adapter; | |
2 | + | |
3 | + | |
4 | +import android.content.Context; | |
5 | +import android.view.LayoutInflater; | |
6 | +import android.view.View; | |
7 | +import android.view.ViewGroup; | |
8 | +import android.widget.ImageView; | |
9 | +import android.widget.TextView; | |
10 | + | |
11 | +import com.share.mvpsdk.base.adapter.BaseRecyclerViewAdapter; | |
12 | +import com.share.mvpsdk.base.adapter.BaseRecyclerViewHolder; | |
13 | +import com.shunzhi.parent.R; | |
14 | +import com.shunzhi.parent.bean.SchoolBean; | |
15 | + | |
16 | +import java.util.List; | |
17 | + | |
18 | +/** | |
19 | + * Created by Administrator on 2018/3/9 0009. | |
20 | + */ | |
21 | + | |
22 | +public class SchoolListAdapter extends BaseRecyclerViewAdapter<SchoolBean> { | |
23 | + | |
24 | + Context context; | |
25 | + List<SchoolBean>list; | |
26 | + | |
27 | + public SchoolListAdapter(Context context,List<SchoolBean>list) { | |
28 | + this.context = context; | |
29 | + this.list=list; | |
30 | + } | |
31 | + | |
32 | + | |
33 | + @Override | |
34 | + public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
35 | + View view = LayoutInflater.from(context).inflate(R.layout.item_school, null); | |
36 | + return new MyViewHolder(view); | |
37 | + } | |
38 | + | |
39 | + private class MyViewHolder extends BaseRecyclerViewHolder<SchoolBean> { | |
40 | + TextView school_name; | |
41 | + ImageView select_school; | |
42 | + TextView tvLetter; | |
43 | + | |
44 | + public MyViewHolder(View view) { | |
45 | + super(view); | |
46 | + school_name = view.findViewById(R.id.school_name); | |
47 | + select_school = view.findViewById(R.id.select_school); | |
48 | + tvLetter = view.findViewById(R.id.uiPPLetter); | |
49 | + } | |
50 | + | |
51 | + @Override | |
52 | + public void onBindViewHolder(SchoolBean object, int position) { | |
53 | + int section = getSectionForPosition(position); | |
54 | + //如果当前位置等于该分类首字母的Char的位置 ,则认为是第一次出现,并且不是老师 | |
55 | + if (position == getPositionForSection(section)) { | |
56 | + tvLetter.setVisibility(View.VISIBLE); | |
57 | + tvLetter.setText(object.getSortLetters()); | |
58 | + if (object.getSortLetters().equals("#")) { | |
59 | + tvLetter.setVisibility(View.GONE); | |
60 | + } | |
61 | + } else { | |
62 | + tvLetter.setVisibility(View.GONE); | |
63 | + } | |
64 | + | |
65 | + school_name.setText(object.getSchoolname()); | |
66 | + | |
67 | + | |
68 | + } | |
69 | + | |
70 | + | |
71 | + | |
72 | + | |
73 | + } | |
74 | + public int getPositionForSection(int section) { | |
75 | + for (int i = 0; i < getCount(); i++) { | |
76 | + String sortStr = list.get(i).getSortLetters(); | |
77 | + char firstChar = sortStr.toUpperCase().charAt(0); | |
78 | + if (firstChar == section) { | |
79 | + return i; | |
80 | + } | |
81 | + } | |
82 | + | |
83 | + return -1; | |
84 | + } | |
85 | + public int getCount() { | |
86 | + return list.size(); | |
87 | + } | |
88 | + | |
89 | + public int getSectionForPosition(int position) { | |
90 | + | |
91 | + return list.get(position).getSortLetters().charAt(0); | |
92 | + | |
93 | + } | |
94 | + | |
95 | + | |
96 | +} | ... | ... |
app/src/main/java/com/shunzhi/parent/bean/SchoolBean.java
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +package com.shunzhi.parent.bean; | |
2 | + | |
3 | +/** | |
4 | + * Created by Administrator on 2018/3/9 0009. | |
5 | + */ | |
6 | + | |
7 | +public class SchoolBean { | |
8 | + String schoolname; | |
9 | + String SortLetters; | |
10 | + | |
11 | + public String getSchoolname() { | |
12 | + return schoolname; | |
13 | + } | |
14 | + | |
15 | + public void setSchoolname(String schoolname) { | |
16 | + this.schoolname = schoolname; | |
17 | + } | |
18 | + | |
19 | + public String getSortLetters() { | |
20 | + return SortLetters; | |
21 | + } | |
22 | + | |
23 | + public void setSortLetters(String sortLetters) { | |
24 | + SortLetters = sortLetters; | |
25 | + } | |
26 | +} | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/activity/MyChildActivity.java
1 | 1 | package com.shunzhi.parent.ui.activity; |
2 | 2 | |
3 | 3 | import android.annotation.SuppressLint; |
4 | +import android.content.Intent; | |
4 | 5 | import android.graphics.Color; |
5 | 6 | import android.os.Bundle; |
6 | 7 | import android.support.annotation.NonNull; |
... | ... | @@ -20,6 +21,7 @@ import com.shunzhi.parent.adapter.ChildAdapter; |
20 | 21 | import com.shunzhi.parent.bean.ChildBean; |
21 | 22 | import com.shunzhi.parent.contract.mine.MyChildContract; |
22 | 23 | import com.shunzhi.parent.presenter.mine.MyChildPresenter; |
24 | +import com.shunzhi.parent.ui.activity.binding.SelectSchoolActivity; | |
23 | 25 | import com.yanzhenjie.recyclerview.swipe.SwipeMenu; |
24 | 26 | import com.yanzhenjie.recyclerview.swipe.SwipeMenuBridge; |
25 | 27 | import com.yanzhenjie.recyclerview.swipe.SwipeMenuCreator; |
... | ... | @@ -106,7 +108,7 @@ public class MyChildActivity extends BaseMVPCompatActivity<MyChildContract.MyChi |
106 | 108 | if (v == back) { |
107 | 109 | finish(); |
108 | 110 | } else if (v == add_child) { |
109 | - | |
111 | + startActivity(new Intent().setClass(MyChildActivity.this, SelectSchoolActivity.class)); | |
110 | 112 | } |
111 | 113 | } |
112 | 114 | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/activity/binding/CheckInfoActivity.java
0 → 100644
... | ... | @@ -0,0 +1,30 @@ |
1 | +package com.shunzhi.parent.ui.activity.binding; | |
2 | + | |
3 | +import android.os.Bundle; | |
4 | +import android.support.annotation.NonNull; | |
5 | + | |
6 | +import com.share.mvpsdk.base.BasePresenter; | |
7 | +import com.share.mvpsdk.base.activity.BaseMVPCompatActivity; | |
8 | +import com.shunzhi.parent.R; | |
9 | + | |
10 | +/** | |
11 | + * Created by Administrator on 2018/3/12 0012. | |
12 | + */ | |
13 | + | |
14 | +public class CheckInfoActivity extends BaseMVPCompatActivity{ | |
15 | + @NonNull | |
16 | + @Override | |
17 | + public BasePresenter initPresenter() { | |
18 | + return null; | |
19 | + } | |
20 | + | |
21 | + @Override | |
22 | + protected void initView(Bundle savedInstanceState) { | |
23 | + | |
24 | + } | |
25 | + | |
26 | + @Override | |
27 | + protected int getLayoutId() { | |
28 | + return R.layout.activity_check_info; | |
29 | + } | |
30 | +} | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/activity/binding/SelectSchoolActivity.java
0 → 100644
... | ... | @@ -0,0 +1,196 @@ |
1 | +package com.shunzhi.parent.ui.activity.binding; | |
2 | + | |
3 | +import android.content.Intent; | |
4 | +import android.os.Bundle; | |
5 | +import android.support.annotation.NonNull; | |
6 | +import android.support.v7.widget.LinearLayoutManager; | |
7 | +import android.support.v7.widget.RecyclerView; | |
8 | +import android.view.View; | |
9 | +import android.widget.TextView; | |
10 | + | |
11 | +import com.share.mvpsdk.base.BasePresenter; | |
12 | +import com.share.mvpsdk.base.activity.BaseMVPCompatActivity; | |
13 | +import com.shunzhi.parent.R; | |
14 | +import com.shunzhi.parent.adapter.SchoolListAdapter; | |
15 | +import com.shunzhi.parent.bean.SchoolBean; | |
16 | +import com.shunzhi.parent.util.CharacterParser; | |
17 | +import com.shunzhi.parent.views.SideBar; | |
18 | + | |
19 | +import java.util.ArrayList; | |
20 | +import java.util.Collections; | |
21 | +import java.util.Comparator; | |
22 | +import java.util.List; | |
23 | + | |
24 | +/** | |
25 | + * Created by Administrator on 2018/3/12 0012. | |
26 | + */ | |
27 | + | |
28 | +public class SelectSchoolActivity extends BaseMVPCompatActivity implements View.OnClickListener{ | |
29 | + | |
30 | + private SideBar sideBar; | |
31 | + private TextView dialog,go_next; | |
32 | + private RecyclerView schoollist; | |
33 | + private List<String> list = new ArrayList<>(); | |
34 | + SchoolListAdapter schoolListAdapter; | |
35 | + | |
36 | + @NonNull | |
37 | + @Override | |
38 | + public BasePresenter initPresenter() { | |
39 | + return null; | |
40 | + } | |
41 | + | |
42 | + @Override | |
43 | + protected void initView(Bundle savedInstanceState) { | |
44 | + sideBar = findViewById(R.id.sidrbar); | |
45 | + dialog = findViewById(R.id.dialog); | |
46 | + go_next=findViewById(R.id.go_next); | |
47 | + go_next.setOnClickListener(this); | |
48 | + | |
49 | + | |
50 | + | |
51 | + | |
52 | + list.add("阿尔卑斯"); | |
53 | + list.add("阿尔卑斯"); | |
54 | + list.add("阿尔卑斯"); | |
55 | + list.add("贝克街"); | |
56 | + list.add("贝克街"); | |
57 | + list.add("贝克街"); | |
58 | + list.add("贝克街"); | |
59 | + list.add("贝克街"); | |
60 | + list.add("阿尔卑斯"); | |
61 | + list.add("阿尔卑斯"); | |
62 | + list.add("贝克街"); | |
63 | + list.add("贝克街"); | |
64 | + list.add("阿尔卑斯"); | |
65 | + list.add("阿尔卑斯"); | |
66 | + list.add("阿尔卑斯"); | |
67 | + list.add("贝克街"); | |
68 | + list.add("贝克街"); | |
69 | + list.add("血色城堡"); | |
70 | + list.add("血色城堡"); | |
71 | + list.add("血色城堡"); | |
72 | + list.add("血色城堡"); | |
73 | + list.add("贝克街"); | |
74 | + list.add("贝克街"); | |
75 | + list.add("贝克街"); | |
76 | + list.add("贝克街"); | |
77 | + list.add("贝克街"); | |
78 | + list.add("贝克街"); | |
79 | + list.add("贝克街"); | |
80 | + list.add("贝克街"); | |
81 | + list.add("贝克街"); | |
82 | + list.add("血色城堡"); | |
83 | + list.add("血色城堡"); | |
84 | + list.add("血色城堡"); | |
85 | + list.add("血色城堡"); | |
86 | + list.add("贝克街"); | |
87 | + list.add("贝克街"); | |
88 | + list.add("贝克街"); | |
89 | + list.add("贝克街"); | |
90 | + list.add("贝克街"); | |
91 | + list.add("血色城堡"); | |
92 | + list.add("贝克街"); | |
93 | + list.add("贝克街"); | |
94 | + list.add("贝克街"); | |
95 | + list.add("贝克街"); | |
96 | + list.add("贝克街"); | |
97 | + list.add("贝克街"); | |
98 | + list.add("贝克街"); | |
99 | + list.add("贝克街"); | |
100 | + list.add("贝克街"); | |
101 | + list.add("血色城堡"); | |
102 | + list.add("血色城堡"); | |
103 | + list.add("血色城堡"); | |
104 | + list.add("血色城堡"); | |
105 | + schoollist = findViewById(R.id.schoollist); | |
106 | + schoollist.setLayoutManager(new LinearLayoutManager(this)); | |
107 | + final List<SchoolBean>schoolList=OrderedSortSmodel(list); | |
108 | + schoolListAdapter = new SchoolListAdapter(this,schoolList); | |
109 | + schoolListAdapter.addAll(schoolList); | |
110 | + schoollist.setAdapter(schoolListAdapter); | |
111 | + sideBar.setOnTouchingLetterChangedListener(new SideBar.OnTouchingLetterChangedListener() { | |
112 | + @Override | |
113 | + public void onTouchingLetterChanged(String s) { | |
114 | + //该字母首次出现的位置 | |
115 | + int position = -1; | |
116 | + if (schoolListAdapter != null && schoolListAdapter.getCount() > 0) { | |
117 | + | |
118 | + position = schoolListAdapter.getPositionForSection(s.charAt(0)); | |
119 | + } | |
120 | + if (position != -1 && position != 0) { | |
121 | + schoollist.smoothScrollToPosition(position); | |
122 | + } | |
123 | + } | |
124 | + }); | |
125 | + | |
126 | + } | |
127 | + | |
128 | + @Override | |
129 | + protected int getLayoutId() { | |
130 | + return R.layout.activity_select_school; | |
131 | + } | |
132 | + | |
133 | + | |
134 | + List<SchoolBean> OrderedSortSmodel(List<String> list) { | |
135 | + List<SchoolBean> schoolList = new ArrayList<>(); | |
136 | + CharacterParser characterParser = CharacterParser.getInstance(); | |
137 | + for (String c : list) { | |
138 | + SchoolBean s = new SchoolBean(); | |
139 | + s.setSchoolname(c); | |
140 | + | |
141 | + //汉字转换成拼音 | |
142 | + String pinyin = characterParser.getSelling(s.getSchoolname()); | |
143 | + String sortString = ""; | |
144 | + try { | |
145 | + sortString = pinyin.substring(0, 1).toUpperCase(); | |
146 | + } catch (Exception err) { | |
147 | + continue; | |
148 | + } | |
149 | + // 正则表达式,判断首字母是否是英文字母 | |
150 | + if (sortString.matches("[A-Z]") ) { | |
151 | + s.setSortLetters(sortString.toUpperCase()); | |
152 | + } else { | |
153 | + s.setSortLetters("#"); | |
154 | + } | |
155 | + schoolList.add(s); | |
156 | + } | |
157 | + | |
158 | + return orderByNameIndexAndIndentity(schoolList); | |
159 | + } | |
160 | + | |
161 | + | |
162 | + public static List<SchoolBean> orderByNameIndexAndIndentity(List<SchoolBean> sortModels) { | |
163 | + Collections.sort(sortModels, new Comparator<SchoolBean>() { | |
164 | + @Override | |
165 | + public int compare(SchoolBean o1, SchoolBean o2) { | |
166 | + if (o1.getSortLetters().equals("#") && o2.getSortLetters().matches("[A-Z]")) { | |
167 | + return -1; | |
168 | + } else if (o1.getSortLetters().equals("#") && !o2.getSortLetters().matches("[A-Z]")) { | |
169 | + | |
170 | + return 0; | |
171 | + } else if (!o1.getSortLetters().equals("#") && o2.getSortLetters().matches("[A-Z]")) { | |
172 | + return o1.getSortLetters().compareTo(o2.getSortLetters()); | |
173 | + } else if (!o1.getSortLetters().equals("#") && !o2.getSortLetters().matches("[A-Z]")) { | |
174 | + return 1; | |
175 | + } | |
176 | + return o1.getSortLetters().compareTo(o2.getSortLetters()); | |
177 | + } | |
178 | + | |
179 | + @Override | |
180 | + public boolean equals(Object o) { | |
181 | + return super.equals(o); | |
182 | + } | |
183 | + }); | |
184 | + return sortModels; | |
185 | + | |
186 | + } | |
187 | + | |
188 | + @Override | |
189 | + public void onClick(View v) { | |
190 | + if(v==go_next){ | |
191 | + startActivity(new Intent().setClass(SelectSchoolActivity.this,CheckInfoActivity.class)); | |
192 | + | |
193 | + } | |
194 | + | |
195 | + } | |
196 | +} | ... | ... |
app/src/main/java/com/shunzhi/parent/util/CharacterParser.java
0 → 100644
... | ... | @@ -0,0 +1,138 @@ |
1 | +package com.shunzhi.parent.util; | |
2 | + | |
3 | +/** | |
4 | + * Created by xf on 2015/9/22. | |
5 | + */ | |
6 | +/** | |
7 | + * Java汉字转换为拼音 | |
8 | + * | |
9 | + */ | |
10 | +public class CharacterParser { | |
11 | + private static int[] pyvalue = new int[] {-20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242, -20230, -20051, -20036, -20032, | |
12 | + -20026, -20002, -19990, -19986, -19982, -19976, -19805, -19784, -19775, -19774, -19763, -19756, -19751, -19746, -19741, -19739, -19728, | |
13 | + -19725, -19715, -19540, -19531, -19525, -19515, -19500, -19484, -19479, -19467, -19289, -19288, -19281, -19275, -19270, -19263, -19261, | |
14 | + -19249, -19243, -19242, -19238, -19235, -19227, -19224, -19218, -19212, -19038, -19023, -19018, -19006, -19003, -18996, -18977, -18961, | |
15 | + -18952, -18783, -18774, -18773, -18763, -18756, -18741, -18735, -18731, -18722, -18710, -18697, -18696, -18526, -18518, -18501, -18490, | |
16 | + -18478, -18463, -18448, -18447, -18446, -18239, -18237, -18231, -18220, -18211, -18201, -18184, -18183, -18181, -18012, -17997, -17988, | |
17 | + -17970, -17964, -17961, -17950, -17947, -17931, -17928, -17922, -17759, -17752, -17733, -17730, -17721, -17703, -17701, -17697, -17692, | |
18 | + -17683, -17676, -17496, -17487, -17482, -17468, -17454, -17433, -17427, -17417, -17202, -17185, -16983, -16970, -16942, -16915, -16733, | |
19 | + -16708, -16706, -16689, -16664, -16657, -16647, -16474, -16470, -16465, -16459, -16452, -16448, -16433, -16429, -16427, -16423, -16419, | |
20 | + -16412, -16407, -16403, -16401, -16393, -16220, -16216, -16212, -16205, -16202, -16187, -16180, -16171, -16169, -16158, -16155, -15959, | |
21 | + -15958, -15944, -15933, -15920, -15915, -15903, -15889, -15878, -15707, -15701, -15681, -15667, -15661, -15659, -15652, -15640, -15631, | |
22 | + -15625, -15454, -15448, -15436, -15435, -15419, -15416, -15408, -15394, -15385, -15377, -15375, -15369, -15363, -15362, -15183, -15180, | |
23 | + -15165, -15158, -15153, -15150, -15149, -15144, -15143, -15141, -15140, -15139, -15128, -15121, -15119, -15117, -15110, -15109, -14941, | |
24 | + -14937, -14933, -14930, -14929, -14928, -14926, -14922, -14921, -14914, -14908, -14902, -14894, -14889, -14882, -14873, -14871, -14857, | |
25 | + -14678, -14674, -14670, -14668, -14663, -14654, -14645, -14630, -14594, -14429, -14407, -14399, -14384, -14379, -14368, -14355, -14353, | |
26 | + -14345, -14170, -14159, -14151, -14149, -14145, -14140, -14137, -14135, -14125, -14123, -14122, -14112, -14109, -14099, -14097, -14094, | |
27 | + -14092, -14090, -14087, -14083, -13917, -13914, -13910, -13907, -13906, -13905, -13896, -13894, -13878, -13870, -13859, -13847, -13831, | |
28 | + -13658, -13611, -13601, -13406, -13404, -13400, -13398, -13395, -13391, -13387, -13383, -13367, -13359, -13356, -13343, -13340, -13329, | |
29 | + -13326, -13318, -13147, -13138, -13120, -13107, -13096, -13095, -13091, -13076, -13068, -13063, -13060, -12888, -12875, -12871, -12860, | |
30 | + -12858, -12852, -12849, -12838, -12831, -12829, -12812, -12802, -12607, -12597, -12594, -12585, -12556, -12359, -12346, -12320, -12300, | |
31 | + -12120, -12099, -12089, -12074, -12067, -12058, -12039, -11867, -11861, -11847, -11831, -11798, -11781, -11604, -11589, -11536, -11358, | |
32 | + -11340, -11339, -11324, -11303, -11097, -11077, -11067, -11055, -11052, -11045, -11041, -11038, -11024, -11020, -11019, -11018, -11014, | |
33 | + -10838, -10832, -10815, -10800, -10790, -10780, -10764, -10587, -10544, -10533, -10519, -10331, -10329, -10328, -10322, -10315, -10309, | |
34 | + -10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256, -10254}; | |
35 | + public static String[] pystr = new String[] {"a", "ai", "an", "ang", "ao", "ba", "bai", "ban", "bang", "bao", "bei", "ben", "beng", "bi", "bian", | |
36 | + "biao", "bie", "bin", "bing", "bo", "bu", "ca", "cai", "can", "cang", "cao", "ce", "ceng", "cha", "chai", "chan", "chang", "chao", "che", | |
37 | + "chen", "cheng", "chi", "chong", "chou", "chu", "chuai", "chuan", "chuang", "chui", "chun", "chuo", "ci", "cong", "cou", "cu", "cuan", | |
38 | + "cui", "cun", "cuo", "da", "dai", "dan", "dang", "dao", "de", "deng", "di", "dian", "diao", "die", "ding", "diu", "dong", "dou", "du", | |
39 | + "duan", "dui", "dun", "duo", "e", "en", "er", "fa", "fan", "fang", "fei", "fen", "feng", "fo", "fou", "fu", "ga", "gai", "gan", "gang", | |
40 | + "gao", "ge", "gei", "gen", "geng", "gong", "gou", "gu", "gua", "guai", "guan", "guang", "gui", "gun", "guo", "ha", "hai", "han", "hang", | |
41 | + "hao", "he", "hei", "hen", "heng", "hong", "hou", "hu", "hua", "huai", "huan", "huang", "hui", "hun", "huo", "ji", "jia", "jian", | |
42 | + "jiang", "jiao", "jie", "jin", "jing", "jiong", "jiu", "ju", "juan", "jue", "jun", "ka", "kai", "kan", "kang", "kao", "ke", "ken", | |
43 | + "keng", "kong", "kou", "ku", "kua", "kuai", "kuan", "kuang", "kui", "kun", "kuo", "la", "lai", "lan", "lang", "lao", "le", "lei", "leng", | |
44 | + "li", "lia", "lian", "liang", "liao", "lie", "lin", "ling", "liu", "long", "lou", "lu", "lv", "luan", "lue", "lun", "luo", "ma", "mai", | |
45 | + "man", "mang", "mao", "me", "mei", "men", "meng", "mi", "mian", "miao", "mie", "min", "ming", "miu", "mo", "mou", "mu", "na", "nai", | |
46 | + "nan", "nang", "nao", "ne", "nei", "nen", "neng", "ni", "nian", "niang", "niao", "nie", "nin", "ning", "niu", "nong", "nu", "nv", "nuan", | |
47 | + "nue", "nuo", "o", "ou", "pa", "pai", "pan", "pang", "pao", "pei", "pen", "peng", "pi", "pian", "piao", "pie", "pin", "ping", "po", "pu", | |
48 | + "qi", "qia", "qian", "qiang", "qiao", "qie", "qin", "qing", "qiong", "qiu", "qu", "quan", "que", "qun", "ran", "rang", "rao", "re", | |
49 | + "ren", "reng", "ri", "rong", "rou", "ru", "ruan", "rui", "run", "ruo", "sa", "sai", "san", "sang", "sao", "se", "sen", "seng", "sha", | |
50 | + "shai", "shan", "shang", "shao", "she", "shen", "sheng", "shi", "shou", "shu", "shua", "shuai", "shuan", "shuang", "shui", "shun", | |
51 | + "shuo", "si", "song", "sou", "su", "suan", "sui", "sun", "suo", "ta", "tai", "tan", "tang", "tao", "te", "teng", "ti", "tian", "tiao", | |
52 | + "tie", "ting", "tong", "tou", "tu", "tuan", "tui", "tun", "tuo", "wa", "wai", "wan", "wang", "wei", "wen", "weng", "wo", "wu", "xi", | |
53 | + "xia", "xian", "xiang", "xiao", "xie", "xin", "xing", "xiong", "xiu", "xu", "xuan", "xue", "xun", "ya", "yan", "yang", "yao", "ye", "yi", | |
54 | + "yin", "ying", "yo", "yong", "you", "yu", "yuan", "yue", "yun", "za", "zai", "zan", "zang", "zao", "ze", "zei", "zen", "zeng", "zha", | |
55 | + "zhai", "zhan", "zhang", "zhao", "zhe", "zhen", "zheng", "zhi", "zhong", "zhou", "zhu", "zhua", "zhuai", "zhuan", "zhuang", "zhui", | |
56 | + "zhun", "zhuo", "zi", "zong", "zou", "zu", "zuan", "zui", "zun", "zuo"}; | |
57 | + private StringBuilder buffer; | |
58 | + private String resource; | |
59 | + | |
60 | + | |
61 | + private static class InstanceHolder{ | |
62 | + private static final CharacterParser characterParser = new CharacterParser(); | |
63 | + } | |
64 | + public static CharacterParser getInstance() { | |
65 | + return InstanceHolder.characterParser; | |
66 | + } | |
67 | + | |
68 | + public String getResource() { | |
69 | + return resource; | |
70 | + } | |
71 | + | |
72 | + public void setResource(String resource) { | |
73 | + this.resource = resource; | |
74 | + } | |
75 | + | |
76 | + /** * 汉字转成ASCII码 * * @param chs * @return */ | |
77 | + private int getChsAscii(String chs) { | |
78 | + int asc = 0; | |
79 | + try { | |
80 | + byte[] bytes = chs.getBytes("gb2312"); | |
81 | + if (bytes == null || bytes.length > 2 || bytes.length <= 0) { | |
82 | + throw new RuntimeException("illegal resource string"); | |
83 | + } | |
84 | + if (bytes.length == 1) { | |
85 | + asc = bytes[0]; | |
86 | + } | |
87 | + if (bytes.length == 2) { | |
88 | + int hightByte = 256 + bytes[0]; | |
89 | + int lowByte = 256 + bytes[1]; | |
90 | + asc = (256 * hightByte + lowByte) - 256 * 256; | |
91 | + } | |
92 | + } catch (Exception e) { | |
93 | + System.out.println("ERROR:ChineseSpelling.class-getChsAscii(String chs)" + e); | |
94 | + } | |
95 | + return asc; | |
96 | + } | |
97 | + | |
98 | + /** * 单字解析 * * @param str * @return */ | |
99 | + public String convert(String str) { | |
100 | + String result = null; | |
101 | + int ascii = getChsAscii(str); | |
102 | + if (ascii > 0 && ascii < 160) { | |
103 | + result = String.valueOf((char) ascii); | |
104 | + } else { | |
105 | + for (int i = (pyvalue.length - 1); i >= 0; i--) { | |
106 | + if (pyvalue[i] <= ascii) { | |
107 | + result = pystr[i]; | |
108 | + break; | |
109 | + } | |
110 | + } | |
111 | + } | |
112 | + return result; | |
113 | + } | |
114 | + | |
115 | + /** * 词组解析 * * @param chs * @return */ | |
116 | + public String getSelling(String chs) { | |
117 | + String key, value; | |
118 | + buffer = new StringBuilder(); | |
119 | + for (int i = 0; i < chs.length(); i++) { | |
120 | + key = chs.substring(i, i + 1); | |
121 | + if (key.getBytes().length >= 2) { | |
122 | + value = (String) convert(key); | |
123 | + if (value == null) { | |
124 | + value = "unknown"; | |
125 | + } | |
126 | + } else { | |
127 | + value = key; | |
128 | + } | |
129 | + buffer.append(value); | |
130 | + } | |
131 | + return buffer.toString(); | |
132 | + } | |
133 | + | |
134 | + public String getSpelling() { | |
135 | + return this.getSelling(this.getResource()); | |
136 | + } | |
137 | + | |
138 | +} | ... | ... |
... | ... | @@ -0,0 +1,140 @@ |
1 | +package com.shunzhi.parent.views; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.graphics.Canvas; | |
5 | +import android.graphics.Color; | |
6 | +import android.graphics.Paint; | |
7 | +import android.graphics.Typeface; | |
8 | +import android.graphics.drawable.ColorDrawable; | |
9 | +import android.util.AttributeSet; | |
10 | +import android.view.MotionEvent; | |
11 | +import android.view.View; | |
12 | +import android.widget.TextView; | |
13 | + | |
14 | +import com.shunzhi.parent.R; | |
15 | + | |
16 | + | |
17 | +public class SideBar extends View { | |
18 | + // 触摸事件 | |
19 | + private OnTouchingLetterChangedListener onTouchingLetterChangedListener; | |
20 | + // 26个字母 | |
21 | + public static String[] b = { "*","A", "B", "C", "D", "E", "F", "G", "H", "I","J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V","W", "X", "Y", "Z", "#" }; | |
22 | + private int choose = -1;// 选中 | |
23 | + private Paint paint = new Paint(); | |
24 | + | |
25 | + private TextView mTextDialog; | |
26 | + | |
27 | + public void setTextView(TextView mTextDialog) { | |
28 | + this.mTextDialog = mTextDialog; | |
29 | + } | |
30 | + | |
31 | + | |
32 | + public SideBar(Context context, AttributeSet attrs, int defStyle) { | |
33 | + super(context, attrs, defStyle); | |
34 | + } | |
35 | + | |
36 | + public SideBar(Context context, AttributeSet attrs) { | |
37 | + super(context, attrs); | |
38 | + } | |
39 | + | |
40 | + public SideBar(Context context) { | |
41 | + super(context); | |
42 | + } | |
43 | + | |
44 | + /** | |
45 | + * 重写这个方法 | |
46 | + */ | |
47 | + protected void onDraw(Canvas canvas) { | |
48 | + super.onDraw(canvas); | |
49 | + // 获取焦点改变背景颜色. | |
50 | + int height = getHeight();// 获取对应高度 | |
51 | + int width = getWidth(); // 获取对应宽度 | |
52 | + //int singleHeight = height / b.length;// 获取每一个字母的高度 | |
53 | + int singleHeight = height / b.length;// 获取每一个字母的高度 | |
54 | + | |
55 | + for (int i = 0; i < b.length; i++) { | |
56 | + if(!b[i].equals("")) { | |
57 | + paint.setColor(Color.rgb(33, 65, 98)); | |
58 | + // paint.setColor(Color.WHITE); | |
59 | + paint.setTypeface(Typeface.DEFAULT_BOLD); | |
60 | + paint.setAntiAlias(true); | |
61 | + //paint.setAlpha(0);//透明 | |
62 | + paint.setTextSize(26); | |
63 | + // 选中的状态 | |
64 | + if (i == choose) { | |
65 | + paint.setColor(Color.parseColor("#3399ff")); | |
66 | + paint.setFakeBoldText(true); | |
67 | + } | |
68 | + // x坐标等于中间-字符串宽度的一半. | |
69 | + float xPos = width / 2 - paint.measureText(b[i]) / 2; | |
70 | + float yPos = singleHeight * i + singleHeight; | |
71 | + canvas.drawText(b[i], xPos, yPos, paint); | |
72 | + paint.reset();// 重置画笔 | |
73 | + } | |
74 | + } | |
75 | + | |
76 | + } | |
77 | + | |
78 | + @Override | |
79 | + public boolean dispatchTouchEvent(MotionEvent event) { | |
80 | + final int action = event.getAction(); | |
81 | + final float y = event.getY();// 点击y坐标 | |
82 | + final int oldChoose = choose; | |
83 | + final OnTouchingLetterChangedListener listener = onTouchingLetterChangedListener; | |
84 | + final int c = (int) (y / getHeight() * b.length);// 点击y坐标所占总高度的比例*b数组的长度就等于点击b中的个数. | |
85 | + switch (action) { | |
86 | + case MotionEvent.ACTION_UP: | |
87 | + gotoStart(); | |
88 | + break; | |
89 | + | |
90 | + default: | |
91 | + setBackgroundResource(R.drawable.sidebar_background); | |
92 | + if (oldChoose != c) { | |
93 | + if (c >= 0 && c < b.length) { | |
94 | + if (listener != null) { | |
95 | + listener.onTouchingLetterChanged(b[c]); | |
96 | + } | |
97 | + if (mTextDialog != null) { | |
98 | + mTextDialog.setText(b[c]); | |
99 | + mTextDialog.setVisibility(View.VISIBLE); | |
100 | + } | |
101 | + | |
102 | + choose = c; | |
103 | + invalidate(); | |
104 | + } | |
105 | + } | |
106 | + | |
107 | + break; | |
108 | + } | |
109 | + return true; | |
110 | + } | |
111 | + | |
112 | + /** | |
113 | + * 向外公开的方法 | |
114 | + * | |
115 | + * @param onTouchingLetterChangedListener | |
116 | + */ | |
117 | + public void setOnTouchingLetterChangedListener( | |
118 | + OnTouchingLetterChangedListener onTouchingLetterChangedListener) { | |
119 | + this.onTouchingLetterChangedListener = onTouchingLetterChangedListener; | |
120 | + } | |
121 | + | |
122 | + /** | |
123 | + * 接口 | |
124 | + * | |
125 | + * @author coder | |
126 | + * | |
127 | + */ | |
128 | + public interface OnTouchingLetterChangedListener { | |
129 | + public void onTouchingLetterChanged(String s); | |
130 | + } | |
131 | + | |
132 | + public void gotoStart(){ | |
133 | + setBackgroundDrawable(new ColorDrawable(0x77dddddd)); | |
134 | + choose = -1; | |
135 | + invalidate(); | |
136 | + if (mTextDialog != null) { | |
137 | + mTextDialog.setVisibility(View.INVISIBLE); | |
138 | + } | |
139 | + } | |
140 | +} | ... | ... |
531 Bytes
1.46 KB
... | ... | @@ -0,0 +1,6 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"> | |
3 | + <stroke android:color="#00000000" android:width="1dp"/> | |
4 | + <solid android:color="#EEEEEE" /> | |
5 | + <corners android:radius="15dp"/> | |
6 | +</shape> | |
0 | 7 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<shape android:shape="rectangle" | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android"> | |
4 | + <gradient android:startColor="@color/gray" android:endColor="@color/white" android:angle="90.0" /> | |
5 | + | |
6 | + <corners | |
7 | + android:topLeftRadius="8dip" | |
8 | + android:bottomLeftRadius="8dip"/> | |
9 | + | |
10 | +</shape> | ... | ... |
... | ... | @@ -0,0 +1,11 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
4 | + xmlns:tools="http://schemas.android.com/tools" | |
5 | + android:layout_width="match_parent" | |
6 | + android:layout_height="match_parent" | |
7 | + tools:context="com.shunzhi.parent.ui.activity.binding.CheckInfoActivity"> | |
8 | + | |
9 | + | |
10 | + | |
11 | +</LinearLayout> | ... | ... |
... | ... | @@ -0,0 +1,109 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
4 | + android:layout_width="match_parent" | |
5 | + android:layout_height="match_parent" | |
6 | + android:background="@color/white" | |
7 | + android:orientation="vertical" | |
8 | + > | |
9 | + | |
10 | + <include layout="@layout/top"/> | |
11 | + <LinearLayout | |
12 | + android:layout_width="match_parent" | |
13 | + android:layout_height="wrap_content" | |
14 | + > | |
15 | + <TextView | |
16 | + android:layout_marginBottom="10dp" | |
17 | + android:layout_marginTop="10dp" | |
18 | + android:id="@+id/tvLocalAddress" | |
19 | + android:layout_width="wrap_content" | |
20 | + android:layout_height="wrap_content" | |
21 | + android:drawablePadding="@dimen/size_dp_5" | |
22 | + android:drawableRight="@drawable/pull" | |
23 | + android:gravity="center" | |
24 | + android:paddingLeft="@dimen/size_dp_15" | |
25 | + android:text="杭州" | |
26 | + android:textColor="@color/textColor" | |
27 | + android:textSize="@dimen/sp_16" /> | |
28 | + <LinearLayout | |
29 | + android:layout_width="wrap_content" | |
30 | + android:layout_weight="1" | |
31 | + android:layout_height="wrap_content" | |
32 | + android:layout_marginRight="@dimen/size_dp_15" | |
33 | + android:paddingTop="5dp" | |
34 | + android:paddingBottom="5dp" | |
35 | + android:background="@drawable/rudiobtn_gray" | |
36 | + android:layout_gravity="center_vertical" | |
37 | + > | |
38 | + | |
39 | + <EditText | |
40 | + android:layout_width="wrap_content" | |
41 | + android:layout_height="wrap_content" | |
42 | + android:layout_marginLeft="10dp" | |
43 | + android:layout_weight="1" | |
44 | + android:hint="请输入搜索内容" | |
45 | + android:textSize="@dimen/sp_16" | |
46 | + android:gravity="center_horizontal" | |
47 | + android:background="@null" | |
48 | + /> | |
49 | +<ImageView | |
50 | + android:layout_width="40dp" | |
51 | + android:layout_height="match_parent" | |
52 | + android:src="@drawable/search_black" | |
53 | + android:layout_marginRight="15dp" | |
54 | + android:layout_gravity="center_vertical" | |
55 | + /> | |
56 | + </LinearLayout> | |
57 | + | |
58 | + </LinearLayout> | |
59 | + <FrameLayout | |
60 | + android:layout_width="fill_parent" | |
61 | + android:layout_height="wrap_content" | |
62 | + android:layout_weight="1" | |
63 | + android:background="@android:color/white"> | |
64 | + | |
65 | + <android.support.v7.widget.RecyclerView | |
66 | + android:id="@+id/schoollist" | |
67 | + android:layout_width="match_parent" | |
68 | + android:layout_height="match_parent" | |
69 | + android:layout_gravity="center" | |
70 | + android:divider="@null" /> | |
71 | + | |
72 | + <TextView | |
73 | + android:id="@+id/dialog" | |
74 | + android:layout_width="80.0dip" | |
75 | + android:layout_height="80.0dip" | |
76 | + android:layout_gravity="center" | |
77 | + android:background="@drawable/progress_bg" | |
78 | + android:gravity="center" | |
79 | + android:textColor="#ffffffff" | |
80 | + android:textSize="30.0dip" | |
81 | + android:visibility="invisible" /> | |
82 | + | |
83 | + <com.shunzhi.parent.views.SideBar | |
84 | + android:id="@+id/sidrbar" | |
85 | + android:layout_width="30.0dip" | |
86 | + android:layout_height="fill_parent" | |
87 | + android:layout_gravity="right|center" | |
88 | + android:background="#77dddddd" | |
89 | + android:layout_marginBottom="5dp" | |
90 | + android:layout_marginTop="5dp" /> | |
91 | + | |
92 | + </FrameLayout> | |
93 | + | |
94 | + <TextView | |
95 | + android:id="@+id/go_next" | |
96 | + android:layout_width="match_parent" | |
97 | + android:layout_height="40dp" | |
98 | + android:layout_marginLeft="10dp" | |
99 | + android:layout_marginRight="10dp" | |
100 | + android:text="下一步" | |
101 | + android:textColor="@color/white" | |
102 | + android:textSize="@dimen/txtsize_title" | |
103 | + android:gravity="center" | |
104 | + android:background="@drawable/rudiobtn" | |
105 | + /> | |
106 | + | |
107 | + | |
108 | + | |
109 | +</LinearLayout> | |
0 | 110 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,44 @@ |
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 | +<LinearLayout | |
7 | + android:layout_width="fill_parent" | |
8 | + android:layout_height="wrap_content" | |
9 | + android:background="#E0E0E0" | |
10 | + > | |
11 | + <TextView | |
12 | + android:id="@+id/uiPPLetter" | |
13 | + android:layout_width="match_parent" | |
14 | + android:layout_height="wrap_content" | |
15 | + android:paddingBottom="5dip" | |
16 | + android:paddingLeft="5dip" | |
17 | + android:paddingTop="5dip" | |
18 | + android:text="A" | |
19 | + android:textColor="#454545" /> | |
20 | +</LinearLayout> | |
21 | + <RelativeLayout | |
22 | + android:layout_width="match_parent" | |
23 | + android:layout_height="wrap_content"> | |
24 | + | |
25 | + <TextView | |
26 | + android:id="@+id/school_name" | |
27 | + android:layout_width="wrap_content" | |
28 | + android:layout_height="40dp" | |
29 | + android:layout_marginLeft="20dp" | |
30 | + android:gravity="center_vertical" | |
31 | + android:text="阿尔卑斯" | |
32 | + android:textColor="@color/textColor" | |
33 | + android:textSize="@dimen/sp_16" /> | |
34 | + | |
35 | + <ImageView | |
36 | + android:layout_alignParentRight="true" | |
37 | + android:id="@+id/select_school" | |
38 | + android:layout_width="20dp" | |
39 | + android:layout_height="40dp" | |
40 | + android:layout_marginRight="40dp" | |
41 | + android:gravity="center_vertical" | |
42 | + android:src="@drawable/select_ok" /> | |
43 | + </RelativeLayout> | |
44 | +</LinearLayout> | ... | ... |