From: David A. Velasco Date: Wed, 4 Jul 2012 13:44:59 +0000 (+0200) Subject: Small improvements to the refresh of the files list and memory handling while synchro... X-Git-Tag: oc-android-1.4.3~312 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/882668c5d90e1b0871a413a9e082c67fe1b26fef Small improvements to the refresh of the files list and memory handling while synchronization is running --- diff --git a/AndroidManifest.xml b/AndroidManifest.xml index d2d03e62..4f334df4 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -18,7 +18,7 @@ --> + android:versionName="0.1.144B" xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java b/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java index 230d3a75..0bd2ec2b 100644 --- a/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java +++ b/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java @@ -21,7 +21,9 @@ package eu.alefzero.owncloud.syncadapter; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; +import java.util.Queue; import java.util.Vector; import org.apache.jackrabbit.webdav.DavException; @@ -70,7 +72,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { Log.d(TAG, "syncing owncloud account " + account.name); - sendStickyBroadcast(true, -1); // starting message to UI + sendStickyBroadcast(true, -1); // message to signal the start to the UI PropFindMethod query; try { @@ -108,8 +110,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { getClient().executeMethod(query); MultiStatus resp = null; resp = query.getResponseBodyAsMultiStatus(); - List paths = new ArrayList(); - List fileIds = new ArrayList(); + Queue paths = new LinkedList(); + Queue fileIds = new LinkedList(); for (int i = 1; i < resp.getResponses().length; ++i) { WebdavEntry we = new WebdavEntry(resp.getResponses()[i], getUri().getPath()); OCFile file = fillOCFile(we); @@ -135,11 +137,11 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { sendStickyBroadcast(true, parentId); // recursive fetch - Iterator pathsIt = paths.iterator(); - Iterator fileIdsIt = fileIds.iterator(); - while (pathsIt.hasNext()) { - fetchData(getUri().toString() + pathsIt.next(), syncResult, fileIdsIt.next()); + while(!paths.isEmpty()) { + fetchData(getUri().toString() + paths.remove(), syncResult, fileIds.remove()); } + paths = null; + fileIds = null; } catch (OperationCanceledException e) { diff --git a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java b/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java index 2c4ae382..74c2ee5b 100644 --- a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java +++ b/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java @@ -610,32 +610,34 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements FileSyncService.IN_PROGRESS, false); String account_name = intent .getStringExtra(FileSyncService.ACCOUNT_NAME); + Log.d("FileDisplay", "sync of account " + account_name + " is in_progress: " + inProgress); - setSupportProgressBarIndeterminateVisibility(inProgress); + + //if (account_name.equals(AccountUtils.getCurrentOwnCloudAccount(context).name)) { // TODO - probably this check should be added, but won't push it until really tests are done; no time now - long OCDirId = intent.getLongExtra(FileSyncService.SYNC_FOLDER, -1); - if (OCDirId >= 0) { - OCFile syncDir = mStorageManager.getFileById(OCDirId); - if (syncDir != null && ( - (mCurrentDir == null && syncDir.getFileName().equals("/")) || - syncDir.equals(mCurrentDir)) - ) { - FileListFragment fileListFragment = (FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList); - if (fileListFragment != null) { - fileListFragment.listDirectory(); + /// try to refresh the view with every message received from the FileSyncAdapter; brute, but more user friendly when there are a lot of files in the server + OCFile currentDir; + if (mCurrentDir == null) + currentDir = mStorageManager.getFileByPath("/"); + else + currentDir = mStorageManager.getFileByPath(mCurrentDir.getRemotePath()); + + if (currentDir != null) { + mCurrentDir = currentDir; + FileListFragment fileListFragment = (FileListFragment) getSupportFragmentManager() + .findFragmentById(R.id.fileList); + if (fileListFragment != null) { + if (!mCurrentDir.equals(fileListFragment.getCurrentFile())) { + fileListFragment.listDirectory(mCurrentDir); // only set the directory in the fragment first time + } else + fileListFragment.listDirectory(); // enough to show new files in the current directory if they are added after } } - } - - if (!inProgress) { - FileListFragment fileListFragment = (FileListFragment) getSupportFragmentManager() - .findFragmentById(R.id.fileList); - if (fileListFragment != null) - fileListFragment.listDirectory(); - } + + setSupportProgressBarIndeterminateVisibility(inProgress); + //} } - }