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