@Test public void testShouldCreateMultiValueWrapper() { assertNotNull(cell.createMultiValueWrapper()); }
protected LinearLayout createMultiValueWrapper() { LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setId(R.id.wrap_content); linearLayout.setFocusable(false); linearLayout.setFocusableInTouchMode(false); ImageButton deleteButton = new ImageButton(getContext()); deleteButton.setId(REMOVE_BUTTON_ID); deleteButton.setFocusableInTouchMode(false); deleteButton.setFocusable(false); Drawable removeIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_remove); removeIcon.setColorFilter(0xffff0000, PorterDuff.Mode.MULTIPLY); deleteButton.setImageDrawable(removeIcon); deleteButton.setBackgroundColor(Color.TRANSPARENT); deleteButton.setVisibility(VISIBLE); deleteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { RowDescriptor rowDescriptor = getRowDescriptor(); SectionDescriptor sectionDescriptor = rowDescriptor.getSectionDescriptor(); sectionDescriptor.removeRow(rowDescriptor); sectionDescriptor.getFormDescriptor().getOnFormRowValueChangedListener().onValueChanged(rowDescriptor, rowDescriptor.getValue(), null); } }); linearLayout.addView(deleteButton); ImageButton addButton = new ImageButton(getContext()); addButton.setId(ADD_BUTTON_ID); addButton.setFocusableInTouchMode(false); addButton.setFocusable(false); Drawable addIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_new); addIcon.setColorFilter(0xff00ff00, PorterDuff.Mode.MULTIPLY); addButton.setImageDrawable(addIcon); addButton.setBackgroundColor(Color.TRANSPARENT); addButton.setVisibility(GONE); addButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); sectionDescriptor.addRow(RowDescriptor.newInstance(getRowDescriptor())); } }); linearLayout.addView(addButton); SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); int index = sectionDescriptor.getIndexOfRowDescriptor(getRowDescriptor()); if (index == sectionDescriptor.getRowCount() - 1) { addButton.setVisibility(VISIBLE); deleteButton.setVisibility(GONE); } else { addButton.setVisibility(GONE); deleteButton.setVisibility(VISIBLE); } mMultiValueWrapper = linearLayout; return mMultiValueWrapper; }
FormBaseCell extends Cell { protected LinearLayout createMultiValueWrapper() { LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setId(R.id.wrap_content); linearLayout.setFocusable(false); linearLayout.setFocusableInTouchMode(false); ImageButton deleteButton = new ImageButton(getContext()); deleteButton.setId(REMOVE_BUTTON_ID); deleteButton.setFocusableInTouchMode(false); deleteButton.setFocusable(false); Drawable removeIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_remove); removeIcon.setColorFilter(0xffff0000, PorterDuff.Mode.MULTIPLY); deleteButton.setImageDrawable(removeIcon); deleteButton.setBackgroundColor(Color.TRANSPARENT); deleteButton.setVisibility(VISIBLE); deleteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { RowDescriptor rowDescriptor = getRowDescriptor(); SectionDescriptor sectionDescriptor = rowDescriptor.getSectionDescriptor(); sectionDescriptor.removeRow(rowDescriptor); sectionDescriptor.getFormDescriptor().getOnFormRowValueChangedListener().onValueChanged(rowDescriptor, rowDescriptor.getValue(), null); } }); linearLayout.addView(deleteButton); ImageButton addButton = new ImageButton(getContext()); addButton.setId(ADD_BUTTON_ID); addButton.setFocusableInTouchMode(false); addButton.setFocusable(false); Drawable addIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_new); addIcon.setColorFilter(0xff00ff00, PorterDuff.Mode.MULTIPLY); addButton.setImageDrawable(addIcon); addButton.setBackgroundColor(Color.TRANSPARENT); addButton.setVisibility(GONE); addButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); sectionDescriptor.addRow(RowDescriptor.newInstance(getRowDescriptor())); } }); linearLayout.addView(addButton); SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); int index = sectionDescriptor.getIndexOfRowDescriptor(getRowDescriptor()); if (index == sectionDescriptor.getRowCount() - 1) { addButton.setVisibility(VISIBLE); deleteButton.setVisibility(GONE); } else { addButton.setVisibility(GONE); deleteButton.setVisibility(VISIBLE); } mMultiValueWrapper = linearLayout; return mMultiValueWrapper; } }
FormBaseCell extends Cell { protected LinearLayout createMultiValueWrapper() { LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setId(R.id.wrap_content); linearLayout.setFocusable(false); linearLayout.setFocusableInTouchMode(false); ImageButton deleteButton = new ImageButton(getContext()); deleteButton.setId(REMOVE_BUTTON_ID); deleteButton.setFocusableInTouchMode(false); deleteButton.setFocusable(false); Drawable removeIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_remove); removeIcon.setColorFilter(0xffff0000, PorterDuff.Mode.MULTIPLY); deleteButton.setImageDrawable(removeIcon); deleteButton.setBackgroundColor(Color.TRANSPARENT); deleteButton.setVisibility(VISIBLE); deleteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { RowDescriptor rowDescriptor = getRowDescriptor(); SectionDescriptor sectionDescriptor = rowDescriptor.getSectionDescriptor(); sectionDescriptor.removeRow(rowDescriptor); sectionDescriptor.getFormDescriptor().getOnFormRowValueChangedListener().onValueChanged(rowDescriptor, rowDescriptor.getValue(), null); } }); linearLayout.addView(deleteButton); ImageButton addButton = new ImageButton(getContext()); addButton.setId(ADD_BUTTON_ID); addButton.setFocusableInTouchMode(false); addButton.setFocusable(false); Drawable addIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_new); addIcon.setColorFilter(0xff00ff00, PorterDuff.Mode.MULTIPLY); addButton.setImageDrawable(addIcon); addButton.setBackgroundColor(Color.TRANSPARENT); addButton.setVisibility(GONE); addButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); sectionDescriptor.addRow(RowDescriptor.newInstance(getRowDescriptor())); } }); linearLayout.addView(addButton); SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); int index = sectionDescriptor.getIndexOfRowDescriptor(getRowDescriptor()); if (index == sectionDescriptor.getRowCount() - 1) { addButton.setVisibility(VISIBLE); deleteButton.setVisibility(GONE); } else { addButton.setVisibility(GONE); deleteButton.setVisibility(VISIBLE); } mMultiValueWrapper = linearLayout; return mMultiValueWrapper; } FormBaseCell(Context context, RowDescriptor rowDescriptor); }
FormBaseCell extends Cell { protected LinearLayout createMultiValueWrapper() { LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setId(R.id.wrap_content); linearLayout.setFocusable(false); linearLayout.setFocusableInTouchMode(false); ImageButton deleteButton = new ImageButton(getContext()); deleteButton.setId(REMOVE_BUTTON_ID); deleteButton.setFocusableInTouchMode(false); deleteButton.setFocusable(false); Drawable removeIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_remove); removeIcon.setColorFilter(0xffff0000, PorterDuff.Mode.MULTIPLY); deleteButton.setImageDrawable(removeIcon); deleteButton.setBackgroundColor(Color.TRANSPARENT); deleteButton.setVisibility(VISIBLE); deleteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { RowDescriptor rowDescriptor = getRowDescriptor(); SectionDescriptor sectionDescriptor = rowDescriptor.getSectionDescriptor(); sectionDescriptor.removeRow(rowDescriptor); sectionDescriptor.getFormDescriptor().getOnFormRowValueChangedListener().onValueChanged(rowDescriptor, rowDescriptor.getValue(), null); } }); linearLayout.addView(deleteButton); ImageButton addButton = new ImageButton(getContext()); addButton.setId(ADD_BUTTON_ID); addButton.setFocusableInTouchMode(false); addButton.setFocusable(false); Drawable addIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_new); addIcon.setColorFilter(0xff00ff00, PorterDuff.Mode.MULTIPLY); addButton.setImageDrawable(addIcon); addButton.setBackgroundColor(Color.TRANSPARENT); addButton.setVisibility(GONE); addButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); sectionDescriptor.addRow(RowDescriptor.newInstance(getRowDescriptor())); } }); linearLayout.addView(addButton); SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); int index = sectionDescriptor.getIndexOfRowDescriptor(getRowDescriptor()); if (index == sectionDescriptor.getRowCount() - 1) { addButton.setVisibility(VISIBLE); deleteButton.setVisibility(GONE); } else { addButton.setVisibility(GONE); deleteButton.setVisibility(VISIBLE); } mMultiValueWrapper = linearLayout; return mMultiValueWrapper; } FormBaseCell(Context context, RowDescriptor rowDescriptor); @Override boolean shouldAddDivider(); @Override void lastInSection(); RowDescriptor getRowDescriptor(); void onValueChanged(Value<?> newValue); }
FormBaseCell extends Cell { protected LinearLayout createMultiValueWrapper() { LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setId(R.id.wrap_content); linearLayout.setFocusable(false); linearLayout.setFocusableInTouchMode(false); ImageButton deleteButton = new ImageButton(getContext()); deleteButton.setId(REMOVE_BUTTON_ID); deleteButton.setFocusableInTouchMode(false); deleteButton.setFocusable(false); Drawable removeIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_remove); removeIcon.setColorFilter(0xffff0000, PorterDuff.Mode.MULTIPLY); deleteButton.setImageDrawable(removeIcon); deleteButton.setBackgroundColor(Color.TRANSPARENT); deleteButton.setVisibility(VISIBLE); deleteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { RowDescriptor rowDescriptor = getRowDescriptor(); SectionDescriptor sectionDescriptor = rowDescriptor.getSectionDescriptor(); sectionDescriptor.removeRow(rowDescriptor); sectionDescriptor.getFormDescriptor().getOnFormRowValueChangedListener().onValueChanged(rowDescriptor, rowDescriptor.getValue(), null); } }); linearLayout.addView(deleteButton); ImageButton addButton = new ImageButton(getContext()); addButton.setId(ADD_BUTTON_ID); addButton.setFocusableInTouchMode(false); addButton.setFocusable(false); Drawable addIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_new); addIcon.setColorFilter(0xff00ff00, PorterDuff.Mode.MULTIPLY); addButton.setImageDrawable(addIcon); addButton.setBackgroundColor(Color.TRANSPARENT); addButton.setVisibility(GONE); addButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); sectionDescriptor.addRow(RowDescriptor.newInstance(getRowDescriptor())); } }); linearLayout.addView(addButton); SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); int index = sectionDescriptor.getIndexOfRowDescriptor(getRowDescriptor()); if (index == sectionDescriptor.getRowCount() - 1) { addButton.setVisibility(VISIBLE); deleteButton.setVisibility(GONE); } else { addButton.setVisibility(GONE); deleteButton.setVisibility(VISIBLE); } mMultiValueWrapper = linearLayout; return mMultiValueWrapper; } FormBaseCell(Context context, RowDescriptor rowDescriptor); @Override boolean shouldAddDivider(); @Override void lastInSection(); RowDescriptor getRowDescriptor(); void onValueChanged(Value<?> newValue);  }