use of com.andframe.listener.SafeListener in project AndFrameWorks by scwang90.
the class AfDialogBuilder method selectDate.
/**
* 选择日期
* @param title 标题
* @param value 默认时间
* @param listener 监听器
*/
@Override
public Dialog selectDate(CharSequence title, Date value, final OnDateSetListener listener) {
Calendar calender = Calendar.getInstance();
calender.setTime(value);
int year = calender.get(Calendar.YEAR);
int month = calender.get(Calendar.MONTH);
int day = calender.get(Calendar.DAY_OF_MONTH);
AlertDialog tDialog = new DatePickerDialog(mContext, new SafeListener(listener), year, month, day) {
@Override
public void show() {
super.show();
if (listener instanceof OnDateSetVerifyListener) {
getButton(BUTTON_POSITIVE).setOnClickListener(v -> {
try {
DatePicker picker = AfReflecter.getMemberByType(this, DatePicker.class);
if (picker == null) {
this.dismiss();
super.onClick(this, BUTTON_POSITIVE);
} else if (((OnDateSetVerifyListener) listener).onPreDateSet(picker, picker.getYear(), picker.getMonth(), picker.getDayOfMonth())) {
this.dismiss();
super.onClick(this, BUTTON_POSITIVE);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
});
}
}
};
if (title != null && title.length() > 0) {
tDialog.setTitle(title);
}
tDialog.show();
tDialog.setCancelable(true);
return tDialog;
}
use of com.andframe.listener.SafeListener in project AndFrameWorks by scwang90.
the class AfDialogBuilder method multiChoice.
/**
* 显示一个多选对话框 (默认可取消)
*
* @param title 对话框标题
* @param items 选择菜单项
* @param checkedItems 选择结果
* @param listener 选择监听器
* @param lpositive 完成选择器
*/
@Override
public Dialog multiChoice(CharSequence title, CharSequence[] items, boolean[] checkedItems, OnMultiChoiceClickListener listener, OnClickListener lpositive) {
Builder dialog = new Builder(mContext);
if (title != null) {
dialog.setTitle(title);
dialog.setNegativeButton("确定", new SafeListener(lpositive));
}
dialog.setMultiChoiceItems(items, checkedItems, new SafeListener(listener));
return dialog.show();
}
use of com.andframe.listener.SafeListener in project AndFrameWorks by scwang90.
the class AfDialogBuilder method selectDateTime.
/**
* 选择日期时间
* @param title 标题
* @param value 默认时间
* @param listener 监听器
*/
@Override
public Dialog selectDateTime(final CharSequence title, final Date value, final OnDateTimeSetListener listener) {
final Calendar calender = Calendar.getInstance();
calender.setTime(value);
int year = calender.get(Calendar.YEAR);
final int month = calender.get(Calendar.MONTH);
final int day = calender.get(Calendar.DAY_OF_MONTH);
final AlertDialog tDialog = new DatePickerDialog(mContext, new SafeListener((view, year1, month1, day1) -> {
int hour = calender.get(Calendar.HOUR_OF_DAY);
int minute = calender.get(Calendar.MINUTE);
Dialog tDialog1 = new TimePickerDialog(mContext, new SafeListener((OnTimeSetListener) (view1, hour1, minute1) -> listener.onDateTimeSet(year1, month1, day1, hour1, minute1)), hour, minute, true) {
@Override
public void show() {
super.show();
if (listener instanceof OnDateTimeSetVerifyListener) {
getButton(BUTTON_POSITIVE).setOnClickListener(v -> {
try {
TimePicker picker = AfReflecter.getMemberByType(this, TimePicker.class);
if (picker == null) {
this.dismiss();
super.onClick(this, BUTTON_POSITIVE);
} else if (((OnDateTimeSetVerifyListener) listener).onPreTimeSet(picker, picker.getCurrentHour(), picker.getCurrentMinute())) {
this.dismiss();
super.onClick(this, BUTTON_POSITIVE);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
});
}
}
};
;
if (title != null && title.length() > 0) {
tDialog1.setTitle(title);
}
tDialog1.show();
tDialog1.setCancelable(true);
}), year, month, day) {
@Override
public void show() {
super.show();
if (listener instanceof OnDateTimeSetVerifyListener) {
getButton(BUTTON_POSITIVE).setOnClickListener(v -> {
try {
DatePicker picker = AfReflecter.getMemberByType(this, DatePicker.class);
if (picker == null) {
this.dismiss();
super.onClick(this, BUTTON_POSITIVE);
} else if (((OnDateTimeSetVerifyListener) listener).onPreDateSet(picker, picker.getYear(), picker.getMonth(), picker.getDayOfMonth())) {
this.dismiss();
super.onClick(this, BUTTON_POSITIVE);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
});
}
}
};
if (title != null && title.length() > 0) {
tDialog.setTitle(title);
}
tDialog.show();
tDialog.setCancelable(true);
return tDialog;
}
use of com.andframe.listener.SafeListener in project AndFrameWorks by scwang90.
the class AfDialogBuilder method showDialog.
/**
* 显示视图对话框
*
* @param theme 主题
* @param iconres 对话框图标
* @param title 显示标题
* @param message 显示内容
* @param positive 确认 按钮显示信息
* @param lpositive 点击 确认 按钮 响应事件
* @param neutral 详细 按钮显示信息
* @param lneutral 点击 详细 按钮 响应事件
* @param negative 按钮显示信息
* @param lnegative 点击 拒绝 按钮 响应事件
*/
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public Dialog showDialog(int theme, int iconres, CharSequence title, CharSequence message, CharSequence negative, OnClickListener lnegative, CharSequence neutral, OnClickListener lneutral, CharSequence positive, OnClickListener lpositive) {
Builder builder = null;
if (theme > 0) {
try {
builder = new Builder(mContext, theme);
} catch (Throwable ignored) {
}
}
if (builder == null) {
try {
builder = new Builder(mContext);
} catch (Throwable ex) {
return null;
}
}
builder.setTitle(title);
builder.setMessage(message);
if (iconres > 0) {
builder.setIcon(iconres);
}
if (positive != null && positive.length() > 0) {
builder.setPositiveButton(positive, new SafeListener(lpositive));
}
if (negative != null && negative.length() > 0) {
builder.setNegativeButton(negative, new SafeListener(lnegative));
}
if (neutral != null && neutral.length() > 0) {
builder.setNeutralButton(neutral, new SafeListener(lneutral));
}
builder.setCancelable(false);
builder.create();
return builder.show();
}
use of com.andframe.listener.SafeListener in project AndFrameWorks by scwang90.
the class BaseMoreFooter method onViewCreated.
@Override
public void onViewCreated() {
super.onViewCreated();
mLayout.setOnClickListener(new SafeListener((OnCancelListener) v -> triggerLoadMore()));
}
Aggregations