WIP - commented pull-refreshes of list view as previous step to trust refresh to observer registered by Cursor

This commit is contained in:
David A. Velasco 2014-04-29 13:53:11 +02:00
parent 65c7d5d5ba
commit 6c33cefba0
4 changed files with 41 additions and 1 deletions

View file

@ -611,6 +611,7 @@ public class FileDataStorageManager {
public Cursor getContent(long parentId) { public Cursor getContent(long parentId) {
Log_OC.d(TAG, "getContent start");
Uri req_uri = Uri.withAppendedPath( Uri req_uri = Uri.withAppendedPath(
ProviderTableMeta.CONTENT_URI_DIR, ProviderTableMeta.CONTENT_URI_DIR,
String.valueOf(parentId)); String.valueOf(parentId));
@ -629,8 +630,11 @@ public class FileDataStorageManager {
c = getContentResolver().query(req_uri, null, c = getContentResolver().query(req_uri, null,
ProviderTableMeta.FILE_PARENT + "=?" , ProviderTableMeta.FILE_PARENT + "=?" ,
new String[] { String.valueOf(parentId)}, null); new String[] { String.valueOf(parentId)}, null);
//c.setNotificationUri(getContentResolver(), req_uri);
} }
Log_OC.d(TAG, "getContent end");
return c; return c;
} }

View file

@ -99,6 +99,8 @@ public class FileContentProvider extends ContentProvider {
private static final int DIRECTORY = 2; private static final int DIRECTORY = 2;
private static final int ROOT_DIRECTORY = 3; private static final int ROOT_DIRECTORY = 3;
private static final int SHARES = 4; private static final int SHARES = 4;
private static final String TAG = FileContentProvider.class.getSimpleName();
// Projection for ocshares table // Projection for ocshares table
private static HashMap<String, String> mOCSharesProjectionMap; private static HashMap<String, String> mOCSharesProjectionMap;
@ -414,6 +416,7 @@ public class FileContentProvider extends ContentProvider {
// DB case_sensitive // DB case_sensitive
db.execSQL("PRAGMA case_sensitive_like = true"); db.execSQL("PRAGMA case_sensitive_like = true");
Cursor c = sqlQuery.query(db, projection, selection, selectionArgs, null, null, order); Cursor c = sqlQuery.query(db, projection, selection, selectionArgs, null, null, order);
Log_OC.d(TAG, "setting notification URI: " + uri);
c.setNotificationUri(getContext().getContentResolver(), uri); c.setNotificationUri(getContext().getContentResolver(), uri);
return c; return c;
} }

View file

