Files
Xuewang365OSLenovo/app/src/main/java/com/uiui/os/utils/FileUtil.java
Godfather f74e6b106c version:1.7
fix:
update:修改布局,爱心守护播放视频,
2022-02-25 17:23:59 +08:00

55 lines
1.5 KiB
Java

package com.uiui.os.utils;
import android.text.TextUtils;
import java.util.HashSet;
public class FileUtil {
public static String getFileType(String url) {
if (url.indexOf("/") == -1) {
return url.substring(url.indexOf("."), url.length());
} else {
String fileName = url.substring(url.lastIndexOf("/"));
return fileName.substring(fileName.indexOf("."), fileName.length());
}
}
private static HashSet<String> videoFormat = new HashSet<String>() {{
this.add(".mp4");
this.add(".avi");
this.add(".nkv");
this.add(".flv");
}};
private static HashSet<String> pictureFormat = new HashSet<String>() {{
this.add(".png");
this.add(".jpg");
this.add(".jpeg");
this.add(".bmp");
}};
public static boolean isVideoFile(String fileName) {
if (TextUtils.isEmpty(fileName)) {
return false;
} else {
if (!fileName.startsWith(".")) {
return videoFormat.contains(getFileType(fileName));
} else {
return videoFormat.contains(fileName);
}
}
}
public static boolean isPictureFile(String fileName) {
if (TextUtils.isEmpty(fileName)) {
return false;
} else {
if (!fileName.startsWith(".")) {
return pictureFormat.contains(getFileType(fileName));
} else {
return pictureFormat.contains(fileName);
}
}
}
}