wxr
2022-11-24 2af932533ef851bf983385244e9912976dbd4daa
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
package com.mm.android.deviceaddmodule.p_devlogin;
 
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
 
import com.mm.android.deviceaddmodule.R;
import com.mm.android.deviceaddmodule.base.BaseDevAddFragment;
import com.mm.android.deviceaddmodule.contract.DevLoginConstract;
import com.mm.android.deviceaddmodule.event.DeviceAddEvent;
import com.mm.android.deviceaddmodule.helper.DeviceAddHelper;
import com.mm.android.deviceaddmodule.helper.PageNavigationHelper;
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.ProviderManager;
import com.mm.android.deviceaddmodule.mobilecommon.common.LCConfiguration;
import com.mm.android.deviceaddmodule.mobilecommon.utils.UIUtils;
import com.mm.android.deviceaddmodule.mobilecommon.widget.ClearEditText;
import com.mm.android.deviceaddmodule.mobilecommon.widget.ClearPasswordEditText;
import com.mm.android.deviceaddmodule.presenter.DevLoginPresenter;
 
import org.greenrobot.eventbus.EventBus;
 
/**
 * 设备登录页面
 */
public class DevLoginFragment extends BaseDevAddFragment implements DevLoginConstract.View,
        View.OnClickListener, ClearEditText.ITextChangeListener {
    DevLoginConstract.Presenter mPresenter;
    ClearPasswordEditText mPwdEdit;
    TextView mNext;
    Handler mHandler = new Handler();
    long mEventStartTime;       //统计开始时间
 
    public static DevLoginFragment newInstance() {
        DevLoginFragment fragment = new DevLoginFragment();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }
 
 
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_dev_login, container, false);
    }
 
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mEventStartTime = System.currentTimeMillis();
    }
 
    protected void initView(View view) {
        DeviceAddHelper.updateTile(DeviceAddHelper.TitleMode.MORE);
        mNext = view.findViewById(R.id.tv_input_ok);
        mPwdEdit = view.findViewById(R.id.et_device_pwd);
        mPwdEdit.openEyeMode(ProviderManager.getAppProvider().getAppType() != LCConfiguration.APP_LECHANGE_OVERSEA);
        mNext.setOnClickListener(this);
        UIUtils.setEnabledEX(false, mNext);
        mPwdEdit.setTextChangeListener(this);
    }
 
    protected void initData() {
        mPresenter = new DevLoginPresenter(this);
    }
 
    @Override
    public void showProgressDialog() {
        hideSoftKeyboard();
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (!isDestoryView()) {
                    EventBus.getDefault().post(new DeviceAddEvent(DeviceAddEvent.SHOW_LOADING_VIEW_ACTION));
                }
            }
        }, 100);
 
    }
 
    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.tv_input_ok) {
            mPresenter.devLogin();
        }
    }
 
    @Override
    public String getDevicePassword() {
        return mPwdEdit.getText().toString();
    }
 
    @Override
    public void goSoftAPWifiListPage() {
        PageNavigationHelper.gotoSoftApWifiListPage(this);
    }
 
    @Override
    public void goDeviceBindPage() {
        PageNavigationHelper.gotoDeviceBindPage(this);
    }
 
    @Override
    public void goBindSuceesPage() {
        PageNavigationHelper.gotoBindSuccessPage(this);
    }
 
    @Override
    public void goOtherUserBindTipPage() {
        PageNavigationHelper.gotoErrorTipPage(this, DeviceAddHelper.ErrorCode.DEVICE_BIND_ERROR_BIND_BY_OTHER);
    }
 
    @Override
    public void goErrorTipPage(int errorCode) {
        PageNavigationHelper.gotoErrorTipPage(this, errorCode);
    }
 
    @Override
    public void completeAction() {
       if(getActivity() != null) getActivity().finish();
    }
 
    @Override
    public void goDevLoginPage() {
        PageNavigationHelper.gotoDevLoginPage(this);
    }
 
    @Override
    public void goDevSecCodePage() {
        PageNavigationHelper.gotoDevSecCodePage(this);
    }
 
    @Override
    public void afterChanged(EditText v, Editable s) {
 
    }
 
    @Override
    public void beforeChanged(EditText v, CharSequence s, int start, int count, int after) {
 
    }
 
    @Override
    public void onTextChanged(EditText v, CharSequence text, int start, int lengthBefore, int lengthAfter) {
        UIUtils.setEnabledEX(text.length() > 0, mNext);
    }
 
}