diff --git a/build.gradle b/build.gradle index 8734e1e..21931f6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'com.github.sanity' -version '0.2.6' +version '0.2.7' buildscript { ext.kotlin_version = '1.1.1' diff --git a/src/main/kotlin/com/github/sanity/shoebox/OrderedViewSet.kt b/src/main/kotlin/com/github/sanity/shoebox/OrderedViewSet.kt index 2eb06c4..ef6c987 100644 --- a/src/main/kotlin/com/github/sanity/shoebox/OrderedViewSet.kt +++ b/src/main/kotlin/com/github/sanity/shoebox/OrderedViewSet.kt @@ -14,7 +14,7 @@ class OrderedViewSet(val view : View, val viewKey : String, val comp init { val ol = ArrayList>() - val kvComparator : Comparator> = Comparator> { o1, o2 -> comparator.thenBy { o1.key.compareTo(o2.key) }.compare(o1.value, o2.value) } + val kvComparator : Comparator> = Comparator> { o1, o2 -> comparator.compare(o1.value, o2.value) }.thenBy(KeyValue::key) ol.addAll(view.getKeyValues(viewKey)) ol.sortWith(kvComparator) orderedList = ol @@ -22,7 +22,7 @@ class OrderedViewSet(val view : View, val viewKey : String, val comp val binarySearchResult = orderedList.betterBinarySearch(keyValue, kvComparator) val insertionPoint: Int = when (binarySearchResult) { is BinarySearchResult.Exact -> { - throw RuntimeException("Listener called for key/value already in list ($keyValue)") + throw RuntimeException("Listener called for key/value already in list keyValue: $keyValue orderedList[${binarySearchResult.index}] = ${orderedList[binarySearchResult.index]}") } is BinarySearchResult.Between -> binarySearchResult.highIndex }