Skip to content

Commit

Permalink
fix bug : throw an exception when call ImmutableSingleDataSource's sh…
Browse files Browse the repository at this point in the history
…ow() or hide()
  • Loading branch information
caodd committed Sep 11, 2018
1 parent 51c7b06 commit 94bf8ad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ class ImmutableSingleDataSource<T>(val data: T) : SingleDataSource<T> {
override var group: SingleGroup<T>? = null

var visible: Boolean = true
set(value) {
if (field && !value) {
field = value
group?.notifyDataSetChanged(1)
}
if (!field && value) {
field = value
group?.notifyDataSetChanged(0)
}
}

override fun haveData(): Boolean {
return visible
Expand All @@ -17,16 +27,10 @@ class ImmutableSingleDataSource<T>(val data: T) : SingleDataSource<T> {
}

fun show() {
if (!visible) {
visible = true
group?.notifyDataSetChanged(1)
}
visible = true
}

fun hide() {
if (visible) {
visible = false
group?.notifyDataSetChanged(0)
}
visible = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ class MutableSingleDataSource<T>(initData: T) : SingleDataSource<T> {
}

var visible: Boolean = true
set(value) {
if (field && !value) {
field = value
group?.notifyDataSetChanged(1)
}
if (!field && value) {
field = value
group?.notifyDataSetChanged(0)
}
}

override fun haveData(): Boolean {
return visible
Expand All @@ -25,16 +35,10 @@ class MutableSingleDataSource<T>(initData: T) : SingleDataSource<T> {
}

fun show() {
if (!visible) {
visible = true
group?.notifyDataSetChanged(0)
}
visible = true
}

fun hide() {
if (visible) {
visible = false
group?.notifyDataSetChanged(1)
}
visible = false
}
}

0 comments on commit 94bf8ad

Please sign in to comment.