1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 04:39:09 -05:00

Fix spaming NoCurentStudentException (#476)

This commit is contained in:
Rafał Borcz 2019-09-02 12:38:09 +02:00 committed by Mikołaj Pich
parent 455b04f183
commit bb9ea7eda1
3 changed files with 10 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import dagger.android.AndroidInjection
import io.github.wulkanowy.R import io.github.wulkanowy.R
import io.github.wulkanowy.data.db.SharedPrefProvider import io.github.wulkanowy.data.db.SharedPrefProvider
import io.github.wulkanowy.data.db.entities.LuckyNumber import io.github.wulkanowy.data.db.entities.LuckyNumber
import io.github.wulkanowy.data.exceptions.NoCurrentStudentException
import io.github.wulkanowy.data.repositories.luckynumber.LuckyNumberRepository import io.github.wulkanowy.data.repositories.luckynumber.LuckyNumberRepository
import io.github.wulkanowy.data.repositories.semester.SemesterRepository import io.github.wulkanowy.data.repositories.semester.SemesterRepository
import io.github.wulkanowy.data.repositories.student.StudentRepository import io.github.wulkanowy.data.repositories.student.StudentRepository
@ -114,7 +115,9 @@ class LuckyNumberWidgetProvider : BroadcastReceiver() {
.subscribeOn(schedulers.backgroundThread) .subscribeOn(schedulers.backgroundThread)
.blockingGet() .blockingGet()
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "An error has occurred in lucky number provider") if (e.cause !is NoCurrentStudentException) {
Timber.e(e, "An error has occurred in lucky number provider")
}
null null
} }
} }

View File

@ -60,8 +60,6 @@ class TimetableWidgetFactory(
.filter { true } .filter { true }
.flatMap { studentRepository.getSavedStudents().toMaybe() } .flatMap { studentRepository.getSavedStudents().toMaybe() }
.flatMap { .flatMap {
if (studentId == 0L) throw IllegalArgumentException("Student id is 0")
it.singleOrNull { student -> student.id == studentId } it.singleOrNull { student -> student.id == studentId }
.let { student -> .let { student ->
if (student != null) Maybe.just(student) if (student != null) Maybe.just(student)

View File

@ -1,5 +1,6 @@
package io.github.wulkanowy.ui.modules.timetablewidget package io.github.wulkanowy.ui.modules.timetablewidget
import android.annotation.SuppressLint
import android.app.PendingIntent import android.app.PendingIntent
import android.app.PendingIntent.FLAG_UPDATE_CURRENT import android.app.PendingIntent.FLAG_UPDATE_CURRENT
import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetManager
@ -17,6 +18,7 @@ import dagger.android.AndroidInjection
import io.github.wulkanowy.R import io.github.wulkanowy.R
import io.github.wulkanowy.data.db.SharedPrefProvider import io.github.wulkanowy.data.db.SharedPrefProvider
import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.db.entities.Student
import io.github.wulkanowy.data.exceptions.NoCurrentStudentException
import io.github.wulkanowy.data.repositories.student.StudentRepository import io.github.wulkanowy.data.repositories.student.StudentRepository
import io.github.wulkanowy.services.widgets.TimetableWidgetService import io.github.wulkanowy.services.widgets.TimetableWidgetService
import io.github.wulkanowy.ui.modules.main.MainActivity import io.github.wulkanowy.ui.modules.main.MainActivity
@ -110,6 +112,7 @@ class TimetableWidgetProvider : BroadcastReceiver() {
} }
} }
@SuppressLint("DefaultLocale")
private fun updateWidget(context: Context, appWidgetId: Int, date: LocalDate, student: Student?) { private fun updateWidget(context: Context, appWidgetId: Int, date: LocalDate, student: Student?) {
RemoteViews(context.packageName, R.layout.widget_timetable).apply { RemoteViews(context.packageName, R.layout.widget_timetable).apply {
setEmptyView(R.id.timetableWidgetList, R.id.timetableWidgetEmpty) setEmptyView(R.id.timetableWidgetList, R.id.timetableWidgetEmpty)
@ -173,7 +176,9 @@ class TimetableWidgetProvider : BroadcastReceiver() {
.subscribeOn(schedulers.backgroundThread) .subscribeOn(schedulers.backgroundThread)
.blockingGet() .blockingGet()
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "An error has occurred in timetable widget provider") if (e.cause !is NoCurrentStudentException) {
Timber.e(e, "An error has occurred in timetable widget provider")
}
null null
} }
} }