-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1012] Context#findActivity util 함수 추가
- AndroidX의 LocalActivity 코드 참고 https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:activity/activity-compose/src/main/java/androidx/activity/compose/LocalActivity.kt;l=34?q=LocalActivity
- Loading branch information
Showing
2 changed files
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
|
||
plugins { | ||
sopt("feature") | ||
sopt("compose") | ||
} | ||
|
||
android { | ||
|
15 changes: 15 additions & 0 deletions
15
core/common/src/main/java/org/sopt/official/common/context/Actvity.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.sopt.official.common.context | ||
|
||
import android.content.Context | ||
import android.content.ContextWrapper | ||
|
||
inline fun <reified T> Context.findActivity(): T? { | ||
var context = this | ||
while (context is ContextWrapper) { | ||
if (context is T) { | ||
return context | ||
} | ||
context = context.baseContext | ||
} | ||
return null | ||
} |