Search in sources :

Example 6 with DialogListener

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);
        }
    });
}
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 7 with DialogListener

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);
        }
    });
}
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 8 with DialogListener

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

Example 9 with DialogListener

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);
        }
    });
}
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 10 with DialogListener

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

Aggregations

DialogInterface (android.content.DialogInterface)11 DialogHelper (com.mnnyang.gzuclassschedule.utils.DialogHelper)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