Skip to content

Instantly share code, notes, and snippets.

@adrianhall
Last active March 28, 2018 19:46
Show Gist options
  • Save adrianhall/15a506022730202d3e83820cb3cd82b1 to your computer and use it in GitHub Desktop.
Save adrianhall/15a506022730202d3e83820cb3cd82b1 to your computer and use it in GitHub Desktop.
Boilerplate code for the AWSProvider
package com.amazonaws.mobile.samples.customauth
import android.content.Context
import com.amazonaws.auth.CognitoCachingCredentialsProvider
import com.amazonaws.mobile.config.AWSConfiguration
class AWSProvider {
companion object {
private var mConfiguration: AWSConfiguration? = null
private var mCredentialsProvider: Cognito
private var mInstance: AWSProvider? = null
/**
* Read-only property for storing the AWSConfiguration
*/
var configuration: AWSConfiguration?
get() = mConfiguration
private set(value) { mConfiguration = value }
/**
* Read-only property for storing the current instance
*/
var instance: AWSProvider?
get() = mInstance
private set(value) { mInstance = value }
/**
* Read-only property for storing the Amazon Cognito credentials provider
*/
var credentialsProvider: CognitoCachingCredentialsProvider?
get() = mCredentialsProvider
private set(value) { mCredentialsProvider = value }
/**
* Initialize the AWSProvider
*
* @param context the application context
*/
@Synchronized
fun initialize(context: Context) {
configuration = AWSConfiguration(context)
credentialsProvider = CognitoCachingCredentialsProvider(context, configuration)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment