-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d83f58
commit f1d8a97
Showing
25 changed files
with
611 additions
and
250 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
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
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
28 changes: 28 additions & 0 deletions
28
features/app-widgets/src/main/java/app/ss/widgets/glance/BaseGlanceAppWidget.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,28 @@ | ||
package app.ss.widgets.glance | ||
|
||
import android.content.Context | ||
import androidx.glance.appwidget.GlanceAppWidget | ||
import app.ss.widgets.WidgetDataProvider | ||
import dagger.hilt.EntryPoint | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.EntryPointAccessors | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@EntryPoint | ||
@InstallIn(SingletonComponent::class) | ||
internal interface AppWidgetDataProviderEntryPoint { | ||
fun widgetDataProvider(): WidgetDataProvider | ||
} | ||
|
||
/** | ||
* A base [GlanceAppWidget] class that handles injection. | ||
*/ | ||
internal abstract class BaseGlanceAppWidget : GlanceAppWidget() { | ||
|
||
fun dataProvider(context: Context): WidgetDataProvider { | ||
val appContext = context.applicationContext ?: throw IllegalStateException() | ||
val hiltEntryPoint = | ||
EntryPointAccessors.fromApplication(appContext, AppWidgetDataProviderEntryPoint::class.java) | ||
return hiltEntryPoint.widgetDataProvider() | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.