Skip to content

Commit

Permalink
[droidknights#259, 위젯 기능 추가]
Browse files Browse the repository at this point in the history
[작업내용]
  - Lint Error 제거
  • Loading branch information
jeongth9446 committed Sep 6, 2023
1 parent 161cec7 commit 28dfecf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import androidx.glance.layout.padding
import com.droidknights.app2023.DroidKnightsWidgetReceiver.Companion.KEY_SESSION_IDS
import com.droidknights.app2023.core.designsystem.theme.KnightsGlanceTheme
import com.droidknights.app2023.core.model.Session
import com.droidknights.app2023.di.WidgetInterface
import com.droidknights.app2023.di.WidgetModule
import dagger.hilt.EntryPoints

class DroidKnightsWidget : GlanceAppWidget() {
Expand All @@ -36,10 +36,9 @@ class DroidKnightsWidget : GlanceAppWidget() {
}

override suspend fun provideGlance(context: Context, id: GlanceId) {

val widgetInterface: WidgetInterface = EntryPoints.get(
val widgetModule: WidgetModule = EntryPoints.get(
context.applicationContext,
WidgetInterface::class.java
WidgetModule::class.java
)

provideContent {
Expand All @@ -50,7 +49,7 @@ class DroidKnightsWidget : GlanceAppWidget() {
LaunchedEffect(state) {
list = arrayListOf<Session>().apply {
state?.forEach {
this.add(widgetInterface.getSessionUseCase().invoke(it))
this.add(widgetModule.getSessionUseCase().invoke(it))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.glance.appwidget.GlanceAppWidgetReceiver
import androidx.glance.appwidget.state.updateAppWidgetState
import androidx.glance.appwidget.updateAll
import androidx.glance.state.PreferencesGlanceStateDefinition
import com.droidknights.app2023.di.WidgetInterface
import com.droidknights.app2023.di.WidgetModule
import dagger.hilt.EntryPoints
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -41,19 +41,18 @@ class DroidKnightsWidgetReceiver : GlanceAppWidgetReceiver() {
}
}


private fun getBookmarkedSessionAndUpdateWidget(
context: Context,
glanceAppWidget: GlanceAppWidget
) {
val widgetInterface: WidgetInterface = EntryPoints.get(
val widgetModule: WidgetModule = EntryPoints.get(
context.applicationContext,
WidgetInterface::class.java
WidgetModule::class.java
)

CoroutineScope(Dispatchers.IO).launch {
val glanceIds = GlanceAppWidgetManager(context).getGlanceIds(DroidKnightsWidget::class.java)
widgetInterface.getBookmarkedSessionsUseCase().invoke().collect { list ->
widgetModule.getBookmarkedSessionsUseCase().invoke().collect { list ->
glanceIds.forEach { glanceId ->
updateAppWidgetState(
context = context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ fun WidgetSessionCard(session: Session) {
)
)
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dagger.hilt.components.SingletonComponent

@EntryPoint
@InstallIn(SingletonComponent::class)
interface WidgetInterface {
interface WidgetModule {
fun getBookmarkedSessionsUseCase(): GetBookmarkedSessionsUseCase

fun getSessionUseCase(): GetSessionUseCase
Expand Down

0 comments on commit 28dfecf

Please sign in to comment.