@ -215,7 +215,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
getSupportActionBar().setIcon(DisplayUtils.getSeasonalIconId()); getSupportActionBar().setIcon(DisplayUtils.getSeasonalIconId());
/*
refeshListOfFilesFragment(); refeshListOfFilesFragment();
*/
} }
@Override @Override
@ -416,12 +418,14 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
updateNavigationElementsInActionBar(null); updateNavigationElementsInActionBar(null);
} }
/* TODO WIP COMMENT
protected void refeshListOfFilesFragment() { protected void refeshListOfFilesFragment() {
OCFileListFragment fileListFragment = getListOfFilesFragment(); OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) { if (fileListFragment != null) {
fileListFragment.listDirectory(); fileListFragment.listDirectory();
} }
} }
*/
protected void refreshSecondFragment(String downloadEvent, String downloadedRemotePath, boolean success) { protected void refreshSecondFragment(String downloadEvent, String downloadedRemotePath, boolean success) {
FileFragment secondFragment = getSecondFragment(); FileFragment secondFragment = getSecondFragment();
@ -940,13 +944,15 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
cleanSecondFragment(); cleanSecondFragment();
currentFile = currentDir; currentFile = currentDir;
} }
/* TODO WIP COMMENT
if (synchFolderRemotePath != null && currentDir.getRemotePath().equals(synchFolderRemotePath)) { if (synchFolderRemotePath != null && currentDir.getRemotePath().equals(synchFolderRemotePath)) {
OCFileListFragment fileListFragment = getListOfFilesFragment(); OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) { if (fileListFragment != null) {
fileListFragment.listDirectory(currentDir); fileListFragment.listDirectory(currentDir);
} }
} }
*/
setFile(currentFile); setFile(currentFile);
} }
@ -999,7 +1005,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
OCFile currentDir = getCurrentDir(); OCFile currentDir = getCurrentDir();
boolean isDescendant = (currentDir != null) && (uploadedRemotePath != null) && (uploadedRemotePath.startsWith(currentDir.getRemotePath())); boolean isDescendant = (currentDir != null) && (uploadedRemotePath != null) && (uploadedRemotePath.startsWith(currentDir.getRemotePath()));
if (sameAccount && isDescendant) { if (sameAccount && isDescendant) {
/*
refeshListOfFilesFragment(); refeshListOfFilesFragment();
*/
} }
} }
@ -1020,7 +1028,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
boolean isDescendant = isDescendant(downloadedRemotePath); boolean isDescendant = isDescendant(downloadedRemotePath);
if (sameAccount && isDescendant) { if (sameAccount && isDescendant) {
/* TODO WIP COMMENT
refeshListOfFilesFragment(); refeshListOfFilesFragment();
*/
refreshSecondFragment(intent.getAction(), downloadedRemotePath, intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false)); 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) if (getAccount() != null && account.name.equals(getAccount().name)
&& getStorageManager() != null && getStorageManager() != null
) { ) {
/*
refeshListOfFilesFragment(); refeshListOfFilesFragment();
*/
} }
if ((getSharesResult != null) && if ((getSharesResult != null) &&
RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(getSharesResult.getCode())) { RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(getSharesResult.getCode())) {
@ -1224,10 +1236,13 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public void onFileStateChanged() { public void onFileStateChanged() {
/* TODO WIP COMMENT
refeshListOfFilesFragment(); refeshListOfFilesFragment();
updateNavigationElementsInActionBar(getSecondFragment().getFile()); updateNavigationElementsInActionBar(getSecondFragment().getFile());
*/
} }
@ -1362,7 +1377,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) { private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) {
if (result.isSuccess()) { if (result.isSuccess()) {
refreshShowDetails(); refreshShowDetails();
/* TODO WIP COMMENT
refeshListOfFilesFragment(); refeshListOfFilesFragment();
*/
} }
} }
@ -1370,10 +1387,14 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) { private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) {
if (result.isSuccess()) { if (result.isSuccess()) {
refreshShowDetails(); refreshShowDetails();
/*
refeshListOfFilesFragment(); refeshListOfFilesFragment();
*/
} else if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { } else if (result.getCode() == ResultCode.SHARE_NOT_FOUND) {
cleanSecondFragment(); cleanSecondFragment();
/*
refeshListOfFilesFragment(); refeshListOfFilesFragment();
*/
} }
} }
@ -1413,7 +1434,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
cleanSecondFragment(); cleanSecondFragment();
} }
if (getStorageManager().getFileById(removedFile.getParentId()).equals(getCurrentDir())) { if (getStorageManager().getFileById(removedFile.getParentId()).equals(getCurrentDir())) {
/*
refeshListOfFilesFragment(); refeshListOfFilesFragment();
*/
} }
} else { } else {
@ -1435,7 +1458,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
private void onCreateFolderOperationFinish(CreateFolderOperation operation, RemoteOperationResult result) { private void onCreateFolderOperationFinish(CreateFolderOperation operation, RemoteOperationResult result) {
if (result.isSuccess()) { if (result.isSuccess()) {
dismissLoadingDialog(); dismissLoadingDialog();
/* TODO WIP COMMENT
refeshListOfFilesFragment(); refeshListOfFilesFragment();
*/
} else { } else {
dismissLoadingDialog(); dismissLoadingDialog();
@ -1472,7 +1497,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
} }
} }
if (getStorageManager().getFileById(renamedFile.getParentId()).equals(getCurrentDir())) { if (getStorageManager().getFileById(renamedFile.getParentId()).equals(getCurrentDir())) {
/*
refeshListOfFilesFragment(); refeshListOfFilesFragment();
*/
} }
} else { } else {
@ -1509,7 +1536,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
} else { } else {
if (operation.transferWasRequested()) { if (operation.transferWasRequested()) {
/*
refeshListOfFilesFragment(); refeshListOfFilesFragment();
*/
onTransferStateChanged(syncedFile, true, true); onTransferStateChanged(syncedFile, true, true);
} else { } else {

View file

@ -854,7 +854,9 @@ public class FileDetailFragment extends FileFragment implements
if (result.isSuccess()) { if (result.isSuccess()) {
updateFileDetails(((RenameFileOperation)operation).getFile(), mAccount); updateFileDetails(((RenameFileOperation)operation).getFile(), mAccount);
/* TODO WIP COMMENT
mContainerActivity.onFileStateChanged(); mContainerActivity.onFileStateChanged();
*/
} else { } else {
if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) { if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) {
@ -896,8 +898,10 @@ public class FileDetailFragment extends FileFragment implements
} else { } else {
if (operation.transferWasRequested()) { if (operation.transferWasRequested()) {
setButtonsForTransferring(); setButtonsForTransferring();
/* TODO WIP COMMENT
mContainerActivity.onFileStateChanged(); // this is not working; FileDownloader won't do NOTHING at all until this method finishes, so 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 // checking the service to see if the file is downloading results in FALSE
*/
} else { } else {
Toast msg = Toast.makeText(getActivity(), R.string.sync_file_nothing_to_do_msg, Toast.LENGTH_LONG); Toast msg = Toast.makeText(getActivity(), R.string.sync_file_nothing_to_do_msg, Toast.LENGTH_LONG);
msg.show(); msg.show();