Skip to content

Instantly share code, notes, and snippets.

@DevHossamHassan
Created June 24, 2020 08:24
Show Gist options
  • Select an option

  • Save DevHossamHassan/b29d00d0020a218ccf07d8ea70e6fa15 to your computer and use it in GitHub Desktop.

Select an option

Save DevHossamHassan/b29d00d0020a218ccf07d8ea70e6fa15 to your computer and use it in GitHub Desktop.
package com.truecaller.sdk.samples
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.Glide
import com.truecaller.android.sdk.TrueProfile
import kotlinx.android.synthetic.main.create_profile_activity.avatarImageView
import kotlinx.android.synthetic.main.create_profile_activity.emailEditText
import kotlinx.android.synthetic.main.create_profile_activity.firstNameEditText
import kotlinx.android.synthetic.main.create_profile_activity.lastNameEditText
class CreateProfileActivity : AppCompatActivity() {
companion object {
private const val EXTRA_TRUE_PROFILE = "extra_true_profile"
fun startIntent(context: Context, profile: TrueProfile? = null) =
Intent(context, CreateProfileActivity::class.java).also { intent ->
intent.putExtra(EXTRA_TRUE_PROFILE, profile)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.create_profile_activity)
if (savedInstanceState == null) {
val trueProfile = intent.getParcelableExtra<TrueProfile>(EXTRA_TRUE_PROFILE)
trueProfile?.let(::fillProfile)
}
}
private fun fillProfile(trueProfile: TrueProfile) {
trueProfile.avatarUrl?.let { avatarUrl ->
Glide.with(this)
.load(avatarUrl)
.circleCrop()
.into(avatarImageView)
}
firstNameEditText.setText(trueProfile.firstName)
lastNameEditText.setText(trueProfile.lastName)
emailEditText.setText(trueProfile.email)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment