| | |
| | | package cn.com.basic.face.fragment;
|
| | |
|
| | | import android.os.Bundle;
|
| | | import android.support.v4.app.Fragment;
|
| | | import android.support.v4.app.FragmentManager;
|
| | | 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.MainUIBaseFragment;
|
| | | import cn.com.basic.face.base.LeftRightBaseFragment;
|
| | | import cn.com.basic.face.base.MainActivity;
|
| | |
|
| | | 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;
|
| | |
|
| | | /**
|
| | | * Created by Sinoe on 2017/2/23.
|
| | | */
|
| | | public class DeviceFragment extends LeftRightBaseFragment {
|
| | |
|
| | | public class DeviceFragment extends MainUIBaseFragment implements View.OnClickListener{
|
| | | private View mViewLeft,mViewRight;
|
| | | private RelativeLayout mLayoutWifi,mLayoutLandline,mLayoutSchool,mLayoutCamera1,mLayoutCamera2;
|
| | | private TextView mTvWifi,mTvLandline,mTvSchool,mTvCamera1,mTvCamera2;
|
| | | private CheckBox mCheckWifi,mCheckLandline,mCheckSchool,mCheckCamera1,mCheckCamera2;
|
| | | private List<CheckBox> listCheck = new ArrayList<>();
|
| | | public static DeviceFragment newInstance() {
|
| | | return new DeviceFragment();
|
| | | 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;
|
| | |
|
| | | 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
|
| | | public View addLeftLayout() {
|
| | | mViewLeft = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_left,null);
|
| | | mLayoutWifi = (RelativeLayout) mViewLeft.findViewById(R.id.device_wifi);
|
| | | mLayoutLandline = (RelativeLayout) mViewLeft.findViewById(R.id.device_landline);
|
| | | mLayoutSchool = (RelativeLayout) mViewLeft.findViewById(R.id.device_school);
|
| | | mLayoutCamera1 = (RelativeLayout) mViewLeft.findViewById(R.id.device_camera1);
|
| | | mLayoutCamera2 = (RelativeLayout) mViewLeft.findViewById(R.id.device_camera2);
|
| | |
|
| | | mTvWifi = (TextView) mLayoutWifi.findViewById(R.id.item_device_tv);
|
| | | mCheckWifi = (CheckBox) mLayoutWifi.findViewById(R.id.item_device_check);
|
| | |
|
| | | mTvLandline = (TextView) mLayoutLandline.findViewById(R.id.item_device_tv);
|
| | | mCheckLandline = (CheckBox) mLayoutLandline.findViewById(R.id.item_device_check);
|
| | |
|
| | | mTvSchool = (TextView) mLayoutSchool.findViewById(R.id.item_device_tv);
|
| | | mCheckSchool = (CheckBox) mLayoutSchool.findViewById(R.id.item_device_check);
|
| | |
|
| | | mTvCamera1 = (TextView) mLayoutCamera1.findViewById(R.id.item_device_tv);
|
| | | mCheckCamera1= (CheckBox) mLayoutCamera1.findViewById(R.id.item_device_check);
|
| | |
|
| | | mTvCamera2 = (TextView) mLayoutCamera2.findViewById(R.id.item_device_tv);
|
| | | mCheckCamera2 = (CheckBox) mLayoutCamera2.findViewById(R.id.item_device_check);
|
| | | listCheck.add(mCheckWifi);
|
| | | listCheck.add(mCheckLandline);
|
| | | listCheck.add(mCheckSchool);
|
| | | listCheck.add(mCheckCamera1);
|
| | | listCheck.add(mCheckCamera2);
|
| | | setLeftCheck(mCheckWifi);
|
| | | ViewUtils.inject(this, mViewLeft);
|
| | | return mViewLeft;
|
| | | 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_school, 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);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public View addRightLayout() {
|
| | | mViewRight = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_right,null);
|
| | | return mViewRight;
|
| | | @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);
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected void initListeners() {
|
| | | mLayoutWifi.setOnClickListener(this);
|
| | | mLayoutLandline.setOnClickListener(this);
|
| | | mLayoutSchool.setOnClickListener(this);
|
| | | mLayoutCamera1.setOnClickListener(this);
|
| | | mLayoutCamera2.setOnClickListener(this);
|
| | | @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);
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected void initData() {
|
| | | mTvWifi.setText(R.string.device_wifi);
|
| | | mTvLandline.setText(R.string.device_landline);
|
| | | mTvSchool.setText(R.string.device_school);
|
| | | mTvCamera1.setText(R.string.device_camera1);
|
| | | mTvCamera2.setText(R.string.device_camera2);
|
| | | @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);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void onClick(View view) {
|
| | | switch (view.getId()){
|
| | | case R.id.device_wifi:
|
| | | setLeftCheck(mCheckWifi);
|
| | | break;
|
| | | case R.id.device_landline:
|
| | | setLeftCheck(mCheckLandline);
|
| | | break;
|
| | | case R.id.device_school:
|
| | | setLeftCheck(mCheckSchool);
|
| | | break;
|
| | | case R.id.device_camera1:
|
| | | setLeftCheck(mCheckCamera1);
|
| | | break;
|
| | | case R.id.device_camera2:
|
| | | setLeftCheck(mCheckCamera2);
|
| | | break;
|
| | | }
|
| | | @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);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 选择器
|
| | | * @param checkBox
|
| | | */
|
| | | private void setLeftCheck(CheckBox checkBox){
|
| | | for (CheckBox box:listCheck){
|
| | | box.setChecked(false);
|
| | | }
|
| | | checkBox.setChecked(true);
|
| | | @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);
|
| | | }
|
| | |
|
| | | @OnClick(R.id.device_manager_back)
|
| | | 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_save)
|
| | | public void fragment_device_right_save_click(View view) {
|
| | |
|
| | | }
|
| | |
|
| | | }
|