Search in sources :

Example 1 with ListHolder

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);
}
Also used : ViewHolder(com.orhanobut.dialogplus.ViewHolder) DialogPlusBuilder(com.orhanobut.dialogplus.DialogPlusBuilder) GridHolder(com.orhanobut.dialogplus.GridHolder) ListHolder(com.orhanobut.dialogplus.ListHolder) LinearLayout(android.widget.LinearLayout) Test(org.junit.Test)

Example 2 with ListHolder

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");
    }
}
Also used : ListView(android.widget.ListView) ListHolder(com.orhanobut.dialogplus.ListHolder) ArrayAdapter(android.widget.ArrayAdapter) Test(org.junit.Test)

Example 3 with ListHolder

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);
}
Also used : View(android.view.View) ListView(android.widget.ListView) ListHolder(com.orhanobut.dialogplus.ListHolder) LinearLayout(android.widget.LinearLayout) Test(org.junit.Test)

Example 4 with ListHolder

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");
    }
}
Also used : ListView(android.widget.ListView) ListHolder(com.orhanobut.dialogplus.ListHolder) Test(org.junit.Test)

Example 5 with ListHolder

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);
}
Also used : OnHolderListener(com.orhanobut.dialogplus.OnHolderListener) ListView(android.widget.ListView) View(android.view.View) ListView(android.widget.ListView) ListHolder(com.orhanobut.dialogplus.ListHolder) ArrayAdapter(android.widget.ArrayAdapter) Test(org.junit.Test)

Aggregations

ListHolder (com.orhanobut.dialogplus.ListHolder)10 Test (org.junit.Test)8 ListView (android.widget.ListView)7 View (android.view.View)6 LinearLayout (android.widget.LinearLayout)5 ArrayAdapter (android.widget.ArrayAdapter)3 LayoutInflater (android.view.LayoutInflater)2 GridHolder (com.orhanobut.dialogplus.GridHolder)2 OnHolderListener (com.orhanobut.dialogplus.OnHolderListener)2 ViewHolder (com.orhanobut.dialogplus.ViewHolder)2 TextView (android.widget.TextView)1 DialogPlus (com.orhanobut.dialogplus.DialogPlus)1 DialogPlusBuilder (com.orhanobut.dialogplus.DialogPlusBuilder)1 Holder (com.orhanobut.dialogplus.Holder)1 OnCancelListener (com.orhanobut.dialogplus.OnCancelListener)1 OnClickListener (com.orhanobut.dialogplus.OnClickListener)1 OnDismissListener (com.orhanobut.dialogplus.OnDismissListener)1 OnItemClickListener (com.orhanobut.dialogplus.OnItemClickListener)1