mirror of
https://github.com/nextcloud/android.git
synced 2024-12-18 06:51:55 +03:00
File#isImage() considers the name of the file, besides the knowledge from server
This commit is contained in:
parent
db7eea712d
commit
a212611a9b
1 changed files with 15 additions and 1 deletions
|
@ -20,9 +20,12 @@ package com.owncloud.android.datamodel;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.webkit.MimeTypeMap;
|
||||||
|
|
||||||
public class OCFile implements Parcelable, Comparable<OCFile> {
|
public class OCFile implements Parcelable, Comparable<OCFile> {
|
||||||
|
|
||||||
|
@ -466,7 +469,18 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
|
||||||
|
|
||||||
/** @return 'True' if the file contains an image */
|
/** @return 'True' if the file contains an image */
|
||||||
public boolean isImage() {
|
public boolean isImage() {
|
||||||
return (mMimeType != null && mMimeType.startsWith("image/"));
|
return ((mMimeType != null && mMimeType.startsWith("image/")) ||
|
||||||
|
getMimeTypeFromName().startsWith("image/"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMimeTypeFromName() {
|
||||||
|
String extension = "";
|
||||||
|
int pos = mRemotePath.lastIndexOf('.');
|
||||||
|
if (pos >= 0) {
|
||||||
|
extension = mRemotePath.substring(pos + 1);
|
||||||
|
}
|
||||||
|
String result = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase());
|
||||||
|
return (result != null) ? result : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue