mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-06 03:50:23 +02:00
Added workaround for crashes in the widget
This commit is contained in:
parent
5c65d3b5b0
commit
add4ab9944
1 changed files with 9 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* TimeLimit Copyright <C> 2019 - 2020 Jonas Lochmann
|
* TimeLimit Copyright <C> 2019 - 2021 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -63,6 +63,10 @@ class TimesWidgetService: RemoteViewsService() {
|
||||||
override fun getCount(): Int = categoriesCurrent.size
|
override fun getCount(): Int = categoriesCurrent.size
|
||||||
|
|
||||||
override fun getViewAt(position: Int): RemoteViews {
|
override fun getViewAt(position: Int): RemoteViews {
|
||||||
|
if (position >= categoriesCurrent.size) {
|
||||||
|
return RemoteViews(packageName, R.layout.widget_times_item)
|
||||||
|
}
|
||||||
|
|
||||||
val category = categoriesCurrent[position]
|
val category = categoriesCurrent[position]
|
||||||
val result = RemoteViews(packageName, R.layout.widget_times_item)
|
val result = RemoteViews(packageName, R.layout.widget_times_item)
|
||||||
|
|
||||||
|
@ -97,6 +101,10 @@ class TimesWidgetService: RemoteViewsService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemId(position: Int): Long {
|
override fun getItemId(position: Int): Long {
|
||||||
|
if (position >= categoriesCurrent.size) {
|
||||||
|
return -(position.toLong())
|
||||||
|
}
|
||||||
|
|
||||||
return categoriesCurrent[position].hashCode().toLong()
|
return categoriesCurrent[position].hashCode().toLong()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue