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,7 +72,6 @@ public class SchoolListAdapter extends BaseRecyclerViewAdapter<SortBean> {
72 @Override 72 @Override
73 public void onBindViewHolder(final SortBean object, final int position) { 73 public void onBindViewHolder(final SortBean object, final int position) {
74 select_school.setVisibility(View.INVISIBLE); 74 select_school.setVisibility(View.INVISIBLE);
75 - Log.e("1111-===",position+"");  
76 if (ischeck[position] ==true) { 75 if (ischeck[position] ==true) {
77 select_school.setVisibility(View.VISIBLE); 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,7 +5,12 @@ import android.os.Bundle;
5 import android.support.annotation.NonNull; 5 import android.support.annotation.NonNull;
6 import android.support.v7.widget.LinearLayoutManager; 6 import android.support.v7.widget.LinearLayoutManager;
7 import android.support.v7.widget.RecyclerView; 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 import android.view.View; 12 import android.view.View;
  13 +import android.widget.EditText;
9 import android.widget.ImageView; 14 import android.widget.ImageView;
10 import android.widget.TextView; 15 import android.widget.TextView;
11 16
@@ -41,12 +46,13 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity<SchoolListContra @@ -41,12 +46,13 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity<SchoolListContra
41 46
42 private SideBar sideBar; 47 private SideBar sideBar;
43 private TextView dialog, go_next, tvLocalAddress, center_title; 48 private TextView dialog, go_next, tvLocalAddress, center_title;
44 - ImageView back; 49 + ImageView back, iv_search;
45 private RecyclerView schoollist; 50 private RecyclerView schoollist;
46 - private List<String> list = new ArrayList<>(); 51 + private List<SchoolBean> currList = new ArrayList<>();
47 SchoolListAdapter schoolListAdapter; 52 SchoolListAdapter schoolListAdapter;
48 int schoolId; 53 int schoolId;
49 CityPicker cityPicker = null; 54 CityPicker cityPicker = null;
  55 + EditText et_search;
50 56
51 @NonNull 57 @NonNull
52 @Override 58 @Override
@@ -74,6 +80,10 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity&lt;SchoolListContra @@ -74,6 +80,10 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity&lt;SchoolListContra
74 tvLocalAddress.setText(AppContext.getInstance().district); 80 tvLocalAddress.setText(AppContext.getInstance().district);
75 setSchoolList(); 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 schoollist = findViewById(R.id.schoollist); 88 schoollist = findViewById(R.id.schoollist);
79 schoollist.setLayoutManager(new LinearLayoutManager(this)); 89 schoollist.setLayoutManager(new LinearLayoutManager(this));
@@ -180,30 +190,54 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity&lt;SchoolListContra @@ -180,30 +190,54 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity&lt;SchoolListContra
180 if (null == cityPicker) cityPicker = new CityPicker(SelectSchoolActivity.this, this); 190 if (null == cityPicker) cityPicker = new CityPicker(SelectSchoolActivity.this, this);
181 if (cityPicker.isShow()) cityPicker.close(); 191 if (cityPicker.isShow()) cityPicker.close();
182 else cityPicker.show(); 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 @Override 214 @Override
189 public void showList(List<SchoolBean> list) { 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 final List<SortBean> schoolList = OrderedSortSmodel(list); 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 schoolListAdapter.addAll(schoolList); 229 schoolListAdapter.addAll(schoolList);
197 schoolListAdapter.notifyDataSetChanged(); 230 schoolListAdapter.notifyDataSetChanged();
198 } 231 }
199 } 232 }
200 233
  234 +
201 @Override 235 @Override
202 public void showChild(CurrentBean currentBean) { 236 public void showChild(CurrentBean currentBean) {
203 if (currentBean.isNew() == 0) { 237 if (currentBean.isNew() == 0) {
204 startActivity(new Intent().putExtra("school_id", schoolId).setClass(SelectSchoolActivity.this, CheckInfoActivity.class)); 238 startActivity(new Intent().putExtra("school_id", schoolId).setClass(SelectSchoolActivity.this, CheckInfoActivity.class));
205 } else { 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,8 +250,27 @@ public class SelectSchoolActivity extends BaseMVPCompatActivity&lt;SchoolListContra
216 @Override 250 @Override
217 public void getCity(String name) { 251 public void getCity(String name) {
218 tvLocalAddress.setText(name.split(" ")[2]); 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 <?xml version="1.0" encoding="utf-8"?> 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 android:layout_width="match_parent" 3 android:layout_width="match_parent"
5 android:layout_height="match_parent" 4 android:layout_height="match_parent"
6 android:background="@color/white" 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 <LinearLayout 10 <LinearLayout
12 android:layout_width="match_parent" 11 android:layout_width="match_parent"
13 - android:layout_height="wrap_content"  
14 - > 12 + android:layout_height="wrap_content">
  13 +
15 <TextView 14 <TextView
16 - android:layout_marginBottom="10dp"  
17 - android:layout_marginTop="10dp"  
18 android:id="@+id/tvLocalAddress" 15 android:id="@+id/tvLocalAddress"
19 android:layout_width="wrap_content" 16 android:layout_width="wrap_content"
20 android:layout_height="wrap_content" 17 android:layout_height="wrap_content"
  18 + android:layout_marginBottom="10dp"
  19 + android:layout_marginTop="10dp"
21 android:drawablePadding="@dimen/size_dp_5" 20 android:drawablePadding="@dimen/size_dp_5"
22 android:drawableRight="@drawable/pull_black" 21 android:drawableRight="@drawable/pull_black"
23 android:gravity="center" 22 android:gravity="center"
@@ -25,37 +24,39 @@ @@ -25,37 +24,39 @@
25 android:text="杭州" 24 android:text="杭州"
26 android:textColor="@color/textColor" 25 android:textColor="@color/textColor"
27 android:textSize="@dimen/sp_16" /> 26 android:textSize="@dimen/sp_16" />
  27 +
28 <LinearLayout 28 <LinearLayout
29 android:layout_width="wrap_content" 29 android:layout_width="wrap_content"
30 - android:layout_weight="1"  
31 android:layout_height="wrap_content" 30 android:layout_height="wrap_content"
  31 + android:layout_gravity="center_vertical"
32 android:layout_marginRight="@dimen/size_dp_15" 32 android:layout_marginRight="@dimen/size_dp_15"
33 - android:paddingTop="5dp"  
34 - android:paddingBottom="5dp" 33 + android:layout_weight="1"
35 android:background="@drawable/rudiobtn_gray" 34 android:background="@drawable/rudiobtn_gray"
36 - android:layout_gravity="center_vertical"  
37 - > 35 + android:paddingBottom="5dp"
  36 + android:paddingTop="5dp">
38 37
39 <EditText 38 <EditText
  39 + android:id="@+id/et_search"
40 android:layout_width="wrap_content" 40 android:layout_width="wrap_content"
41 android:layout_height="wrap_content" 41 android:layout_height="wrap_content"
42 android:layout_marginLeft="10dp" 42 android:layout_marginLeft="10dp"
43 android:layout_weight="1" 43 android:layout_weight="1"
44 - android:hint="请输入搜索内容"  
45 - android:textSize="@dimen/sp_16"  
46 - android:gravity="center_horizontal"  
47 android:background="@null" 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 </LinearLayout> 56 </LinearLayout>
57 57
58 </LinearLayout> 58 </LinearLayout>
  59 +
59 <FrameLayout 60 <FrameLayout
60 android:layout_width="fill_parent" 61 android:layout_width="fill_parent"
61 android:layout_height="wrap_content" 62 android:layout_height="wrap_content"
@@ -85,9 +86,9 @@ @@ -85,9 +86,9 @@
85 android:layout_width="30.0dip" 86 android:layout_width="30.0dip"
86 android:layout_height="fill_parent" 87 android:layout_height="fill_parent"
87 android:layout_gravity="right|center" 88 android:layout_gravity="right|center"
88 - android:background="#77dddddd"  
89 android:layout_marginBottom="5dp" 89 android:layout_marginBottom="5dp"
90 - android:layout_marginTop="5dp" /> 90 + android:layout_marginTop="5dp"
  91 + android:background="#77dddddd" />
91 92
92 </FrameLayout> 93 </FrameLayout>
93 94
@@ -95,16 +96,14 @@ @@ -95,16 +96,14 @@
95 android:id="@+id/go_next" 96 android:id="@+id/go_next"
96 android:layout_width="match_parent" 97 android:layout_width="match_parent"
97 android:layout_height="40dp" 98 android:layout_height="40dp"
  99 + android:layout_marginBottom="10dp"
98 android:layout_marginLeft="10dp" 100 android:layout_marginLeft="10dp"
99 android:layout_marginRight="10dp" 101 android:layout_marginRight="10dp"
  102 + android:background="@drawable/rudiobtn"
  103 + android:gravity="center"
100 android:text="下一步" 104 android:text="下一步"
101 android:textColor="@color/white" 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 </LinearLayout> 109 </LinearLayout>
111 \ No newline at end of file 110 \ No newline at end of file