From 6c33cefba0cccd62af326d9656173edef26d6376 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 29 Apr 2014 13:53:11 +0200 Subject: [PATCH] WIP - commented pull-refreshes of list view as previous step to trust refresh to observer registered by Cursor --- .../datamodel/FileDataStorageManager.java | 4 +++ .../providers/FileContentProvider.java | 3 ++ .../ui/activity/FileDisplayActivity.java | 31 ++++++++++++++++++- .../ui/fragment/FileDetailFragment.java | 4 +++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index cc4fa95a42..04f3271aaa 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -611,6 +611,7 @@ public class FileDataStorageManager { public Cursor getContent(long parentId) { + Log_OC.d(TAG, "getContent start"); Uri req_uri = Uri.withAppendedPath( ProviderTableMeta.CONTENT_URI_DIR, String.valueOf(parentId)); @@ -629,8 +630,11 @@ public class FileDataStorageManager { c = getContentResolver().query(req_uri, null, ProviderTableMeta.FILE_PARENT + "=?" , new String[] { String.valueOf(parentId)}, null); + + //c.setNotificationUri(getContentResolver(), req_uri); } + Log_OC.d(TAG, "getContent end"); return c; } diff --git a/src/com/owncloud/android/providers/FileContentProvider.java b/src/com/owncloud/android/providers/FileContentProvider.java index 54e67a242d..c84d66b04e 100644 --- a/src/com/owncloud/android/providers/FileContentProvider.java +++ b/src/com/owncloud/android/providers/FileContentProvider.java @@ -99,6 +99,8 @@ public class FileContentProvider extends ContentProvider { private static final int DIRECTORY = 2; private static final int ROOT_DIRECTORY = 3; private static final int SHARES = 4; + + private static final String TAG = FileContentProvider.class.getSimpleName(); // Projection for ocshares table private static HashMap mOCSharesProjectionMap; @@ -414,6 +416,7 @@ public class FileContentProvider extends ContentProvider { // DB case_sensitive db.execSQL("PRAGMA case_sensitive_like = true"); Cursor c = sqlQuery.query(db, projection, selection, selectionArgs, null, null, order); + Log_OC.d(TAG, "setting notification URI: " + uri); c.setNotificationUri(getContext().getContentResolver(), uri); return c; } diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index f6136ed375..c59471717f 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -215,7 +215,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa protected void onStart() { super.onStart(); getSupportActionBar().setIcon(DisplayUtils.getSeasonalIconId()); + /* refeshListOfFilesFragment(); + */ } @Override @@ -416,12 +418,14 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa updateNavigationElementsInActionBar(null); } + /* TODO WIP COMMENT protected void refeshListOfFilesFragment() { OCFileListFragment fileListFragment = getListOfFilesFragment(); if (fileListFragment != null) { fileListFragment.listDirectory(); } } + */ protected void refreshSecondFragment(String downloadEvent, String downloadedRemotePath, boolean success) { FileFragment secondFragment = getSecondFragment(); @@ -940,13 +944,15 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa cleanSecondFragment(); currentFile = currentDir; } - + + /* TODO WIP COMMENT if (synchFolderRemotePath != null && currentDir.getRemotePath().equals(synchFolderRemotePath)) { OCFileListFragment fileListFragment = getListOfFilesFragment(); if (fileListFragment != null) { fileListFragment.listDirectory(currentDir); } } + */ setFile(currentFile); } @@ -999,7 +1005,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa OCFile currentDir = getCurrentDir(); boolean isDescendant = (currentDir != null) && (uploadedRemotePath != null) && (uploadedRemotePath.startsWith(currentDir.getRemotePath())); if (sameAccount && isDescendant) { + /* refeshListOfFilesFragment(); + */ } } @@ -1020,7 +1028,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa boolean isDescendant = isDescendant(downloadedRemotePath); if (sameAccount && isDescendant) { + /* TODO WIP COMMENT refeshListOfFilesFragment(); + */ refreshSecondFragment(intent.getAction(), downloadedRemotePath, intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false)); } @@ -1069,7 +1079,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa if (getAccount() != null && account.name.equals(getAccount().name) && getStorageManager() != null ) { + /* refeshListOfFilesFragment(); + */ } if ((getSharesResult != null) && RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(getSharesResult.getCode())) { @@ -1224,10 +1236,13 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa /** * {@inheritDoc} */ + @Override public void onFileStateChanged() { + /* TODO WIP COMMENT refeshListOfFilesFragment(); updateNavigationElementsInActionBar(getSecondFragment().getFile()); + */ } @@ -1362,7 +1377,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) { if (result.isSuccess()) { refreshShowDetails(); + /* TODO WIP COMMENT refeshListOfFilesFragment(); + */ } } @@ -1370,10 +1387,14 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) { if (result.isSuccess()) { refreshShowDetails(); + /* refeshListOfFilesFragment(); + */ } else if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { cleanSecondFragment(); + /* refeshListOfFilesFragment(); + */ } } @@ -1413,7 +1434,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa cleanSecondFragment(); } if (getStorageManager().getFileById(removedFile.getParentId()).equals(getCurrentDir())) { + /* refeshListOfFilesFragment(); + */ } } else { @@ -1435,7 +1458,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa private void onCreateFolderOperationFinish(CreateFolderOperation operation, RemoteOperationResult result) { if (result.isSuccess()) { dismissLoadingDialog(); + /* TODO WIP COMMENT refeshListOfFilesFragment(); + */ } else { dismissLoadingDialog(); @@ -1472,7 +1497,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa } } if (getStorageManager().getFileById(renamedFile.getParentId()).equals(getCurrentDir())) { + /* refeshListOfFilesFragment(); + */ } } else { @@ -1509,7 +1536,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa } else { if (operation.transferWasRequested()) { + /* refeshListOfFilesFragment(); + */ onTransferStateChanged(syncedFile, true, true); } else { diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index dc8c9f629f..ddbaca37a5 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -854,7 +854,9 @@ public class FileDetailFragment extends FileFragment implements if (result.isSuccess()) { updateFileDetails(((RenameFileOperation)operation).getFile(), mAccount); + /* TODO WIP COMMENT mContainerActivity.onFileStateChanged(); + */ } else { if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) { @@ -896,8 +898,10 @@ public class FileDetailFragment extends FileFragment implements } else { if (operation.transferWasRequested()) { setButtonsForTransferring(); + /* TODO WIP COMMENT mContainerActivity.onFileStateChanged(); // this is not working; FileDownloader won't do NOTHING at all until this method finishes, so // checking the service to see if the file is downloading results in FALSE + */ } else { Toast msg = Toast.makeText(getActivity(), R.string.sync_file_nothing_to_do_msg, Toast.LENGTH_LONG); msg.show();