private void setupClickables(Context context) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.sample_control_2, null); mLayout = (ControlViewGroup) parseLayout(layout); if (mLayout != null) { ControlView upperLeft = mLayout.findViewById(R.id.sample_control_object_1); upperLeft.setOnClickListener( new OnClickListener() { @Override public void onClick() { sendImage(R.id.sample_control_object_1, R.drawable.left_top_selected); mHandler.postDelayed( new SelectToggler(R.id.sample_control_object_1, R.drawable.left_top), SELECT_TOGGLER_MS); } }); ControlView upperRight = mLayout.findViewById(R.id.sample_control_object_2); upperRight.setOnClickListener( new OnClickListener() { @Override public void onClick() { sendImage(R.id.sample_control_object_2, R.drawable.right_top_selected); mHandler.postDelayed( new SelectToggler(R.id.sample_control_object_2, R.drawable.right_top), SELECT_TOGGLER_MS); } }); ControlView bottomLeft = mLayout.findViewById(R.id.sample_control_object_3); bottomLeft.setOnClickListener( new OnClickListener() { @Override public void onClick() { sendImage(R.id.sample_control_object_3, R.drawable.left_bottom_selected); mHandler.postDelayed( new SelectToggler(R.id.sample_control_object_3, R.drawable.left_bottom), SELECT_TOGGLER_MS); } }); ControlView bottomRight = mLayout.findViewById(R.id.sample_control_object_4); bottomRight.setOnClickListener( new OnClickListener() { @Override public void onClick() { sendImage(R.id.sample_control_object_4, R.drawable.right_bottom_selected); mHandler.postDelayed( new SelectToggler(R.id.sample_control_object_4, R.drawable.right_bottom), SELECT_TOGGLER_MS); } }); } }
@Override public void onObjectClick(final ControlObjectClickEvent event) { Log.d(SampleExtensionService.LOG_TAG, "onObjectClick() " + event.getClickType()); if (event.getLayoutReference() != -1) { mLayout.onClick(event.getLayoutReference()); } }