Search in sources :

Example 1 with DialogListener

use of com.mnnyang.gzuclassschedule.utils.DialogListener in project GzuClassSchedule by mnnyang.

the class AboutActivity method showUpdateVersionInfo.

@Override
public void showUpdateVersionInfo(Version version) {
    DialogHelper dialogHelper = new DialogHelper();
    dialogHelper.showNormalDialog(this, getString(R.string.now_version), version.getMsg(), new DialogListener() {

        @Override
        public void onPositive(DialogInterface dialog, int which) {
            super.onPositive(dialog, which);
            VersionUpdate.goToMarket(getBaseContext());
        }
    });
}
Also used : DialogHelper(com.mnnyang.gzuclassschedule.utils.DialogHelper) DialogInterface(android.content.DialogInterface) DialogListener(com.mnnyang.gzuclassschedule.utils.DialogListener)

Example 2 with DialogListener

use of com.mnnyang.gzuclassschedule.utils.DialogListener in project GzuClassSchedule by mnnyang.

the class PopupWindowDialog method showSelectTimeDialog.

public void showSelectTimeDialog(Activity activity, final int week, int nodeStart, int nodeEnd, final SelectTimeCallback callback) {
    mWeek = week;
    mNodeStart = nodeStart;
    mNodeEnd = nodeEnd;
    DialogHelper helper = new DialogHelper();
    View view = LayoutInflater.from(activity).inflate(R.layout.dialog_select_week_and_node, null);
    final ArrayList<String> weeks = new ArrayList<>();
    final ArrayList<String> nodes = new ArrayList<>();
    WheelView wvWeek = (WheelView) view.findViewById(R.id.wv_week);
    WheelView wvStart = (WheelView) view.findViewById(R.id.wv_start_node);
    final WheelView wvEnd = (WheelView) view.findViewById(R.id.wv_end_node);
    final int noonNode = Preferences.getInt(activity.getString(R.string.app_preference_noon_node), Integer.parseInt(activity.getString(R.string.default_noon_node)));
    for (int i = 1; i <= 7; i++) {
        weeks.add(Constant.WEEK[i]);
    }
    int maxNode = Preferences.getInt(activity.getString(R.string.app_preference_max_node), Constant.DEFAULT_MAX_NODE_COUNT);
    for (int i = 1; i <= maxNode; i++) {
        nodes.add("第" + i + "节");
    }
    wvWeek.setItems(weeks);
    wvStart.setItems(nodes);
    wvEnd.setItems(nodes);
    wvWeek.setSeletion(mWeek - 1);
    wvStart.setSeletion(mNodeStart - 1);
    wvEnd.setSeletion(mNodeEnd - 1);
    wvWeek.setOnWheelViewListener(new WheelView.OnWheelViewListener() {

        @Override
        public void onSelected(int selectedIndex, String item) {
            mStartWeek = selectedIndex;
        }
    });
    wvWeek.setOnWheelViewListener(new WheelView.OnWheelViewListener() {

        @Override
        public void onSelected(int selectedIndex, String item) {
            mWeek = selectedIndex;
        }
    });
    wvStart.setOnWheelViewListener(new WheelView.OnWheelViewListener() {

        @Override
        public void onSelected(int selectedIndex, String item) {
            mNodeStart = selectedIndex;
            if (mNodeStart > mNodeEnd) {
                wvEnd.setSeletion(mNodeStart - 1);
                return;
            }
            if (mNodeEnd > noonNode && mNodeStart <= noonNode) {
                wvEnd.setSeletion(noonNode - 1);
            }
        }
    });
    wvEnd.setOnWheelViewListener(new WheelView.OnWheelViewListener() {

        @Override
        public void onSelected(int selectedIndex, String item) {
            mNodeEnd = selectedIndex;
            if (mNodeEnd > noonNode && mNodeStart <= noonNode) {
                ToastUtils.show("早上课程的最大为 " + noonNode + " 节");
                wvEnd.setSeletion(noonNode - 1);
                return;
            }
            if (mNodeStart > mNodeEnd) {
                wvEnd.setSeletion(mNodeStart - 1);
            }
        }
    });
    helper.showCustomDialog(activity, view, activity.getString(R.string.select_course_time), new DialogListener() {

        @Override
        public void onPositive(DialogInterface dialog, int which) {
            super.onPositive(dialog, which);
            dialog.dismiss();
            callback.onSelected(mWeek, mNodeStart, mNodeEnd);
        }
    });
}
Also used : DialogHelper(com.mnnyang.gzuclassschedule.utils.DialogHelper) WheelView(com.mnnyang.gzuclassschedule.custom.WheelView) DialogInterface(android.content.DialogInterface) DialogListener(com.mnnyang.gzuclassschedule.utils.DialogListener) ArrayList(java.util.ArrayList) WheelView(com.mnnyang.gzuclassschedule.custom.WheelView) View(android.view.View)

Example 3 with DialogListener

use of com.mnnyang.gzuclassschedule.utils.DialogListener in project GzuClassSchedule by mnnyang.

the class MgActivity method switchDialog.

private void switchDialog(final int tag) {
    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);
            mPresenter.switchCsName(tag);
            notifiUpdateMainPage(Constant.INTENT_UPDATE_TYPE_COURSE);
        }
    });
}
Also used : DialogHelper(com.mnnyang.gzuclassschedule.utils.DialogHelper) DialogInterface(android.content.DialogInterface) DialogListener(com.mnnyang.gzuclassschedule.utils.DialogListener)

Example 4 with DialogListener

use of com.mnnyang.gzuclassschedule.utils.DialogListener in project GzuClassSchedule by mnnyang.

the class SettingActivity method showThemeDialog.

private void showThemeDialog() {
    ScrollView scrollView = new ScrollView(this);
    RadioGroup radioGroup = new RadioGroup(this);
    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(this);
        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(this, 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) HorizontalScrollView(android.widget.HorizontalScrollView) ScrollView(android.widget.ScrollView) DialogListener(com.mnnyang.gzuclassschedule.utils.DialogListener)

Example 5 with DialogListener

use of com.mnnyang.gzuclassschedule.utils.DialogListener 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)

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