408 lines
13 KiB
Java
408 lines
13 KiB
Java
package cn.shangyu.gdxzExpert.activity;
|
||
|
||
import android.content.BroadcastReceiver;
|
||
import android.content.Context;
|
||
import android.content.Intent;
|
||
import android.content.IntentFilter;
|
||
import android.graphics.drawable.Drawable;
|
||
import android.view.View;
|
||
import android.widget.Button;
|
||
import android.widget.ExpandableListView;
|
||
import android.widget.ExpandableListView.OnChildClickListener;
|
||
import android.widget.ImageView;
|
||
import android.widget.LinearLayout;
|
||
import android.widget.TextView;
|
||
|
||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||
|
||
import com.gyf.immersionbar.ImmersionBar;
|
||
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
import cn.shangyu.gdxzExpert.R;
|
||
import cn.shangyu.gdxzExpert.adapter.GroupingAdapter;
|
||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||
import cn.shangyu.gdxzExpert.bean.GroupPatientList;
|
||
import cn.shangyu.gdxzExpert.bean.GroupPatientList.Group;
|
||
import cn.shangyu.gdxzExpert.bean.GroupPatientList.PatientData;
|
||
import cn.shangyu.gdxzExpert.big.activity.BigPatientActivity;
|
||
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||
import cn.shangyu.gdxzExpert.utils.Constant;
|
||
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||
import cn.shangyu.gdxzExpert.utils.Url;
|
||
import cn.shangyu.gdxzExpert.view.DrawableCenterButtonR;
|
||
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
||
|
||
public class GroupingActivity extends BaseActivity implements
|
||
OnCallBackFromNet, OnChildClickListener {
|
||
View view;
|
||
private ExpandableListView mElv_group;
|
||
private GroupingActivity mActivity;
|
||
private String uuid;
|
||
List<List<PatientData>> groups;
|
||
List<Group> group;
|
||
private GroupingAdapter mAdapter;
|
||
private TextView load_empty;
|
||
private Button bt_mylan1;
|
||
private String group_sort = "0";//0 按首字母排序 1 分组人数排序
|
||
private String list_sort = "0";//0 按首字母排序 1 随访时间排序
|
||
private DrawableCenterButtonR sort,sort1;
|
||
private LinearLayout ll_sort,ll_sort1;
|
||
private LinearLayout ll_new,ll_hot;
|
||
private LinearLayout ll_new1,ll_hot1;
|
||
private TextView tv_hot,tv_new;
|
||
private TextView tv_hot1,tv_new1;
|
||
private ImageView iv_hot,iv_new;
|
||
private ImageView iv_hot1,iv_new1;
|
||
|
||
@Override
|
||
public void setTitle() {
|
||
// TODO Auto-generated method stub
|
||
top_right_text.setVisibility(View.VISIBLE);
|
||
top_right_text.setText("新建");
|
||
top_right_text.setOnClickListener(this);
|
||
top_title.setText("患者分组");
|
||
if(CommonUtil.BigModule())
|
||
{
|
||
top_title.setTextSize(23);
|
||
top_right_text.setTextSize(18);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public View onCreateSuccessedView() {
|
||
// TODO Auto-generated method stub
|
||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||
if(CommonUtil.BigModule())
|
||
{
|
||
view = UIUtils.inflate(R.layout.activity_grouping_big);
|
||
}
|
||
else
|
||
{
|
||
view = UIUtils.inflate(R.layout.activity_grouping);
|
||
}
|
||
|
||
mActivity = this;
|
||
mElv_group = (ExpandableListView) view.findViewById(R.id.elv_group_patient);
|
||
load_empty = (TextView) view.findViewById(R.id.load_empty);
|
||
sort = view.findViewById(R.id.sort);//分组
|
||
sort1 = view.findViewById(R.id.sort1);//组内
|
||
ll_sort = view.findViewById(R.id.ll_sort);//分组
|
||
ll_sort1 = view.findViewById(R.id.ll_sort1);//组内
|
||
ll_new = view.findViewById(R.id.ll_new);//组内
|
||
ll_new1 = view.findViewById(R.id.ll_new1);//组内
|
||
ll_hot = view.findViewById(R.id.ll_hot);//组内
|
||
ll_hot1 = view.findViewById(R.id.ll_hot1);//组内
|
||
tv_new = view.findViewById(R.id.tv_new);
|
||
tv_new1 = view.findViewById(R.id.tv_new1);
|
||
tv_hot = view.findViewById(R.id.tv_hot);
|
||
tv_hot1 = view.findViewById(R.id.tv_hot1);
|
||
iv_hot = view.findViewById(R.id.iv_hot);
|
||
iv_hot1 = view.findViewById(R.id.iv_hot1);
|
||
iv_new = view.findViewById(R.id.iv_new);
|
||
iv_new1 = view.findViewById(R.id.iv_new1);
|
||
|
||
|
||
bt_mylan1 = view.findViewById(R.id.bt_mylan1);
|
||
if (Constant.isMaiLanExpert==1){
|
||
bt_mylan1.setVisibility(View.VISIBLE);
|
||
}
|
||
mElv_group.setOnChildClickListener(this);
|
||
sort.setOnClickListener(this);
|
||
sort1.setOnClickListener(this);
|
||
ll_new.setOnClickListener(this);
|
||
ll_new1.setOnClickListener(this);
|
||
ll_hot.setOnClickListener(this);
|
||
ll_hot1.setOnClickListener(this);
|
||
bt_mylan1.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
if (ll_sort.getVisibility()==View.VISIBLE){
|
||
ll_sort.setVisibility(View.GONE);
|
||
return;
|
||
}
|
||
if (ll_sort1.getVisibility()==View.VISIBLE){
|
||
ll_sort1.setVisibility(View.GONE);
|
||
return;
|
||
}
|
||
// Intent intent = new Intent(GroupingActivity.this, MylanFollow_upProjectActivity.class);
|
||
Intent intent = new Intent(GroupingActivity.this, MylanFollowActivity.class);
|
||
startActivity(intent);
|
||
}
|
||
});
|
||
uuid = SharePrefUtil.getString(mActivity, Constant.uuid, "");
|
||
getGroupAndPatient();
|
||
registerDeletPatient();
|
||
return view;
|
||
}
|
||
|
||
@Override
|
||
protected void onResume() {
|
||
super.onResume();
|
||
needreportPage("患者分组");
|
||
}
|
||
|
||
@Override
|
||
public ResultState onLoad() {
|
||
// TODO Auto-generated method stub
|
||
return ResultState.STATE_SUCCESSED;
|
||
}
|
||
|
||
public static final int GET_GROUP_RESULt = 201;
|
||
public static final int GET_GROUP_DETAIL_RESULt = 222;
|
||
|
||
@Override
|
||
protected void processClick(View v) {
|
||
// TODO Auto-generated method stub
|
||
// AGP 8.0+ R.id 不再是 final 常量,不能用于 switch,改用 if-else
|
||
int id = v.getId();
|
||
if (id == R.id.top_right_text) {
|
||
Intent intent = new Intent(mActivity, AddGroupActivity.class);
|
||
startActivityForResult(intent, GET_GROUP_RESULt);
|
||
} else if (id == R.id.sort) {//分组排序
|
||
if (ll_sort.getVisibility() == View.VISIBLE) {
|
||
ll_sort.setVisibility(View.GONE);
|
||
mElv_group.setEnabled(true);
|
||
mElv_group.setFocusable(true);
|
||
ll_sort.setFocusable(false);
|
||
}else {
|
||
ll_sort.setVisibility(View.VISIBLE);
|
||
ll_sort.setFocusable(true);
|
||
mElv_group.setEnabled(false);
|
||
}
|
||
if (ll_sort1.getVisibility() == View.VISIBLE) {
|
||
ll_sort1.setVisibility(View.GONE);
|
||
return;
|
||
}
|
||
} else if (id == R.id.sort1) {//组内排序
|
||
if (ll_sort1.getVisibility() == View.VISIBLE) {
|
||
ll_sort1.setVisibility(View.GONE);
|
||
mElv_group.setEnabled(true);
|
||
mElv_group.setFocusable(true);
|
||
}else {
|
||
ll_sort1.setVisibility(View.VISIBLE);
|
||
mElv_group.setEnabled(false);
|
||
mElv_group.setFocusable(false);
|
||
}
|
||
if (ll_sort.getVisibility() == View.VISIBLE) {
|
||
ll_sort.setVisibility(View.GONE);
|
||
return;
|
||
}
|
||
} else if (id == R.id.ll_new) {
|
||
mElv_group.setEnabled(true);
|
||
mElv_group.setFocusable(true);
|
||
tv_hot.setTextColor(getResources().getColor(
|
||
R.color.text_color));
|
||
tv_new.setTextColor(getResources().getColor(
|
||
R.color.top_title));
|
||
iv_new.setVisibility(View.VISIBLE);
|
||
iv_hot.setVisibility(View.GONE);
|
||
sort.setText("按首字母");
|
||
chengeImg(sort);
|
||
ll_sort.setVisibility(View.GONE);
|
||
|
||
group_sort = "0";
|
||
getGroupAndPatient();
|
||
} else if (id == R.id.ll_hot) {
|
||
mElv_group.setEnabled(true);
|
||
mElv_group.setFocusable(true);
|
||
tv_new.setTextColor(getResources().getColor(
|
||
R.color.text_color));
|
||
tv_hot.setTextColor(getResources().getColor(
|
||
R.color.top_title));
|
||
iv_new.setVisibility(View.GONE);
|
||
iv_hot.setVisibility(View.VISIBLE);
|
||
sort.setText("分组人数");
|
||
chengeImg(sort);
|
||
ll_sort.setVisibility(View.GONE);
|
||
|
||
group_sort = "1";
|
||
getGroupAndPatient();
|
||
} else if (id == R.id.ll_new1) {
|
||
mElv_group.setEnabled(true);
|
||
mElv_group.setFocusable(true);
|
||
tv_hot1.setTextColor(getResources().getColor(
|
||
R.color.text_color));
|
||
tv_new1.setTextColor(getResources().getColor(
|
||
R.color.top_title));
|
||
iv_new1.setVisibility(View.VISIBLE);
|
||
iv_hot1.setVisibility(View.GONE);
|
||
sort1.setText("按首字母");
|
||
chengeImg(sort1);
|
||
ll_sort1.setVisibility(View.GONE);
|
||
|
||
list_sort = "0";
|
||
getGroupAndPatient();
|
||
} else if (id == R.id.ll_hot1) {
|
||
mElv_group.setEnabled(true);
|
||
mElv_group.setFocusable(true);
|
||
tv_new1.setTextColor(getResources().getColor(
|
||
R.color.text_color));
|
||
tv_hot1.setTextColor(getResources().getColor(
|
||
R.color.top_title));
|
||
iv_new1.setVisibility(View.GONE);
|
||
iv_hot1.setVisibility(View.VISIBLE);
|
||
sort1.setText("随访时间");
|
||
chengeImg(sort1);
|
||
ll_sort1.setVisibility(View.GONE);
|
||
|
||
list_sort = "1";
|
||
getGroupAndPatient();
|
||
}
|
||
}
|
||
|
||
public static final int GET_GROUP_PATIENT_RESULT = 101;
|
||
|
||
public void getGroupAndPatient() {
|
||
// 网络是否可用
|
||
if (!CommonUtil.isNetworkAvailable()) {
|
||
mElv_group.setEmptyView(tv_load_fail);
|
||
return;
|
||
}
|
||
showProgressDialog("正在加载");
|
||
Map<String, String> param = new HashMap<String, String>();
|
||
param.put("expert_uuid", uuid);
|
||
param.put("group_sort", group_sort);
|
||
param.put("list_sort", list_sort);
|
||
sendParamtoNet(Url.getGroupList, param, GET_GROUP_PATIENT_RESULT,
|
||
mActivity, true);
|
||
}
|
||
|
||
@Override
|
||
public void onCallbackFromThread(String resultJson) {
|
||
// TODO Auto-generated method stub
|
||
}
|
||
|
||
@Override
|
||
public void onCallBackFromThread(String resultJson, int resultCode) {
|
||
// TODO Auto-generated method stub
|
||
LogUtil.i("患者分组 = "+resultJson);
|
||
switch (resultCode) {
|
||
case GET_GROUP_PATIENT_RESULT:
|
||
|
||
processData(resultJson);
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 解析并处理数据
|
||
*
|
||
* @param result
|
||
*/
|
||
private void processData(String result) {
|
||
closeProgressDialog();
|
||
GroupPatientList bean = GsonTools.fromGsonToBean(result,
|
||
GroupPatientList.class);
|
||
SharePrefUtil.saveString(mActivity, Url.getGroupList, result);
|
||
if (bean == null || bean.data == null || bean.data.size() == 0) {
|
||
load_empty.setVisibility(View.VISIBLE);
|
||
return;
|
||
|
||
} else {
|
||
load_empty.setVisibility(View.GONE);
|
||
group = bean.data;
|
||
}
|
||
|
||
// if (mAdapter == null) {
|
||
mAdapter = new GroupingAdapter(mActivity, group);
|
||
mElv_group.setAdapter(mAdapter);
|
||
// } else {
|
||
// mAdapter.notifyDataSetChanged();
|
||
// }
|
||
|
||
}
|
||
|
||
@Override
|
||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||
// TODO Auto-generated method stub
|
||
super.onActivityResult(requestCode, resultCode, data);
|
||
switch (resultCode) {
|
||
case GET_GROUP_RESULt:
|
||
getGroupAndPatient();
|
||
break;
|
||
case GET_GROUP_DETAIL_RESULt:
|
||
getGroupAndPatient();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public boolean onChildClick(ExpandableListView parent, View v,
|
||
int groupPosition, int childPosition, long id) {
|
||
// TODO Auto-generated method stub
|
||
PatientData patient;
|
||
patient = group.get(groupPosition).patientList.get(childPosition);
|
||
if (patient!=null){
|
||
String mobile = patient.mobile;
|
||
Intent intent = new Intent(mActivity, BigPatientActivity.class);
|
||
intent.putExtra("mobile", mobile);
|
||
intent.putExtra("realName", patient.realName);
|
||
intent.putExtra("patientUuid", patient.uuid);
|
||
intent.putExtra("photo", patient.photo);
|
||
intent.putExtra("birthDate", patient.birthDate);
|
||
intent.putExtra("type", Constant.typePatient);
|
||
startActivityForResult(intent, GET_GROUP_DETAIL_RESULt);
|
||
}
|
||
|
||
return false;
|
||
}
|
||
public void chengeImg(DrawableCenterButtonR mDb_sort){
|
||
if(CommonUtil.BigModule())
|
||
{
|
||
Drawable icon_new = UIUtils.getDrawable(R.drawable.triangle_green_theme_big);
|
||
icon_new.setBounds(0, 0, icon_new.getMinimumWidth(),
|
||
icon_new.getMinimumHeight());
|
||
mDb_sort.setCompoundDrawables(null, null, icon_new,
|
||
null);
|
||
mDb_sort.setTextColor(GroupingActivity.this.getResources().getColor(
|
||
R.color.top_title));
|
||
}
|
||
else
|
||
{
|
||
Drawable icon_new = UIUtils.getDrawable(R.drawable.triangle_green_theme);
|
||
icon_new.setBounds(0, 0, icon_new.getMinimumWidth(),
|
||
icon_new.getMinimumHeight());
|
||
mDb_sort.setCompoundDrawables(null, null, icon_new,
|
||
null);
|
||
mDb_sort.setTextColor(GroupingActivity.this.getResources().getColor(
|
||
R.color.top_title));
|
||
}
|
||
|
||
}
|
||
@Override
|
||
protected void onDestroy() {
|
||
super.onDestroy();
|
||
localBroadcastManager.unregisterReceiver(localReceiver);
|
||
}
|
||
private LocalBroadcastManager localBroadcastManager;
|
||
private IntentFilter intentFilter;
|
||
LocalReceiver localReceiver;
|
||
private void registerDeletPatient()
|
||
{
|
||
localBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||
intentFilter = new IntentFilter();
|
||
intentFilter.addAction("DELET_PATION_ACTION");
|
||
localReceiver = new LocalReceiver();
|
||
//注册本地接收器
|
||
localBroadcastManager.registerReceiver(localReceiver,intentFilter);
|
||
}
|
||
private class LocalReceiver extends BroadcastReceiver {
|
||
@Override
|
||
public void onReceive(Context context, Intent intent) {
|
||
finish();
|
||
}
|
||
}
|
||
}
|