Skip to content

Commit

Permalink
Clean-up code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane Baiget committed Aug 29, 2017
1 parent 642c4b6 commit b6cf512
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions dependencies.gradle
Expand Up @@ -22,6 +22,7 @@ ext {
// Packages
supportPackage = 'com.android.support'
rangeViewPackage = 'me.bendik.simplerangeview'
kotlinPackage = 'org.jetbrains.kotlin'

supportDependencies = [
appCompat : buildDependency(supportPackage, 'appcompat-v7', supportVersion),
Expand All @@ -34,6 +35,8 @@ ext {
percent : buildDependency(supportPackage, 'percent', supportVersion)
]

kotlinDependency = buildDependency(kotlinPackage, 'kotlin-stdlib-jre8', kotlin_version)

rangeView = buildDependency(rangeViewPackage, 'simplerangeview', rangeViewVersion)
}

Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Expand Up @@ -36,5 +36,5 @@ dependencies {
implementation supportDependencies.appCompat
implementation supportDependencies.percent
implementation supportDependencies.grid
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
implementation kotlinDependency
}
Expand Up @@ -96,8 +96,7 @@ class DecimalPickerDialog : DialogFragment() {
if (result.isEmpty()) result = "0"
result = result.replace(',', '.')
if (result == ".") result = "0"

val number = java.lang.Float.parseFloat(result)
val number = result.toFloat()

val activity = activity
val fragment = parentFragment
Expand Down Expand Up @@ -193,7 +192,10 @@ class DecimalPickerDialog : DialogFragment() {
backspaceButton.isEnabled = 0 != numberTextView.length()
if (numberTextView.text.isEmpty()) {
dialog.getButton(DialogInterface.BUTTON_POSITIVE).isEnabled = false
} else dialog.getButton(DialogInterface.BUTTON_POSITIVE).isEnabled = !(1 == numberTextView.text.length && '-' == numberTextView.text[0])
} else {
dialog.getButton(DialogInterface.BUTTON_POSITIVE).isEnabled =
!(1 == numberTextView.text.length && '-' == numberTextView.text[0])
}
}

private fun initDecimalSeparator() {
Expand Down
Expand Up @@ -90,6 +90,7 @@ class HexaPickerDialog : DialogFragment() {
.setPositiveButton(android.R.string.ok) { _, _ ->
if (numberTextView.text.isEmpty()) numberTextView.text = "0"
val number = numberTextView.text.toString()

val activity = activity
val fragment = parentFragment
if (activity is HexaPickerHandler) {
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Expand Up @@ -50,5 +50,5 @@ dependencies {
implementation supportDependencies.appCompat
implementation supportDependencies.design
implementation rangeView
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
implementation kotlinDependency
}
Expand Up @@ -39,7 +39,7 @@ class MainActivity : AppCompatActivity(), HexaPickerHandler, DecimalPickerHandle

@SuppressLint("SetTextI18n")
override fun onDecimalNumberPicked(reference: Int, number: Float) {
decimalTextView.text = java.lang.Float.toString(number)
decimalTextView.text = "$number"
}

fun showDecimalPicker() {
Expand Down

0 comments on commit b6cf512

Please sign in to comment.