Search in sources :

Example 6 with DialogHelper

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));
            }
        }
    });
}
Also used : AppCompatRadioButton(android.support.v7.widget.AppCompatRadioButton) RadioGroup(android.widget.RadioGroup) DialogHelper(com.mnnyang.gzuclassschedule.utils.DialogHelper) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ScrollView(android.widget.ScrollView) DialogListener(com.mnnyang.gzuclassschedule.utils.DialogListener)

Example 7 with DialogHelper

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);
        }
    });
}
Also used : RadioGroup(android.widget.RadioGroup) DialogHelper(com.mnnyang.gzuclassschedule.utils.DialogHelper) WheelView(com.mnnyang.gzuclassschedule.custom.WheelView) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) WheelView(com.mnnyang.gzuclassschedule.custom.WheelView) View(android.view.View) DialogListener(com.mnnyang.gzuclassschedule.utils.DialogListener)

Example 8 with DialogHelper

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);
        }
    });
}
Also used : EditText(android.widget.EditText) DialogHelper(com.mnnyang.gzuclassschedule.utils.DialogHelper) DialogInterface(android.content.DialogInterface) DialogListener(com.mnnyang.gzuclassschedule.utils.DialogListener) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 9 with DialogHelper

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);
        }
    });
}
Also used : DialogHelper(com.mnnyang.gzuclassschedule.utils.DialogHelper) DialogInterface(android.content.DialogInterface) DialogListener(com.mnnyang.gzuclassschedule.utils.DialogListener)

Example 10 with DialogHelper

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);
        }
    });
}
Also used : EditText(android.widget.EditText) DialogHelper(com.mnnyang.gzuclassschedule.utils.DialogHelper) DialogInterface(android.content.DialogInterface) DialogListener(com.mnnyang.gzuclassschedule.utils.DialogListener) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

DialogHelper (com.mnnyang.gzuclassschedule.utils.DialogHelper)13 DialogInterface (android.content.DialogInterface)11 DialogListener (com.mnnyang.gzuclassschedule.utils.DialogListener)11 View (android.view.View)5 RadioGroup (android.widget.RadioGroup)4 AppCompatRadioButton (android.support.v7.widget.AppCompatRadioButton)3 Intent (android.content.Intent)2 RecyclerView (android.support.v7.widget.RecyclerView)2 EditText (android.widget.EditText)2 ScrollView (android.widget.ScrollView)2 WheelView (com.mnnyang.gzuclassschedule.custom.WheelView)2 ArrayList (java.util.ArrayList)2 HorizontalScrollView (android.widget.HorizontalScrollView)1