Search in sources :

Example 1 with GridHolder

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

Example 2 with GridHolder

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

Example 3 with GridHolder

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);
}
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 4 with GridHolder

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

Example 5 with GridHolder

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;
}
Also used : LayoutInflater(android.view.LayoutInflater) GridHolder(com.orhanobut.dialogplus.GridHolder) LinearLayout(android.widget.LinearLayout)

Aggregations

GridHolder (com.orhanobut.dialogplus.GridHolder)7 View (android.view.View)5 LinearLayout (android.widget.LinearLayout)5 Test (org.junit.Test)5 GridView (android.widget.GridView)4 LayoutInflater (android.view.LayoutInflater)2 ListHolder (com.orhanobut.dialogplus.ListHolder)2 ViewHolder (com.orhanobut.dialogplus.ViewHolder)2 ArrayAdapter (android.widget.ArrayAdapter)1 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 OnHolderListener (com.orhanobut.dialogplus.OnHolderListener)1 OnItemClickListener (com.orhanobut.dialogplus.OnItemClickListener)1