Skip to content

Commit

Permalink
Fix crash when creating an empty path
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Aug 20, 2022
1 parent eddb7b5 commit d58b726
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import kotlin.math.sqrt
class HikingService(private val geology: IGeologyService = GeologyService()) : IHikingService {

override fun getDistances(points: List<PathPoint>): List<Float> {
if (points.isEmpty()){
return emptyList()
}
var distance = 0f
var last = points.first()

Expand All @@ -26,6 +29,9 @@ class HikingService(private val geology: IGeologyService = GeologyService()) : I
}

override fun correctElevations(points: List<PathPoint>): List<PathPoint> {
if (points.isEmpty()){
return emptyList()
}
val distances = getDistances(points)
val smoothed = DataUtils.smooth(
points,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.kylecorry.trail_sense.navigation.paths.ui.commands

import android.content.Context
import com.kylecorry.andromeda.pickers.CoroutinePickers
import com.kylecorry.trail_sense.R
import com.kylecorry.trail_sense.navigation.paths.domain.IPathService
import com.kylecorry.trail_sense.navigation.paths.domain.Path
import com.kylecorry.trail_sense.navigation.paths.domain.PathMetadata
import com.kylecorry.trail_sense.navigation.paths.infrastructure.persistence.IPathPreferences
import com.kylecorry.trail_sense.navigation.paths.infrastructure.persistence.PathService
import com.kylecorry.trail_sense.shared.UserPreferences
import com.kylecorry.trail_sense.shared.alerts.CoroutineAlerts
import com.kylecorry.trail_sense.shared.extensions.onIO
import com.kylecorry.trail_sense.shared.extensions.onMain

Expand All @@ -21,7 +21,7 @@ class CreatePathCommand(

suspend fun execute(parentId: Long?): Long? {
val name = onMain {
CoroutineAlerts.text(
CoroutinePickers.text(
context,
context.getString(R.string.path),
hint = context.getString(R.string.name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.kylecorry.trail_sense.navigation.paths.ui.commands

import android.content.Context
import com.kylecorry.andromeda.pickers.CoroutinePickers
import com.kylecorry.trail_sense.R
import com.kylecorry.trail_sense.navigation.paths.domain.IPathService
import com.kylecorry.trail_sense.navigation.paths.domain.PathGroup
import com.kylecorry.trail_sense.navigation.paths.infrastructure.persistence.PathService
import com.kylecorry.trail_sense.shared.alerts.CoroutineAlerts
import com.kylecorry.trail_sense.shared.extensions.onIO
import com.kylecorry.trail_sense.shared.extensions.onMain

Expand All @@ -17,7 +17,7 @@ class CreatePathGroupCommand(

suspend fun execute(parentId: Long?) {
val name = onMain {
CoroutineAlerts.text(
CoroutinePickers.text(
context,
context.getString(R.string.group),
hint = context.getString(R.string.name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.kylecorry.trail_sense.navigation.paths.ui.commands

import android.content.Context
import com.kylecorry.andromeda.alerts.CoroutineAlerts
import com.kylecorry.trail_sense.R
import com.kylecorry.trail_sense.navigation.paths.domain.IPathService
import com.kylecorry.trail_sense.navigation.paths.domain.PathGroup
import com.kylecorry.trail_sense.navigation.paths.infrastructure.persistence.PathService
import com.kylecorry.trail_sense.shared.alerts.CoroutineAlerts
import com.kylecorry.trail_sense.shared.extensions.onIO
import com.kylecorry.trail_sense.shared.extensions.onMain

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.kylecorry.trail_sense.navigation.paths.ui.commands

import android.content.Context
import com.kylecorry.andromeda.pickers.CoroutinePickers
import com.kylecorry.trail_sense.R
import com.kylecorry.trail_sense.navigation.paths.domain.IPathService
import com.kylecorry.trail_sense.navigation.paths.domain.PathGroup
import com.kylecorry.trail_sense.navigation.paths.infrastructure.persistence.PathService
import com.kylecorry.trail_sense.shared.alerts.CoroutineAlerts
import com.kylecorry.trail_sense.shared.extensions.onIO
import com.kylecorry.trail_sense.shared.extensions.onMain

Expand All @@ -17,7 +17,7 @@ class RenamePathGroupGroupCommand(

override suspend fun execute(group: PathGroup) {
val newName = onMain {
CoroutineAlerts.text(
CoroutinePickers.text(
context,
context.getString(R.string.rename),
default = group.name,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.ViewGroup
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.navigation.fragment.findNavController
import com.kylecorry.andromeda.alerts.CoroutineAlerts
import com.kylecorry.andromeda.core.system.Resources
import com.kylecorry.andromeda.core.time.Timer
import com.kylecorry.andromeda.fragments.BoundFragment
Expand All @@ -19,7 +20,6 @@ import com.kylecorry.trail_sense.shared.CustomUiUtils
import com.kylecorry.trail_sense.shared.CustomUiUtils.setCompoundDrawables
import com.kylecorry.trail_sense.shared.FormatService
import com.kylecorry.trail_sense.shared.UserPreferences
import com.kylecorry.trail_sense.shared.alerts.CoroutineAlerts
import com.kylecorry.trail_sense.shared.extensions.onMain
import com.kylecorry.trail_sense.tools.tides.domain.TideService
import com.kylecorry.trail_sense.tools.tides.domain.TideTable
Expand Down

0 comments on commit d58b726

Please sign in to comment.