Search in sources :

Example 1 with OnBackPressListener

use of com.orhanobut.dialogplus.OnBackPressListener 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 2 with OnBackPressListener

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

the class DialogPlusBuilderTest method testSetOnBackPressListener.

@Test
public void testSetOnBackPressListener() {
    DialogPlusBuilder builder = DialogPlus.newDialog(context);
    assertThat(builder.getOnBackPressListener()).isNull();
    OnBackPressListener listener = new OnBackPressListener() {

        @Override
        public void onBackPressed(DialogPlus dialogPlus) {
        }
    };
    builder.setOnBackPressListener(listener);
    assertThat(builder.getOnBackPressListener()).isNotNull();
    assertThat(builder.getOnBackPressListener()).isEqualTo(listener);
}
Also used : DialogPlus(com.orhanobut.dialogplus.DialogPlus) DialogPlusBuilder(com.orhanobut.dialogplus.DialogPlusBuilder) OnBackPressListener(com.orhanobut.dialogplus.OnBackPressListener) Test(org.junit.Test)

Aggregations

DialogPlus (com.orhanobut.dialogplus.DialogPlus)2 OnBackPressListener (com.orhanobut.dialogplus.OnBackPressListener)2 ActionBar (android.support.v7.app.ActionBar)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 ArrayAdapter (android.widget.ArrayAdapter)1 TextView (android.widget.TextView)1 DialogPlusBuilder (com.orhanobut.dialogplus.DialogPlusBuilder)1 OnCancelListener (com.orhanobut.dialogplus.OnCancelListener)1 OnDismissListener (com.orhanobut.dialogplus.OnDismissListener)1 Test (org.junit.Test)1