Created
March 23, 2018 18:41
-
-
Save adrianhall/572a137f40958fd9abd9e78cb9597f81 to your computer and use it in GitHub Desktop.
AWS Provider Class for abstracting the Analytics Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.amazon.aws.mobile.samples.tasks.providers | |
import android.content.Context | |
import com.amazonaws.auth.AWSCredentialsProvider | |
import com.amazonaws.mobile.client.AWSMobileClient | |
import com.amazonaws.mobile.config.AWSConfiguration | |
class AWSProvider { | |
companion object { | |
var instance: AWSMobileClient? = null | |
val credentialsProvider: AWSCredentialsProvider? | |
get() = instance?.credentialsProvider | |
val configuration: AWSConfiguration? | |
get() = instance?.configuration | |
@Synchronized | |
fun initialize(context: Context) { | |
if (instance == null) { | |
AWSMobileClient.getInstance().initialize(context).execute() | |
instance = AWSMobileClient.getInstance() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment