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();
}
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);
}
Aggregations