|
|
@@ -88,7 +88,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
@Override
|
|
|
public void onConfirm(PasswordDialog dialog, String password) {
|
|
|
dialog.dismiss();
|
|
|
- if (MyApplication.password != null && MyApplication.password.equals(password)) {
|
|
|
+ if (MyApplication.getPassword() != null && MyApplication.getPassword().equals(password)) {
|
|
|
if (mDoorBinder != null) {
|
|
|
mDoorBinder.getService().openDoor();
|
|
|
}
|
|
|
@@ -136,40 +136,44 @@ public class MainActivity extends AppCompatActivity {
|
|
|
rlMeetings.setVisibility(View.VISIBLE);
|
|
|
}
|
|
|
adapter.notifyDataSetChanged();
|
|
|
- List<Meeting> meetings = new ArrayList<>();
|
|
|
+ boolean b = false;
|
|
|
for (RoomMeetings todayMeeting : MyApplication.todayMeetings) {
|
|
|
- meetings.addAll(todayMeeting.getMeetings());
|
|
|
- }
|
|
|
- for (Meeting meeting : meetings) {
|
|
|
- try {
|
|
|
- Date start = Utils.parseDateTime(meeting.getBeginTimeStr());
|
|
|
- Date end = Utils.parseDateTime(meeting.getEndTimeStr());
|
|
|
- Date date = new Date();
|
|
|
- if ((date.equals(start) || date.after(start)) && (date.equals(end) || date.before(end))) {
|
|
|
- RetrofitManager.getInstance().getRetrofit().create(ApiService.class)
|
|
|
- .getEmpInfo(meeting.getCreateUser().getUserId()).enqueue(new Callback<EmpInfo>() {
|
|
|
- @Override
|
|
|
- public void onResponse(@NonNull Call<EmpInfo> call, @NonNull Response<EmpInfo> response) {
|
|
|
- if (response.code() == 200) {
|
|
|
- WelcomeActivity.start(MainActivity.this, meeting, response.body());
|
|
|
- } else {
|
|
|
- try {
|
|
|
- Toasty.error(MainActivity.this, response.errorBody().string()).show();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ for (Meeting meeting : todayMeeting.getMeetings()) {
|
|
|
+ try {
|
|
|
+ Date start = Utils.parseDateTime(meeting.getBeginTimeStr());
|
|
|
+ Date end = Utils.parseDateTime(meeting.getEndTimeStr());
|
|
|
+ Date date = new Date();
|
|
|
+ if ((date.equals(start) || date.after(start)) && (date.equals(end) || date.before(end))) {
|
|
|
+ MyApplication.setPassword(MainActivity.this, todayMeeting.getRoom().getDevicePassword());
|
|
|
+ RetrofitManager.getInstance().getRetrofit().create(ApiService.class)
|
|
|
+ .getEmpInfo(meeting.getCreateUser().getUserId()).enqueue(new Callback<EmpInfo>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(@NonNull Call<EmpInfo> call, @NonNull Response<EmpInfo> response) {
|
|
|
+ if (response.code() == 200) {
|
|
|
+ WelcomeActivity.start(MainActivity.this, meeting, response.body());
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ Toasty.error(MainActivity.this, response.errorBody().string()).show();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public void onFailure(@NonNull Call<EmpInfo> call, @NonNull Throwable t) {
|
|
|
- Toasty.error(MainActivity.this, "设备绑定失败,请稍后再试").show();
|
|
|
- }
|
|
|
- });
|
|
|
+ @Override
|
|
|
+ public void onFailure(@NonNull Call<EmpInfo> call, @NonNull Throwable t) {
|
|
|
+ Toasty.error(MainActivity.this, "设备绑定失败,请稍后再试").show();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ b = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (b) {
|
|
|
break;
|
|
|
}
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|