use of com.orhanobut.dialogplus.GridHolder in project dialogplus by orhanobut.
the class GridHolderTest method testViewInflation.
@Test
public void testViewInflation() {
GridHolder holder = new GridHolder(3);
LayoutInflater layoutInflater = LayoutInflater.from(context);
View view = holder.getView(layoutInflater, new LinearLayout(context));
assertThat(view).isNotNull();
assertThat(holder.getInflatedView().getId()).isEqualTo(R.id.dialogplus_list);
GridView gridView = (GridView) holder.getInflatedView();
assertThat(gridView.getOnItemClickListener()).isInstanceOf(GridHolder.class);
}
use of com.orhanobut.dialogplus.GridHolder in project dialogplus by orhanobut.
the class GridHolderTest method testFooter.
@Test
public void testFooter() {
GridHolder holder = getHolder();
assertThat(holder.getFooter()).isNull();
View footer = new LinearLayout(context);
holder.addFooter(footer);
assertThat(holder.getFooter()).isEqualTo(footer);
}
use of com.orhanobut.dialogplus.GridHolder 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.GridHolder in project dialogplus by orhanobut.
the class GridHolderTest method testOnItemClick.
@Test
public void testOnItemClick() {
GridHolder holder = getHolder();
GridView view = (GridView) holder.getInflatedView();
//there is no listener, it shouldn't crash
view.performItemClick(null, 0, 0);
//with adapter set
ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, new String[] { "test" });
holder.setAdapter(adapter);
view.performItemClick(null, 0, 0);
//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();
}
});
view.performItemClick(null, 0, 0);
}
use of com.orhanobut.dialogplus.GridHolder in project dialogplus by orhanobut.
the class GridHolderTest method getHolder.
private GridHolder getHolder() {
GridHolder holder = new GridHolder(3);
LayoutInflater layoutInflater = LayoutInflater.from(context);
holder.getView(layoutInflater, new LinearLayout(context));
return holder;
}
Aggregations