|
|
@ -6,6 +6,7 @@ import android.os.Bundle; |
|
|
|
import android.os.Handler; |
|
|
|
import android.os.Handler; |
|
|
|
import android.text.Editable; |
|
|
|
import android.text.Editable; |
|
|
|
import android.text.TextWatcher; |
|
|
|
import android.text.TextWatcher; |
|
|
|
|
|
|
|
import android.util.Log; |
|
|
|
import android.view.KeyEvent; |
|
|
|
import android.view.KeyEvent; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
import android.view.WindowManager; |
|
|
|
import android.view.WindowManager; |
|
|
@ -41,15 +42,17 @@ public class HospitalActivity extends BaseActivity { |
|
|
|
private HospitalAdapter hospitalAdapter; |
|
|
|
private HospitalAdapter hospitalAdapter; |
|
|
|
private int startNum = 1; |
|
|
|
private int startNum = 1; |
|
|
|
private int endNum = 10; |
|
|
|
private int endNum = 10; |
|
|
|
private int numberOfColumns=2; |
|
|
|
private int numberOfColumns = 2; |
|
|
|
List<GetHospitalApi.MemberBean> list=new ArrayList<>(); |
|
|
|
List<GetHospitalApi.MemberBean> list = new ArrayList<>(); |
|
|
|
private EditText et_search; |
|
|
|
private EditText et_search; |
|
|
|
private Handler handler = new Handler(); |
|
|
|
private Handler handler = new Handler(); |
|
|
|
private int selectPostion = 0;//当前列表item点击位置
|
|
|
|
private int selectPostion = 0;//当前列表item点击位置
|
|
|
|
public static void StartActivity(Context context){ |
|
|
|
|
|
|
|
Intent intent=new Intent(context, HospitalActivity.class); |
|
|
|
public static void StartActivity(Context context) { |
|
|
|
|
|
|
|
Intent intent = new Intent(context, HospitalActivity.class); |
|
|
|
context.startActivity(intent); |
|
|
|
context.startActivity(intent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) { |
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) { |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
super.onCreate(savedInstanceState); |
|
|
@ -58,12 +61,13 @@ public class HospitalActivity extends BaseActivity { |
|
|
|
initView(); |
|
|
|
initView(); |
|
|
|
loadData(1); |
|
|
|
loadData(1); |
|
|
|
} |
|
|
|
} |
|
|
|
public void initView(){ |
|
|
|
|
|
|
|
et_search=findViewById(R.id.et_search); |
|
|
|
public void initView() { |
|
|
|
|
|
|
|
et_search = findViewById(R.id.et_search); |
|
|
|
et_search.setOnFocusChangeListener(new View.OnFocusChangeListener() { |
|
|
|
et_search.setOnFocusChangeListener(new View.OnFocusChangeListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onFocusChange(View view, boolean b) { |
|
|
|
public void onFocusChange(View view, boolean b) { |
|
|
|
InputKeyBoardUtils.show(HospitalActivity.this,view,b); |
|
|
|
InputKeyBoardUtils.show(HospitalActivity.this, view, b); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
et_search.addTextChangedListener(new TextWatcher() { |
|
|
|
et_search.addTextChangedListener(new TextWatcher() { |
|
|
@ -83,26 +87,27 @@ public class HospitalActivity extends BaseActivity { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
recyclerView=findViewById(R.id.recyclerView); |
|
|
|
recyclerView = findViewById(R.id.recyclerView); |
|
|
|
recyclerView.requestFocus(); |
|
|
|
recyclerView.requestFocus(); |
|
|
|
recyclerView=findViewById(R.id.recyclerView); |
|
|
|
recyclerView = findViewById(R.id.recyclerView); |
|
|
|
MyGridLayoutManager gridLayoutManager= new MyGridLayoutManager(HospitalActivity.this,numberOfColumns); |
|
|
|
MyGridLayoutManager gridLayoutManager = new MyGridLayoutManager(HospitalActivity.this, numberOfColumns); |
|
|
|
|
|
|
|
gridLayoutManager.setUpView(et_search); |
|
|
|
recyclerView.setLayoutManager(gridLayoutManager); |
|
|
|
recyclerView.setLayoutManager(gridLayoutManager); |
|
|
|
hospitalAdapter =new HospitalAdapter(list, new OnChildClickListener() { |
|
|
|
hospitalAdapter = new HospitalAdapter(list, new OnChildClickListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public <T> void onChildClick(View view, int position, T data) { |
|
|
|
public <T> void onChildClick(View view, int position, T data) { |
|
|
|
selectPostion = position; |
|
|
|
selectPostion = position; |
|
|
|
GetHospitalApi.MemberBean memberBean= (GetHospitalApi.MemberBean) data; |
|
|
|
GetHospitalApi.MemberBean memberBean = (GetHospitalApi.MemberBean) data; |
|
|
|
if(position==list.size()-1){ |
|
|
|
if (memberBean.isLast()) { |
|
|
|
startNum++; |
|
|
|
startNum = startNum + endNum; |
|
|
|
loadData(0); |
|
|
|
loadData(0); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
HospitalDetailActivity.StartActivity(HospitalActivity.this,memberBean.getChosCode()); |
|
|
|
HospitalDetailActivity.StartActivity(HospitalActivity.this, memberBean.getChosCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
recyclerView.setAdapter(hospitalAdapter); |
|
|
|
recyclerView.setAdapter(hospitalAdapter); |
|
|
|
recyclerView.addItemDecoration(new LinearSpacingItemDecoration(HospitalActivity.this,24)); |
|
|
|
recyclerView.addItemDecoration(new LinearSpacingItemDecoration(HospitalActivity.this, 24)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Runnable searchRunnable = new Runnable() { |
|
|
|
private Runnable searchRunnable = new Runnable() { |
|
|
@ -114,9 +119,10 @@ public class HospitalActivity extends BaseActivity { |
|
|
|
// ...
|
|
|
|
// ...
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
public void loadData(int type){ |
|
|
|
|
|
|
|
|
|
|
|
public void loadData(int type) { |
|
|
|
EasyHttp.post(HospitalActivity.this) |
|
|
|
EasyHttp.post(HospitalActivity.this) |
|
|
|
.api(new GetHospitalApi(et_search.getText().toString(),startNum, CacheUtil.getPkey(),endNum)) |
|
|
|
.api(new GetHospitalApi(et_search.getText().toString(), startNum, CacheUtil.getPkey(), endNum)) |
|
|
|
.request(new OnHttpListener<HttpData<ApiResponse<GetHospitalApi>>>() { |
|
|
|
.request(new OnHttpListener<HttpData<ApiResponse<GetHospitalApi>>>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSucceed(HttpData<ApiResponse<GetHospitalApi>> stringHttpData) { |
|
|
|
public void onSucceed(HttpData<ApiResponse<GetHospitalApi>> stringHttpData) { |
|
|
@ -136,14 +142,13 @@ public class HospitalActivity extends BaseActivity { |
|
|
|
memberBean.setLast(true); |
|
|
|
memberBean.setLast(true); |
|
|
|
list.add(memberBean); |
|
|
|
list.add(memberBean); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
hospitalAdapter.notifyDataSetChanged(); |
|
|
|
hospitalAdapter.notifyDataSetChanged(); |
|
|
|
if (type == 0) { |
|
|
|
if (type == 0) { |
|
|
|
recyclerView.requestFocus(); |
|
|
|
recyclerView.requestFocus(); |
|
|
|
recyclerView.post(new Runnable() { |
|
|
|
recyclerView.post(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
View view = recyclerView.getLayoutManager().findViewByPosition(selectPostion); |
|
|
|
View view = recyclerView.getLayoutManager().findViewByPosition(selectPostion - 1); |
|
|
|
if (view != null) { |
|
|
|
if (view != null) { |
|
|
|
recyclerView.requestFocus(); |
|
|
|
recyclerView.requestFocus(); |
|
|
|
view.requestFocus(); |
|
|
|
view.requestFocus(); |
|
|
|