use of com.mnnyang.gzuclassschedule.utils.DialogListener in project GzuClassSchedule by mnnyang.
the class PopupWindowDialog method showWeekRangeDialog.
public void showWeekRangeDialog(Activity activity, int defStart, final int defEnd, int defType, final WeekRangeCallback callback) {
mStartWeek = defStart;
mEndWeek = defEnd;
mWeekType = defType;
DialogHelper helper = new DialogHelper();
View view = LayoutInflater.from(activity).inflate(R.layout.dialog_select_week_range, null);
WheelView wvStart = (WheelView) view.findViewById(R.id.wv_week_start);
final WheelView wvEnd = (WheelView) view.findViewById(R.id.wv_week_end);
RadioGroup rgWeekType = (RadioGroup) view.findViewById(R.id.rg_week_type);
ArrayList<String> weeks = new ArrayList<String>();
for (int i = 1; i <= 25; i++) {
weeks.add("第" + i + "周");
}
wvStart.setItems(weeks);
wvEnd.setItems(weeks);
wvStart.setSeletion(defStart - 1);
wvEnd.setSeletion(defEnd - 1);
wvStart.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
@Override
public void onSelected(int selectedIndex, String item) {
LogUtil.e(this, selectedIndex + "");
mStartWeek = selectedIndex;
if (mStartWeek > mEndWeek) {
wvEnd.setSeletion(mStartWeek - 1);
}
}
});
wvEnd.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
@Override
public void onSelected(int selectedIndex, String item) {
mEndWeek = selectedIndex;
if (mStartWeek > mEndWeek) {
wvEnd.setSeletion(mStartWeek - 1);
}
}
});
rgWeekType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch(checkedId) {
case R.id.arb_all:
mWeekType = Course.WEEK_ALL;
break;
case R.id.arb_single:
mWeekType = Course.WEEK_SINGLE;
break;
case R.id.arb_double:
mWeekType = Course.WEEK_DOUBLE;
break;
}
}
});
helper.showCustomDialog(activity, view, app.mContext.getString(R.string.select_week_count), new DialogListener() {
@Override
public void onPositive(DialogInterface dialog, int which) {
super.onPositive(dialog, which);
dialog.dismiss();
callback.onSelected(mStartWeek, mEndWeek, mWeekType);
}
});
}
use of com.mnnyang.gzuclassschedule.utils.DialogListener in project GzuClassSchedule by mnnyang.
the class MgActivity method editDialog.
private void editDialog(final int id) {
mCsNameDialogHelper = new DialogHelper();
View view = LayoutInflater.from(this).inflate(R.layout.layout_input_course_table_name, null);
final EditText editText = view.findViewById(R.id.et_course_table_name);
// default value
editText.setHint(CourseDbDao.newInstance().getCsName(id));
mCsNameDialogHelper.showCustomDialog(this, view, getString(R.string.please_input_course_table_name), new DialogListener() {
@Override
public void onNegative(DialogInterface dialog, int which) {
super.onNegative(dialog, which);
mCsNameDialogHelper = null;
}
@Override
public void onPositive(DialogInterface dialog, int which) {
super.onPositive(dialog, which);
String courseTableName = editText.getText().toString().trim();
if (TextUtils.isEmpty(courseTableName)) {
toast(getString(R.string.course_name_can_not_be_empty));
return;
}
mPresenter.editCsName(id, courseTableName);
}
});
}
use of com.mnnyang.gzuclassschedule.utils.DialogListener in project GzuClassSchedule by mnnyang.
the class MgActivity method deleteDialog.
private void deleteDialog(final int id) {
/* String currentScheduleName = Preferences.getString(
getString(R.string.app_preference_current_sd_name),
getString(R.string.default_course_name));*/
int csNameId = Preferences.getInt(getString(R.string.app_preference_current_sd_name_id), 0);
if (id == csNameId) {
toast(getString(R.string.you_can_not_delete_the_current_class_schedule));
return;
}
DialogHelper dh = new DialogHelper();
dh.showNormalDialog(this, getString(R.string.warning), "确认要删除该课表吗?", new DialogListener() {
@Override
public void onPositive(DialogInterface dialog, int which) {
super.onPositive(dialog, which);
deletingDialog(id);
}
});
}
use of com.mnnyang.gzuclassschedule.utils.DialogListener in project GzuClassSchedule by mnnyang.
the class MgActivity method add.
private void add() {
mCsNameDialogHelper = new DialogHelper();
View view = LayoutInflater.from(this).inflate(R.layout.layout_input_course_table_name, null);
final EditText editText = view.findViewById(R.id.et_course_table_name);
mCsNameDialogHelper.showCustomDialog(this, view, getString(R.string.please_input_course_table_name), new DialogListener() {
@Override
public void onNegative(DialogInterface dialog, int which) {
super.onNegative(dialog, which);
mCsNameDialogHelper = null;
}
@Override
public void onPositive(DialogInterface dialog, int which) {
super.onPositive(dialog, which);
String courseTableName = editText.getText().toString().trim();
mPresenter.addCsName(courseTableName);
}
});
}
use of com.mnnyang.gzuclassschedule.utils.DialogListener in project GzuClassSchedule by mnnyang.
the class ShowTermDialog method showSelectTimeTermDialog.
public void showSelectTimeTermDialog(Context context, String[] times, final TimeTermCallback callback) {
if (times.length == 0) {
return;
}
View dialogView = LayoutInflater.from(context).inflate(R.layout.layout_course_time_dialog, null);
final RadioGroup rg = dialogView.findViewById(R.id.rg_course_time);
int i = 1;
for (String time : times) {
AppCompatRadioButton tempButton = new AppCompatRadioButton(context);
tempButton.setTextColor(ColorUtil.getColor(context, R.attr.colorPrimary));
tempButton.setText(time);
tempButton.setId(i);
rg.addView(tempButton, LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
i++;
}
rg.invalidate();
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
AppCompatRadioButton arb = group.findViewById(checkedId);
System.out.println("6:" + arb);
callback.onTimeChanged(arb.getText().toString());
}
});
RadioGroup termRg = dialogView.findViewById(R.id.rg_term);
termRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
AppCompatRadioButton arb = group.findViewById(checkedId);
callback.onTermChanged(arb.getTag().toString());
}
});
AppCompatRadioButton at = (AppCompatRadioButton) rg.getChildAt(0);
if (at != null)
at.setChecked(true);
at = (AppCompatRadioButton) termRg.getChildAt(0);
if (at != null)
at.setChecked(true);
DialogHelper helper = new DialogHelper();
helper.showCustomDialog(context, dialogView, "", new DialogListener() {
@Override
public void onPositive(DialogInterface dialog, int which) {
super.onPositive(dialog, which);
dialog.dismiss();
callback.onPositive(dialog, which);
}
});
}
Aggregations