From: Bartek Przybylski Date: Sat, 7 Apr 2012 12:53:05 +0000 (+0200) Subject: small optimization for ocfile X-Git-Tag: oc-android-1.4.3~471 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/8db0692daf94db68e08d765dcc3e57f0de638d28?ds=inline small optimization for ocfile --- diff --git a/src/eu/alefzero/owncloud/datamodel/OCFile.java b/src/eu/alefzero/owncloud/datamodel/OCFile.java index f377a047..736a5de3 100644 --- a/src/eu/alefzero/owncloud/datamodel/OCFile.java +++ b/src/eu/alefzero/owncloud/datamodel/OCFile.java @@ -51,7 +51,8 @@ public class OCFile { ProviderTableMeta._ID + "=?", new String[]{account_.name, String.valueOf(id)}, null); - setFileData(c); + if (c.moveToFirst()) + setFileData(c); } public OCFile(ContentProvider cp, Account account, String path) { @@ -63,8 +64,10 @@ public class OCFile { ProviderTableMeta.FILE_PATH + "=?", new String[]{account_.name, path}, null); - setFileData(c); - if (path_ != null) path_ = path; + if (c.moveToFirst()) { + setFileData(c); + if (path_ != null) path_ = path; + } } public long getFileId() { return id_; } @@ -112,8 +115,8 @@ public class OCFile { if (c.moveToFirst()) do { - long id = c.getLong(c.getColumnIndex(ProviderTableMeta._ID)); - OCFile child = new OCFile(cp_, account_, id); + OCFile child = new OCFile(cp_, account_); + child.setFileData(c); ret.add(child); } while (c.moveToNext()); @@ -122,6 +125,11 @@ public class OCFile { return null; } + private OCFile(ContentProvider cp, Account account) { + account_ = account; + cp_ = cp; + } + private void setFileData(Cursor c) { id_ = -1; path_ = null; @@ -130,7 +138,7 @@ public class OCFile { length_ = 0; creation_timestamp_ = 0; modified_timestamp_ = 0; - if (c != null && c.moveToFirst()) { + if (c != null) { id_ = c.getLong(c.getColumnIndex(ProviderTableMeta._ID)); path_ = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PATH)); storage_path_ = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH));