Commit 3fe36dd96a5e39fdbbeaf142ff8e758333923160

Authored by 姚旭斌
1 parent 5b908d62
Exists in yxb_dev and in 1 other branch developer

no message

app/src/main/java/com/shunzhi/parent/adapter/SchoolListAdapter.java
... ... @@ -72,7 +72,6 @@ public class SchoolListAdapter extends BaseRecyclerViewAdapter<SortBean> {
72 72 @Override
73 73 public void onBindViewHolder(final SortBean object, final int position) {
74 74 select_school.setVisibility(View.INVISIBLE);
75   - Log.e("1111-===",position+"");
76 75 if (ischeck[position] ==true) {
77 76 select_school.setVisibility(View.VISIBLE);
78 77 }
... ...
app/src/main/java/com/shunzhi/parent/ui/activity/binding/SelectSchoolActivity.java
... ... @@ -5,7 +5,12 @@ import android.os.Bundle;
5 5 import android.support.annotation.NonNull;
6 6 import android.support.v7.widget.LinearLayoutManager;
7 7 import android.support.v7.widget.RecyclerView;
  8 +import android.text.Editable;
  9 +import android.text.TextUtils;
  10 +import android.text.TextWatcher;
  11 +import android.util.Log;
8 12 import android.view.View;
  13 +import android.widget.EditText;
9 14 import android.widget.ImageView;
10 15 import android.widget.TextView;
11 16  
... ... @@ -41,12 +46,13 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity<SchoolListContra
41 46  
42 47 private SideBar sideBar;
43 48 private TextView dialog, go_next, tvLocalAddress, center_title;
44   - ImageView back;
  49 + ImageView back, iv_search;
45 50 private RecyclerView schoollist;
46   - private List<String> list = new ArrayList<>();
  51 + private List<SchoolBean> currList = new ArrayList<>();
47 52 SchoolListAdapter schoolListAdapter;
48 53 int schoolId;
49 54 CityPicker cityPicker = null;
  55 + EditText et_search;
50 56  
51 57 @NonNull
52 58 @Override
... ... @@ -74,6 +80,10 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity&lt;SchoolListContra
74 80 tvLocalAddress.setText(AppContext.getInstance().district);
75 81 setSchoolList();
76 82  
  83 + et_search = findViewById(R.id.et_search);
  84 + iv_search = findViewById(R.id.iv_search);
  85 + iv_search.setOnClickListener(this);
  86 + et_search.addTextChangedListener(textWatcher);
77 87  
78 88 schoollist = findViewById(R.id.schoollist);
79 89 schoollist.setLayoutManager(new LinearLayoutManager(this));
... ... @@ -180,30 +190,54 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity&lt;SchoolListContra
180 190 if (null == cityPicker) cityPicker = new CityPicker(SelectSchoolActivity.this, this);
181 191 if (cityPicker.isShow()) cityPicker.close();
182 192 else cityPicker.show();
  193 + } else if (v == iv_search) {
  194 + setNewSchoolList(et_search.getText().toString().trim());
183 195 }
184 196  
185 197 }
186 198  
  199 + private void setNewSchoolList(String s) {
  200 + List<SchoolBean> list = new ArrayList<>();
  201 + if (!TextUtils.isEmpty(s)) {
  202 + for (int i = 0; i < currList.size(); i++) {
  203 + if (currList.get(i).school_name.contains(s)) {
  204 + list.add(currList.get(i));
  205 + }
  206 + }
  207 + showResult(list);
  208 + return;
  209 + }
  210 + showResult(currList);
  211 + }
  212 +
187 213  
188 214 @Override
189 215 public void showList(List<SchoolBean> list) {
  216 + currList.clear();
  217 + currList.addAll(list);
  218 + showResult(list);
  219 +
  220 + }
  221 +
  222 + void showResult(List<SchoolBean> list) {
190 223 final List<SortBean> schoolList = OrderedSortSmodel(list);
191   - if(schoolListAdapter==null){
192   - schoolListAdapter = new SchoolListAdapter(this, schoolList);
193   - schoolListAdapter.addAll(schoolList);
194   - schoollist.setAdapter(schoolListAdapter);
195   - }else{
  224 + if (schoolListAdapter == null) {
  225 + schoolListAdapter = new SchoolListAdapter(this, schoolList);
  226 + schoolListAdapter.addAll(schoolList);
  227 + schoollist.setAdapter(schoolListAdapter);
  228 + } else {
196 229 schoolListAdapter.addAll(schoolList);
197 230 schoolListAdapter.notifyDataSetChanged();
198 231 }
199 232 }
200 233  
  234 +
201 235 @Override
202 236 public void showChild(CurrentBean currentBean) {
203 237 if (currentBean.isNew() == 0) {
204 238 startActivity(new Intent().putExtra("school_id", schoolId).setClass(SelectSchoolActivity.this, CheckInfoActivity.class));
205 239 } else {
206   - startActivity(new Intent().putExtra("school_id",schoolId).setClass(SelectSchoolActivity.this, InviteCodeActivity.class));
  240 + startActivity(new Intent().putExtra("school_id", schoolId).setClass(SelectSchoolActivity.this, InviteCodeActivity.class));
207 241 }
208 242 }
209 243  
... ... @@ -216,8 +250,27 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity&lt;SchoolListContra
216 250 @Override
217 251 public void getCity(String name) {
218 252 tvLocalAddress.setText(name.split(" ")[2]);
219   - mPresenter.schoolListResult(name.split(" ")[2],"");
  253 + mPresenter.schoolListResult(name.split(" ")[2], "");
220 254  
221 255  
222 256 }
  257 +
  258 + TextWatcher textWatcher = new TextWatcher() {
  259 + @Override
  260 + public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  261 +
  262 + }
  263 +
  264 + @Override
  265 + public void onTextChanged(CharSequence s, int start, int before, int count) {
  266 + setNewSchoolList(s.toString());
  267 + }
  268 +
  269 + @Override
  270 + public void afterTextChanged(Editable s) {
  271 +
  272 + }
  273 + };
  274 +
  275 +
