Android Open Source - SNISI-droid Shared Checks






From Project

Back to project page SNISI-droid.

License

The source code is released under:

Apache License

If you think the Android project SNISI-droid 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

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.//from   ww  w . ja  va  2 s .c o  m
 */

package com.yeleman.smir;

import java.util.Vector;
import java.util.GregorianCalendar;
import java.util.Calendar;

import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.DatePicker;


public class SharedChecks {

    protected boolean _check_unsigned_int(TextView widget) {
        try {
            return Integer.parseInt(widget.getText().toString()) >= 0;
        } catch(NumberFormatException nfe) {
            return false;
        }
    }

    protected boolean _check_unsigned_int_message(TextView widget, String fieldName, Vector<String> errors) {
        if (_check_unsigned_int(widget)) {
            return true;
        }
        errors.add("" + fieldName + " doit tre un entier postif ou nul.");
        return false;
    }

    protected static boolean _check_not_valid(TextView widgetcas, TextView widgetdeces) {
        return Integer.parseInt(widgetdeces.getText().toString()) <= Integer.parseInt(widgetcas.getText().toString());
    }

    protected static boolean _check_isValid_message(TextView widgetcas, TextView widgetdeces, String fieldName, Vector<String> errors) {
        if (_check_not_valid(widgetcas, widgetdeces)) {
            return true;
        }
        errors.add("" + fieldName + " Nombre de dcs ne doit pas tre suprieur au nombre cas.");
        return false;
    }

    protected static boolean _check_not_empty(TextView widget) {
        return widget.getText().toString().length() > 0;
    }

    protected static boolean _check_not_empty_message(TextView widget, String fieldName, Vector<String> errors) {
        if (_check_not_empty(widget)) {
            return true;
        }
        errors.add("" + fieldName + " ne doit pas tre vide.");
        return false;
    }

    protected static boolean _check_min_characters(TextView widget, int nb_chars) {
        return widget.getText().toString().length() >= nb_chars;
    }

    protected static boolean _check_min_characters_message(TextView widget, int nb_chars, String fieldName, Vector<String> errors) {
        if (_check_min_characters(widget, nb_chars)) {
            return true;
        }
        errors.add("" + fieldName + " doit tre compos d'au moins " + nb_chars + " caractres.");
        return false;
    }

    protected static boolean _check_date_is_friday(DatePicker widget) {
        GregorianCalendar adate = new GregorianCalendar(widget.getYear(), widget.getMonth(), widget.getDayOfMonth());
        return adate.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY;
    }

    protected static boolean _check_date_is_friday_message(DatePicker widget, String fieldName, Vector<String> errors) {
        if (_check_date_is_friday(widget)) {
            return true;
        }
        errors.add("" + fieldName + " doit tre un vendredi.");
        return false;
    }

    public static boolean is_empty(EditText editText) {

        String text = editText.getText().toString().trim();
        editText.setError(null);
        // length 0 means there is no text
        if (text.isEmpty()) {
            return false;
        }
        return true;
    }


}




Java Source Code List

com.yeleman.nutrition.NutritionHome.java
com.yeleman.nutrition.NutritionInputsReportData.java
com.yeleman.nutrition.NutritionInputsReport.java
com.yeleman.nutrition.NutritionMonthlyHome.java
com.yeleman.nutrition.NutritionMonthlyReportData.java
com.yeleman.nutrition.NutritionSummaryReport.java
com.yeleman.nutrition.NutritionURENAMExsamReport.java
com.yeleman.nutrition.NutritionURENAMO59Report.java
com.yeleman.nutrition.NutritionURENAMPWReport.java
com.yeleman.nutrition.NutritionURENAMReportData.java
com.yeleman.nutrition.NutritionURENAMReport.java
com.yeleman.nutrition.NutritionURENAMU23O6Report.java
com.yeleman.nutrition.NutritionURENAMU59O23Report.java
com.yeleman.nutrition.NutritionURENASO59Report.java
com.yeleman.nutrition.NutritionURENASReportData.java
com.yeleman.nutrition.NutritionURENASReport.java
com.yeleman.nutrition.NutritionURENASU59O6Report.java
com.yeleman.nutrition.NutritionURENFormIface.java
com.yeleman.nutrition.NutritionURENForm.java
com.yeleman.nutrition.NutritionURENIO59Report.java
com.yeleman.nutrition.NutritionURENIReportData.java
com.yeleman.nutrition.NutritionURENIReport.java
com.yeleman.nutrition.NutritionURENIU59O6Report.java
com.yeleman.nutrition.NutritionURENIU6Report.java
com.yeleman.nutrition.NutritionWeeklyReportData.java
com.yeleman.nutrition.NutritionWeeklyReport.java
com.yeleman.projetsnisi.ApplicationTest.java
com.yeleman.smir.Constants.java
com.yeleman.smir.CustomOnItemSelectedListener.java
com.yeleman.smir.SMIRAlert.java
com.yeleman.smir.SMIRHome.java
com.yeleman.smir.SharedChecks.java
com.yeleman.snisidroid.ChangePassword.java
com.yeleman.snisidroid.CheckedFormActivity.java
com.yeleman.snisidroid.Constants.java
com.yeleman.snisidroid.Popups.java
com.yeleman.snisidroid.Preferences.java
com.yeleman.snisidroid.ReportData.java
com.yeleman.snisidroid.SMSDeliveredReceiver.java
com.yeleman.snisidroid.SMSReceiver.java
com.yeleman.snisidroid.SMSSentReceiver.java
com.yeleman.snisidroid.SMSUpdater.java
com.yeleman.snisidroid.SNISIAbout.java
com.yeleman.snisidroid.SNISIApp.java
com.yeleman.snisidroid.SNISIHome.java
com.yeleman.snisidroid.SharedChecks.java