mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 07:05:49 +03:00
Merge pull request #8833 from nextcloud/fixNPE
catch AccountNotFoundException from createNextcloudClient
This commit is contained in:
commit
8090cd0e13
4 changed files with 40 additions and 8 deletions
|
@ -25,12 +25,20 @@ package com.nextcloud.ui
|
|||
import android.accounts.Account
|
||||
import android.content.Context
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.users.ClearStatusMessageRemoteOperation
|
||||
|
||||
public class ClearStatusTask(val account: Account?, val context: Context?) : Function0<Boolean> {
|
||||
override fun invoke(): Boolean {
|
||||
return try {
|
||||
val client = OwnCloudClientFactory.createNextcloudClient(account, context)
|
||||
|
||||
return ClearStatusMessageRemoteOperation().execute(client).isSuccess
|
||||
ClearStatusMessageRemoteOperation().execute(client).isSuccess
|
||||
} catch (e: AccountUtils.AccountNotFoundException) {
|
||||
Log_OC.e(this, "Error clearing status", e)
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ package com.nextcloud.ui
|
|||
import android.accounts.Account
|
||||
import android.content.Context
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.users.SetPredefinedCustomStatusMessageRemoteOperation
|
||||
|
||||
public class SetPredefinedCustomStatusTask(
|
||||
|
@ -34,8 +36,14 @@ public class SetPredefinedCustomStatusTask(
|
|||
val context: Context?
|
||||
) : Function0<Boolean> {
|
||||
override fun invoke(): Boolean {
|
||||
return try {
|
||||
val client = OwnCloudClientFactory.createNextcloudClient(account, context)
|
||||
|
||||
return SetPredefinedCustomStatusMessageRemoteOperation(messageId, clearAt).execute(client).isSuccess
|
||||
SetPredefinedCustomStatusMessageRemoteOperation(messageId, clearAt).execute(client).isSuccess
|
||||
} catch (e: AccountUtils.AccountNotFoundException) {
|
||||
Log_OC.e(this, "Error setting predefined status", e)
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ package com.nextcloud.ui
|
|||
import android.accounts.Account
|
||||
import android.content.Context
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.users.SetStatusRemoteOperation
|
||||
import com.owncloud.android.lib.resources.users.StatusType
|
||||
|
||||
|
@ -34,8 +36,14 @@ class SetStatusTask(
|
|||
val context: Context?
|
||||
) : Function0<Boolean> {
|
||||
override fun invoke(): Boolean {
|
||||
return try {
|
||||
val client = OwnCloudClientFactory.createNextcloudClient(account, context)
|
||||
|
||||
return SetStatusRemoteOperation(statusType).execute(client).isSuccess
|
||||
SetStatusRemoteOperation(statusType).execute(client).isSuccess
|
||||
} catch (e: AccountUtils.AccountNotFoundException) {
|
||||
Log_OC.e(this, "Error setting status", e)
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ package com.nextcloud.ui
|
|||
import android.accounts.Account
|
||||
import android.content.Context
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.users.SetUserDefinedCustomStatusMessageRemoteOperation
|
||||
|
||||
public class SetUserDefinedCustomStatusTask(
|
||||
|
@ -35,8 +37,14 @@ public class SetUserDefinedCustomStatusTask(
|
|||
val context: Context?
|
||||
) : Function0<Boolean> {
|
||||
override fun invoke(): Boolean {
|
||||
return try {
|
||||
val client = OwnCloudClientFactory.createNextcloudClient(account, context)
|
||||
|
||||
return SetUserDefinedCustomStatusMessageRemoteOperation(message, icon, clearAt).execute(client).isSuccess
|
||||
} catch (e: AccountUtils.AccountNotFoundException) {
|
||||
Log_OC.e(this, "Error setting user defined custom status", e)
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue