Changed initialize to reset.
This commit is contained in:
parent
61706679e9
commit
ae134efac4
2 changed files with 9 additions and 5 deletions
|
@ -81,19 +81,19 @@ class ReadingTime @JvmOverloads constructor(
|
|||
|
||||
var text: String = text
|
||||
set(value) {
|
||||
initialize()
|
||||
reset(value != text)
|
||||
field = value
|
||||
}
|
||||
|
||||
var wpm: Int = wpm
|
||||
set(value) {
|
||||
initialize()
|
||||
reset(value != wpm)
|
||||
field = value
|
||||
}
|
||||
|
||||
var excludeImages: Boolean = excludeImages
|
||||
set(value) {
|
||||
initialize()
|
||||
reset(value != excludeImages)
|
||||
field = value
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class ReadingTime @JvmOverloads constructor(
|
|||
return time
|
||||
}
|
||||
|
||||
private fun initialize() {
|
||||
readTime = INVALID
|
||||
private fun reset(isChanged: Boolean) {
|
||||
if (isChanged) readTime = INVALID
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,5 +98,9 @@ class ReadingTimeTest {
|
|||
rt.text = "This is a test."
|
||||
rt.postfix = ""
|
||||
assertEquals("1", rt.calcReadingTime())
|
||||
|
||||
rt.text = ""
|
||||
assertEquals("0", rt.calcReadingTime())
|
||||
assertEquals( 0.0, rt.calcReadingTimeInSec())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue