zhangzengfei
2020-03-31 0ce893695d32ab686f9e2309509e80c6feb0d380
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package com.basic.security.activity.helper;
 
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
 
import com.basic.security.base.BaseFragment;
import com.basic.security.fragment.PasswordOpenDoorFragment;
import com.basic.security.manager.impl.cblite.AccountManager;
import com.basic.security.utils.KeyboardUtil;
 
import org.androidannotations.annotations.EActivity;
 
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
@EActivity
public abstract class MaClick extends MaMenu {
 
    public long lastAdminClickTime = 0;
    protected Set<BaseFragment> adminFragments = new HashSet<>();
 
    public void setUpClickHook() {
        List<BaseFragment> allFragments = Arrays.asList(fragment_account_setting,
                fragment_admin_face_login,
                fragment_admin_password_login,
                fragment_cluster_setting,
                fragment_base_setting,
                fragment_device_setting,
                fragment_home,
                fragment_menu,
                fragment_rule_detail,
                fragment_rule_list,
                fragment_su_auto_ic_compare_success,
                fragment_su_auto_ic_wait_idcard,
                fragment_su_auto_nic_wait_detail,
                fragment_su_logged_ic_compare_success,
                fragment_su_logged_ic_wait_face,
                fragment_su_logged_ic_wait_idcard,
                fragment_su_logged_nic_wait_face,
                fragment_su_auto_wait_admin,
                fragment_su_auto_wait_face,
                fragment_toolbar,
                fragment_person_manage,
                fragment_video_view,
                fragment_camera,
                fragment_face_list,
                fragment_face_detail,
                fragment_face_detail_time
        );
        for (BaseFragment fragment : allFragments) {
            setupUI(fragment.getView());
        }
        adminFragments.addAll(Arrays.asList(
                fragment_account_setting,
                fragment_base_setting,
                fragment_cluster_setting,
                fragment_device_setting,
                fragment_person_identity,
                fragment_person_manage,
                fragment_rule_detail,
                fragment_rule_list,
                fragment_su_logged_ic_compare_success,
                fragment_su_logged_ic_wait_face,
                fragment_su_logged_ic_wait_idcard,
                fragment_su_logged_nic_wait_detail,
                fragment_su_logged_nic_wait_face,
                fragment_su_logged_nic_wait_detail,
                fragment_system_setting_tabs,
                //新加
                fragment_face_detail,
                fragment_face_detail_time,
                fragment_face_list,
                fragment_business_person,
                fragment_hint_door_access,
                fragment_hint_recognize,
                fragment_hint_sign_up,
                fragment_person_identity,
                fragment_rule_detail,
                fragment_rule_list,
                fragment_time_rule,
                fragment_time_rule_add,
                fragment_visit_record_list,
                fragment_visit_record_list
 
 
        ));
    }
 
    @Override
    public void onUserInteraction() {
        setLastAdminClickTime();
    }
 
    public void setLastAdminClickTime() {
        if (adminFragments.contains(currentFragment) && AccountManager.adminLoggedIn()) {
            lastAdminClickTime = System.currentTimeMillis();
        }
    }
 
    public void setupUI(final View view) {
        if (!(view instanceof EditText)) {
            view.setOnTouchListener(new View.OnTouchListener() {
                public boolean onTouch(View v, MotionEvent event) {
                    PasswordOpenDoorFragment.showKeyboardTime = System.currentTimeMillis();
                    setLastAdminClickTime();
                    refreshCurrentFragmentShowTime();
                    KeyboardUtil.hideSoftKeyboard();
                    return false;
                }
            });
        }
        if (view instanceof EditText) {
            view.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                @Override
                public void onFocusChange(View v, boolean hasFocus) {
                    if (hasFocus) {
                        KeyboardUtil.showKeyboard();
                    } else {
                        KeyboardUtil.hideSoftKeyboard();
                    }
                }
            });
 
        }
        view.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                PasswordOpenDoorFragment.showKeyboardTime = System.currentTimeMillis();
                if (v == fragment_rule_detail.rl_check_hint) {
                    return true;
                }
                if (v == fragment_face_detail_time.rl_check_pass_time) {
                    return true;
                }
                setLastAdminClickTime();
                refreshCurrentFragmentShowTime();
                if (view == fragment_toolbar.menu) {
                } else {
                    if (fragment_menu.isVisible()) {
                        hideOneFragment(fragment_menu);
                    }
                }
                if (view != fragment_face_list.person_manager_ll_hide
                        && view != fragment_face_list.person_manager_lv
                        && view != fragment_face_list.person_manage_btn_sure
                        ) {
                    fragment_face_list.hidePersonIdentityPopupFromNotSureButton();
                }
                if (view == fragment_face_list.person_manager_ll_hide) {
                    return true;
                }
                //=========点击其他地方,访客页面选择身份消失========
                if (view != fragment_visitor_model.ll_temp_person_check_identity
                        && view != fragment_visitor_model.gv_temp_person
                        && view != fragment_visitor_model.btn_temp_person_sure
                        ) {
                    fragment_visitor_model.ll_temp_person_check_identity.setVisibility(View.GONE);
                }
                if (view == fragment_visitor_model.ll_temp_person_check_identity) {
                    return true;
                }
                //=================
                //=========点击其他地方,访客页面组织机构消失========
                if (view != fragment_visitor_model.rl_show_organization
                        && view != fragment_visitor_model.lv_organization
                        ) {
                    fragment_visitor_model.rl_show_organization.setVisibility(View.GONE);
                }
                if (view == fragment_visitor_model.rl_show_organization) {
                    return true;
                }
                //=================
//                if (view != ((SystemSettingTabsFragment) fragment_system_setting_tabs).ll_all_base_setting) {
//                    ((SystemSettingTabsFragment) fragment_system_setting_tabs).hideAllSettingPopup();
//                }
                if (!(view instanceof EditText)) {
                    KeyboardUtil.hideSoftKeyboard();
                }
                return false;
            }
        });
        if (view instanceof ViewGroup) {
            for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
                View innerView = ((ViewGroup) view).getChildAt(i);
                setupUI(innerView);
            }
        }
 
    }
 
}