Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MagicWeather part 2 #458

Merged
merged 1 commit into from Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2,6 +2,7 @@ package com.revenuecat.sample

import android.app.Application
import com.revenuecat.purchases.Purchases
import com.revenuecat.purchases.PurchasesConfiguration
import com.revenuecat.purchases.interfaces.UpdatedCustomerInfoListener
import com.revenuecat.sample.data.Constants
import com.revenuecat.sample.ui.user.UserViewModel
Expand All @@ -21,7 +22,10 @@ class MainApplication : Application() {
- appUserID is nil, so an anonymous ID will be generated automatically by the Purchases SDK. Read more about Identifying Users here: https://docs.revenuecat.com/docs/user-ids
- observerMode is false, so Purchases will automatically handle finishing transactions. Read more about Observer Mode here: https://docs.revenuecat.com/docs/observer-mode
*/
Purchases.configure(this, Constants.API_KEY, null, false)
val builder = PurchasesConfiguration.Builder(this, Constants.API_KEY)
.appUserID(null)
.observerMode(false)
Purchases.configure(builder.build())

/*
Whenever the `sharedInstance` of Purchases updates the CustomerInfo cache, this method will be called.
Expand Down
Expand Up @@ -47,7 +47,7 @@ class SampleWeatherData(val emoji: String, val temperature: String) {
fun generateSampleData(environment: Environment, temperature: Int?): SampleWeatherData {
val temp: Int = temperature ?: Random.nextInt(-20, 120)

var emoji: String
val emoji: String
when (temp) {
in 0..32 -> {
emoji = "❄️"
Expand Down
Expand Up @@ -21,7 +21,7 @@ class PaywallFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
root = inflater.inflate(R.layout.fragment_paywall, container, false)

recyclerView = root.findViewById(R.id.paywall_list)
Expand Down
Expand Up @@ -25,7 +25,7 @@ class UserFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
userViewModel = UserViewModel.shared

root = inflater.inflate(R.layout.fragment_user, container, false)
Expand Down Expand Up @@ -106,11 +106,11 @@ class UserFragment : Fragment() {
/*
Call `identify` with the Purchases SDK with the unique user ID
*/
Purchases.sharedInstance.identifyWith(input.text.toString(),
Purchases.sharedInstance.logInWith(input.text.toString(),
onError = { error ->
buildError(context, error.message)
},
onSuccess = { info ->
onSuccess = { info, _ ->
updateUserDetails(info)
})
}
Expand All @@ -119,7 +119,7 @@ class UserFragment : Fragment() {

alert.show()
} else {
Purchases.sharedInstance.resetWith {}
Purchases.sharedInstance.logOut()
}
}
}
Expand Up @@ -26,7 +26,7 @@ class WeatherFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
weatherViewModel = WeatherViewModel.shared

root = inflater.inflate(R.layout.fragment_weather, container, false)
Expand Down