Skip to content

Commit

Permalink
fix adoption of oprhaned widget
Browse files Browse the repository at this point in the history
  • Loading branch information
mattvchandler committed Mar 1, 2020
1 parent 0873145 commit 1e882c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ android {
applicationId "org.mattvchandler.progressbars"
minSdkVersion 19
targetSdkVersion 29
versionName "2.1.0"
versionName "2.1.1"
// version code is <MIN_SDK>0<2-digit MAJOR><2-digit MINOR><2-digit PATCH>
versionCode 190020100
versionCode 190020101
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/Widget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Widget: AppWidgetProvider()
{
val db = DB(context).writableDatabase
val cursor = db.rawQuery(Progress_bars_table.SELECT_WIDGET, arrayOf(widget_id.toString()))
if(cursor.count == 0)
if(cursor.count == 0 && data.rowid == null)
{
data.register_alarms(context)
data.insert(db)
Expand Down Expand Up @@ -148,7 +148,7 @@ class Widget: AppWidgetProvider()
{
Log.d("Widget::create_data_fr…", "Adopting orphaned id: $orphan_widget_id to $widget_id")

val adopted_cursor = db.rawQuery(Progress_bars_table.SELECT_WIDGET, arrayOf(widget_id.toString()))
val adopted_cursor = db.rawQuery(Progress_bars_table.SELECT_WIDGET, arrayOf(orphan_widget_id.toString()))
adopted_cursor.moveToFirst()
data = Data(adopted_cursor)
data.widget_id = widget_id
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/db/Data.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import java.util.*
// struct w/ copy of all DB columns. Serializable so we can store the whole thing
open class Data(): Serializable
{
var rowid: Long? = null // is -1 when not set, ie. the data doesn't exist in the DB
var rowid: Long? = null // is null when not set, ie. the data doesn't exist in the DB
var id = -1

var order_ind: Int? = null
Expand Down

0 comments on commit 1e882c9

Please sign in to comment.