Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.widget.EditText;

public class Main {
    /**
     * Checks if String in fields match one another. Does NOT compare case
     * @param et1
     * @param et2
     * @return
     */
    public static boolean doFieldsMatch(EditText et1, EditText et2) {
        String str1 = getFromEditText(et1);
        String str2 = getFromEditText(et2);
        if (str1.equalsIgnoreCase(str2)) {
            return true;
        }
        if (str1 == null && str2 == null) {
            return false;
        }
        return false;
    }

    /**
     * Gets a String from an edit text. It also trims off any leading or ending white space
     * @param et
     * @return
     */
    public static String getFromEditText(EditText et) {
        if (et == null) {
            return null;
        }

        String str = et.getText().toString();
        if (!str.equals(null)) {
            str = str.trim();
            return str;
        }
        return str;
    }
}