xuxiuxi
2017-05-05 0fb71a3ade434e50dce77d31c42059cf5f973af9
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
195
196
197
198
199
200
package cn.com.basic.face.fragment;
 
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.RadioButton;
 
import com.bsk.zhangbo.demoforbsk.R;
import cn.com.basic.face.base.LeftRightBaseFragment;
import cn.com.basic.face.base.MainActivity;
import cn.com.basic.face.service.DeviceMng;
 
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
 
import java.util.HashMap;
import java.util.Map;
 
public class DeviceFragment extends LeftRightBaseFragment {
 
    private static DeviceFragment instance = new DeviceFragment();
    public static DeviceFragment getInstance() {
        return instance;
    }
 
    @ViewInject(R.id.fragment_device_left_wifi_check_box)
    private RadioButton fragment_device_left_wifi_check_box;
    @ViewInject(R.id.fragment_device_left_search)
    private EditText fragment_device_left_search;
    @ViewInject(R.id.fragment_device_left_lan_check_box)
    private RadioButton fragment_device_left_lan_check_box;
    @ViewInject(R.id.fragment_device_left_school_check_box)
    private RadioButton fragment_device_left_school_check_box;
    @ViewInject(R.id.fragment_device_left_camera1_check_box)
    private RadioButton fragment_device_left_camera1_check_box;
    @ViewInject(R.id.fragment_device_left_camera2_check_box)
    private RadioButton fragment_device_left_camera2_check_box;
    @OnClick(R.id.fragment_device_left_wifi_relative_layout)
    public void fragment_device_left_wifi_relative_layout_click(View view) { fragment_device_left_wifi_check_box_click(view); }
    @OnClick(R.id.fragment_device_left_lan_relative_layout)
    public void fragment_device_left_lan_relative_layout_click(View view) { fragment_device_left_lan_check_box_click(view); }
    @OnClick(R.id.fragment_device_left_school_relative_layout)
    public void fragment_device_left_school_relative_layout_click(View view) { fragment_device_left_school_check_box_click(view); }
    @OnClick(R.id.fragment_device_left_camera1_relative_layout)
    public void fragment_device_left_camera1_relative_layout_click(View view) { fragment_device_left_camera1_check_box_click(view); }
    @OnClick(R.id.fragment_device_left_camera2_relative_layout)
    public void fragment_device_left_camera2_relative_layout_click(View view) { fragment_device_left_camera2_check_box_click(view); }
    @ViewInject(R.id.fragment_left_right_frame_layout_right)
    private FrameLayout fragment_left_right_frame_layout_right;
 
    @ViewInject(R.id.fragment_device_right_camera1_brand)
    private EditText fragment_device_right_camera1_brand;
    @ViewInject(R.id.fragment_device_right_camera1_ip)
    private EditText fragment_device_right_camera1_ip;
    @ViewInject(R.id.fragment_device_right_camera1_port)
    private EditText fragment_device_right_camera1_port;
    @ViewInject(R.id.fragment_device_right_camera1_resolution)
    private EditText fragment_device_right_camera1_resolution;
    @ViewInject(R.id.fragment_device_right_camera1_username)
    private EditText fragment_device_right_camera1_username;
    @ViewInject(R.id.fragment_device_right_camera1_password)
    private EditText fragment_device_right_camera1_password;
 
    @ViewInject(R.id.fragment_device_right_camera2_brand)
    private EditText fragment_device_right_camera2_brand;
    @ViewInject(R.id.fragment_device_right_camera2_ip)
    private EditText fragment_device_right_camera2_ip;
    @ViewInject(R.id.fragment_device_right_camera2_port)
    private EditText fragment_device_right_camera2_port;
    @ViewInject(R.id.fragment_device_right_camera2_resolution)
    private EditText fragment_device_right_camera2_resolution;
    @ViewInject(R.id.fragment_device_right_camera2_username)
    private EditText fragment_device_right_camera2_username;
    @ViewInject(R.id.fragment_device_right_camera2_password)
    private EditText fragment_device_right_camera2_password;
 
    @ViewInject(R.id.fragment_device_right_lan_ip)
    private EditText fragment_device_right_lan_ip;
    @ViewInject(R.id.fragment_device_right_lan_port)
    private EditText fragment_device_right_lan_port;
    @ViewInject(R.id.fragment_device_right_lan_protocol)
    private EditText fragment_device_right_lan_protocol;
    @ViewInject(R.id.fragment_device_right_device_info_sn)
    private EditText fragment_device_right_school_sn;
    @ViewInject(R.id.fragment_device_right_device_info_device_address)
    private EditText fragment_device_right_school_device_address;
 
