package tw.realtime.project.lativtest;

import android.content.Context;
import android.os.Build;

/**
 * Created by vexonelite on 2016/10/20.
 */
public class CodeUtils {


    public static int getColorFromResourceId (Context context, int resID) {
        return (Build.VERSION.SDK_INT < 23)
                ? context.getResources().getColor(resID)
                : context.getResources().getColor(resID, null);
    }
}

@@ -94,322 +94,2796 @@
 ld;%0A
-%0A/**%0A * Created by vexonelite on 2016/10/20.%0A */%0Apublic class CodeUtils %7B%0A%0A%0A    public static int getColorFromResourceId (Context context, int resID) %7B%0A        return (Build.VERSION.SDK_INT %3C 23)%0A                ? context.getResources().getColor(resID)%0A                : context.getResources().getColor(resID, null
+import android.util.Log;%0A%0Aimport java.math.BigInteger;%0Aimport java.security.SecureRandom;%0A%0A/**%0A * Created by vexonelite on 2016/10/20.%0A */%0Apublic class CodeUtils %7B%0A%0A    private static String getLogTag () %7B%0A        return CodeUtils.class.getSimpleName();%0A    %7D%0A%0A    public static int getColorFromResourceId (Context context, int resID) %7B%0A        return (Build.VERSION.SDK_INT %3C 23)%0A                ? context.getResources().getColor(resID)%0A                : context.getResources().getColor(resID, null);%0A    %7D%0A%0A    /**%0A     * @param random It must be a SecureRandom instance.%0A     * @param length The desired length of result.%0A     * @return Return a randomly generated String with length is exactly 32.%0A     */%0A    public static String generateRandomStringWithLength (SecureRandom random, int length) throws Exception %7B%0A//        return random.ints(48,122)%0A//                .filter(i-%3E (i%3C57 %7C%7C i%3E65) && (i %3C90 %7C%7C i%3E97))%0A//                .mapToObj(i -%3E (char) i)%0A//                .limit(length)%0A//                .collect(StringBuilder::new, StringBuilder::append, StringBuilder::append)%0A//                .toString();%0A%0A        String randomString = %22%22;%0A        while (randomString.length() %3C length) %7B%0A            randomString = randomString + generateRandomString(random);%0A            LogWrapper.showLog(Log.INFO, getLogTag(), %22randomString: %22 + randomString + %22, length: %22 + randomString.length());%0A        %7D%0A%0A        String result = %22%22;%0A        if (randomString.length() %3E= length) %7B%0A            result = randomString.substring(0, length);%0A        %7D%0A        LogWrapper.showLog(Log.INFO, getLogTag(), %22result: %22 + result + %22, length: %22 + result.length());%0A%0A        return result;%0A    %7D%0A%0A    /**%0A     * This works by choosing 130 bits from a cryptographically secure random bit generator,%0A     * and encoding them in base-32.%0A     * 128 bits is considered to be cryptographically strong,%0A     * but each digit in a base 32 number can encode 5 bits,%0A     * so 128 is rounded up to the next multiple of 5.%0A     * This encoding is compact and efficient, with 5 random bits per character.%0A     *%0A     * Compare this to a random UUID, which only has 3.4 bits per character in standard layout,%0A     * and only 122 random bits in total.%0A     *%0A     * If you allow session identifiers to be easily guessable%0A     * (too short, flawed random number generator, etc.), attackers can hijack other's sessions.%0A     *%0A     * Note that SecureRandom objects are expensive to initialize, so you'll want to keep one around and reuse it.%0A     *%0A     * @param random It must be a SecureRandom instance.%0A     * @return Return a randomly generated String.%0A     */%0A    private static String generateRandomString (SecureRandom random) throws Exception %7B%0A        return new BigInteger(130, random).toString(32
 );%0A 

add method to generate random string