Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
przybylski committed Jun 20, 2016
1 parent f054c7d commit 7eed96e
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/org/nextcloud/providers/DocumentsStorageProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public Cursor queryDocument(String documentId, String[] projection) throws FileN
updateCurrentStorageManagerIfNeeded(docId);

final FileCursor result = new FileCursor(projection);
result.addFile(mCurrentStorageManager.getFileById(docId));
OCFile file = mCurrentStorageManager.getFileById(docId);
if (file != null)
result.addFile(file);

return result;
}
Expand All @@ -84,8 +86,9 @@ public Cursor queryChildDocuments(String parentDocumentId, String[] projection,
final FileCursor result = new FileCursor(projection);

final OCFile browsedDir = mCurrentStorageManager.getFileById(folderId);
for (OCFile file : mCurrentStorageManager.getFolderContent(browsedDir))
for (OCFile file : mCurrentStorageManager.getFolderContent(browsedDir)) {
result.addFile(file);
}

return result;
}
Expand All @@ -106,8 +109,9 @@ public ParcelFileDescriptor openDocument(String documentId, String mode, Cancell
getContext().startService(i);

do {
if (!waitOrGetCancelled(cancellationSignal))
if (!waitOrGetCancelled(cancellationSignal)) {
return null;
}
file = mCurrentStorageManager.getFileById(docId);

} while (!file.isDown());
Expand All @@ -123,7 +127,10 @@ public boolean onCreate() {
}

@Override
public AssetFileDescriptor openDocumentThumbnail(String documentId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException {
public AssetFileDescriptor openDocumentThumbnail(String documentId,
Point sizeHint,
CancellationSignal signal)
throws FileNotFoundException {
long docId = Long.parseLong(documentId);
updateCurrentStorageManagerIfNeeded(docId);

Expand All @@ -144,8 +151,9 @@ public Cursor querySearchDocuments(String rootId, String query, String[] project
OCFile root = mCurrentStorageManager.getFileByPath("/");
FileCursor result = new FileCursor(projection);

for (OCFile f : findFiles(root, query))
for (OCFile f : findFiles(root, query)) {
result.addFile(f);
}

return result;
}
Expand All @@ -160,8 +168,9 @@ private void updateCurrentStorageManagerIfNeeded(long docId) {

private void updateCurrentStorageManagerIfNeeded(String rootId) {
for (FileDataStorageManager data : mRootIdToStorageManager.values())
if (data.getAccount().name.equals(rootId))
if (data.getAccount().name.equals(rootId)) {
mCurrentStorageManager = data;
}
}

private void initiateStorageMap() {
Expand All @@ -186,8 +195,9 @@ private boolean waitOrGetCancelled(CancellationSignal cancellationSignal) {
return false;
}

if (cancellationSignal != null && cancellationSignal.isCanceled())
if (cancellationSignal != null && cancellationSignal.isCanceled()) {
return false;
}

return true;
}
Expand All @@ -197,9 +207,8 @@ Vector<OCFile> findFiles(OCFile root, String query) {
for (OCFile f : mCurrentStorageManager.getFolderContent(root)) {
if (f.isFolder()) {
result.addAll(findFiles(f, query));
} else {
if (f.getFileName().contains(query))
result.add(f);
} else if (f.getFileName().contains(query)) {
result.add(f);
}
}
return result;
Expand Down

0 comments on commit 7eed96e

Please sign in to comment.