Skip to content

Commit

Permalink
Closes #86
Browse files Browse the repository at this point in the history
Merge branch 'fix/shedule-date' into develop

* fix/shedule-date:
  Adds save int parse for to/from date and changes input type to signed
  • Loading branch information
7LPdWcaW committed Jun 29, 2019
2 parents 4953656 + f4c8e38 commit 576ee0c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ import android.widget.TextView
import kotlinx.android.synthetic.main.schedule_date_details_view.*
import me.anon.grow.R
import me.anon.lib.Unit
import me.anon.lib.ext.toSafeInt
import me.anon.lib.manager.ScheduleManager
import me.anon.model.Additive
import me.anon.model.FeedingScheduleDate
import me.anon.model.PlantStage

/**
* // TODO: Add class description
*/
class ScheduleDateDetailsFragment : Fragment()
{
companion object
Expand Down Expand Up @@ -110,8 +108,8 @@ class ScheduleDateDetailsFragment : Fragment()
return@setOnClickListener
}

val fromDate = from_date.text.toString().toInt()
val toDate = if (to_date.text.isEmpty()) fromDate else to_date.text.toString().toInt()
val fromDate = from_date.text.toString().toSafeInt()
val toDate = if (to_date.text.isEmpty()) fromDate else to_date.text.toString().toSafeInt()
val fromStage = PlantStage.valueOfPrintString(from_stage.selectedItem as String)!!
val toStage = PlantStage.valueOfPrintString(to_stage.selectedItem as String)!!

Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/me/anon/lib/ExportCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

import java.io.File;

/**
* // TODO: Add class description
*
* @author Callum Taylor
*/
public class ExportCallback
{
@WorkerThread
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/me/anon/lib/ext/IntUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package me.anon.lib.ext

import java.lang.Exception

public fun String?.toSafeInt(): Int
{
try
{
if (this?.indexOf('.') ?: -1 > -1)
{
return this?.toDouble()?.toInt() ?: 0
}

return this?.toInt() ?: 0
}
catch (e: Exception)
{
return 0
}
}
4 changes: 2 additions & 2 deletions app/src/main/res/layout/schedule_date_details_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
android:layout_height="wrap_content"
android:id="@+id/from_date"
android:hint="15"
android:inputType="numberDecimal"
android:inputType="numberSigned"
android:layout_gravity="bottom"
android:nextFocusDown="@+id/description"
style="@style/SubsectionSubTitle"
Expand Down Expand Up @@ -129,7 +129,7 @@
android:layout_height="wrap_content"
android:id="@+id/to_date"
android:hint="15"
android:inputType="numberDecimal"
android:inputType="numberSigned"
android:layout_gravity="bottom"
android:nextFocusDown="@+id/description"
style="@style/SubsectionSubTitle"
Expand Down

0 comments on commit 576ee0c

Please sign in to comment.