/** * @see {@link ArrayUtils#getLast(Object[], Object, Object, boolean)} defaultValue is null */ public static <V> V getLast(V[] sourceArray, V value, boolean isCircle) { return getLast(sourceArray, value, null, isCircle); }
/** * Initialize * * @param context */ public void init(Context context) { init(context, "/crash/"); }
private static String badPositionIndexes(int start, int end, int size) { if (start < 0 || start > size) { return badPositionIndex(start, size, "start index"); } if (end < 0 || end > size) { return badPositionIndex(end, size, "end index"); } // end < start return format("end index (%s) must not be less than start index (%s)", end, start); }
/** * Indicates if the file represents a directory exists. * * @param directoryPath * @return */ public static boolean isFolderExist(String directoryPath) { if (!BasicUtils.judgeNotNull(directoryPath)) { return false; } File dire = new File(directoryPath); return (dire.exists() && dire.isDirectory()); }
private boolean handleException(Throwable ex) { if (ex == null) { return false; } new Thread() { @Override public void run() { Looper.prepare(); Toast.makeText(mContext, showMessage, Toast.LENGTH_SHORT).show(); Looper.loop(); } }.start(); collectDeviceInfo(mContext); String filemameString = saveCrashInfo2File(ex); Logs.d("filemameString", filemameString); return true; }
/** * @see {@link ArrayUtils#getNext(Object[], Object, Object, boolean)} Object is Integer */ public static int getNext(int[] sourceArray, int value, int defaultValue, boolean isCircle) { if (sourceArray.length == 0) { throw new IllegalArgumentException("The length of source array must be greater than 0."); } Integer[] array = transformIntArray(sourceArray); return getNext(array, value, defaultValue, isCircle); }
/** * @see {@link ArrayUtils#getLast(Object[], Object, Object, boolean)} Object is Long */ public static long getLast(long[] sourceArray, long value, long defaultValue, boolean isCircle) { if (sourceArray.length == 0) { throw new IllegalArgumentException("The length of source array must be greater than 0."); } Long[] array = transformLongArray(sourceArray); return getLast(array, value, defaultValue, isCircle); }
/** * @see {@link ArrayUtils#getNext(Object[], Object, Object, boolean)} Object is Long */ public static long getNext(long[] sourceArray, long value, long defaultValue, boolean isCircle) { if (sourceArray.length == 0) { throw new IllegalArgumentException("The length of source array must be greater than 0."); } Long[] array = transformLongArray(sourceArray); return getNext(array, value, defaultValue, isCircle); }
/** * @see {@link ArrayUtils#getLast(Object[], Object, Object, boolean)} Object is Integer */ public static int getLast(int[] sourceArray, int value, int defaultValue, boolean isCircle) { if (sourceArray.length == 0) { throw new IllegalArgumentException("The length of source array must be greater than 0."); } Integer[] array = transformIntArray(sourceArray); return getLast(array, value, defaultValue, isCircle); }
private static String badPositionIndex(int index, int size, String desc) { if (index < 0) { return format("%s (%s) must not be negative", desc, index); } else if (size < 0) { throw new IllegalArgumentException("negative size: " + size); } else { // index > size return format("%s (%s) must not be greater than size (%s)", desc, index, size); } }
/** * @see {@link ArrayUtils#getNext(Object[], Object, Object, boolean)} defaultValue is null */ public static <V> V getNext(V[] sourceArray, V value, boolean isCircle) { return getNext(sourceArray, value, null, isCircle); }
/** * Send an empty message which default what value is 0 * * @param handler */ public static void sendMessageHandler(Handler handler) { sendMessageHandler(handler, 0); }
/** * Ensures that {@code index} specifies a valid <i>element</i> in an array, list or string of size * {@code size}. An element index may range from zero, inclusive, to {@code size}, exclusive. * * @param index a user-supplied index identifying an element of an array, list or string * @param size the size of that array, list or string * @return the value of {@code index} * @throws IndexOutOfBoundsException if {@code index} is negative or is not less than {@code size} * @throws IllegalArgumentException if {@code size} is negative */ public static int checkElementIndex(int index, int size) { return checkElementIndex(index, size, "index"); }
/** * Ensures that {@code index} specifies a valid <i>position</i> in an array, list or string of * size {@code size}. A position index may range from zero to {@code size}, inclusive. * * @param index a user-supplied index identifying a position in an array, list or string * @param size the size of that array, list or string * @return the value of {@code index} * @throws IndexOutOfBoundsException if {@code index} is negative or is greater than {@code size} * @throws IllegalArgumentException if {@code size} is negative */ public static int checkPositionIndex(int index, int size) { return checkPositionIndex(index, size, "index"); }
/** * Initialize * * @param context * @param crashFilePath */ public void init(Context context, String crashFilePath, String showMessage) { mContext = context; mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler(this); // this.systemServiceObject = systemServiceObject; this.crashFilePath = crashFilePath; if (BasicUtils.judgeNotNull(showMessage)) { this.showMessage = showMessage; } }
private static String badElementIndex(int index, int size, String desc) { if (index < 0) { return format("%s (%s) must not be negative", desc, index); } else if (size < 0) { throw new IllegalArgumentException("negative size: " + size); } else { // index >= size return format("%s (%s) must be less than size (%s)", desc, index, size); } }
/** * Initialize * * @param context */ public void init(Context context, String crashFilePath) { init(context, crashFilePath, ""); }
/** * Indicates if the file represents a file exists. * * @param filePath * @return */ public static boolean isFileExist(String filePath) { if (!BasicUtils.judgeNotNull(filePath)) { return false; } File file = new File(filePath); return (file.exists() && file.isFile()); }
/** * Ensures the truth of an expression involving one or more parameters to the calling method. * <p/> * <p>See {@link #checkArgument(boolean, String, Object...)} for details. */ public static void checkArgument( boolean b, @Nullable String errorMessageTemplate, int p1, @Nullable Object p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } }
/** * Get size of the file * * @param path * @return Return the length of the file in bytes. Return -1 if the file does not exist. */ public static long getFileSize(String path) { if (!BasicUtils.judgeNotNull(path)) { return -1; } File file = new File(path); return (file.exists() && file.isFile() ? file.length() : -1); }