xuxiuxi
2017-05-05 0fb71a3ade434e50dce77d31c42059cf5f973af9
VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/DeviceFragment.java
@@ -1,27 +1,23 @@
package cn.com.basic.face.fragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
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.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
public class DeviceFragment extends LeftRightBaseFragment {
@@ -55,6 +51,43 @@
    @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;
@@ -67,17 +100,29 @@
        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.removeAllViews();
        if (wifiView == null) {
            wifiView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_right_wifi, null);
        }
        fragment_left_right_frame_layout_right.addView(wifiView);
    }
@@ -85,11 +130,6 @@
    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.removeAllViews();
        if (lanView == null) {
            lanView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_right_lan, null);
        }
        fragment_left_right_frame_layout_right.addView(lanView);
    }
@@ -97,11 +137,6 @@
    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.removeAllViews();
        if (schoolView == null) {
            schoolView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_right_school, null);
        }
        fragment_left_right_frame_layout_right.addView(schoolView);
    }
@@ -109,11 +144,6 @@
    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.removeAllViews();
        if (camera1View == null) {
            camera1View = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_right_camera1, null);
        }
        fragment_left_right_frame_layout_right.addView(camera1View);
    }
@@ -121,11 +151,6 @@
    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.removeAllViews();
        if (camera2View == null) {
            camera2View = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_right_camera2, null);
        }
        fragment_left_right_frame_layout_right.addView(camera2View);
    }
@@ -148,9 +173,28 @@
    }
    @OnClick(R.id.fragment_device_right_save)
    public void fragment_device_right_save_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);
    }
}