From ec82897b2cd3ed12a7f8c0110e57838af21468b3 Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 25 Apr 2024 17:29:49 +0800 Subject: [PATCH] Use SocialApp as the context param --- app/src/main/java/androidx/core/app/Person.java | 4 +++- .../com/google/android/samples/socialite/SocialApp.kt | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/androidx/core/app/Person.java b/app/src/main/java/androidx/core/app/Person.java index af285162..f2c5aab9 100644 --- a/app/src/main/java/androidx/core/app/Person.java +++ b/app/src/main/java/androidx/core/app/Person.java @@ -28,6 +28,8 @@ import androidx.annotation.RestrictTo; import androidx.core.graphics.drawable.IconCompat; +import com.google.android.samples.socialite.SocialApp; + import java.util.Objects; /** @@ -424,7 +426,7 @@ static Person fromAndroidPerson(android.app.Person person) { static android.app.Person toAndroidPerson(Person person) { return new android.app.Person.Builder() .setName(person.getName()) - .setIcon((person.getIcon() != null) ? person.getIcon().toIcon() : null) + .setIcon((person.getIcon() != null) ? person.getIcon().toIcon(SocialApp.app) : null) .setUri(person.getUri()) .setKey(person.getKey()) .setBot(person.isBot()) diff --git a/app/src/main/java/com/google/android/samples/socialite/SocialApp.kt b/app/src/main/java/com/google/android/samples/socialite/SocialApp.kt index d340cd02..ed384a2f 100644 --- a/app/src/main/java/com/google/android/samples/socialite/SocialApp.kt +++ b/app/src/main/java/com/google/android/samples/socialite/SocialApp.kt @@ -19,4 +19,13 @@ import android.app.Application import dagger.hilt.android.HiltAndroidApp @HiltAndroidApp -class SocialApp : Application() +class SocialApp : Application() { + override fun onCreate() { + super.onCreate() + app = this + } + + companion object { + lateinit var app: SocialApp + } +}