use of com.owncloud.android.lib.resources.files.ToggleFavoriteRemoteOperation in project android by nextcloud.
the class OCFileListFragment method onMessageEvent.
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(FavoriteEvent event) {
try {
User user = accountManager.getUser();
OwnCloudClient client = clientFactory.create(user);
ToggleFavoriteRemoteOperation toggleFavoriteOperation = new ToggleFavoriteRemoteOperation(event.shouldFavorite, event.remotePath);
RemoteOperationResult remoteOperationResult = toggleFavoriteOperation.execute(client);
if (remoteOperationResult.isSuccess()) {
boolean removeFromList = currentSearchType == SearchType.FAVORITE_SEARCH && !event.shouldFavorite;
mAdapter.setFavoriteAttributeForItemID(event.remoteId, event.shouldFavorite, removeFromList);
}
} catch (ClientFactory.CreationException e) {
Log_OC.e(TAG, "Error processing event", e);
}
}
use of com.owncloud.android.lib.resources.files.ToggleFavoriteRemoteOperation in project android by nextcloud.
the class FileDetailFragment method onMessageEvent.
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(FavoriteEvent event) {
try {
User user = accountManager.getUser();
OwnCloudClient client = clientFactory.create(user);
ToggleFavoriteRemoteOperation toggleFavoriteOperation = new ToggleFavoriteRemoteOperation(event.shouldFavorite, event.remotePath);
RemoteOperationResult remoteOperationResult = toggleFavoriteOperation.execute(client);
if (remoteOperationResult.isSuccess()) {
getFile().setFavorite(event.shouldFavorite);
OCFile file = storageManager.getFileByEncryptedRemotePath(event.remotePath);
file.setFavorite(event.shouldFavorite);
storageManager.saveFile(file);
}
} catch (ClientFactory.CreationException e) {
Log_OC.e(TAG, "Error processing event", e);
}
}
Aggregations