use of com.mnnyang.gzuclassschedule.utils.DialogHelper in project GzuClassSchedule by mnnyang.
the class SettingFragment method showThemeDialog.
private void showThemeDialog() {
ScrollView scrollView = new ScrollView(getActivity());
RadioGroup radioGroup = new RadioGroup(getActivity());
scrollView.addView(radioGroup);
int margin = ScreenUtils.dp2px(16);
radioGroup.setPadding(margin / 2, margin, margin, margin);
for (int i = 0; i < themeColorArray.length; i++) {
AppCompatRadioButton arb = new AppCompatRadioButton(getActivity());
RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
arb.setLayoutParams(params);
arb.setId(i);
arb.setTextColor(getResources().getColor(themeColorArray[i]));
arb.setText(themeNameArray[i]);
arb.setTextSize(16);
arb.setPadding(0, margin / 2, 0, margin / 2);
radioGroup.addView(arb);
}
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
theme = checkedId;
}
});
DialogHelper dialogHelper = new DialogHelper();
dialogHelper.showCustomDialog(getActivity(), scrollView, getString(R.string.theme_preference), new DialogListener() {
@Override
public void onPositive(DialogInterface dialog, int which) {
super.onPositive(dialog, which);
dialog.dismiss();
String key = getString(R.string.app_preference_theme);
int oldTheme = Preferences.getInt(key, 0);
if (theme != oldTheme) {
Preferences.putInt(key, theme);
ActivityUtil.finishAll();
startActivity(new Intent(app.mContext, CourseActivity.class));
}
}
});
}
use of com.mnnyang.gzuclassschedule.utils.DialogHelper 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.DialogHelper 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.DialogHelper 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.DialogHelper 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);
}
});
}
Aggregations