Isic Discounts Sdk
This class covers following use-cases:
Show Discounts screen
Launch Discounts screen
To launch discounts screen, use IsicDiscountsSdk.launchDiscountsScreen method. See method documentation for more details.
Complete sample code attached below might be helpful.
Customize UI
The appearance/behaviour of the screen can be customized in following ways:
Default location can be changed
Locale can be changed
Different translations can be provided
Custom (or predefined theme) can be provided
For details, please see UiConfig.
Custom theme
Custom theme can be created by creating a theme extending BaseVirtualIdTheme
.
Example of custom Discounts theme:
<style name="CustomDiscountsIsicTheme" parent="BaseDiscountsIsicTheme">
<item name="isicThemeColor">@color/isic_greeny_blue</item>
<item name="isicThemeColorDull">@color/isic_greeny_blue_dull</item>
</style>
Then provide custom Theme by providing it's resource ID.
Sample
Sample below covers complete functionality provided by IsicDiscountsSdk.
Samples
import android.util.Log
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.isic.sdk.discount.model.*
import org.isic.sdk.discount.IsicDiscountsSdk
fun main() {
//sampleStart
class DiscountsSampleActivity : AppCompatActivity() {
/**
* Launch Discounts screen
*/
private fun launch() {
lifecycleScope.launch() {
IsicDiscountsSdk.launchDiscountsScreen(
activityContext = this@DiscountsSampleActivity,
clientCredentials = clientCredentials,
uiConfig = UiConfig(
locale = "cs",
),
defaultLocation = "Prague, Czechia",
)
}
}
private companion object {
private val clientCredentials: ClientCredentials = ClientCredentials(
clientId = "example-client-id", // TODO: Change me
clientSecret = "example-client-secret", // TODO: Change me
)
}
}
//sampleEnd
}
Functions
Method launching discounts screen.