/** 初始化所有panner处于非focus样式 * */ private void initPaneTextColor() { tvPane1.setTextColor(getResources().getColor(R.color.white)); tvPane2.setTextColor(getResources().getColor(R.color.white)); tvPane3.setTextColor(getResources().getColor(R.color.white)); mChildPane1.setBackgroundResource(R.drawable.v1_base_btn_white__unpress); mChildPane2.setBackgroundResource(R.drawable.v1_base_btn_white__unpress); mChildPane3.setBackgroundResource(R.drawable.v1_base_btn_white__unpress); }
/** * 使panner显示foces样式 * * @param position */ private void setPannerToFoces(int position) { initPaneTextColor(); switch (position) { case 0: tvPane1.setTextColor(getResources().getColor(R.color.yellow)); mChildPane1.setBackgroundResource(R.drawable.v1_base_btn_yellow__unpress); break; case 1: tvPane2.setTextColor(getResources().getColor(R.color.yellow)); mChildPane2.setBackgroundResource(R.drawable.v1_base_btn_yellow__unpress); break; case 2: tvPane3.setTextColor(getResources().getColor(R.color.yellow)); mChildPane3.setBackgroundResource(R.drawable.v1_base_btn_yellow__unpress); break; default: initPaneTextColor(); break; } }
private void iniPane() { mChildPaneData1 = new ArrayList<SenceItem>(); mChildPaneData2 = new ArrayList<SenceItem>(); mChildPaneData3 = new ArrayList<SenceItem>(); mChildPaneAdaper1 = new ShowPannerAdapter(mContext, mChildPaneData1); mChildPaneAdaper2 = new ShowPannerAdapter(mContext, mChildPaneData2); mChildPaneAdaper3 = new ShowPannerAdapter(mContext, mChildPaneData3); mChildPane1.setNumColumns(1); mChildPane2.setNumColumns(1); mChildPane3.setNumColumns(1); mChildPane1.setAdapter(mChildPaneAdaper1); mChildPane2.setAdapter(mChildPaneAdaper2); mChildPane3.setAdapter(mChildPaneAdaper3); }
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); } } } }); }