Android Open Source - SNISI-droid Nutrition U R E N A M P W Report






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

package com.yeleman.nutrition;
/*ww w .j a v  a2 s  .  com*/
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yeleman.snisidroid.CheckedFormActivity;
import com.yeleman.snisidroid.Constants;
import com.yeleman.snisidroid.R;

public class NutritionURENAMPWReport extends NutritionURENForm implements NutritionURENFormIface {

    private final static String TAG = Constants.getLogTag("NutritionURENAMPWReport");

    /* NutritionURENFormIFace */
    public String getUREN() { return URENAM; }
    public String getAge() { return PW; }

    /* NutritionURENForm */
    protected boolean ensureDataCoherence() { return ensureURENCoherence(); }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nutrition_uren_unit_fillout);
        setTitle(String.format(getString(R.string.nutrition_fillout_section),
                getString(R.string.pw)));
        Log.d(TAG, "onCreate NutritionURENAMPWReport");

        setupSMSReceiver();
        setupUI();
    }

    protected void setupUI() {
        Log.d(TAG, "setupUI NutritionURENAMPWReport");

        totalStartMField = (EditText) findViewById(R.id.totalStartMField);
        totalStartMField.setVisibility(View.GONE);
        totalStartFField = (EditText) findViewById(R.id.totalStartFField);
        newCasesField = (EditText) findViewById(R.id.newCasesField);
        returnedField = (EditText) findViewById(R.id.returnedField);
        totalInMField = (EditText) findViewById(R.id.totalInMField);
        totalInMField.setVisibility(View.GONE);
        totalInFField = (EditText) findViewById(R.id.totalInFField);
        LinearLayout transferred_parent = (LinearLayout) findViewById(R.id.transferredLinearLayout);
        transferred_parent.setVisibility(View.GONE);

        LinearLayout grand_total_in_parent = (LinearLayout) findViewById(R.id.grandTotalInLinearLayout);
        grand_total_in_parent.setVisibility(View.GONE);

        healedField = (EditText) findViewById(R.id.healedField);
        deceasedField = (EditText) findViewById(R.id.deceasedField);
        abandonField = (EditText) findViewById(R.id.abandonField);
        notRespondingField = (EditText) findViewById(R.id.notRespondingField);
        totalOutMField = (EditText) findViewById(R.id.totalOutMField);
        totalOutMField.setVisibility(View.GONE);
        totalOutFField = (EditText) findViewById(R.id.totalOutFField);
        referredLabel = (TextView) findViewById(R.id.referredLabel);
        referredLabel.setText(getString(R.string.nutrition_referred_label_urenam));
        referredField = (EditText) findViewById(R.id.referredField);
        referredField.setHint(getString(R.string.nutrition_referred_label_urenam));

        LinearLayout grand_total_out_parent = (LinearLayout) findViewById(R.id.grandTotalOutLinearLayout);
        grand_total_out_parent.setVisibility(View.GONE);

        totalEndMField = (EditText) findViewById(R.id.totalEndMField);
        totalEndMField.setVisibility(View.GONE);
        totalEndFField = (EditText) findViewById(R.id.totalEndFField);

        NutritionURENAMReportData report = NutritionURENAMReportData.get();
        if (report.pw_is_complete){
            restoreReportData();
        }
        // setup invalid inputs checks
        setupInvalidInputChecks();

        saveButton = (Button) findViewById(R.id.saveButton);
        saveButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // ensure data is OK
                if (!checkInputsAndCoherence()) { return; }

                // save data to DB
                storeReportData();

                finish();
            }
        });
    }

    protected void storeReportData() {
        Log.d(TAG, "storeReportData");
        NutritionURENAMReportData report = NutritionURENAMReportData.get();
        report.updateMetaData();

        report.pw_total_start_f = integerFromField(totalStartFField);
        report.pw_new_cases = integerFromField(newCasesField);
        report.pw_returned = integerFromField(returnedField);
        report.pw_total_in_f = integerFromField(totalInFField);
        report.pw_healed = integerFromField(healedField);
        report.pw_deceased = integerFromField(deceasedField);
        report.pw_abandon = integerFromField(abandonField);
        report.pw_not_responding = integerFromField(notRespondingField);
        report.pw_total_out_f = integerFromField(totalOutFField);
        report.pw_referred = integerFromField(referredField);
        report.pw_total_end_f = integerFromField(totalEndFField);
        report.pw_is_complete = true;
        report.safeSave();
        Log.d(TAG, "storeReportData -- end");

    }

    protected void restoreReportData() {
        Log.d(TAG, "restoreReportData");
        NutritionURENAMReportData report = NutritionURENAMReportData.get();

        setTextOnField(totalStartFField, report.pw_total_start_f);
        setTextOnField(newCasesField, report.pw_new_cases);
        setTextOnField(returnedField, report.pw_returned);
        setTextOnField(totalInFField, report.pw_total_in_f);
        setTextOnField(healedField, report.pw_healed);
        setTextOnField(deceasedField, report.pw_deceased);
        setTextOnField(abandonField, report.pw_abandon);
        setTextOnField(notRespondingField, report.pw_not_responding);
        setTextOnField(totalOutFField, report.pw_total_out_f);
        setTextOnField(referredField, report.pw_referred);
        setTextOnField(totalEndFField, report.pw_total_end_f);

    }

    protected void setupInvalidInputChecks() {

        setAssertPositiveInteger(totalStartFField);
        setAssertPositiveInteger(newCasesField);
        setAssertPositiveInteger(returnedField);
        setAssertPositiveInteger(totalInFField);
        setAssertPositiveInteger(healedField);
        setAssertPositiveInteger(deceasedField);
        setAssertPositiveInteger(abandonField);
        setAssertPositiveInteger(notRespondingField);
        setAssertPositiveInteger(totalOutFField);
        setAssertPositiveInteger(referredField);
        setAssertPositiveInteger(totalEndFField);
    }
}




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