OC-2585: Refreshthe share items.
authormasensio <masensio@solidgear.es>
Mon, 27 Jan 2014 08:40:07 +0000 (09:40 +0100)
committermasensio <masensio@solidgear.es>
Mon, 27 Jan 2014 08:40:07 +0000 (09:40 +0100)
src/com/owncloud/android/datamodel/FileDataStorageManager.java
src/com/owncloud/android/datamodel/OCFile.java
src/com/owncloud/android/operations/GetSharedFilesOperation.java
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

index e32633d..313ad06 100644 (file)
@@ -932,4 +932,24 @@ public class FileDataStorageManager {
     public boolean fileShareExists(String path) {
         return fileShareExists(ProviderTableMeta.OCSHARES_PATH, path);
     }
+    
+    public void cleanShareFile() {
+        ContentValues cv = new ContentValues();
+        cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, false);
+        cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
+        String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
+        String [] whereArgs = new String[]{mAccount.name};
+        
+        if (getContentResolver() != null) {
+            getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
+
+        } else {
+            try {
+                getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
+                
+            } catch (RemoteException e) {
+                Log_OC.e(TAG, "Exception in cleanShareFile" + e.getMessage());
+            }
+        }
+    } 
 }
index 2d8f59e..82c341c 100644 (file)
@@ -102,7 +102,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
         mLastSyncDateForProperties = source.readLong();
         mLastSyncDateForData = source.readLong();
         mEtag = source.readString();
-        mShareByLink = source.readInt() == 0;
+        mShareByLink = source.readInt() == 1;
         mPublicLink = source.readString();
     }
 
index 4ee4cb6..68fd6ab 100644 (file)
@@ -23,7 +23,6 @@ import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.datamodel.OCShare;
 import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
-import com.owncloud.android.oc_framework.operations.OnRemoteOperationListener;
 import com.owncloud.android.oc_framework.operations.RemoteOperation;
 import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
 import com.owncloud.android.oc_framework.operations.ShareRemoteFile;
@@ -59,6 +58,8 @@ public class GetSharedFilesOperation extends RemoteOperation {
         
         if (result.isSuccess()) {
             
+            // Clean Share data in filelist table
+            mStorageManager.cleanShareFile();
             // Update DB with the response
             ArrayList<ShareRemoteFile> shareRemoteFiles = operation.getSharedFiles();
             Log_OC.d(TAG, "Share list size = " + shareRemoteFiles.size());
index a698ceb..ee6a2ad 100644 (file)
@@ -1301,11 +1301,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
     private void onGetSharedFilesOperationFinish(GetSharedFilesOperation operation, RemoteOperationResult result) {
         // TODO
         // Refresh the filelist with the information
-        refeshListOfFilesFragment();
-//        OCFileListFragment fileListFragment = getListOfFilesFragment();
-//        if (fileListFragment != null) { 
-//            fileListFragment.listDirectory(getCurrentDir());
-//        }      
+        refeshListOfFilesFragment();    
         
     }