@Test public void shouldSetupListView(){ ListView listView = new ListView(activity); FormDescriptor formDescriptor = new FormDescriptor(); formManager.setup(formDescriptor, listView, activity); assertThat(listView.getAdapter(), is(notNullValue())); }
public void setup(FormDescriptor formDescriptor, final ListView listView, Activity activity){ Context context = activity; mFormDescriptor = formDescriptor; mFormDescriptor.setOnFormRowChangeListener(this); mFormDescriptor.setOnFormRowValueChangedListener(this); final FormAdapter adapter = FormAdapter.newInstance(mFormDescriptor, context); listView.setAdapter(adapter); listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FormItemDescriptor itemDescriptor = adapter.getItem(position); Cell cell = itemDescriptor.getCell(); if (cell != null && itemDescriptor instanceof RowDescriptor){ RowDescriptor rowDescriptor = (RowDescriptor) itemDescriptor; if (!rowDescriptor.getDisabled()){ cell.onCellSelected(); } } OnFormRowClickListener descriptorListener = itemDescriptor.getOnFormRowClickListener(); if (descriptorListener != null){ descriptorListener.onFormRowClick(itemDescriptor); } if (mOnFormRowClickListener != null){ mOnFormRowClickListener.onFormRowClick(itemDescriptor); } } }); mListView = listView; }
FormManager implements OnFormRowChangeListener, OnFormRowValueChangedListener { public void setup(FormDescriptor formDescriptor, final ListView listView, Activity activity){ Context context = activity; mFormDescriptor = formDescriptor; mFormDescriptor.setOnFormRowChangeListener(this); mFormDescriptor.setOnFormRowValueChangedListener(this); final FormAdapter adapter = FormAdapter.newInstance(mFormDescriptor, context); listView.setAdapter(adapter); listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FormItemDescriptor itemDescriptor = adapter.getItem(position); Cell cell = itemDescriptor.getCell(); if (cell != null && itemDescriptor instanceof RowDescriptor){ RowDescriptor rowDescriptor = (RowDescriptor) itemDescriptor; if (!rowDescriptor.getDisabled()){ cell.onCellSelected(); } } OnFormRowClickListener descriptorListener = itemDescriptor.getOnFormRowClickListener(); if (descriptorListener != null){ descriptorListener.onFormRowClick(itemDescriptor); } if (mOnFormRowClickListener != null){ mOnFormRowClickListener.onFormRowClick(itemDescriptor); } } }); mListView = listView; } }
FormManager implements OnFormRowChangeListener, OnFormRowValueChangedListener { public void setup(FormDescriptor formDescriptor, final ListView listView, Activity activity){ Context context = activity; mFormDescriptor = formDescriptor; mFormDescriptor.setOnFormRowChangeListener(this); mFormDescriptor.setOnFormRowValueChangedListener(this); final FormAdapter adapter = FormAdapter.newInstance(mFormDescriptor, context); listView.setAdapter(adapter); listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FormItemDescriptor itemDescriptor = adapter.getItem(position); Cell cell = itemDescriptor.getCell(); if (cell != null && itemDescriptor instanceof RowDescriptor){ RowDescriptor rowDescriptor = (RowDescriptor) itemDescriptor; if (!rowDescriptor.getDisabled()){ cell.onCellSelected(); } } OnFormRowClickListener descriptorListener = itemDescriptor.getOnFormRowClickListener(); if (descriptorListener != null){ descriptorListener.onFormRowClick(itemDescriptor); } if (mOnFormRowClickListener != null){ mOnFormRowClickListener.onFormRowClick(itemDescriptor); } } }); mListView = listView; } FormManager(); }
FormManager implements OnFormRowChangeListener, OnFormRowValueChangedListener { public void setup(FormDescriptor formDescriptor, final ListView listView, Activity activity){ Context context = activity; mFormDescriptor = formDescriptor; mFormDescriptor.setOnFormRowChangeListener(this); mFormDescriptor.setOnFormRowValueChangedListener(this); final FormAdapter adapter = FormAdapter.newInstance(mFormDescriptor, context); listView.setAdapter(adapter); listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FormItemDescriptor itemDescriptor = adapter.getItem(position); Cell cell = itemDescriptor.getCell(); if (cell != null && itemDescriptor instanceof RowDescriptor){ RowDescriptor rowDescriptor = (RowDescriptor) itemDescriptor; if (!rowDescriptor.getDisabled()){ cell.onCellSelected(); } } OnFormRowClickListener descriptorListener = itemDescriptor.getOnFormRowClickListener(); if (descriptorListener != null){ descriptorListener.onFormRowClick(itemDescriptor); } if (mOnFormRowClickListener != null){ mOnFormRowClickListener.onFormRowClick(itemDescriptor); } } }); mListView = listView; } FormManager(); void setup(FormDescriptor formDescriptor, final ListView listView, Activity activity); OnFormRowClickListener getOnFormRowClickListener(); void setOnFormRowClickListener(OnFormRowClickListener onFormRowClickListener); void updateRows(); OnFormRowChangeListener getOnFormRowChangeListener(); void setOnFormRowChangeListener(OnFormRowChangeListener onFormRowChangeListener); @Override void onRowAdded(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor); @Override void onRowRemoved(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor); @Override void onRowChanged(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor); @Override void onValueChanged(RowDescriptor rowDescriptor, Value<?> oldValue, Value<?> newValue); void setOnFormRowValueChangedListener(
            OnFormRowValueChangedListener onFormRowValueChangedListener); }
FormManager implements OnFormRowChangeListener, OnFormRowValueChangedListener { public void setup(FormDescriptor formDescriptor, final ListView listView, Activity activity){ Context context = activity; mFormDescriptor = formDescriptor; mFormDescriptor.setOnFormRowChangeListener(this); mFormDescriptor.setOnFormRowValueChangedListener(this); final FormAdapter adapter = FormAdapter.newInstance(mFormDescriptor, context); listView.setAdapter(adapter); listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FormItemDescriptor itemDescriptor = adapter.getItem(position); Cell cell = itemDescriptor.getCell(); if (cell != null && itemDescriptor instanceof RowDescriptor){ RowDescriptor rowDescriptor = (RowDescriptor) itemDescriptor; if (!rowDescriptor.getDisabled()){ cell.onCellSelected(); } } OnFormRowClickListener descriptorListener = itemDescriptor.getOnFormRowClickListener(); if (descriptorListener != null){ descriptorListener.onFormRowClick(itemDescriptor); } if (mOnFormRowClickListener != null){ mOnFormRowClickListener.onFormRowClick(itemDescriptor); } } }); mListView = listView; } FormManager(); void setup(FormDescriptor formDescriptor, final ListView listView, Activity activity); OnFormRowClickListener getOnFormRowClickListener(); void setOnFormRowClickListener(OnFormRowClickListener onFormRowClickListener); void updateRows(); OnFormRowChangeListener getOnFormRowChangeListener(); void setOnFormRowChangeListener(OnFormRowChangeListener onFormRowChangeListener); @Override void onRowAdded(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor); @Override void onRowRemoved(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor); @Override void onRowChanged(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor); @Override void onValueChanged(RowDescriptor rowDescriptor, Value<?> oldValue, Value<?> newValue); void setOnFormRowValueChangedListener(
            OnFormRowValueChangedListener onFormRowValueChangedListener);  }