Skip to content

Commit

Permalink
Fixed crash after declining calendar permission
Browse files Browse the repository at this point in the history
  • Loading branch information
diareuse committed Sep 19, 2023
1 parent 4f0c9af commit ecd4cf9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package movie.calendar

class CalendarListRecover(
private val origin: CalendarList
) : CalendarList {

override fun query() = try {
origin.query()
} catch (e: Throwable) {
emptyList()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import movie.calendar.CalendarList
import movie.calendar.CalendarListPlatform
import movie.calendar.CalendarListRecover
import movie.calendar.CalendarWriter
import movie.calendar.CalendarWriterPlatform
import movie.calendar.CalendarWriterPreventIfExists
Expand All @@ -21,7 +22,10 @@ internal class CalendarModule {
fun list(
resolver: ContentResolver
): CalendarList {
return CalendarListPlatform(resolver)
var out: CalendarList
out = CalendarListPlatform(resolver)
out = CalendarListRecover(out)
return out
}

@Provides
Expand Down

0 comments on commit ecd4cf9

Please sign in to comment.