illega-------------------->
IllegalHomeActivity
package com.example.smartcity1.service.illegal;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.smartcity1.R;
public class IllegalHomeActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_illegal_home);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("违章查询");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
}
}
life------------------------------------>
LifeHomeActivity
package com.example.smartcity1.service.life;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.example.smartcity1.R;
import java.util.HashSet;
import java.util.Set;
public class LifeHomeActivity extends AppCompatActivity {
private ConstraintLayout waterCon;
private ConstraintLayout electricityCon;
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_life_home);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("生活缴费");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
initView();
waterCon.setOnClickListener(v -> {
});
electricityCon.setOnClickListener(v -> {
});
button.setOnClickListener(v -> {
startActivity(new Intent(LifeHomeActivity.this,LifeHouseActivity.class));
});
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
private void initView() {
waterCon = findViewById(R.id.water_con);
electricityCon = findViewById(R.id.electricity_con);
button = findViewById(R.id.button);
}
}
LifeHouseActivity
package com.example.smartcity1.service.life;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.example.smartcity1.R;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class LifeHouseActivity extends AppCompatActivity {
private Button button;
private ListView listVIew;
List<String> names = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_life_house);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("户号管理");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
initView();
names.add("我家");
names.add("父母");
// names.add("房东");
// names.add("朋友");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, names);
listVIew.setAdapter(adapter);
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
private void initView() {
button = findViewById(R.id.button);
listVIew = findViewById(R.id.listVIew);
}
}
parklot----------------------------------->
ParklotListActivity
package com.example.smartcity1.service.parklot;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.example.smartcity1.R;
import com.example.smartcity1.adapter.ParklotListAdapter;
import com.example.smartcity1.bean.ParklotListBean;
import com.example.smartcity1.network.RetrofitClient;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ParklotListActivity extends AppCompatActivity {
private ListView listView;
private Button button;
private int size = 1;
private Boolean allOK = false;
private List<ParklotListBean.RowsDTO> rows = new ArrayList<>();
private ParklotListAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_parklot_list);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("停车场");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
initView();
adapter = new ParklotListAdapter(ParklotListActivity.this, R.layout.item_parklot_list, rows);
listView.setAdapter(adapter);
setData(1);
button.setOnClickListener(v -> {
if (!allOK) {
size += 1;
setData(size);
} else if (allOK) {
Toast.makeText(this, "已全部加载", Toast.LENGTH_SHORT).show();
}
});
listView.setOnItemClickListener((parent, view, position, id) -> {
Intent intent = new Intent(ParklotListActivity.this, ParklotPageActivity.class);
intent.putExtra("id", rows.get(position).getId());
startActivity(intent);
});
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
private void initView() {
listView = findViewById(R.id.listView);
button = findViewById(R.id.button);
}
private void setData(int size) {
RetrofitClient.serviceService().getParklotListData(size).enqueue(new Callback<ParklotListBean>() {
@Override
public void onResponse(Call<ParklotListBean> call, Response<ParklotListBean> response) {
ParklotListBean body = response.body();
if (body != null && body.getCode() == 200) {
rows.addAll(body.getRows());
adapter.notifyDataSetChanged();
if (rows.size() == body.getTotal()) {
allOK = true;
}
}
}
@Override
public void onFailure(Call<ParklotListBean> call, Throwable t) {
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_parklot_list, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.historyList:
startActivity(new Intent(ParklotListActivity.this,ParklotOldListActivity.class));
}
return super.onOptionsItemSelected(item);
}
}
ParklotOldListActivity
package com.example.smartcity1.service.parklot;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.example.smartcity1.R;
import com.example.smartcity1.adapter.ParklotListAdapter;
import com.example.smartcity1.adapter.ParklotOldAdapter;
import com.example.smartcity1.bean.ParklotListBean;
import com.example.smartcity1.bean.ParklotOldListBean;
import com.example.smartcity1.network.RetrofitClient;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ParklotOldListActivity extends AppCompatActivity {
private EditText entryTimeEdit;
private EditText outTimeEdit;
private ImageButton searchBtn;
private ListView listView;
private Button button;
private List<ParklotOldListBean.RowsDTO> rows = new ArrayList<>();
private ParklotOldAdapter adapter;
private int size = 1;
private String entryTime = "";
private String outTime = "";
private Boolean allOK = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_parklot_old_list);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("停车记录");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
initView();
adapter = new ParklotOldAdapter(ParklotOldListActivity.this, R.layout.item_parkolt_old, rows);
listView.setAdapter(adapter);
setData();
button.setOnClickListener(v -> {
if (!allOK) {
size += 1;
setData();
} else {
Toast.makeText(this, "已全部加载", Toast.LENGTH_SHORT).show();
}
});
searchBtn.setOnClickListener(v -> {
if (entryTimeEdit.getText().toString().equals("") || outTimeEdit.getText().toString().equals("")) {
Toast.makeText(this, "请检查时间", Toast.LENGTH_SHORT).show();
} else {
entryTime = entryTimeEdit.getText().toString();
outTime = outTimeEdit.getText().toString();
size = 1;
allOK = false;
rows.clear();
setData();
}
});
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
private void initView() {
entryTimeEdit = findViewById(R.id.entryTime_edit);
outTimeEdit = findViewById(R.id.outTime_edit);
searchBtn = findViewById(R.id.search_btn);
listView = findViewById(R.id.listView);
button = findViewById(R.id.button);
}
private void setData() {
RetrofitClient.serviceService().getParklotOldListData(size,entryTime,outTime).enqueue(new Callback<ParklotOldListBean>() {
@Override
public void onResponse(Call<ParklotOldListBean> call, Response<ParklotOldListBean> response) {
ParklotOldListBean body = response.body();
if (body != null && body.getCode() == 200) {
rows.addAll(body.getRows());
adapter.notifyDataSetChanged();
if (rows.size() == body.getTotal()) {
allOK = true;
}
} else {
Toast.makeText(ParklotOldListActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<ParklotOldListBean> call, Throwable t) {
}
});
}
}
ParklotPageActivity
package com.example.smartcity1.service.parklot;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.bumptech.glide.Glide;
import com.example.smartcity1.R;
import com.example.smartcity1.bean.ParklotPageBean;
import com.example.smartcity1.network.RetrofitClient;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static com.example.smartcity1.network.RetrofitClient.IP;
public class ParklotPageActivity extends AppCompatActivity {
private TextView parkNameText;
private ImageView imageView;
private TextView addressText;
private TextView distanceText;
private TextView allParkText;
private TextView ratesText;
private TextView vacancyText;
private TextView priceCapsText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_parklot_page);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("停车场详情");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
initView();
Intent intent = getIntent();
int id = intent.getIntExtra("id", 1);
RetrofitClient.serviceService().getParklotPageData(id).enqueue(new Callback<ParklotPageBean>() {
@Override
public void onResponse(Call<ParklotPageBean> call, Response<ParklotPageBean> response) {
ParklotPageBean body = response.body();
if (body != null && body.getCode() == 200) {
ParklotPageBean.DataDTO data = body.getData();
parkNameText.setText(data.getParkName());
Glide.with(ParklotPageActivity.this).load(IP + data.getImgUrl())
.placeholder(R.drawable.ic_baseline_cloud_download_24)
.centerCrop()
.into(imageView);
addressText.setText(data.getAddress());
distanceText.setText("距离 " + data.getDistance() + " 公里");
if (Integer.parseInt(data.getAllPark()) - Integer.parseInt(data.getVacancy()) == 0) {
allParkText.setText("不对外开放");
} else {
allParkText.setText("对外开放");
}
ratesText.setText(data.getRates() + " 元/小时");
vacancyText.setText(data.getVacancy() + "个");
priceCapsText.setText("每小时"+ data.getRates() +"元, 最高"+ data.getPriceCaps() +"元/天。");
}
}
@Override
public void onFailure(Call<ParklotPageBean> call, Throwable t) {
}
});
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
private void initView() {
parkNameText = findViewById(R.id.plateNumber_text);
imageView = findViewById(R.id.imageView);
addressText = findViewById(R.id.parkName_text);
distanceText = findViewById(R.id.monetary_text);
allParkText = findViewById(R.id.allPark_text);
ratesText = findViewById(R.id.outTime_text);
vacancyText = findViewById(R.id.entryTime_text);
priceCapsText = findViewById(R.id.priceCaps_text);
}
}
patient-------------------------------------------->
HospitalListActivity
package com.example.smartcity1.service.patient;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ListView;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.example.smartcity1.R;
import com.example.smartcity1.adapter.HospitalListAdapter;
import com.example.smartcity1.bean.HostpitalListBean;
import com.example.smartcity1.network.RetrofitClient;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class HospitalListActivity extends AppCompatActivity {
private ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hospital_list);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("医院推荐");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
initView();
initListViewData();
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
return super.onCreateOptionsMenu(menu);
}
private void initView() {
listView = findViewById(R.id.listView);
}
private void initListViewData() {
RetrofitClient.serviceService().getHospitalListData().enqueue(new Callback<HostpitalListBean>() {
@Override
public void onResponse(Call<HostpitalListBean> call, Response<HostpitalListBean> response) {
HostpitalListBean bean = response.body();
if (bean != null && bean.getCode()==200) {
List<HostpitalListBean.RowsDTO> rows = bean.getRows();
HospitalListAdapter adapter = new HospitalListAdapter(HospitalListActivity.this,R.layout.item_hospital_list,rows);
listView.setAdapter(adapter);
listView.setOnItemClickListener((parent, view, position, id) -> {
Intent intent = new Intent(HospitalListActivity.this, HospitalPageActivity.class);
intent.putExtra("id",rows.get(position).getId());
startActivity(intent);
});
}
}
@Override
public void onFailure(Call<HostpitalListBean> call, Throwable t) {
}
});
}
}
HospitalPageActivity
package com.example.smartcity1.service.patient;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.example.smartcity1.R;
import com.example.smartcity1.bean.HospitalBannerBean;
import com.example.smartcity1.bean.HospitalPageBean;
import com.example.smartcity1.my.MyLoginActivity;
import com.example.smartcity1.network.RetrofitClient;
import com.youth.banner.Banner;
import com.youth.banner.adapter.BannerImageAdapter;
import com.youth.banner.holder.BannerImageHolder;
import com.youth.banner.indicator.CircleIndicator;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static com.example.smartcity1.network.RetrofitClient.IP;
import static com.example.smartcity1.network.Utils.login;
public class HospitalPageActivity extends AppCompatActivity {
private TextView titleView;
private Banner banner;
private TextView contentView;
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hospital_page);
initView();
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("医院详情");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
Intent intent = getIntent();
int id = intent.getIntExtra("id", 1);
RetrofitClient.serviceService().getHospitalPageData(id).enqueue(new Callback<HospitalPageBean>() {
@Override
public void onResponse(Call<HospitalPageBean> call, Response<HospitalPageBean> response) {
HospitalPageBean bean = response.body();
if (bean != null && bean.getCode() == 200) {
HospitalPageBean.DataDTO data = bean.getData();
titleView.setText(data.getHospitalName());
contentView.setText(data.getBrief());
}
}
@Override
public void onFailure(Call<HospitalPageBean> call, Throwable t) {
}
});
SharedPreferences user = getSharedPreferences("user",MODE_PRIVATE);
String token = user.getString("token", "");
RetrofitClient.serviceService().getHospitalBannerData(token,id).enqueue(new Callback<HospitalBannerBean>() {
@Override
public void onResponse(Call<HospitalBannerBean> call, Response<HospitalBannerBean> response) {
HospitalBannerBean body = response.body();
if (body != null && body.getCode() == 200) {
List<HospitalBannerBean.DataDTO> rows = body.getData();
banner.setAdapter(new BannerImageAdapter<HospitalBannerBean.DataDTO>(rows) {
@Override
public void onBindView(BannerImageHolder bannerImageHolder, HospitalBannerBean.DataDTO rowsDTO, int i, int i1) {
Glide.with(HospitalPageActivity.this)
.load(IP + rows.get(i).getImgUrl())
.apply(RequestOptions.bitmapTransform(new RoundedCorners(30)))
.placeholder(R.drawable.ic_baseline_cloud_download_24)
.into(bannerImageHolder.imageView);
}
}).addBannerLifecycleObserver(HospitalPageActivity.this)//添加生命周期观察者
.setIndicator(new CircleIndicator(HospitalPageActivity.this));
}
}
@Override
public void onFailure(Call<HospitalBannerBean> call, Throwable t) {
}
});
button.setOnClickListener(v -> {
if (login == 0) {
Toast.makeText(HospitalPageActivity.this, "尚未登录, 请登录", Toast.LENGTH_SHORT).show();
startActivity(new Intent(HospitalPageActivity.this, MyLoginActivity.class));
} else {
startActivity(new Intent(HospitalPageActivity.this,PatientListActivity.class));
}
});
}
private void initView() {
titleView = findViewById(R.id.title);
banner = findViewById(R.id.banner);
contentView = findViewById(R.id.content);
button = findViewById(R.id.button);
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
}
PatientClassListActivity
package com.example.smartcity1.service.patient;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.example.smartcity1.R;
import com.example.smartcity1.adapter.MyOrderAdapter;
import com.example.smartcity1.bean.NewsTypeBean;
import com.example.smartcity1.bean.PatientClassListBean;
import com.example.smartcity1.my.MyUserOrderActivity;
import com.example.smartcity1.network.RetrofitClient;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class PatientClassListActivity extends AppCompatActivity {
private RadioGroup didGroup;
private RadioButton did1Radio;
private RadioButton did2Radio;
private ListView listView;
private String token;
private String patientName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_patient_class_list);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("门诊科室分诊");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
SharedPreferences user = getSharedPreferences("user", MODE_PRIVATE);
token = user.getString("token", "");
Intent intent = getIntent();
patientName = intent.getStringExtra("patientName");
initView();
did1Radio.setClickable(false);
did2Radio.setClickable(false);
didGroup.setOnCheckedChangeListener((group, checkedId) -> {
switch (checkedId) {
case R.id.did_1_radio:
setListData(1);
break;
case R.id.did_2_radio:
setListData(2);
}
});
setListData(1);
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
private void initView() {
didGroup = findViewById(R.id.did_group);
did1Radio = findViewById(R.id.did_1_radio);
did2Radio = findViewById(R.id.did_2_radio);
listView = findViewById(R.id.listView);
}
private void setListData(int did){
RetrofitClient.serviceService().getPatientClassListData(token,did).enqueue(new Callback<PatientClassListBean>() {
@Override
public void onResponse(Call<PatientClassListBean> call, Response<PatientClassListBean> response) {
PatientClassListBean body = response.body();
if (body != null && body.getCode() == 200) {
List<PatientClassListBean.RowsDTO> rows = body.getRows();
List<String> data = new ArrayList<>();
for (PatientClassListBean.RowsDTO i : rows) {
data.add(i.getCategoryName());
}
listView.setAdapter(new ArrayAdapter<String>(PatientClassListActivity.this,android.R.layout.simple_list_item_1,data));
listView.setOnItemClickListener((parent, view, position, id) -> {
Intent intent = new Intent(PatientClassListActivity.this,PatientClassPageActivity.class);
intent.putExtra("patientName",patientName);
intent.putExtra("categoryName",rows.get(position).getCategoryName());
intent.putExtra("divisionId",rows.get(position).getId());
intent.putExtra("did",rows.get(position).getDid());
intent.putExtra("money",rows.get(position).getMoney());
startActivity(intent);
});
did1Radio.setClickable(true);
did2Radio.setClickable(true);
}
}
@Override
public void onFailure(Call<PatientClassListBean> call, Throwable t) {
}
});
}
}
PatientClassPageActivity
package com.example.smartcity1.service.patient;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.example.smartcity1.R;
import com.example.smartcity1.bean.MsgCodeBean;
import com.example.smartcity1.bean.PatientOrderPostBean;
import com.example.smartcity1.network.RetrofitClient;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class PatientClassPageActivity extends AppCompatActivity {
private TextView patientNameText;
private TextView categoryNameText;
private TextView didText;
private TextView moneyText;
private EditText dateEdit;
private EditText timeEdit;
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_patient_class_page);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("预约挂号确认");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
initView();
Intent intent = getIntent();
String patientName = intent.getStringExtra("patientName");
String categoryName = intent.getStringExtra("categoryName");
int divisionId = intent.getIntExtra("divisionId",1);
int did = intent.getIntExtra("did",1);
String money = intent.getStringExtra("money");
patientNameText.setText(patientName);
categoryNameText.setText(categoryName);
if (did == 1) {
didText.setText("专家门诊");
} else if (did == 2){
didText.setText("普通门诊");
}
moneyText.setText(money);
SharedPreferences user = getSharedPreferences("user", MODE_PRIVATE);
String token = user.getString("token", "");
String userId = user.getString("userId", "1");
button.setOnClickListener(v -> {
if (dateEdit.getText().toString().equals("") || timeEdit.getText().toString().equals("")) {
Toast.makeText(this, "请正确填写时间", Toast.LENGTH_SHORT).show();
} else {
PatientOrderPostBean bean = new PatientOrderPostBean();
bean.setPatientName(patientName);
bean.setDivisionId(divisionId);
bean.setTypesId(String.valueOf(did));
bean.setMoeny(money);
bean.setUserId(userId);
bean.setTypesId(dateEdit.getText().toString() + " " + timeEdit.getText().toString());
RetrofitClient.serviceService().getPatientOrderData(token,bean).enqueue(new Callback<MsgCodeBean>() {
@Override
public void onResponse(Call<MsgCodeBean> call, Response<MsgCodeBean> response) {
MsgCodeBean body = response.body();
if (body != null && body.getCode() == 200) {
Intent intent1 = new Intent(PatientClassPageActivity.this,PatientClassYesActivity.class);
intent1.putExtra("patientName",patientName);
intent1.putExtra("categoryName",categoryName);
intent1.putExtra("did",did);
intent1.putExtra("money",money);
intent1.putExtra("date",dateEdit.getText().toString());
intent1.putExtra("time",timeEdit.getText().toString());
startActivity(intent1);
finish();
} else {
Toast.makeText(PatientClassPageActivity.this, "预约失败, 请重试", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<MsgCodeBean> call, Throwable t) {
}
});
}
});
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
private void initView() {
patientNameText = findViewById(R.id.patientName_text);
categoryNameText = findViewById(R.id.categoryName_text);
didText = findViewById(R.id.did_text);
moneyText = findViewById(R.id.money_text);
dateEdit = findViewById(R.id.date_edit);
timeEdit = findViewById(R.id.time_edit);
button = findViewById(R.id.button);
}
}
PatientClassYesActivity
package com.example.smartcity1.service.patient;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.example.smartcity1.R;
public class PatientClassYesActivity extends AppCompatActivity {
private TextView patientNameText;
private TextView categoryNameText;
private TextView didText;
private TextView moneyText;
private TextView dateText;
private TextView timeText;
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_patient_class_yes);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("预约单");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
initView();
Intent intent = getIntent();
String patientName = intent.getStringExtra("patientName");
String categoryName = intent.getStringExtra("categoryName");
int did = intent.getIntExtra("did",1);
String money = intent.getStringExtra("money");
String date = intent.getStringExtra("date");
String time = intent.getStringExtra("time");
patientNameText.setText(patientName);
categoryNameText.setText(categoryName);
if (did == 1) {
didText.setText("专家门诊");
} else if (did == 2){
didText.setText("普通门诊");
}
moneyText.setText(money);
dateText.setText(date);
timeText.setText(time);
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
private void initView() {
patientNameText = findViewById(R.id.patientName_text);
categoryNameText = findViewById(R.id.categoryName_text);
didText = findViewById(R.id.did_text);
moneyText = findViewById(R.id.money_text);
dateText = findViewById(R.id.date_text);
timeText = findViewById(R.id.time_text);
button = findViewById(R.id.button);
}
}
PatientListActivity
package com.example.smartcity1.service.patient;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.example.smartcity1.R;
import com.example.smartcity1.adapter.PatientListAdapter;
import com.example.smartcity1.bean.MyUserInfoBean;
import com.example.smartcity1.bean.PatientListBean;
import com.example.smartcity1.network.RetrofitClient;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class PatientListActivity extends AppCompatActivity {
private ListView listView;
private FloatingActionButton floatingActionButton;
private String name;
private int sex;
private List<PatientListBean.RowsDTO> rows;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_patient_list);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle("就诊人卡片");
actionBar.setDisplayHomeAsUpEnabled(true);
}
initView();
floatingActionButton.setOnClickListener(v -> startActivity(new Intent(this,PatientPageActivity.class)));
}
@Override
protected void onStart() {
super.onStart();
SharedPreferences user = getSharedPreferences("user", MODE_PRIVATE);
RetrofitClient.serviceService().getPatientListData(user.getString("token", ""), user.getString("userId", "1")).enqueue(new Callback<PatientListBean>() {
@Override
public void onResponse(Call<PatientListBean> call, Response<PatientListBean> response) {
PatientListBean body = response.body();
if (body != null && body.getCode() == 200) {
rows = body.getRows();
if (body.getTotal() == 0) {
RetrofitClient.appService().getMyUserInfoData(user.getString("token","")).enqueue(new Callback<MyUserInfoBean>() {
@Override
public void onResponse(Call<MyUserInfoBean> call, Response<MyUserInfoBean> response) {
MyUserInfoBean body1 = response.body();
if (body1 != null && body1.getCode() == 200) {
MyUserInfoBean.UserDTO user1 = body1.getUser();
name = user1.getNickName();
sex = Integer.parseInt(user1.getSex());
PatientListBean.RowsDTO row = new PatientListBean.RowsDTO();
row.setName(name);
row.setSex(sex);
rows.add(row);
PatientListAdapter adapter = new PatientListAdapter(PatientListActivity.this, R.layout.item_patient_list, rows);
listView.setAdapter(adapter);
listView.setOnItemClickListener((parent, view, position, id) -> {
Intent intent = new Intent(PatientListActivity.this,PatientPageActivity.class);
startActivity(intent);
});
}
}
@Override
public void onFailure(Call<MyUserInfoBean> call, Throwable t) {
}
});
} else {
PatientListAdapter adapter = new PatientListAdapter(PatientListActivity.this, R.layout.item_patient_list, rows);
listView.setAdapter(adapter);
listView.setOnItemClickListener((parent, view, position, id) -> {
Toast.makeText(PatientListActivity.this, "111", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(PatientListActivity.this,PatientPageActivity.class);
intent.putExtra("id",rows.get(position).getId());
startActivity(intent);
});
}
}
}
@Override
public void onFailure(Call<PatientListBean> call, Throwable t) {
}
});
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
private void initView() {
listView = findViewById(R.id.listView);
floatingActionButton = findViewById(R.id.floatingActionButton);
}
}
PatientPageActivity
package com.example.smartcity1.service.patient;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.bumptech.glide.Glide;
import com.example.smartcity1.R;
import com.example.smartcity1.bean.MsgCodeBean;
import com.example.smartcity1.bean.MyUserInfoBean;
import com.example.smartcity1.bean.PatientNewPostBean;
import com.example.smartcity1.my.MyUserInfoActivity;
import com.example.smartcity1.network.RetrofitClient;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static com.example.smartcity1.network.RetrofitClient.IP;
public class PatientPageActivity extends AppCompatActivity {
private EditText nameEdit;
private RadioGroup sexGroup;
private RadioButton sex1Radio;
private RadioButton sex0Radio;
private EditText cardIdEdit;
private EditText birthdayEdit;
private EditText phoneEdit;
private EditText addersEdit;
private Button button;
private String token;
private String sex = "1";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_patient_page);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle("创建就诊人");
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
initView();
SharedPreferences user = getSharedPreferences("user", MODE_PRIVATE);
token = user.getString("token","");
initData();
button.setOnClickListener(v ->{
if (nameEdit.getText().toString().equals("") || cardIdEdit.getText().toString().equals("") || birthdayEdit.getText().toString().equals("")) {
Toast.makeText(this, "请正确填写必填项", Toast.LENGTH_SHORT).show();
} else {
PatientNewPostBean bean = new PatientNewPostBean();
bean.setName(nameEdit.getText().toString());
bean.setCardId(cardIdEdit.getText().toString());
bean.setBirthday(birthdayEdit.getText().toString());
if (sex.equals("1")) {
bean.setSex(1);
} else {
bean.setSex(0);
}
bean.setTel(phoneEdit.getText().toString());
bean.setAdders(addersEdit.getText().toString());
bean.setUserId(Integer.valueOf(user.getString("userId", "1")));
RetrofitClient.serviceService().getPatientNewData(token,bean).enqueue(new Callback<MsgCodeBean>() {
@Override
public void onResponse(Call<MsgCodeBean> call, Response<MsgCodeBean> response) {
MsgCodeBean body = response.body();
if (body != null && body.getCode() == 200) {
Toast.makeText(PatientPageActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
finish();
} else {
Toast.makeText(PatientPageActivity.this, "创建失败", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<MsgCodeBean> call, Throwable t) {
}
});
}
});
}
@Override
public boolean onSupportNavigateUp() {
finish();
return super.onSupportNavigateUp();
}
private void initView() {
nameEdit = findViewById(R.id.name_edit);
sexGroup = findViewById(R.id.sex_group);
sex1Radio = findViewById(R.id.sex_1_radio);
sex0Radio = findViewById(R.id.sex_0_radio);
cardIdEdit = findViewById(R.id.cardId_edit);
birthdayEdit = findViewById(R.id.birthday_edit);
phoneEdit = findViewById(R.id.phone_edit);
addersEdit = findViewById(R.id.adders_edit);
button = findViewById(R.id.button);
}
private void initData() {
RetrofitClient.appService().getMyUserInfoData(token).enqueue(new Callback<MyUserInfoBean>() {
@Override
public void onResponse(Call<MyUserInfoBean> call, Response<MyUserInfoBean> response) {
MyUserInfoBean myUserInfoBean = response.body();
if (myUserInfoBean != null && myUserInfoBean.getCode() == 200) {
MyUserInfoBean.UserDTO user = myUserInfoBean.getUser();
if (user.getSex().equals("1")) {
sex = "1";
sex1Radio.setChecked(true);
} else {
sex = "0";
sex0Radio.setChecked(false);
}
nameEdit.setText(user.getNickName());
phoneEdit.setText(user.getPhonenumber());
if (user.getIdCard() != null) {
cardIdEdit.setText(user.getIdCard().toString());
}
}
}
@Override
public void onFailure(Call<MyUserInfoBean> call, Throwable t) {
}
});
}
}