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

View file

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

View file

@ -251,10 +251,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
public void onResume() {
super.onResume();
if (remoteOperationAsyncTask != null) {
remoteOperationAsyncTask.cancel(true);
}
if (getActivity() != null) {
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));
if (searchEvent != null) {
if (searchEvent != null && searchFragment) {
onMessageEvent(searchEvent);
}
}
@ -964,10 +960,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
public void refreshDirectory() {
searchFragment = false;
if (remoteOperationAsyncTask != null) {
remoteOperationAsyncTask.cancel(true);
}
setFabEnabled(true);
listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice(), false);
}
@ -1449,8 +1441,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
} else {
new Handler(Looper.getMainLooper()).post(switchViewsRunnable);
}
searchEvent = null;
}
private void setTitle(@StringRes int title) {
@ -1474,7 +1464,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
public void onRefresh() {
super.onRefresh();
if (searchEvent != null) {
if (searchEvent != null && searchFragment) {
onMessageEvent(searchEvent);
}
}