Skip to content

Instantly share code, notes, and snippets.

View bingoogolapple's full-sized avatar
🎒
Studying

王浩 bingoogolapple

🎒
Studying
View GitHub Profile
public class ExtUtil {
private ExtUtil() {
}
public static boolean isVideo(String filePath) {
String ext = filePath.toLowerCase();
return ext.endsWith(".mp4") || ext.endsWith(".avi") || ext.endsWith(".wmv") || ext.endsWith(".rmvb") || ext.endsWith(".mpg") || ext.endsWith(".mpeg") || ext.endsWith(".3gp");
}
public static boolean isImage(String filePath) {
public class MediaScanner {
private static String AUDIO_PATH = MediaStore.Audio.AudioColumns.DATA;
private static String AUDIO_DISPLAYHNAME = MediaStore.Audio.AudioColumns.DISPLAY_NAME;
private static String AUDIO_COLUMN_STRS[] = { AUDIO_PATH, AUDIO_DISPLAYHNAME };
private static String VIDEO_PATH = MediaStore.Video.VideoColumns.DATA;
private static String VIDEO_DISPLAYHNAME = MediaStore.Video.VideoColumns.DISPLAY_NAME;
private static String VIDEO_COLUMN_STRS[] = { VIDEO_PATH, VIDEO_DISPLAYHNAME };
private static String IMAGE_PATH = MediaStore.Images.ImageColumns.DATA;
public class ByteUtil {
private ByteUtil() {
}
public static byte[] intToBytes(int number) {
return new byte[] { (byte) ((number >> 24) & 0xFF), (byte) ((number >> 16) & 0xFF), (byte) ((number >> 8) & 0xFF), (byte) (number & 0xFF) };
}
public static int bytesToInt(byte[] bytes) {
return bytes[3] & 0xFF | (bytes[2] & 0xFF) << 8 | (bytes[1] & 0xFF) << 16 | (bytes[0] & 0xFF) << 24;
public class StorageUtil {
private StorageUtil() {
}
public static Context mContext;
public static void init(Context context) {
mContext = context;
}
public class IntentUtil {
private IntentUtil() {
}
public static Intent openFile(String filePath) {
if (ExtUtil.isAudio(filePath)) {
return getAudioFileIntent(filePath);
} else if (ExtUtil.isVideo(filePath)) {
return getVideoFileIntent(filePath);
} else if (ExtUtil.isImage(filePath)) {
public class ExtUtil {
private ExtUtil() {
}
public static boolean isVideo(String filePath) {
String ext = filePath.toLowerCase();
return ext.endsWith(".mp4") || ext.endsWith(".avi") || ext.endsWith(".wmv") || ext.endsWith(".rmvb") || ext.endsWith(".mpg") || ext.endsWith(".mpeg") || ext.endsWith(".3gp");
}
public static boolean isImage(String filePath) {