Search in sources :

Example 6 with DialogPlus

use of com.orhanobut.dialogplus.DialogPlus in project dialogplus by orhanobut.

the class DialogPlusTest method testFindViewById.

@Test
public void testFindViewById() {
    LinearLayout layout = new LinearLayout(context);
    TextView textView = new TextView(context);
    textView.setId(android.R.id.text1);
    layout.addView(textView);
    DialogPlus dialog = DialogPlus.newDialog(context).setContentHolder(new ViewHolder(layout)).create();
    assertThat(dialog.findViewById(android.R.id.text1)).isNotNull();
}
Also used : DialogPlus(com.orhanobut.dialogplus.DialogPlus) ViewHolder(com.orhanobut.dialogplus.ViewHolder) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) Test(org.junit.Test)

Example 7 with DialogPlus

use of com.orhanobut.dialogplus.DialogPlus in project dialogplus by orhanobut.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.activity_toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle(getString(R.string.app_name));
    radioGroup = (RadioGroup) findViewById(R.id.radio_group);
    headerCheckBox = (CheckBox) findViewById(R.id.header_check_box);
    footerCheckBox = (CheckBox) findViewById(R.id.footer_check_box);
    expandedCheckBox = (CheckBox) findViewById(R.id.expanded_check_box);
    findViewById(R.id.button_bottom).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showDialog(radioGroup.getCheckedRadioButtonId(), Gravity.BOTTOM, headerCheckBox.isChecked(), footerCheckBox.isChecked(), expandedCheckBox.isChecked());
        }
    });
    findViewById(R.id.button_center).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showDialog(radioGroup.getCheckedRadioButtonId(), Gravity.CENTER, headerCheckBox.isChecked(), footerCheckBox.isChecked(), expandedCheckBox.isChecked());
        }
    });
    findViewById(R.id.button_top).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showDialog(radioGroup.getCheckedRadioButtonId(), Gravity.TOP, headerCheckBox.isChecked(), footerCheckBox.isChecked(), expandedCheckBox.isChecked());
        }
    });
    View contentView = getLayoutInflater().inflate(R.layout.content2, null);
    DialogPlus dialogPlus = DialogPlus.newDialog(this).setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new String[] { "asdfa" })).setCancelable(true).setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogPlus dialog) {
        }
    }).setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogPlus dialog) {
        }
    }).setOnBackPressListener(new OnBackPressListener() {

        @Override
        public void onBackPressed(DialogPlus dialogPlus) {
        }
    }).create();
    dialogPlus.show();
}
Also used : DialogPlus(com.orhanobut.dialogplus.DialogPlus) OnDismissListener(com.orhanobut.dialogplus.OnDismissListener) TextView(android.widget.TextView) View(android.view.View) OnBackPressListener(com.orhanobut.dialogplus.OnBackPressListener) ActionBar(android.support.v7.app.ActionBar) ArrayAdapter(android.widget.ArrayAdapter) Toolbar(android.support.v7.widget.Toolbar) OnCancelListener(com.orhanobut.dialogplus.OnCancelListener)

Example 8 with DialogPlus

use of com.orhanobut.dialogplus.DialogPlus in project dialogplus by orhanobut.

the class MainActivity method showNoHeaderDialog.

private void showNoHeaderDialog(Holder holder, int gravity, BaseAdapter adapter, OnClickListener clickListener, OnItemClickListener itemClickListener, OnDismissListener dismissListener, OnCancelListener cancelListener, boolean expanded) {
    final DialogPlus dialog = DialogPlus.newDialog(this).setContentHolder(holder).setFooter(R.layout.footer).setCancelable(true).setGravity(gravity).setAdapter(adapter).setOnClickListener(clickListener).setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(DialogPlus dialog, Object item, View view, int position) {
            Log.d("DialogPlus", "onItemClick() called with: " + "item = [" + item + "], position = [" + position + "]");
        }
    }).setOnDismissListener(dismissListener).setOnCancelListener(cancelListener).setExpanded(expanded).create();
    dialog.show();
}
Also used : DialogPlus(com.orhanobut.dialogplus.DialogPlus) OnItemClickListener(com.orhanobut.dialogplus.OnItemClickListener) TextView(android.widget.TextView) View(android.view.View)

Example 9 with DialogPlus

use of com.orhanobut.dialogplus.DialogPlus in project dialogplus by orhanobut.

the class DialogPlusBuilderTest method testSetOnCancelListener.

@Test
public void testSetOnCancelListener() {
    DialogPlusBuilder builder = DialogPlus.newDialog(context);
    assertThat(builder.getOnCancelListener()).isNull();
    OnCancelListener listener = new OnCancelListener() {

        @Override
        public void onCancel(DialogPlus dialog) {
        }
    };
    builder.setOnCancelListener(listener);
    assertThat(builder.getOnCancelListener()).isNotNull();
    assertThat(builder.getOnCancelListener()).isEqualTo(listener);
}
Also used : DialogPlus(com.orhanobut.dialogplus.DialogPlus) DialogPlusBuilder(com.orhanobut.dialogplus.DialogPlusBuilder) OnCancelListener(com.orhanobut.dialogplus.OnCancelListener) Test(org.junit.Test)

Example 10 with DialogPlus

use of com.orhanobut.dialogplus.DialogPlus in project dialogplus by orhanobut.

the class DialogPlusBuilderTest method testSetOnItemClickListener.

@Test
public void testSetOnItemClickListener() {
    DialogPlusBuilder builder = DialogPlus.newDialog(context);
    assertThat(builder.getOnItemClickListener()).isNull();
    OnItemClickListener listener = new OnItemClickListener() {

        @Override
        public void onItemClick(DialogPlus dialog, Object item, View view, int position) {
        }
    };
    builder.setOnItemClickListener(listener);
    assertThat(builder.getOnItemClickListener()).isNotNull();
    assertThat(builder.getOnItemClickListener()).isEqualTo(listener);
}
Also used : DialogPlus(com.orhanobut.dialogplus.DialogPlus) OnItemClickListener(com.orhanobut.dialogplus.OnItemClickListener) DialogPlusBuilder(com.orhanobut.dialogplus.DialogPlusBuilder) View(android.view.View) Test(org.junit.Test)

Aggregations

DialogPlus (com.orhanobut.dialogplus.DialogPlus)18 Test (org.junit.Test)12 View (android.view.View)8 TextView (android.widget.TextView)7 OnItemClickListener (com.orhanobut.dialogplus.OnItemClickListener)6 DialogPlusBuilder (com.orhanobut.dialogplus.DialogPlusBuilder)5 ViewHolder (com.orhanobut.dialogplus.ViewHolder)5 LinearLayout (android.widget.LinearLayout)4 OnCancelListener (com.orhanobut.dialogplus.OnCancelListener)3 OnDismissListener (com.orhanobut.dialogplus.OnDismissListener)3 OnBackPressListener (com.orhanobut.dialogplus.OnBackPressListener)2 OnClickListener (com.orhanobut.dialogplus.OnClickListener)2 ActionBar (android.support.v7.app.ActionBar)1 Toolbar (android.support.v7.widget.Toolbar)1 ArrayAdapter (android.widget.ArrayAdapter)1 GridHolder (com.orhanobut.dialogplus.GridHolder)1 Holder (com.orhanobut.dialogplus.Holder)1 ListHolder (com.orhanobut.dialogplus.ListHolder)1