a
554325746@qq.com
2020-01-02 e52632329ef8342a2f692bf58184fc54db3d2b4c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.basic.security.fragment;
 
import android.os.SystemClock;
import android.widget.TextView;
 
import com.basic.security.R;
import com.basic.security.base.BaseApplication;
import com.basic.security.base.BaseFragment;
import com.basic.security.manager.impl.cblite.AccountManager;
import com.basic.security.manager.impl.sqlite.SlDeviceSettingManager;
 
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;
 
 
@EFragment(R.layout.fragment_door_access_result)
public class DoorAccessResultFragment extends BaseFragment {
    @ViewById
    TextView tv_text;
    boolean isSleepInBackGround = false;
 
    @Override
    public void show() {
        super.show();
        sleepInBackGround(Integer.parseInt(SlDeviceSettingManager.getOpenDoorTime()));
    }
 
    // 伪代码
    @UiThread
    public void openDoor() {
        tv_text.setText("开门成功");
        tv_text.setTextColor(getResources().getColor(R.color.colorGreen));
    }
 
    public void refuseOpenDoor() {
        tv_text.setText("拒绝开门");
        tv_text.setTextColor(getResources().getColor(R.color.colorRed));
    }
 
    public void confirmOpenDoor() {
        tv_text.setText("设备设置:确认开门");
        tv_text.setTextColor(getResources().getColor(R.color.colorRed));
    }
 
    public void notReachTime() {
        tv_text.setText("未到通行时间");
        tv_text.setTextColor(getResources().getColor(R.color.colorRed));
    }
 
    void sleepInBackGround(int sleepTime) {
        synchronized (this) {
            if (isSleepInBackGround) {
                return;
            }
            isSleepInBackGround = true;
        }
        BaseApplication.getApplication().executorService.execute(() -> {
            SystemClock.sleep(1000 * sleepTime);
            backToWaitFace();
            synchronized (DoorAccessResultFragment.this) {
                isSleepInBackGround = false;
            }
        });
 
    }
 
 
    public String openDoorTitle() {
        return tv_text.getText().toString().trim();
    }
 
    @UiThread
    void backToWaitFace() {
        if (!AccountManager.adminLoggedIn()
                && mainActivity().currentFragment != mainActivity().fragment_admin_face_login
                && mainActivity().currentFragment != mainActivity().fragment_admin_password_login
                ) {
            showFragment(mainActivity().fragment_su_auto_wait_face);
        }
    }
 
}