parent
d652195dde
commit
84702e202a
@ -0,0 +1,32 @@ |
||||
package net.pokeranalytics.android.model.extensions |
||||
|
||||
import net.pokeranalytics.android.model.realm.Session |
||||
import java.util.* |
||||
|
||||
enum class SessionState { |
||||
PENDING, |
||||
STARTED, |
||||
PAUSED, |
||||
FINISHED, |
||||
INVALID; |
||||
} |
||||
|
||||
/** |
||||
* Return the current state of a session |
||||
* For example: STARTED, PAUSED, FINISHED |
||||
*/ |
||||
fun Session.getState(): SessionState { |
||||
val endDate = timeFrame?.endDate |
||||
timeFrame?.startDate?.let {startDate -> |
||||
if (startDate > Date()) { |
||||
return SessionState.PENDING |
||||
} else if (endDate != null) { |
||||
return SessionState.FINISHED |
||||
} else if (isPaused) { |
||||
return SessionState.PAUSED |
||||
} else { |
||||
return SessionState.STARTED |
||||
} |
||||
} |
||||
return SessionState.INVALID |
||||
} |
||||
@ -1,9 +0,0 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="24dp" |
||||
android:height="24dp" |
||||
android:viewportWidth="24.0" |
||||
android:viewportHeight="24.0"> |
||||
<path |
||||
android:fillColor="#FF000000" |
||||
android:pathData="M3,13h8L11,3L3,3v10zM3,21h8v-6L3,15v6zM13,21h8L21,11h-8v10zM13,3v6h8L21,3h-8z"/> |
||||
</vector> |
||||
@ -1,5 +0,0 @@ |
||||
<vector android:height="24dp" android:tint="#FFFFFF" |
||||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<path android:fillColor="#FF000000" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/> |
||||
</vector> |
||||
@ -1,9 +0,0 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="24dp" |
||||
android:height="24dp" |
||||
android:viewportWidth="24.0" |
||||
android:viewportHeight="24.0"> |
||||
<path |
||||
android:fillColor="#FF000000" |
||||
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/> |
||||
</vector> |
||||
@ -0,0 +1,9 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="24dp" |
||||
android:height="24dp" |
||||
android:viewportWidth="24" |
||||
android:viewportHeight="24"> |
||||
<path |
||||
android:fillColor="#FFFFFFFF" |
||||
android:pathData="M16,9v10H8V9h8m-1.5,-6h-5l-1,1H5v2h14V4h-3.5l-1,-1zM18,7H6v12c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7z"/> |
||||
</vector> |
||||
@ -0,0 +1,9 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="24dp" |
||||
android:height="24dp" |
||||
android:viewportWidth="24" |
||||
android:viewportHeight="24"> |
||||
<path |
||||
android:fillColor="#FFFFFFFF" |
||||
android:pathData="M14,12c0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2 0.9,2 2,2 2,-0.9 2,-2zM12,3c-4.97,0 -9,4.03 -9,9L0,12l4,4 4,-4L5,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.51,0 -2.91,-0.49 -4.06,-1.3l-1.42,1.44C8.04,20.3 9.94,21 12,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9z"/> |
||||
</vector> |
||||
@ -1,25 +1,25 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.constraintlayout.widget.ConstraintLayout |
||||
xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:padding="16dp"> |
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:background="?selectableItemBackground" |
||||
android:padding="16dp"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/date" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
android:layout_marginEnd="8dp" |
||||
android:layout_marginTop="8dp" |
||||
android:textSize="16sp" |
||||
tools:text="This date" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
android:layout_marginStart="8dp" |
||||
android:layout_marginBottom="8dp" |
||||
app:layout_constraintBottom_toBottomOf="parent"/> |
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/date" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="8dp" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="8dp" |
||||
android:layout_marginBottom="8dp" |
||||
android:textSize="16sp" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="This date" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
@ -0,0 +1,10 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto"> |
||||
|
||||
<item |
||||
android:id="@+id/stop" |
||||
android:title="@string/stop" |
||||
app:showAsAction="always" /> |
||||
|
||||
</menu> |
||||
@ -0,0 +1,17 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto"> |
||||
|
||||
<item |
||||
android:id="@+id/restart" |
||||
android:title="@string/restart_timer" |
||||
android:icon="@drawable/ic_outline_restart" |
||||
app:showAsAction="withText" /> |
||||
|
||||
<item |
||||
android:id="@+id/delete" |
||||
android:icon="@drawable/ic_outline_delete" |
||||
android:title="@string/delete" |
||||
app:showAsAction="withText" /> |
||||
|
||||
</menu> |
||||
Loading…
Reference in new issue