Skip to content

Commit

Permalink
[#1012] Context#findActivity util 함수 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
l2hyunwoo committed Jan 2, 2025
1 parent d10b4dc commit dff6d25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

plugins {
sopt("feature")
sopt("compose")
}

android {
Expand Down
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
}

0 comments on commit dff6d25

Please sign in to comment.