Android Open Source - CreditCardEditText String Util






From Project

Back to project page CreditCardEditText.

License

The source code is released under:

Apache License

If you think the Android project CreditCardEditText 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.alihafizji.library;
/*from w  ww.  j  a va  2  s .  c  om*/
/**
 * Created by kauserali on 05/05/14.
 */
public class StringUtil {
    private static final int INDEX_NOT_FOUND = -1;

    public static String difference(String str1, String str2) {
        if (str1 == null) {
            return str2;
        }
        if (str2 == null) {
            return str1;
        }
        int at = indexOfDifference(str1, str2);
        if (at == INDEX_NOT_FOUND) {
            return "";
        }
        return str2.substring(at);
    }

    public static int indexOfDifference(CharSequence cs1, CharSequence cs2) {
        if (cs1 == cs2) {
            return INDEX_NOT_FOUND;
        }
        if (cs1 == null || cs2 == null) {
            return 0;
        }
        int i;
        for (i = 0; i < cs1.length() && i < cs2.length(); ++i) {
            if (cs1.charAt(i) != cs2.charAt(i)) {
                break;
            }
        }
        if (i < cs2.length() || i < cs1.length()) {
            return i;
        }
        return INDEX_NOT_FOUND;
    }
}




Java Source Code List

com.alihafizji.MainActivity.java
com.alihafizji.library.CreditCardEditText.java
com.alihafizji.library.CreditCardPatterns.java
com.alihafizji.library.CreditCardTextWatcher.java
com.alihafizji.library.CreditCardTypeEnum.java
com.alihafizji.library.StringUtil.java