Search in sources :

Example 1 with PredefinedStatus

use of com.owncloud.android.lib.resources.users.PredefinedStatus in project android by nextcloud.

the class RefreshFolderOperation method updatePredefinedStatus.

private void updatePredefinedStatus(ArbitraryDataProvider arbitraryDataProvider) {
    NextcloudClient client;
    try {
        client = OwnCloudClientFactory.createNextcloudClient(user.toPlatformAccount(), mContext);
    } catch (AccountUtils.AccountNotFoundException | NullPointerException e) {
        Log_OC.e(this, "Update of predefined status not possible!");
        return;
    }
    RemoteOperationResult<ArrayList<PredefinedStatus>> result = new GetPredefinedStatusesRemoteOperation().execute(client);
    if (result.isSuccess()) {
        ArrayList<PredefinedStatus> predefinedStatuses = result.getResultData();
        String json = new Gson().toJson(predefinedStatuses);
        arbitraryDataProvider.storeOrUpdateKeyValue(user.getAccountName(), ArbitraryDataProvider.PREDEFINED_STATUS, json);
    } else {
        arbitraryDataProvider.deleteKeyForAccount(user.getAccountName(), ArbitraryDataProvider.PREDEFINED_STATUS);
    }
}
Also used : NextcloudClient(com.nextcloud.common.NextcloudClient) GetPredefinedStatusesRemoteOperation(com.owncloud.android.lib.resources.users.GetPredefinedStatusesRemoteOperation) PredefinedStatus(com.owncloud.android.lib.resources.users.PredefinedStatus) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson)

Aggregations

Gson (com.google.gson.Gson)1 NextcloudClient (com.nextcloud.common.NextcloudClient)1 GetPredefinedStatusesRemoteOperation (com.owncloud.android.lib.resources.users.GetPredefinedStatusesRemoteOperation)1 PredefinedStatus (com.owncloud.android.lib.resources.users.PredefinedStatus)1 ArrayList (java.util.ArrayList)1