use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.
the class OCFileListFragment method handleSearchEvent.
private void handleSearchEvent(SearchEvent event) {
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.getSearchType()) {
return;
}
prepareCurrentSearch(event);
searchFragment = true;
setEmptyListLoadingMessage();
mAdapter.setData(new ArrayList<>(), SearchType.NO_SEARCH, mContainerActivity.getStorageManager(), mFile, true);
setFabVisible(false);
Runnable switchViewsRunnable = () -> {
if (isGridViewPreferred(mFile) && !isGridEnabled()) {
switchToGridView();
} else if (!isGridViewPreferred(mFile) && isGridEnabled()) {
switchToListView();
}
};
new Handler(Looper.getMainLooper()).post(switchViewsRunnable);
final User currentUser = accountManager.getUser();
final RemoteOperation remoteOperation;
if (currentSearchType != SearchType.SHARED_FILTER) {
boolean searchOnlyFolders = false;
if (getArguments() != null && getArguments().getBoolean(ARG_SEARCH_ONLY_FOLDER, false)) {
searchOnlyFolders = true;
}
OCCapability ocCapability = mContainerActivity.getStorageManager().getCapability(currentUser.getAccountName());
remoteOperation = new SearchRemoteOperation(event.getSearchQuery(), event.getSearchType(), searchOnlyFolders, ocCapability);
} else {
remoteOperation = new GetSharesRemoteOperation();
}
remoteOperationAsyncTask = new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... voids) {
setTitle();
if (getContext() != null && !isCancelled()) {
RemoteOperationResult remoteOperationResult = remoteOperation.execute(currentUser.toPlatformAccount(), getContext());
FileDataStorageManager storageManager = null;
if (mContainerActivity != null && mContainerActivity.getStorageManager() != null) {
storageManager = mContainerActivity.getStorageManager();
}
if (remoteOperationResult.isSuccess() && remoteOperationResult.getResultData() != null && !isCancelled() && searchFragment) {
searchEvent = event;
if (remoteOperationResult.getResultData() == null || ((List) remoteOperationResult.getResultData()).isEmpty()) {
setEmptyView(event);
} else {
mAdapter.setData(((RemoteOperationResult<List>) remoteOperationResult).getResultData(), currentSearchType, storageManager, mFile, true);
}
final ToolbarActivity fileDisplayActivity = (ToolbarActivity) getActivity();
if (fileDisplayActivity != null) {
fileDisplayActivity.runOnUiThread(() -> {
if (fileDisplayActivity != null) {
setLoading(false);
}
});
}
}
return remoteOperationResult.isSuccess();
} else {
return Boolean.FALSE;
}
}
@Override
protected void onPostExecute(Boolean bool) {
if (!isCancelled()) {
mAdapter.notifyDataSetChanged();
}
}
};
remoteOperationAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations