Implemented equals() and toString() on OCFile. Renamed getPath() to make
authorLennart Rosam <lennart@familie-rosam.de>
Wed, 23 May 2012 20:39:37 +0000 (22:39 +0200)
committerLennart Rosam <lennart@familie-rosam.de>
Wed, 23 May 2012 20:39:37 +0000 (22:39 +0200)
it more clear what that refers to

src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java
src/eu/alefzero/owncloud/datamodel/OCFile.java
src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java

index a766957..e0870b9 100644 (file)
@@ -93,13 +93,13 @@ public class FileDataStorageManager implements DataStorageManager {
         cv.put(ProviderTableMeta.FILE_NAME, file.getFileName());
         if (file.getParentId() != 0)
             cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId());
-        cv.put(ProviderTableMeta.FILE_PATH, file.getPath());
+        cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
         cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
         cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
         cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDate());
 
-        if (fileExists(file.getPath())) {
-            OCFile tmpfile = getFileByPath(file.getPath());
+        if (fileExists(file.getRemotePath())) {
+            OCFile tmpfile = getFileByPath(file.getRemotePath());
             file.setStoragePath(tmpfile.getStoragePath());
             cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
             file.setFileId(tmpfile.getFileId());
index 7e8f428..9566a19 100644 (file)
@@ -86,11 +86,11 @@ public class OCFile implements Parcelable {
     }
 
     /**
-     * Returns the path of the file
+     * Returns the remote path of the file on ownCloud
      * 
-     * @return The path
+     * @return The remote path to the file
      */
-    public String getPath() {
+    public String getRemotePath() {
         return mRemotePath;
     }
 
@@ -119,7 +119,7 @@ public class OCFile implements Parcelable {
      * @return true if it is
      */
     public boolean isDownloaded() {
-        return mLocalPath != null || mLocalPath.equals("");
+        return mLocalPath != null && !mLocalPath.equals("");
     }
 
     /**
@@ -321,4 +321,19 @@ public class OCFile implements Parcelable {
         dest.writeLong(mLastSyncDate);
     }
 
+    @Override
+    public boolean equals(Object o) {
+        OCFile that = (OCFile) o;
+        return this.mId == that.mId;
+    }
+
+    @Override
+    public String toString() {
+        String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s]";
+        asString = String.format(asString, new Long(mId), getFileName(), mMimeType, isDownloaded(), mLocalPath, mRemotePath);
+        return asString;
+    }
+    
+    
+
 }
index 45ec0a9..78c636b 100644 (file)
@@ -137,7 +137,7 @@ public class FileDetailFragment extends SherlockFragment implements
         Intent i = new Intent(getActivity(), FileDownloader.class);\r
         i.putExtra(FileDownloader.EXTRA_ACCOUNT,\r
                 mIntent.getParcelableExtra(FileDownloader.EXTRA_ACCOUNT));\r
-        i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getPath());\r
+        i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getRemotePath());\r
         getActivity().startService(i);\r
     }\r
 \r