Reworked the text file preview system to avoid UI freezes with large text files
[pub/Android/ownCloud.git] / src / com / owncloud / android / datamodel / OCFile.java
index 853b01c..d568ea3 100644 (file)
@@ -448,7 +448,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
 
     @Override
     public int describeContents() {
-        return ((Object) this).hashCode();
+        return super.hashCode();
     }
 
     @Override
@@ -537,6 +537,14 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
                 getMimeTypeFromName().startsWith("image/"));
     }
 
+    /**
+     * @return 'True' if the file is simple text (e.g. not application-dependent, like .doc or .docx)
+     */
+    public boolean isText() {
+        return !isFolder() && !isAudio() && !isVideo() && !isImage() && ((mMimeType != null && mMimeType.startsWith("text/")) ||
+                getMimeTypeFromName().startsWith("text/"));
+    }
+
     public String getMimeTypeFromName() {
         String extension = "";
         int pos = mRemotePath.lastIndexOf('.');
@@ -562,5 +570,4 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
     public void setRemoteId(String remoteId) {
         this.mRemoteId = remoteId;
     }
-
 }