Rewrite 'messages' to Kotlin

This commit is contained in:
Niko Diamadis
2022-12-26 01:22:11 +01:00
parent ec5761a948
commit b75cb740b9
26 changed files with 1318 additions and 1541 deletions

View File

@@ -0,0 +1,34 @@
package com.github.gotify.messages
import android.app.Activity
import androidx.lifecycle.ViewModel
import com.github.gotify.Settings
import com.github.gotify.api.ClientFactory
import com.github.gotify.client.ApiClient
import com.github.gotify.client.api.MessageApi
import com.github.gotify.messages.provider.ApplicationHolder
import com.github.gotify.messages.provider.MessageFacade
import com.github.gotify.messages.provider.MessageState
import com.github.gotify.picasso.PicassoHandler
import com.squareup.picasso.Target
class MessagesModel(parentView: Activity) : ViewModel() {
val settings: Settings
val picassoHandler: PicassoHandler
val client: ApiClient
val appsHolder: ApplicationHolder
val messages: MessageFacade
// we need to keep the target references otherwise they get gc'ed before they can be called.
val targetReferences = mutableListOf<Target>()
var appId = MessageState.ALL_MESSAGES
init {
settings = Settings(parentView)
picassoHandler = PicassoHandler(parentView, settings)
client = ClientFactory.clientToken(settings.url(), settings.sslSettings(), settings.token())
appsHolder = ApplicationHolder(parentView, client)
messages = MessageFacade(client.createService(MessageApi::class.java), appsHolder)
}
}