Skip to content

Commit 3a454c3

Browse files
committed
历史记录
1 parent 041e48f commit 3a454c3

10 files changed

+551
-26
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<activity android:name=".ui.activity.UpdatePswActivity"></activity>
3333
<activity android:name=".ui.activity.SettingActivity"></activity>
3434
<activity android:name=".ui.activity.UpdateDotInfoActivity"></activity>
35+
<activity android:name=".ui.activity.HistoryActivity"></activity>
36+
<activity android:name=".ui.activity.HistoryDetailActivity"></activity>
3537

3638
<service android:name=".service.FindUserService"></service>
3739

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package com.zhuolang.main.adapter;
2+
3+
import android.content.Context;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
import android.widget.BaseAdapter;
8+
import android.widget.TextView;
9+
import com.zhuolang.main.R;
10+
import com.zhuolang.main.model.AppointmentDto;
11+
import com.zhuolang.main.utils.TimeUtil;
12+
13+
import java.util.Date;
14+
import java.util.List;
15+
16+
17+
/**
18+
* Created by hzg on 2016/11/9.
19+
*/
20+
public class HistoryListAdapter extends BaseAdapter {
21+
private Context context;
22+
private List<AppointmentDto> appointmentDtos;
23+
24+
private LayoutInflater inflater;
25+
private ViewHolder holder;
26+
27+
public HistoryListAdapter(Context context, List<AppointmentDto> appointmentDtos) {
28+
this.context = context;
29+
this.appointmentDtos = appointmentDtos;
30+
31+
inflater = LayoutInflater.from(context);
32+
holder = new ViewHolder();
33+
}
34+
35+
36+
@Override
37+
public int getCount() {
38+
if (appointmentDtos == null) {
39+
return 0;
40+
} else {
41+
return appointmentDtos.size();
42+
}
43+
}
44+
45+
@Override
46+
public Object getItem(int position) {
47+
return appointmentDtos.get(position);
48+
}
49+
50+
@Override
51+
public long getItemId(int position) {
52+
return 0;
53+
}
54+
55+
//先用myappoint的子布局来用用,如果不同到时候再新建一个
56+
@Override
57+
public View getView(int position, View convertView, ViewGroup parent) {
58+
if (convertView == null) {
59+
convertView = inflater.inflate(R.layout.item_my_appoint, null);
60+
holder.doctor_name = (TextView) convertView.findViewById(R.id.tv_item_my_appoint_doctor_name);
61+
holder.disease = (TextView) convertView.findViewById(R.id.tv_item_my_appoint_disease);
62+
holder.time = (TextView) convertView.findViewById(R.id.tv_item_my_apponint_time);
63+
convertView.setTag(holder);
64+
} else {
65+
holder = (ViewHolder) convertView.getTag();
66+
}
67+
holder.doctor_name.setText("" + appointmentDtos.get(position).getDoctor_name());
68+
holder.disease.setText(appointmentDtos.get(position).getDisease());
69+
Date date = TimeUtil.longToDateNoTime(appointmentDtos.get(position).getSeeTime());
70+
holder.time.setText(TimeUtil.dateToStrNoTime(date));
71+
return convertView;
72+
}
73+
74+
public class ViewHolder {
75+
TextView doctor_name;
76+
TextView disease;
77+
TextView time;
78+
79+
}
80+
81+
}

