|
|
@@ -4,39 +4,89 @@ import androidx.appcompat.app.AppCompatActivity;
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
import android.content.ComponentName;
|
|
|
+import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.content.ServiceConnection;
|
|
|
import android.content.SharedPreferences;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.IBinder;
|
|
|
+import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
+import android.util.TypedValue;
|
|
|
import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.ht.gate.domain.Meeting;
|
|
|
+import com.ht.gate.domain.RoomMeetings;
|
|
|
+import com.ht.gate.domain.emp.EmpInfo;
|
|
|
+import com.squareup.picasso.Picasso;
|
|
|
+
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
|
import org.greenrobot.eventbus.ThreadMode;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
+import java.util.Timer;
|
|
|
+import java.util.TimerTask;
|
|
|
+
|
|
|
import butterknife.BindView;
|
|
|
import butterknife.ButterKnife;
|
|
|
import butterknife.OnClick;
|
|
|
|
|
|
+@SuppressLint("SetTextI18n")
|
|
|
public class WelcomeActivity extends AppCompatActivity {
|
|
|
private static final String TAG = "WelcomeActivity";
|
|
|
|
|
|
+ public static void start(Context context, Meeting meeting, EmpInfo empInfo) {
|
|
|
+ Intent intent = new Intent(context, WelcomeActivity.class);
|
|
|
+ intent.putExtra("meeting", meeting);
|
|
|
+ intent.putExtra("empInfo", empInfo);
|
|
|
+ context.startActivity(intent);
|
|
|
+ }
|
|
|
+
|
|
|
@BindView(R.id.unlock_view)
|
|
|
UnlockView unlockView;
|
|
|
- @BindView(R.id.tv_space_name)
|
|
|
- TextView tvSpaceName;
|
|
|
+ @BindView(R.id.tv_room_name)
|
|
|
+ TextView tvRoomName;
|
|
|
+ @BindView(R.id.tv_room_num)
|
|
|
+ TextView tvRoomNum;
|
|
|
@BindView(R.id.rl_meetings)
|
|
|
RelativeLayout rlMeetings;
|
|
|
@BindView(R.id.rv_meetings)
|
|
|
RecyclerView rvMeetings;
|
|
|
+ @BindView(R.id.iv_portrait)
|
|
|
+ ImageView ivPortrait;
|
|
|
+ @BindView(R.id.tv_welcome)
|
|
|
+ TextView tvWelcome;
|
|
|
+ @BindView(R.id.tv_adviser_name)
|
|
|
+ TextView tvAdviserName;
|
|
|
+ @BindView(R.id.tv_rate)
|
|
|
+ TextView tvRate;
|
|
|
+ @BindView(R.id.tv_rate_d)
|
|
|
+ TextView tvRateD;
|
|
|
+ @BindView(R.id.tv_intro)
|
|
|
+ TextView tvIntro;
|
|
|
+ @BindView(R.id.tv_cert_no)
|
|
|
+ TextView tvCertNo;
|
|
|
+ @BindView(R.id.rl_job_year)
|
|
|
+ RelativeLayout rlJobYear;
|
|
|
+ @BindView(R.id.tv_job_year)
|
|
|
+ TextView tvJobYear;
|
|
|
+
|
|
|
private MeetingAdapter adapter;
|
|
|
- private SharedPreferences sharedPreferences;
|
|
|
private DoorService.DoorBinder mDoorBinder;
|
|
|
+ private Meeting meeting;
|
|
|
+ private EmpInfo empInfo;
|
|
|
|
|
|
private ServiceConnection connection = new ServiceConnection() {
|
|
|
@Override
|
|
|
@@ -58,7 +108,8 @@ public class WelcomeActivity extends AppCompatActivity {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_welcome);
|
|
|
ButterKnife.bind(this);
|
|
|
- sharedPreferences = getSharedPreferences(SettingsActivity.PREF_NAME_SETTINGS, MODE_PRIVATE);
|
|
|
+ meeting = (Meeting) getIntent().getSerializableExtra("meeting");
|
|
|
+ empInfo = (EmpInfo) getIntent().getSerializableExtra("empInfo");
|
|
|
unlockView.setUnlockListener(() -> {
|
|
|
if (mDoorBinder != null) {
|
|
|
mDoorBinder.getService().openDoor();
|
|
|
@@ -68,6 +119,57 @@ public class WelcomeActivity extends AppCompatActivity {
|
|
|
adapter = new MeetingAdapter(this);
|
|
|
rvMeetings.setLayoutManager(new LinearLayoutManager(this));
|
|
|
rvMeetings.setAdapter(adapter);
|
|
|
+
|
|
|
+ if (empInfo.getHeadShot() != null) {
|
|
|
+ Picasso.get().load(empInfo.getHeadShot()).placeholder(R.mipmap.portrait).into(ivPortrait);
|
|
|
+ }
|
|
|
+ if (TextUtils.isEmpty(meeting.getWelcomeText())) {
|
|
|
+ tvWelcome.setText("欢迎");
|
|
|
+ tvWelcome.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 63, getResources().getDisplayMetrics()));
|
|
|
+ } else {
|
|
|
+ if (meeting.getWelcomeText().length() <= 4) {
|
|
|
+ tvWelcome.setText("欢迎," + meeting.getWelcomeText());
|
|
|
+ tvWelcome.setTextSize(TypedValue.COMPLEX_UNIT_SP, 63);
|
|
|
+ } else if (meeting.getWelcomeText().length() <= 8) {
|
|
|
+ tvWelcome.setText("欢迎\n" + meeting.getWelcomeText());
|
|
|
+ tvWelcome.setTextSize(TypedValue.COMPLEX_UNIT_SP, 55);
|
|
|
+ } else {
|
|
|
+ tvWelcome.setText("欢迎\n" + meeting.getWelcomeText());
|
|
|
+ tvWelcome.setTextSize(TypedValue.COMPLEX_UNIT_SP, 44);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tvAdviserName.setText(empInfo.getUserName());
|
|
|
+ if (empInfo.getTgStarLevel() != null) {
|
|
|
+ tvRate.setText(empInfo.getTgStarLevel().toString());
|
|
|
+ } else {
|
|
|
+ tvRate.setVisibility(View.GONE);
|
|
|
+ tvRateD.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ if (empInfo.getCertifications() == null || empInfo.getCertifications().isEmpty()) {
|
|
|
+ tvCertNo.setVisibility(View.GONE);
|
|
|
+ rlJobYear.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ tvCertNo.setText("执业证书编号:" + empInfo.getCertifications().get(0).getCertificateNumber());
|
|
|
+ int year = (int) ((System.currentTimeMillis() - empInfo.getCertifications().get(0).getCertificateAcquisitionTime()) / 1000 / 60 / 60 / 24 / 365);
|
|
|
+ if (year < 1) {
|
|
|
+ rlJobYear.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ tvJobYear.setText(year + "年");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ Date endTime = Utils.parseDateTime(meeting.getEndTimeStr());
|
|
|
+ Timer timer = new Timer();
|
|
|
+ timer.schedule(new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ }, endTime);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@OnClick(R.id.btn_settings)
|
|
|
@@ -75,22 +177,35 @@ public class WelcomeActivity extends AppCompatActivity {
|
|
|
startActivity(new Intent(this, SettingsActivity.class));
|
|
|
}
|
|
|
|
|
|
+ @OnClick(R.id.iv_arrow)
|
|
|
+ void clickArrow() {
|
|
|
+ ViewGroup.LayoutParams layoutParams = rlMeetings.getLayoutParams();
|
|
|
+ int dp36 = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 36, getResources().getDisplayMetrics());
|
|
|
+ int dp108 = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 108, getResources().getDisplayMetrics());
|
|
|
+ layoutParams.height = layoutParams.height < dp108 ? dp108 : dp36;
|
|
|
+ rlMeetings.setLayoutParams(layoutParams);
|
|
|
+ }
|
|
|
+
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void onMessageEvent(String msg) {
|
|
|
updateStatus();
|
|
|
if ("closed".equals(msg)) {
|
|
|
finish();
|
|
|
}
|
|
|
- if ("meetings".equals(msg)) {
|
|
|
- if (MyApplication.todayMeetings.isEmpty()) {
|
|
|
- rlMeetings.setVisibility(View.GONE);
|
|
|
- } else {
|
|
|
- rlMeetings.setVisibility(View.VISIBLE);
|
|
|
- }
|
|
|
- adapter.notify();
|
|
|
+ if (Constants.EVENT_MEETINGS.equals(msg)) {
|
|
|
+ updateMeetings();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void updateMeetings() {
|
|
|
+ if (MyApplication.todayMeetings.isEmpty()) {
|
|
|
+ rlMeetings.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ rlMeetings.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
private void updateStatus() {
|
|
|
if (mDoorBinder != null) {
|
|
|
String status = mDoorBinder.getService().getStatus();
|
|
|
@@ -110,7 +225,8 @@ public class WelcomeActivity extends AppCompatActivity {
|
|
|
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
|
|
| View.SYSTEM_UI_FLAG_IMMERSIVE;
|
|
|
decorView.setSystemUiVisibility(uiOptions);
|
|
|
- tvSpaceName.setText(sharedPreferences.getString(SettingsActivity.PREF_KEY_SPACE_NAME, ""));
|
|
|
+ tvRoomName.setText(MyApplication.roomInfo.getRoomName());
|
|
|
+ tvRoomNum.setText(MyApplication.roomInfo.getRoomBizNum());
|
|
|
updateStatus();
|
|
|
}
|
|
|
|
|
|
@@ -134,4 +250,8 @@ public class WelcomeActivity extends AppCompatActivity {
|
|
|
unbindService(connection);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onBackPressed() {
|
|
|
+ }
|
|
|
}
|