223 276 }
... ...
app/src/main/res/layout/activity_select_school.xml
1 1 <?xml version="1.0" encoding="utf-8"?>
2   -<LinearLayout
3   - xmlns:android="http://schemas.android.com/apk/res/android"
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4 3 android:layout_width="match_parent"
5 4 android:layout_height="match_parent"
6 5 android:background="@color/white"
7   - android:orientation="vertical"
8   - >
  6 + android:orientation="vertical">
  7 +
  8 + <include layout="@layout/top" />
9 9  
10   - <include layout="@layout/top"/>
11 10 <LinearLayout
12 11 android:layout_width="match_parent"
13   - android:layout_height="wrap_content"
14   - >
  12 + android:layout_height="wrap_content">
  13 +
15 14 <TextView
16   - android:layout_marginBottom="10dp"
17   - android:layout_marginTop="10dp"
18 15 android:id="@+id/tvLocalAddress"
19 16 android:layout_width="wrap_content"
20 17 android:layout_height="wrap_content"
  18 + android:layout_marginBottom="10dp"
  19 + android:layout_marginTop="10dp"
21 20 android:drawablePadding="@dimen/size_dp_5"
22 21 android:drawableRight="@drawable/pull_black"
23 22 android:gravity="center"
... ... @@ -25,37 +24,39 @@
25 24 android:text="杭州"
26 25 android:textColor="@color/textColor"
27 26 android:textSize="@dimen/sp_16" />
  27 +
28 28 <LinearLayout
29 29 android:layout_width="wrap_content"
30   - android:layout_weight="1"
31 30 android:layout_height="wrap_content"
  31 + android:layout_gravity="center_vertical"
32 32 android:layout_marginRight="@dimen/size_dp_15"
33   - android:paddingTop="5dp"
34   - android:paddingBottom="5dp"
  33 + android:layout_weight="1"
35 34 android:background="@drawable/rudiobtn_gray"
36   - android:layout_gravity="center_vertical"
37   - >
  35 + android:paddingBottom="5dp"
  36 + android:paddingTop="5dp">
38 37  
39 38 <EditText
  39 + android:id="@+id/et_search"
40 40 android:layout_width="wrap_content"
41 41 android:layout_height="wrap_content"
42 42 android:layout_marginLeft="10dp"
43 43 android:layout_weight="1"
44   - android:hint="请输入搜索内容"
45   - android:textSize="@dimen/sp_16"
46   - android:gravity="center_horizontal"
47 44 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   - />
  45 + android:gravity="center_horizontal"
  46 + android:hint="请输入搜索内容"
  47 + android:textSize="@dimen/sp_16" />
  48 +
  49 + <ImageView
  50 + android:id="@+id/iv_search"
  51 + android:layout_width="40dp"
  52 + android:layout_height="match_parent"
  53 + android:layout_gravity="center_vertical"
  54 + android:layout_marginRight="15dp"
  55 + android:src="@drawable/search_black" />
56 56 </LinearLayout>
57 57  
58 58 </LinearLayout>
  59 +
59 60 <FrameLayout
60 61 android:layout_width="fill_parent"
61 62 android:layout_height="wrap_content"
... ... @@ -85,9 +86,9 @@
85 86 android:layout_width="30.0dip"
86 87 android:layout_height="fill_parent"
87 88 android:layout_gravity="right|center"
88   - android:background="#77dddddd"
89 89 android:layout_marginBottom="5dp"
90   - android:layout_marginTop="5dp" />
  90 + android:layout_marginTop="5dp"
  91 + android:background="#77dddddd" />
91 92  
92 93 </FrameLayout>
93 94  
... ... @@ -95,16 +96,14 @@
95 96 android:id="@+id/go_next"
96 97 android:layout_width="match_parent"
97 98 android:layout_height="40dp"
  99 + android:layout_marginBottom="10dp"
98 100 android:layout_marginLeft="10dp"
99 101 android:layout_marginRight="10dp"
  102 + android:background="@drawable/rudiobtn"
  103 + android:gravity="center"
100 104 android:text="下一步"
101 105 android:textColor="@color/white"
102   - android:textSize="@dimen/txtsize_title"
103   - android:gravity="center"
104   - android:background="@drawable/rudiobtn"
105   - android:layout_marginBottom="10dp"
106   - />
107   -
  106 + android:textSize="@dimen/txtsize_title" />
108 107  
109 108  
110 109 </LinearLayout>
111 110 \ No newline at end of file
... ...