app/src/main/java/com/zhuolang/main/common/APPConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
public class APPConfig {
88
// private static String base_url="http://192.168.23.1:8080/MicroDoctorServer/";
99
// private static String base_url="http://192.168.43.123:8080/MicroDoctorServer/";
10-
private static String base_url="http://192.168.168.100:8080/MicroDoctorServer/";
11-
// private static String base_url = "http:// 27.45.9.166:80/MicroDoctorServer/";
10+
// private static String base_url="http://10.11.37.107:8080/MicroDoctorServer/";
11+
// private static String base_url="http://192.168.168.100:8080/MicroDoctorServer/";
12+
private static String base_url = "http://27.45.36.67:80/MicroDoctorServer/";
1213
public static String addAppointment = base_url + "add_appointment";
1314
public static String login = base_url + "login_user";
1415
public static String showDoctor = base_url + "findByType_user";
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package com.zhuolang.main.ui.activity;
2+
3+
import android.app.Activity;
4+
import android.content.Intent;
5+
import android.os.Bundle;
6+
import android.os.Handler;
7+
import android.os.Message;
8+
import android.support.annotation.Nullable;
9+
import android.view.View;
10+
import android.widget.AdapterView;
11+
import android.widget.ImageView;
12+
import android.widget.ListView;
13+
import android.widget.Toast;
14+
import com.google.gson.Gson;
15+
import com.google.gson.reflect.TypeToken;
16+
import com.zhuolang.main.R;
17+
import com.zhuolang.main.adapter.HistoryListAdapter;
18+
import com.zhuolang.main.common.APPConfig;
19+
import com.zhuolang.main.model.Appointment;
20+
import com.zhuolang.main.model.AppointmentDto;
21+
import com.zhuolang.main.model.User;
22+
import com.zhuolang.main.utils.OkHttpUtils;
23+
import com.zhuolang.main.utils.SharedPrefsUtil;
24+
import com.zhuolang.main.view.CustomWaitDialog;
25+
26+
import java.util.ArrayList;
27+
import java.util.List;
28+
29+
/**
30+
* Created by hzg on 2016/11/9.
31+
*/
32+
public class HistoryActivity extends Activity implements AdapterView.OnItemClickListener {
33+
private ListView listView;
34+
private List<AppointmentDto> appointmentDtos;
35+
private List<AppointmentDto> appointHistory = new ArrayList<AppointmentDto>();
36+
private ImageView img_back;
37+
private HistoryListAdapter adapter;
38+
39+
private Handler handler = new Handler() {
40+
@Override
41+
public void handleMessage(Message msg) {
42+
String result = msg.obj.toString();
43+
CustomWaitDialog.miss();
44+
Gson gson = new Gson();
45+
appointmentDtos = gson.fromJson(result, new TypeToken<List<AppointmentDto>>() {
46+
}.getType());
47+
//循环通过判断诊断的信息是否为空来判断是否是历史记录,如果有填过就诊信息就是历史记录
48+
for (AppointmentDto a : appointmentDtos) {
49+
if (a.getDiagnose() != null) {
50+
appointHistory.add(a);
51+
}
52+
}
53+
adapter = new HistoryListAdapter(HistoryActivity.this, appointHistory);
54+
listView.setAdapter(adapter);
55+
}
56+
};
57+
58+
59+
@Override
60+
protected void onCreate(@Nullable Bundle savedInstanceState) {
61+
super.onCreate(savedInstanceState);
62+
setContentView(R.layout.activity_history);
63+
initMotion();
64+
65+
listView = (ListView) findViewById(R.id.lv_appoint_history_list);
66+
listView.setOnItemClickListener(this);
67+
img_back = (ImageView) findViewById(R.id.img_back);
68+
img_back.setOnClickListener(new View.OnClickListener() {
69+
@Override
70+
public void onClick(View v) {
71+
finish();
72+
}
73+
});
74+
}
75+
76+
private void initMotion() {
77+
final List<OkHttpUtils.Param> list = new ArrayList<OkHttpUtils.Param>();
78+
Gson gson = new Gson();
79+
String userData = SharedPrefsUtil.getValue(HistoryActivity.this, APPConfig.USERDATA, "读取失败");
80+
User user = gson.fromJson(userData, User.class);
81+
OkHttpUtils.Param typeParam = new OkHttpUtils.Param("patientId", user.getId() + "");
82+
list.add(typeParam);
83+
CustomWaitDialog.show(HistoryActivity.this, "连接服务中...");
84+
new Thread(new Runnable() {
85+
@Override
86+
public void run() {
87+
OkHttpUtils.post(APPConfig.showMyAppointList, new OkHttpUtils.ResultCallback() {
88+
@Override
89+
public void onSuccess(Object response) {
90+
Message message = new Message();
91+
message.what = 0;
92+
message.obj = response;
93+
if (response.toString().equals("find_failure")) {
94+
CustomWaitDialog.miss();
95+
Toast.makeText(HistoryActivity.this, "没有找到您的预约记录!", Toast.LENGTH_LONG).show();
96+
} else {
97+
handler.sendMessage(message);
98+
}
99+
}
100+
101+
@Override
102+
public void onFailure(Exception e) {
103+
Toast.makeText(HistoryActivity.this, "网络连接失败,请重试!", Toast.LENGTH_SHORT).show();
104+
CustomWaitDialog.miss();
105+
}
106+
}, list);
107+
}
108+
}).start();
109+
}
110+
111+
@Override
112+
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
113+
Intent intent = new Intent();
114+
intent.setClass(HistoryActivity.this, HistoryDetailActivity.class);
115+
AppointmentDto appointmentDto = appointHistory.get(position);
116+
Gson gson = new Gson();
117+
String appointHistoryStr = gson.toJson(appointmentDto);
118+
intent.putExtra("appointHistoryStr", appointHistoryStr);
119+
startActivity(intent);
120+
}
121+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.zhuolang.main.ui.activity;
2+
3+
import android.app.Activity;
4+
import android.os.Bundle;
5+
import android.support.annotation.Nullable;
6+
import android.view.View;
7+
import android.widget.ImageView;
8+
import android.widget.TextView;
9+
import com.google.gson.Gson;
10+
import com.zhuolang.main.R;
11+
import com.zhuolang.main.model.AppointmentDto;
12+
import com.zhuolang.main.utils.TimeUtil;
13+
14+
import java.util.Date;
15+
16+
/**
17+
* Created by hzg on 2016/11/9.
18+
*/
19+
public class HistoryDetailActivity extends Activity {
20+
21+
private String appointHistoryStr;
22+
private AppointmentDto appointmentDto;
23+
private TextView tv_history_doctorName;
24+
private TextView tv_history_seeTime;
25+
private TextView tv_history_disease;
26+
private TextView tv_history_dNumber;
27+
private TextView tv_history_diagnose;
28+
private TextView tv_history_discuss;
29+
private ImageView img_history_back;
30+
31+
@Override
32+
protected void onCreate(@Nullable Bundle savedInstanceState) {
33+
super.onCreate(savedInstanceState);
34+
setContentView(R.layout.activity_appoint_history);
35+
init();
36+
img_history_back.setOnClickListener(new View.OnClickListener() {
37+
@Override
38+
public void onClick(View v) {
39+
finish();
40+
}
41+
});
42+
43+
Gson gson = new Gson();
44+
appointHistoryStr = getIntent().getStringExtra("appointHistoryStr");
45+
appointmentDto = gson.fromJson(appointHistoryStr, AppointmentDto.class);
46+
47+
tv_history_doctorName.setText(appointmentDto.getDoctor_name());
48+
Date date = TimeUtil.longToDateNoTime(appointmentDto.getSeeTime());
49+
tv_history_seeTime.setText(TimeUtil.dateToStrNoTime(date));
50+
tv_history_disease.setText(appointmentDto.getDisease());
51+
tv_history_dNumber.setText("" + appointmentDto.getdNumber());
52+
tv_history_diagnose.setText(appointmentDto.getDiagnose());
53+
tv_history_discuss.setText("" + appointmentDto.getDstar());
54+
}
55+
56+
private void init() {
57+
tv_history_doctorName = (TextView) findViewById(R.id.tv_history_doctorName);
58+
tv_history_seeTime = (TextView) findViewById(R.id.tv_history_seeTime);
59+
tv_history_disease = (TextView) findViewById(R.id.tv_history_disease);
60+
tv_history_dNumber = (TextView) findViewById(R.id.tv_history_dNumber);
61+
tv_history_diagnose = (TextView) findViewById(R.id.tv_history_diagnose);
62+
tv_history_discuss = (TextView) findViewById(R.id.tv_history_discuss);
63+
img_history_back = (ImageView) findViewById(R.id.img_history_back);
64+
}
65+
66+
}

app/src/main/java/com/zhuolang/main/ui/activity/MyAppointListActivity.java

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,20 @@
2828
*/
2929
public class MyAppointListActivity extends Activity implements AdapterView.OnItemClickListener {
3030
private ListView listView;
31-
private SimpleAdapter simpleAdapter;
32-
private List<Map<String, Object>> dataList;
33-
// private List<Appointment> appointments = new ArrayList<>();
3431
private List<AppointmentDto> appointmentDtos = new ArrayList<>();
3532
private ImageView img_back;
3633
private MyAppointListAdapter adapter;
3734

38-
private Handler handler = new Handler(){
35+
private Handler handler = new Handler() {
3936
@Override
4037
public void handleMessage(Message msg) {
41-
// super.handleMessage(msg);
4238
String result = msg.obj.toString();
43-
Log.d("testRun","result======"+result);
39+
Log.d("testRun", "result======" + result);
4440
CustomWaitDialog.miss();
4541
Gson gson = new Gson();
4642
appointmentDtos = gson.fromJson(result, new TypeToken<List<AppointmentDto>>() {}.getType());
47-
adapter = new MyAppointListAdapter(MyAppointListActivity.this,appointmentDtos);
43+
adapter = new MyAppointListAdapter(MyAppointListActivity.this, appointmentDtos);
4844
listView.setAdapter(adapter);
49-
// dataList = new ArrayList<Map<String, Object>>();
50-
// for (Appointment a : appointments) {
51-
// Map<String, Object> map = new HashMap<String, Object>();
52-
//// map.put("imageView", R.drawable.myicon);
53-
//// map.put("name", a.getName());
54-
//// map.put("amount", d.getAmount());
55-
//// map.put("introduction", d.getIntroduction());
56-
//// map.put("office", d.getOffice());
57-
//// map.put("doctorId", d.getId());
58-
// dataList.add(map);
59-
// }
6045
}
6146
};
6247

@@ -82,9 +67,9 @@ public void initMotion() {
8267
Gson gson = new Gson();
8368
String userData = SharedPrefsUtil.getValue(MyAppointListActivity.this, APPConfig.USERDATA, "读取失败");
8469
User user = gson.fromJson(userData, User.class);
85-
OkHttpUtils.Param typeParam = new OkHttpUtils.Param("patientId", user.getId()+"");//接口要求传类型,类型一为医师
70+
OkHttpUtils.Param typeParam = new OkHttpUtils.Param("patientId", user.getId() + "");//接口要求传类型,类型一为医师
8671
list.add(typeParam);
87-
CustomWaitDialog.show(MyAppointListActivity.this,"连接服务中...");
72+
CustomWaitDialog.show(MyAppointListActivity.this, "连接服务中...");
8873
new Thread(new Runnable() {
8974
@Override
9075
public void run() {
@@ -98,9 +83,8 @@ public void onSuccess(Object response) {
9883
if (response.toString().equals("find_failure")) {
9984
CustomWaitDialog.miss();
10085
Toast.makeText(MyAppointListActivity.this, "没有找到您的预约数据!", Toast.LENGTH_LONG).show();
101-
}else {
86+
} else {
10287
handler.sendMessage(message);
103-
// Toast.makeText(MyAppointListActivity.this, "发送数据失败,请重试!", Toast.LENGTH_SHORT).show();
10488
}
10589
}
10690

app/src/main/java/com/zhuolang/main/ui/fragment/HomepageTabFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private void clickImage(View v) {
8080
break;
8181
case R.id.image_item_consult:
8282
Intent intent4 = new Intent();
83-
intent4.setClass(getActivity(), MyConsultActivity.class);
83+
intent4.setClass(getActivity(), HistoryActivity.class);
8484
startActivity(intent4);
8585
break;
8686
}

0 commit comments

Comments
 (0)