NetworkSettingActivity.java
1.84 KB
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
package com.huaheng.mes;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.huaheng.mes.activity.model.CommonActivity;
import com.huaheng.mes.bean.Constant;
import com.huaheng.mes.https.HttpConstant;
import com.huaheng.mes.util.MESUtils;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* Created by youjie on 2018/9/19
*/
public class NetworkSettingActivity extends CommonActivity {
@BindView(R.id.networkEdit)
EditText networkEdit;
@BindView(R.id.myNetwork)
TextView myNetwork;
@Override
protected void initActivityOnCreate(Bundle savedInstanceState) {
super.initActivityOnCreate(savedInstanceState);
setContentView(R.layout.activity_network_setting);
ButterKnife.bind(this);
setTitle(getString(R.string.configure_network));
freshText();
}
@OnClick({R.id.resetDefaultBtn, R.id.setBtn})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.resetDefaultBtn:
networkEdit.setText(HttpConstant.URL);
break;
case R.id.setBtn:
setNetwork();
break;
}
}
private void freshText() {
String network = MESUtils.getData(Constant.NETWORK);
network = this.getString(R.string.local ) + network;
myNetwork.setText(network);
}
private void setNetwork() {
String network = networkEdit.getText().toString();
if (network != null && network.length() > 0) {
MESUtils.saveData(Constant.NETWORK, network);
MESUtils.showShort(getString(R.string.setting_success));
freshText();
} else {
MESUtils.showShort(getString(R.string.enter_error_network));
}
}
}