Loading app/src/main/kotlin/at/bitfire/davdroid/servicedetection/RefreshCollectionsWorker.kt +14 −7 Original line number Diff line number Diff line Loading @@ -168,11 +168,16 @@ class RefreshCollectionsWorker @AssistedInject constructor( } val serviceId: Long = inputData.getLong(ARG_SERVICE_ID, -1) override fun doWork(): Result { val service = db.serviceDao().get(serviceId) ?: throw IllegalArgumentException("Service #$serviceId not found") if (service == null) { Logger.log.severe("Service #$serviceId not found") return Result.failure() } val account = Account(service.accountName, service.accountType) override fun doWork(): Result { try { Logger.log.info("Refreshing ${service.type} collections of service #$service") Loading Loading @@ -213,7 +218,8 @@ class RefreshCollectionsWorker @AssistedInject constructor( .putExtra(SettingsActivity.EXTRA_ACCOUNT, account) notifyRefreshError( applicationContext.getString(R.string.sync_error_authentication_failed), settingsIntent settingsIntent, account.name ) return Result.failure() } catch (e: Exception) { Loading @@ -225,7 +231,8 @@ class RefreshCollectionsWorker @AssistedInject constructor( .build() notifyRefreshError( applicationContext.getString(R.string.refresh_collections_worker_refresh_couldnt_refresh), debugIntent debugIntent, account.name ) return Result.failure() } Loading @@ -250,7 +257,7 @@ class RefreshCollectionsWorker @AssistedInject constructor( completer.set(ForegroundInfo(NotificationUtils.NOTIFY_SYNC_EXPEDITED, notification)) } private fun notifyRefreshError(contentText: String, contentIntent: Intent) { private fun notifyRefreshError(contentText: String, contentIntent: Intent, accountName: String) { val notify = NotificationUtils.newBuilder(applicationContext, NotificationUtils.CHANNEL_GENERAL) .setSmallIcon(R.drawable.ic_sync_problem_notify) Loading @@ -264,7 +271,7 @@ class RefreshCollectionsWorker @AssistedInject constructor( PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) ) .setSubText(account.name) .setSubText(accountName) .setCategory(NotificationCompat.CATEGORY_ERROR) .build() NotificationManagerCompat.from(applicationContext) Loading Loading
app/src/main/kotlin/at/bitfire/davdroid/servicedetection/RefreshCollectionsWorker.kt +14 −7 Original line number Diff line number Diff line Loading @@ -168,11 +168,16 @@ class RefreshCollectionsWorker @AssistedInject constructor( } val serviceId: Long = inputData.getLong(ARG_SERVICE_ID, -1) override fun doWork(): Result { val service = db.serviceDao().get(serviceId) ?: throw IllegalArgumentException("Service #$serviceId not found") if (service == null) { Logger.log.severe("Service #$serviceId not found") return Result.failure() } val account = Account(service.accountName, service.accountType) override fun doWork(): Result { try { Logger.log.info("Refreshing ${service.type} collections of service #$service") Loading Loading @@ -213,7 +218,8 @@ class RefreshCollectionsWorker @AssistedInject constructor( .putExtra(SettingsActivity.EXTRA_ACCOUNT, account) notifyRefreshError( applicationContext.getString(R.string.sync_error_authentication_failed), settingsIntent settingsIntent, account.name ) return Result.failure() } catch (e: Exception) { Loading @@ -225,7 +231,8 @@ class RefreshCollectionsWorker @AssistedInject constructor( .build() notifyRefreshError( applicationContext.getString(R.string.refresh_collections_worker_refresh_couldnt_refresh), debugIntent debugIntent, account.name ) return Result.failure() } Loading @@ -250,7 +257,7 @@ class RefreshCollectionsWorker @AssistedInject constructor( completer.set(ForegroundInfo(NotificationUtils.NOTIFY_SYNC_EXPEDITED, notification)) } private fun notifyRefreshError(contentText: String, contentIntent: Intent) { private fun notifyRefreshError(contentText: String, contentIntent: Intent, accountName: String) { val notify = NotificationUtils.newBuilder(applicationContext, NotificationUtils.CHANNEL_GENERAL) .setSmallIcon(R.drawable.ic_sync_problem_notify) Loading @@ -264,7 +271,7 @@ class RefreshCollectionsWorker @AssistedInject constructor( PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) ) .setSubText(account.name) .setSubText(accountName) .setCategory(NotificationCompat.CATEGORY_ERROR) .build() NotificationManagerCompat.from(applicationContext) Loading