Пример #1
0
 private void initData() {
   mSenceBeans = LCConfig.getSences();
   mSenceItems = DataUtils.coverSenceBeansToSenceItems(mContext, mSenceBeans);
   List<ShowBean> list = LCConfig.getShows();
   List<ShowItem> mShowData = DataUtils.coverShowBeansToShowItems(mContext, list);
   mShowView.changeData(mShowData);
   mSenceView.changeData(mSenceItems);
   curShowItem = mShowData.get(0);
   initPaneData(curShowItem);
 }
Пример #2
0
  @Override
  protected View bindView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (rootView == null) {
      rootView = inflater.inflate(R.layout.v1_lc_setting_show_fragment_layout, null);
    }
    tvName = (TextView) rootView.findViewById(R.id.v1_lc_setting_show_name);
    tvPlay = (TextView) rootView.findViewById(R.id.v1_lc_setting_show_return);
    tvStop = (TextView) rootView.findViewById(R.id.v1_lc_setting_show_stop);
    rlShowList = (RelativeLayout) rootView.findViewById(R.id.v1_lc_setting_show_show_list);

    rlSenceList = (RelativeLayout) rootView.findViewById(R.id.v1_lc_setting_show_sence_list);

    llPane = (LinearLayout) rootView.findViewById(R.id.v1_lc_setting_show_pane);
    mChildPane1 = (LCGridView) rootView.findViewById(R.id.v1_lc_setting_show_pane_1);
    mChildPane2 = (LCGridView) rootView.findViewById(R.id.v1_lc_setting_show_pane_2);
    mChildPane3 = (LCGridView) rootView.findViewById(R.id.v1_lc_setting_show_pane_3);

    tvPane1 = (TextView) rootView.findViewById(R.id.v1_lc_setting_show_pane_text1);
    tvPane2 = (TextView) rootView.findViewById(R.id.v1_lc_setting_show_pane_text2);
    tvPane3 = (TextView) rootView.findViewById(R.id.v1_lc_setting_show_pane_text3);

    ivPaneAdd1 = (ImageView) rootView.findViewById(R.id.v1_lc_setting_show_pane_image_1);
    ivPaneAdd2 = (ImageView) rootView.findViewById(R.id.v1_lc_setting_show_pane_image_2);

    mShowView = new LCShowView(mContext);
    mShowView.setColumnsNum(1);
    mSenceView = new LCSenceView(mContext, true);
    mSenceView.setColumnsNum(1);
    mSenceView.setCanMoveChild(true);
    rlShowList.addView(mShowView.getRootView());
    rlSenceList.addView(mSenceView.getRootView());

    iniPane();
    initData();
    initEvents();

    return rootView;
  }
