version:1.9.4
fix: update:作业页面完善
This commit is contained in:
@@ -16,11 +16,17 @@ import androidx.core.content.FileProvider;
|
||||
|
||||
import com.uiui.zyos.BuildConfig;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URLConnection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
public class OpenFileUtil {
|
||||
private static final String TAG = "OpenFileUtil";
|
||||
|
||||
public static void openFile(Context context, String filePath) {
|
||||
File file = new File(filePath);
|
||||
@@ -63,6 +69,20 @@ public class OpenFileUtil {
|
||||
type = map.get(end);
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "getMimeTypeFromFile: " + type);
|
||||
Log.e(TAG, "getMimeType: " + getMimeType(file.getAbsolutePath()));
|
||||
return type;
|
||||
}
|
||||
|
||||
private static String getMimeType(String filePath) {
|
||||
String type = "*/*";
|
||||
try {
|
||||
FileInputStream inputFile = new FileInputStream(filePath);
|
||||
type = URLConnection.guessContentTypeFromStream(new BufferedInputStream(inputFile));
|
||||
return type;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -75,6 +95,7 @@ public class OpenFileUtil {
|
||||
*/
|
||||
public static HashMap<String, String> getMimeMap() {
|
||||
if (mapSimple.size() == 0) {
|
||||
mapSimple.put("", "*/*");
|
||||
mapSimple.put(".3gp", "video/3gpp");
|
||||
mapSimple.put(".apk", "application/vnd.android.package-archive");
|
||||
mapSimple.put(".asf", "video/x-ms-asf");
|
||||
@@ -142,7 +163,6 @@ public class OpenFileUtil {
|
||||
mapSimple.put(".xlsx", "application/vnd.ms-excel");
|
||||
mapSimple.put(".z", "application/x-compress");
|
||||
mapSimple.put(".zip", "application/zip");
|
||||
mapSimple.put("", "*/*");
|
||||
}
|
||||
return mapSimple;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user