Created
June 24, 2020 08:24
-
-
Save DevHossamHassan/b29d00d0020a218ccf07d8ea70e6fa15 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.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