Пример #3
0
  private void initEvents() {
    mSenceView.setMoveCallback(
        new TouchMoveCallBackInterface() {

          @Override
          public void moveCallback(int x, int y, int position) {
            if (DataUtils.isContains(x, y, mChildPane1)) {
              if (lastPannerFocus != 0) {
                setPannerToFoces(0);
                curPannerFocus = 0;
                lastPannerFocus = 0;
              }
            } else if (DataUtils.isContains(x, y, mChildPane2)) {
              if (lastPannerFocus != 1) {
                setPannerToFoces(1);
                curPannerFocus = 1;
                lastPannerFocus = 1;
              }
            } else if (DataUtils.isContains(x, y, mChildPane3)) {
              if (lastPannerFocus != 2) {
                setPannerToFoces(2);
                curPannerFocus = 2;
                lastPannerFocus = 2;
              }
            } else {
              if (lastPannerFocus != -1) {
                setPannerToFoces(-1);
                curPannerFocus = -1;
                lastPannerFocus = -1;
              }
            }
          }
        });

    mSenceView.setUpCallbck(
        new TouchUpCallBackInterface() {

          @Override
          public void upCallback(int x, int y, int position) {
            switch (curPannerFocus) {
              case 0:
                if (DataUtils.isContains(x, y, mChildPane1)) {
                  SenceItem mSenceItem1 = mSenceView.getData().get(position);
                  if (isContainItem(mChildPaneData1, mSenceItem1)) {
                    return;
                  } else {
                    mSenceItem1.setSelect(true);
                    addSenceItemToPanner(mSenceItem1, mChildPaneData1, mChildPaneAdaper1, 0);
                  }
                }
                break;
              case 1:
                if (DataUtils.isContains(x, y, mChildPane2)) {
                  if (mChildPaneData1.size() > 0) {
                    SenceItem mSenceItem2 = mSenceView.getData().get(position);
                    if (isContainItem(mChildPaneData2, mSenceItem2)) {
                      return;
                    } else {
                      mSenceItem2.setSelect(true);
                      addSenceItemToPanner(mSenceItem2, mChildPaneData2, mChildPaneAdaper2, 1);
                    }
                  } else {
                    Toast.makeText(mContext, "容器1不能为空,请先向添加容器1添加场景。", Toast.LENGTH_SHORT).show();
                  }
                }
                break;
              case 2:
                if (DataUtils.isContains(x, y, mChildPane3)) {
                  if (mChildPaneData1.size() > 0 && mChildPaneData2.size() > 0) {
                    SenceItem mSenceItem3 = mSenceView.getData().get(position);
                    if (isContainItem(mChildPaneData3, mSenceItem3)) {
                      return;
                    } else {
                      mSenceItem3.setSelect(true);
                      addSenceItemToPanner(mSenceItem3, mChildPaneData3, mChildPaneAdaper3, 2);
                    }
                  } else {
                    Toast.makeText(mContext, "容器1,2不能为空,请先向添加容器1,2添加场景。", Toast.LENGTH_SHORT)
                        .show();
                  }
                }
                break;
              default:
                break;
            }
          }
        });

    mShowView.setOnShowItemClickListen(
        new OnShowItemClickListen() {

          @Override
          public void OnShowItemClick(int position, ShowItem showitem) {
            curShowItem = mShowView.getData().get(position);
            initPaneData(curShowItem);
            mSenceView.notifyAllItemToNoSelect();
            mSenceView.showTargetToFocus(curShowItem.getChildData(), true);
          }
        });
    mChildPane1.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
                if (curPannerFocus != 0) {
                  curPannerFocus = 0;
                  setPannerToFoces(0);
                } else {
                  curPannerFocus = -1;
                  setPannerToFoces(-1);
                }
                break;
              default:
                break;
            }

            return false;
          }
        });

    mChildPane1.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            curPannerFocus = 0;
            setPannerToFoces(0);
          }
        });
    mChildPane2.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
                if (curPannerFocus != 1) {
                  curPannerFocus = 1;
                  setPannerToFoces(1);
                } else {
                  curPannerFocus = -1;
                  setPannerToFoces(-1);
                }
                break;
              default:
                break;
            }

            return false;
          }
        });

    mChildPane2.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            curPannerFocus = 1;
            setPannerToFoces(1);
          }
        });
    mChildPane3.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
                if (curPannerFocus != 2) {
                  curPannerFocus = 2;
                  setPannerToFoces(2);
                } else {
                  curPannerFocus = -1;
                  setPannerToFoces(-1);
                }
                break;
              default:
                break;
            }

            return false;
          }
        });

    mChildPane3.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            curPannerFocus = 2;
            setPannerToFoces(2);
          }
        });

    mChildPane3.setDoubleClickCallBack(
        new DoubleClickCallBackInterface() {

          @Override
          public void doubleClickCallback(int x, int y, int position) {
            showDeleteDialog(2, position);
          }
        });

    mChildPane1.setDoubleClickCallBack(
        new DoubleClickCallBackInterface() {

          @Override
          public void doubleClickCallback(int x, int y, int position) {
            if (mChildPaneData2.size() == 0 && mChildPaneData3.size() == 0) {
              showDeleteDialog(0, position);
            } else {
              Toast.makeText(mContext, "请先删除容器2、3的场景!", Toast.LENGTH_SHORT).show();
            }
          }
        });

    mChildPane2.setDoubleClickCallBack(
        new DoubleClickCallBackInterface() {

          @Override
          public void doubleClickCallback(int x, int y, int position) {
            if (mChildPaneData3.size() == 0) {
              showDeleteDialog(1, position);
            } else {
              Toast.makeText(mContext, "请先删除容器3的场景!", Toast.LENGTH_SHORT).show();
            }
          }
        });

    ivPaneAdd1.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (setTimeDialog1 == null) {
              setTimeDialog1 = new SetTimeDialog(mContext);
              setTimeDialog1.setTimerGetter(
                  new TimerGetterInterface() {

                    @Override
                    public void onGetTime(int time) {
                      sendShowTime(time);
                    }
                  });
            }

            setTimeDialog1.showDialog();
          }
        });
    ivPaneAdd2.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (setTimeDialog2 == null) {
              setTimeDialog2 = new SetTimeDialog(mContext);
              setTimeDialog2.setTimerGetter(
                  new TimerGetterInterface() {

                    @Override
                    public void onGetTime(int time) {
                      sendShowTime(time);
                    }
                  });
            }

            setTimeDialog2.showDialog();
          }
        });

    tvPlay.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (mSendDataListen != null) {
              if (mSendDataListen != null) {
                DataConbine mConbine = new DataConbine(DataConfig.SHOW_RUNNING);
                mConbine.addByte(DataUtils.getByte(curShowItem.getItemId()));
                mSendDataListen.sendData(mConbine.getTotalData(), curShowItem);
              }
            }
          }
        });

    tvStop.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (mSendDataListen != null) {
              if (mSendDataListen != null) {
                DataConbine mConbine = new DataConbine(DataConfig.SHOW_STOPPING);
                mConbine.addByte(DataUtils.getByte(curShowItem.getItemId()));
                mSendDataListen.sendData(mConbine.getTotalData(), curShowItem);
              }
            }
          }
        });
  }