use of com.orhanobut.dialogplus.ListHolder in project dialogplus by orhanobut.
the class DialogPlusBuilderTest method testSetContentHolder.
@Test
public void testSetContentHolder() {
DialogPlusBuilder builder = DialogPlus.newDialog(context);
//Test ListHolder
ListHolder listHolder = new ListHolder();
builder.setContentHolder(listHolder);
assertThat(builder.getHolder()).isEqualTo(listHolder);
//test GridHolder
GridHolder gridHolder = new GridHolder(3);
builder.setContentHolder(gridHolder);
assertThat(builder.getHolder()).isEqualTo(gridHolder);
//test ViewHolder
ViewHolder viewHolder = new ViewHolder(new LinearLayout(context));
builder.setContentHolder(viewHolder);
assertThat(builder.getHolder()).isEqualTo(viewHolder);
//should accept null
builder.setContentHolder(null);
}
use of com.orhanobut.dialogplus.ListHolder in project dialogplus by orhanobut.
the class ListHolderTest method testOnItemClickWithoutItemListenerOnly.
@Test
public void testOnItemClickWithoutItemListenerOnly() {
ListHolder holder = getListHolder();
ListView listView = (ListView) holder.getInflatedView();
//with adapter set
ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, new String[] { "test" });
holder.setAdapter(adapter);
try {
listView.performItemClick(null, 0, 0);
} catch (Exception e) {
fail("it should not crash");
}
}
use of com.orhanobut.dialogplus.ListHolder in project dialogplus by orhanobut.
the class ListHolderTest method testFooter.
@Test
public void testFooter() {
ListHolder holder = getListHolder();
assertThat(holder.getFooter()).isNull();
View footer = new LinearLayout(context);
holder.addFooter(footer);
assertThat(holder.getFooter()).isEqualTo(footer);
}
use of com.orhanobut.dialogplus.ListHolder in project dialogplus by orhanobut.
the class ListHolderTest method testOnItemClickWithoutItemListenerAndAdapter.
@Test
public void testOnItemClickWithoutItemListenerAndAdapter() {
ListHolder holder = getListHolder();
ListView listView = (ListView) holder.getInflatedView();
try {
listView.performItemClick(null, 0, 0);
} catch (Exception e) {
fail("it should not crash");
}
}
use of com.orhanobut.dialogplus.ListHolder in project dialogplus by orhanobut.
the class ListHolderTest method testOnItemClick.
@Test
public void testOnItemClick() {
ListHolder holder = getListHolder();
ListView listView = (ListView) holder.getInflatedView();
//with adapter set
ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, new String[] { "test" });
holder.setAdapter(adapter);
//set listener
holder.setOnItemClickListener(new OnHolderListener() {
@Override
public void onItemClick(Object item, View view, int position) {
assertThat(String.valueOf(item)).isEqualTo("test");
assertThat(position).isEqualTo(0);
assertThat(view).isNull();
}
});
listView.performItemClick(null, 0, 0);
}
Aggregations