- search view shows data again

- no crash while rotation during search view is populated
This commit is contained in:
tobiasKaminsky 2017-04-30 12:14:39 +02:00 committed by Mario Danic
parent 0dc569bc94
commit 6c2d881dfe
3 changed files with 11 additions and 21 deletions

View file

@ -251,7 +251,7 @@ public class FileDataStorageManager {
return overriden; return overriden;
} }
public long saveFileWithParent(OCFile file, Context context) { public OCFile saveFileWithParent(OCFile file, Context context) {
if (file.getParentId() != 0 || file.getRemotePath().equals("/")) { if (file.getParentId() != 0 || file.getRemotePath().equals("/")) {
saveFile(file); saveFile(file);
@ -261,7 +261,7 @@ public class FileDataStorageManager {
OCFile parentFile = getFileByPath(parentPath); OCFile parentFile = getFileByPath(parentPath);
long fileId; OCFile returnFile;
if (parentFile == null) { if (parentFile == null) {
// remote request // remote request
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(parentPath); ReadRemoteFileOperation operation = new ReadRemoteFileOperation(parentPath);
@ -269,20 +269,20 @@ public class FileDataStorageManager {
if (result.isSuccess()) { if (result.isSuccess()) {
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0)); OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
fileId = saveFileWithParent(remoteFolder, context); returnFile = saveFileWithParent(remoteFolder, context);
} else { } else {
fileId = -1; returnFile = null;
Log_OC.e(TAG, "Error during saving file with parents: " + file.getRemotePath()); Log_OC.e(TAG, "Error during saving file with parents: " + file.getRemotePath());
} }
} else { } else {
fileId = saveFileWithParent(parentFile, context); returnFile = saveFileWithParent(parentFile, context);
} }
file.setParentId(fileId); file.setParentId(returnFile.getFileId());
saveFile(file); saveFile(file);
} }
return getFileByPath(file.getRemotePath()).getFileId(); return file;
} }
public void saveNewFile(OCFile newFile) { public void saveNewFile(OCFile newFile) {

View file

@ -561,8 +561,8 @@ public class FileListListAdapter extends BaseAdapter {
for (int i = 0; i < objects.size(); i++) { for (int i = 0; i < objects.size(); i++) {
OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) objects.get(i)); OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) objects.get(i));
searchForLocalFileInDefaultPath(ocFile); searchForLocalFileInDefaultPath(ocFile);
mStorageManager.saveFileWithParent(ocFile, mContext); ocFile = mStorageManager.saveFileWithParent(ocFile, mContext);
mStorageManager.saveVirtual(type, mStorageManager.getFileByPath(ocFile.getRemotePath())); mStorageManager.saveVirtual(type, ocFile);
} }
mFiles.addAll(mStorageManager.getVirtualFolderContent(type, onlyImages)); mFiles.addAll(mStorageManager.getVirtualFolderContent(type, onlyImages));

View file

@ -251,10 +251,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (remoteOperationAsyncTask != null) {
remoteOperationAsyncTask.cancel(true);
}
if (getActivity() != null) { if (getActivity() != null) {
AnalyticsUtils.setCurrentScreenName(getActivity(), SCREEN_NAME, TAG); AnalyticsUtils.setCurrentScreenName(getActivity(), SCREEN_NAME, TAG);
} }
@ -322,7 +318,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
} }
searchEvent = Parcels.unwrap(getArguments().getParcelable(OCFileListFragment.SEARCH_EVENT)); searchEvent = Parcels.unwrap(getArguments().getParcelable(OCFileListFragment.SEARCH_EVENT));
if (searchEvent != null) { if (searchEvent != null && searchFragment) {
onMessageEvent(searchEvent); onMessageEvent(searchEvent);
} }
} }
@ -964,10 +960,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
public void refreshDirectory() { public void refreshDirectory() {
searchFragment = false; searchFragment = false;
if (remoteOperationAsyncTask != null) {
remoteOperationAsyncTask.cancel(true);
}
setFabEnabled(true); setFabEnabled(true);
listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice(), false); listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice(), false);
} }
@ -1449,8 +1441,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
} else { } else {
new Handler(Looper.getMainLooper()).post(switchViewsRunnable); new Handler(Looper.getMainLooper()).post(switchViewsRunnable);
} }
searchEvent = null;
} }
private void setTitle(@StringRes int title) { private void setTitle(@StringRes int title) {
@ -1474,7 +1464,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
public void onRefresh() { public void onRefresh() {
super.onRefresh(); super.onRefresh();
if (searchEvent != null) { if (searchEvent != null && searchFragment) {
onMessageEvent(searchEvent); onMessageEvent(searchEvent);
} }
} }