Android Open Source - Attendance-AutoCounter Course Modify Dialog






From Project

Back to project page Attendance-AutoCounter.

License

The source code is released under:

GNU General Public License

If you think the Android project Attendance-AutoCounter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.etonn.attendance_autocounter;
/*  www  . jav  a  2s.  com*/
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.etonn.attendance_autocounter.db.DBManager;

/**
 * Created by Zeshi on 11/23/14.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class CourseModifyDialog extends DialogFragment {
    DBManager db;

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        db = new DBManager(getActivity());

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        final LayoutInflater inflater = getActivity().getLayoutInflater();
        //set custom dialog view, in this case is two edittext box
        final View mView = inflater.inflate(R.layout.dialog_course_modify, null);
        builder.setView(mView)
                .setTitle("Modify Course")
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                EditText courseName = (EditText) mView.findViewById(R.id.dialogCourseName);
                                EditText headcount = (EditText) mView.findViewById(R.id.dialogHeadcount);
                                //set input type ---- only number in dialog_course_modify.xml

                                String courseNameS = courseName.getText().toString();
                                String headcountS = headcount.getText().toString();

                                if (courseNameS.equals("") || headcountS.equals("")) {
                                    Toast.makeText(getActivity(), "please fill in both two blanks", Toast.LENGTH_SHORT).show();
                                }
                                //can't modify course name now in DB
                                else {
                                    if (db.queryCourseByName(courseNameS) == null) {
                                        Toast.makeText(getActivity(), "No such a course", Toast.LENGTH_SHORT).show();
                                    } else {
                                        int headcountI = Integer.parseInt(headcountS);
                                        db.updateCourseByName(courseNameS, headcountI);
                                    }

                                }
                            }

                        }
                )
                .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                dismiss();
                            }
                        }
                );
        return builder.create();
    }
}




Java Source Code List

com.etonn.attendance_autocounter.ApplicationTest.java
com.etonn.attendance_autocounter.ClassActivity.java
com.etonn.attendance_autocounter.CourseModifyDialog.java
com.etonn.attendance_autocounter.EmailAbsenteeActivity.java
com.etonn.attendance_autocounter.MainActivity.java
com.etonn.attendance_autocounter.ReportActivity.java
com.etonn.attendance_autocounter.ScanningActivity.java
com.etonn.attendance_autocounter.bluetooth.BluetoothHelper.java
com.etonn.attendance_autocounter.db.Attendance.java
com.etonn.attendance_autocounter.db.Course.java
com.etonn.attendance_autocounter.db.DBHelper.java
com.etonn.attendance_autocounter.db.DBManager.java
com.etonn.attendance_autocounter.db.Student.java