    private View wifiView;
    private View lanView;
    private View schoolView;
    private View camera1View;
    private View camera2View;
 
    public void clearAll() {
        fragment_device_left_wifi_check_box.setChecked(false);
        fragment_device_left_lan_check_box.setChecked(false);
        fragment_device_left_school_check_box.setChecked(false);
        fragment_device_left_camera1_check_box.setChecked(false);
        fragment_device_left_camera2_check_box.setChecked(false);
        fragment_left_right_frame_layout_right.removeAllViews();
    }
 
    @Override
    protected void initViews(View view, Bundle savedInstanceState) {
        super.initViews(view, savedInstanceState);
        wifiView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_right_wifi, null);
        lanView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_right_lan, null);
        schoolView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_right_device_info, null);
        camera1View = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_right_camera1, null);
        camera2View = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_right_camera2, null);
        ViewUtils.inject(this, wifiView);
        ViewUtils.inject(this, lanView);
        ViewUtils.inject(this, schoolView);
        ViewUtils.inject(this, camera1View);
        ViewUtils.inject(this, camera2View);
        fragment_device_left_wifi_check_box.setChecked(true);
    }
 
    @OnClick(R.id.fragment_device_left_wifi_check_box)
    public void fragment_device_left_wifi_check_box_click(View view) {
        clearAll();
        fragment_device_left_wifi_check_box.setChecked(true);
        fragment_left_right_frame_layout_right.addView(wifiView);
    }
 
    @OnClick(R.id.fragment_device_left_lan_check_box)
    public void fragment_device_left_lan_check_box_click(View view) {
        clearAll();
        fragment_device_left_lan_check_box.setChecked(true);
        fragment_left_right_frame_layout_right.addView(lanView);
    }
 
    @OnClick(R.id.fragment_device_left_school_check_box)
    public void fragment_device_left_school_check_box_click(View view) {
        clearAll();
        fragment_device_left_school_check_box.setChecked(true);
        fragment_left_right_frame_layout_right.addView(schoolView);
    }
 
    @OnClick(R.id.fragment_device_left_camera1_check_box)
    public void fragment_device_left_camera1_check_box_click(View view) {
        clearAll();
        fragment_device_left_camera1_check_box.setChecked(true);
        fragment_left_right_frame_layout_right.addView(camera1View);
    }
 
    @OnClick(R.id.fragment_device_left_camera2_check_box)
    public void fragment_device_left_camera2_check_box_click(View view) {
        clearAll();
        fragment_device_left_camera2_check_box.setChecked(true);
        fragment_left_right_frame_layout_right.addView(camera2View);
    }
 
    public int[] getLeftRightLayoutIds() {
        return new int[]{R.layout.fragment_device_left, R.layout.fragment_device_right};
    }
 
    @OnClick(R.id.fragment_device_back)
    public void back(View view){
        MainActivity.selectPage(0);
    }
 
    @OnClick(R.id.fragment_device_right_delete)
    public void fragment_device_right_delete_click(View view) {
 
    }
 
    @OnClick(R.id.fragment_device_right_add)
    public void fragment_device_right_add_click(View view) {
 
    }
 
    @OnClick(R.id.fragment_device_right_lan_save)
    public void fragment_device_right_lan_save_click(View view) {
        Map<String, String> fields = new HashMap<>();
        DeviceMng.getInstance().saveLanSetting(fields);
    }
 
    @OnClick(R.id.fragment_device_right_school_save)
    public void fragment_device_right_school_save_click(View view) {
        Map<String, String> fields = new HashMap<>();
        DeviceMng.getInstance().saveSchoolSetting(fields);
    }
 
    @OnClick(R.id.fragment_device_right_camera1_save)
    public void fragment_device_right_camera1_save_click(View view) {
        Map<String, String> fields = new HashMap<>();
        DeviceMng.getInstance().saveCamera1Setting(fields);
    }
 
    @OnClick(R.id.fragment_device_right_camera2_save)
    public void fragment_device_right_camera2_save_click(View view) {
        Map<String, String> fields = new HashMap<>();
        DeviceMng.getInstance().saveCamera2Setting(fields);
    }
 
}