diff --git a/app/src/main/java/eu/m724/vastapp/vastai/data/RentedInstance.kt b/app/src/main/java/eu/m724/vastapp/vastai/data/RentedInstance.kt index c3570fc..91b0140 100644 --- a/app/src/main/java/eu/m724/vastapp/vastai/data/RentedInstance.kt +++ b/app/src/main/java/eu/m724/vastapp/vastai/data/RentedInstance.kt @@ -72,4 +72,26 @@ data class RentedInstance( ) } } + + /** + * returns whether the instance is running + * this is true also if the instance is stopping + * vice versa, false if stopped or starting + * @return is the instance running + */ + fun isRunning(): Boolean { + return status == "running" + } + + fun isStopping(): Boolean { + return status == "running" && targetStatus == "stopped" + } + + fun isStarting(): Boolean { + return status == "exited" && targetStatus == "running" + } + + fun isChangingState(): Boolean { + return isStopping() || isStarting() + } } \ No newline at end of file