1
wxr
2023-04-23 2cd55265ccff3b0a267d7953b2dd9e5dca437aa6
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
package com.videogo.ui.LanDevice;
 
import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
 
import com.videogo.openapi.EZHCNetDeviceSDK;
import com.videogo.constant.IntentConsts;
import com.videogo.util.Utils;
 
import ezviz.ezopensdk.R;
 
public class LanDeviceActivateActivity extends Activity implements View.OnClickListener {
    private static final String TAG = LanDeviceActivateActivity.class.getName();
    EditText mPasswordETV;
    Button mActivateBtn;
    private String mSeriNo;
    private TextView mTitleTextView;
    private String mPassword;
 
 
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hcactive);
        mTitleTextView = (TextView) findViewById(R.id.title_text);
        mPasswordETV = (EditText) findViewById(R.id.passwordETV);
        mActivateBtn = (Button) findViewById(R.id.activateBtn);
        mActivateBtn.setOnClickListener(this);
        mSeriNo = getIntent().getStringExtra(IntentConsts.EXTRA_DEVICE_ID);
    }
 
    @Override
    public void onClick(View v) {
        if (v == mActivateBtn){
            mPassword = mPasswordETV.getText().toString().trim();
            if (TextUtils.isEmpty(mPassword)) {
                Utils.showToast(this, R.string.sadp_password_toast);
                return;
            }
            activateDevice();
        }
    }
 
    private void activateDevice(){
        new Thread(new Runnable() {
            @Override
            public void run() {
                final int result = EZHCNetDeviceSDK.getInstance().activeDeviceWithSerial(mSeriNo, mPassword);
                if (result == 1) {
                    // TODO: 2017/8/15 Activation successful
                    setResult(LanDeviceActivity.RESULT_OK,null);
                    finish();
                    return;
                }else {
                    //TODO: 2017/8/15 Activation failed
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if(result == 2020){
                                // TODO: 2017/8/16 密码太弱
                                Utils.showToast(LanDeviceActivateActivity.this, R.string.sadp_password_too_weak);
                            }else{
                                Utils.showToast(LanDeviceActivateActivity.this, R.string.title_activate_device_fail);
                            }
                        }
                    });
                }
            }
        }).start();
    }
}