-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
App: Introduce the App class to provide global application states
Several properties in the Application class are dynamically bound after the application launches, which means accessing those properties before bound incurs NPE. To avoid such unintended NPE, this patch introduces the App singleton class holding those properties like applicationContext. Signed-off-by: Wook Song <[email protected]>
- Loading branch information
Showing
2 changed files
with
19 additions
and
1 deletion.
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
18 changes: 18 additions & 0 deletions
18
ml_inference_offloading/src/main/java/ai/nnstreamer/ml/inference/offloading/App.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,18 @@ | ||
package ai.nnstreamer.ml.inference.offloading | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
|
||
class App : Application() { | ||
init{ | ||
instance = this | ||
} | ||
|
||
companion object { | ||
lateinit var instance: App | ||
|
||
fun context() : Context { | ||
return instance.applicationContext | ||
} | ||
} | ||
} |