Skip to content

Commit a97e1cd

Browse files
committed
use some helper functions when setting up widget elements
1 parent 37fc800 commit a97e1cd

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ android {
3232
}
3333

3434
dependencies {
35-
compile 'com.simplemobiletools:commons:2.28.3'
35+
compile 'com.simplemobiletools:commons:2.28.4'
3636
compile 'com.facebook.stetho:stetho:1.4.1'
3737
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
3838
}

app/src/main/kotlin/com/simplemobiletools/notes/helpers/MyWidgetProvider.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import android.content.Context
77
import android.content.Intent
88
import android.view.View
99
import android.widget.RemoteViews
10+
import com.simplemobiletools.commons.extensions.setBackgroundColor
11+
import com.simplemobiletools.commons.extensions.setText
12+
import com.simplemobiletools.commons.extensions.setTextSize
1013
import com.simplemobiletools.notes.R
1114
import com.simplemobiletools.notes.R.layout.widget
1215
import com.simplemobiletools.notes.activities.SplashActivity
@@ -30,9 +33,9 @@ class MyWidgetProvider : AppWidgetProvider() {
3033

3134
for (id in textIds) {
3235
mRemoteViews.apply {
33-
setInt(id, "setBackgroundColor", widgetBgColor)
34-
setInt(id, "setTextColor", widgetTextColor)
35-
setFloat(id, "setTextSize", context.getTextSize() / context.resources.displayMetrics.density)
36+
setBackgroundColor(id, widgetBgColor)
37+
setTextColor(id, widgetTextColor)
38+
setTextSize(id, context.getTextSize() / context.resources.displayMetrics.density)
3639
setViewVisibility(id, View.GONE)
3740
}
3841
}
@@ -70,7 +73,7 @@ class MyWidgetProvider : AppWidgetProvider() {
7073
val note = mDb.getNote(context.config.widgetNoteId)
7174
for (id in textIds) {
7275
if (note != null)
73-
remoteViews.setTextViewText(id, context.getNoteStoredValue(note))
76+
remoteViews.setText(id, context.getNoteStoredValue(note)!!)
7477
}
7578
widgetManager.updateAppWidget(widgetId, remoteViews)
7679
}

0 commit comments

Comments
 (0)