Skip to content

Commit

Permalink
Fix crashes specific to low or high api levels
Browse files Browse the repository at this point in the history
  • Loading branch information
rcgroot committed Mar 13, 2017
1 parent 97323d6 commit 64bba3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package nl.sogeti.android.gpstracker.ng.common.controllers

import android.content.Context
import android.databinding.Observable
import android.databinding.ObservableField
import android.net.Uri
import android.os.Handler
import android.os.Looper

/**
* Control the observing and monitoring for a observable uri value
Expand All @@ -21,7 +21,7 @@ class ContentController(val context: Context, val listener: ContentListener) {
contentObserver.unregister()
}

private inner class ContentObserver: android.database.ContentObserver(null) {
private inner class ContentObserver : android.database.ContentObserver(Handler(Looper.getMainLooper())) {

var registeredUri: Uri? = null

Expand All @@ -36,12 +36,13 @@ class ContentController(val context: Context, val listener: ContentListener) {
fun unregister() {
if (registeredUri != null) {
context.contentResolver.unregisterContentObserver(contentObserver)
registeredUri = null
registeredUri = null4
}
}

override fun onChange(selfChange: Boolean, changedUri: Uri) {
registeredUri?.let { listener.onChangeUriContent(it, changedUri) }

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class TrackEditPresenter(val model: TrackEditModel, val listener: TrackEditModel
}
val trackType = model.trackTypes[position]
viewHolder.textView.text = context?.getString(trackType.stringId)
viewHolder.imageView.setImageDrawable(context?.getDrawable(trackType.drawableId))
context?.let { viewHolder.imageView.setImageDrawable(AppCompatResources.getDrawable(it, trackType.drawableId)) }

return itemView
Expand Down

0 comments on commit 64bba3c

Please sign in to comment.