use of com.orhanobut.dialogplus.OnHolderListener 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.OnHolderListener 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);
}
use of com.orhanobut.dialogplus.OnHolderListener in project dialogplus by orhanobut.
the class ListHolderTest method doNotCountHeaderForPositionCalculation.
@Test
public void doNotCountHeaderForPositionCalculation() {
ListHolder holder = getListHolder();
holder.addHeader(new View(context));
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, 1, 0);
}
Aggregations