use of com.orhanobut.dialogplus.DialogPlus in project dialogplus by orhanobut.
the class DialogPlusBuilderTest method testSetOnClickListener.
@Test
public void testSetOnClickListener() {
DialogPlusBuilder builder = DialogPlus.newDialog(context);
assertThat(builder.getOnClickListener()).isNull();
OnClickListener clickListener = new OnClickListener() {
@Override
public void onClick(DialogPlus dialog, View view) {
}
};
builder.setOnClickListener(clickListener);
assertThat(builder.getOnClickListener()).isNotNull();
assertThat(builder.getOnClickListener()).isEqualTo(clickListener);
}
use of com.orhanobut.dialogplus.DialogPlus 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);
}
use of com.orhanobut.dialogplus.DialogPlus in project dialogplus by orhanobut.
the class MainActivity method showDialog.
private void showDialog(int holderId, int gravity, boolean showHeader, boolean showFooter, boolean expanded) {
boolean isGrid;
Holder holder;
switch(holderId) {
case R.id.basic_holder_radio_button:
holder = new ViewHolder(R.layout.content);
isGrid = false;
break;
case R.id.list_holder_radio_button:
holder = new ListHolder();
isGrid = false;
break;
default:
holder = new GridHolder(3);
isGrid = true;
}
OnClickListener clickListener = new OnClickListener() {
@Override
public void onClick(DialogPlus dialog, View view) {
// switch (view.getId()) {
// case R.id.header_container:
// Toast.makeText(MainActivity.this, "Header clicked", Toast.LENGTH_LONG).show();
// break;
// case R.id.like_it_button:
// Toast.makeText(MainActivity.this, "We're glad that you like it", Toast.LENGTH_LONG).show();
// break;
// case R.id.love_it_button:
// Toast.makeText(MainActivity.this, "We're glad that you love it", Toast.LENGTH_LONG).show();
// break;
// case R.id.footer_confirm_button:
// Toast.makeText(MainActivity.this, "Confirm button clicked", Toast.LENGTH_LONG).show();
// break;
// case R.id.footer_close_button:
// Toast.makeText(MainActivity.this, "Close button clicked", Toast.LENGTH_LONG).show();
// break;
// }
// dialog.dismiss();
}
};
OnItemClickListener itemClickListener = new OnItemClickListener() {
@Override
public void onItemClick(DialogPlus dialog, Object item, View view, int position) {
TextView textView = (TextView) view.findViewById(R.id.text_view);
String clickedAppName = textView.getText().toString();
// dialog.dismiss();
// Toast.makeText(MainActivity.this, clickedAppName + " clicked", Toast.LENGTH_LONG).show();
}
};
OnDismissListener dismissListener = new OnDismissListener() {
@Override
public void onDismiss(DialogPlus dialog) {
// Toast.makeText(MainActivity.this, "dismiss listener invoked!", Toast.LENGTH_SHORT).show();
}
};
OnCancelListener cancelListener = new OnCancelListener() {
@Override
public void onCancel(DialogPlus dialog) {
// Toast.makeText(MainActivity.this, "cancel listener invoked!", Toast.LENGTH_SHORT).show();
}
};
SimpleAdapter adapter = new SimpleAdapter(MainActivity.this, isGrid);
if (showHeader && showFooter) {
showCompleteDialog(holder, gravity, adapter, clickListener, itemClickListener, dismissListener, cancelListener, expanded);
return;
}
if (showHeader && !showFooter) {
showNoFooterDialog(holder, gravity, adapter, clickListener, itemClickListener, dismissListener, cancelListener, expanded);
return;
}
if (!showHeader && showFooter) {
showNoHeaderDialog(holder, gravity, adapter, clickListener, itemClickListener, dismissListener, cancelListener, expanded);
return;
}
showOnlyContentDialog(holder, gravity, adapter, itemClickListener, dismissListener, cancelListener, expanded);
}
Aggregations