commit
22d0459436
@ -1,24 +1,79 @@ |
||||
package net.pokeranalytics.android.model.realm |
||||
|
||||
import io.realm.RealmObject |
||||
import io.realm.annotations.PrimaryKey |
||||
import io.realm.RealmResults |
||||
import io.realm.annotations.LinkingObjects |
||||
import java.util.* |
||||
|
||||
|
||||
|
||||
open class TimeFrame : RealmObject() { |
||||
|
||||
// A start date |
||||
var startDate: Date = Date() |
||||
set(value) { |
||||
field = value |
||||
this.computeDuration() |
||||
if (this.session != null) { |
||||
this.notifyDateChange() |
||||
} |
||||
} |
||||
|
||||
// An end date |
||||
var endDate: Date? = null |
||||
set(value) { |
||||
field = value |
||||
this.computeDuration() |
||||
if (this.session != null) { |
||||
this.notifyDateChange() |
||||
} |
||||
} |
||||
|
||||
// The break duration |
||||
var breakDuration: Double = 0.0 |
||||
var breakDuration: Long = 0L |
||||
set(value) { |
||||
field = value |
||||
this.computeDuration() |
||||
} |
||||
|
||||
// the total duration |
||||
var duration: Double = 0.0 |
||||
var duration: Long = 0L |
||||
private set |
||||
|
||||
// indicates a state of pause |
||||
var paused: Boolean = false |
||||
|
||||
@LinkingObjects("timeFrame") |
||||
private val session: RealmResults<Session>? = null |
||||
|
||||
@LinkingObjects("timeFrame") |
||||
private val group: RealmResults<TimeFrameGroup>? = null |
||||
|
||||
private fun computeDuration() { |
||||
|
||||
var endDate: Date |
||||
if (this.endDate != null) { |
||||
endDate = this.endDate!! |
||||
} else { |
||||
endDate = Date() |
||||
} |
||||
this.duration = endDate.time - startDate.time - this.breakDuration |
||||
} |
||||
|
||||
private fun notifyDateChange() { |
||||
// val realm = Realm.getDefaultInstance() |
||||
// |
||||
// var query: RealmQuery<TimeFrame> = realm.where(TimeFrame::class.java) |
||||
// query.greaterThan("startDate", this.startDate.time) |
||||
// |
||||
// this.endDate?.let { endDate -> |
||||
// query.or() |
||||
// .greaterThan("startDate", endDate.time) |
||||
// .lessThan("endDate", endDate.time) |
||||
// } |
||||
// |
||||
// |
||||
// realm.close() |
||||
} |
||||
|
||||
} |
||||
|
||||
@ -0,0 +1,13 @@ |
||||
package net.pokeranalytics.android.ui.fragment.components |
||||
|
||||
enum class BottomSheetType { |
||||
|
||||
NONE, |
||||
GAME, |
||||
BLINDS, |
||||
LOCATION, |
||||
BANKROLL, |
||||
TABLE_SIZE, |
||||
DATE |
||||
|
||||
} |
||||
@ -0,0 +1,26 @@ |
||||
package net.pokeranalytics.android.util |
||||
|
||||
import android.app.DatePickerDialog |
||||
import android.app.Dialog |
||||
import android.os.Bundle |
||||
import android.widget.DatePicker |
||||
import androidx.fragment.app.DialogFragment |
||||
import java.util.* |
||||
|
||||
class DatePickerFragment : DialogFragment(), DatePickerDialog.OnDateSetListener { |
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { |
||||
// Use the current date as the default date in the picker |
||||
val c = Calendar.getInstance() |
||||
val year = c.get(Calendar.YEAR) |
||||
val month = c.get(Calendar.MONTH) |
||||
val day = c.get(Calendar.DAY_OF_MONTH) |
||||
|
||||
// Create a new instance of DatePickerDialog and return it |
||||
return DatePickerDialog(activity, this, year, month, day) |
||||
} |
||||
|
||||
override fun onDateSet(view: DatePicker, year: Int, month: Int, day: Int) { |
||||
// Do something with the date chosen by the user |
||||
} |
||||
} |
||||
@ -0,0 +1,26 @@ |
||||
package net.pokeranalytics.android.util |
||||
|
||||
import android.app.Dialog |
||||
import android.app.TimePickerDialog |
||||
import android.os.Bundle |
||||
import android.text.format.DateFormat |
||||
import android.widget.TimePicker |
||||
import androidx.fragment.app.DialogFragment |
||||
import java.util.* |
||||
|
||||
class TimePickerFragment : DialogFragment(), TimePickerDialog.OnTimeSetListener { |
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { |
||||
// Use the current time as the default values for the picker |
||||
val c = Calendar.getInstance() |
||||
val hour = c.get(Calendar.HOUR_OF_DAY) |
||||
val minute = c.get(Calendar.MINUTE) |
||||
|
||||
// Create a new instance of TimePickerDialog and return it |
||||
return TimePickerDialog(activity, this, hour, minute, DateFormat.is24HourFormat(activity)) |
||||
} |
||||
|
||||
override fun onTimeSet(view: TimePicker, hourOfDay: Int, minute: Int) { |
||||
// Do something with the time chosen by the user |
||||
} |
||||
} |
||||
@ -0,0 +1,5 @@ |
||||
<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="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/> |
||||
</vector> |
||||
@ -0,0 +1,5 @@ |
||||
<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="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/> |
||||
</vector> |
||||
@ -0,0 +1,5 @@ |
||||
<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="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> |
||||
</vector> |
||||
@ -0,0 +1,5 @@ |
||||
<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> |
||||
@ -0,0 +1,13 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="horizontal"> |
||||
|
||||
<androidx.recyclerview.widget.RecyclerView |
||||
android:id="@+id/bankrollRecyclerView" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:minHeight="200dp" /> |
||||
|
||||
</LinearLayout> |
||||
@ -0,0 +1,59 @@ |
||||
<?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:orientation="vertical" |
||||
tools:background="@color/gray_dark_1"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/appCompatTextView" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginEnd="8dp" |
||||
android:layout_marginBottom="16dp" |
||||
android:text="Blinds" |
||||
android:textColor="@color/white" |
||||
android:textSize="16sp" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toStartOf="@+id/smallBlind" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText |
||||
android:id="@+id/smallBlind" |
||||
android:layout_width="96dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="8dp" |
||||
android:layout_marginBottom="8dp" |
||||
android:gravity="end|center_vertical" |
||||
android:imeOptions="actionNext" |
||||
android:inputType="numberDecimal" |
||||
android:lines="1" |
||||
android:textColor="@color/white" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toStartOf="@+id/bigBlind" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText |
||||
android:id="@+id/bigBlind" |
||||
android:layout_width="96dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="8dp" |
||||
android:layout_marginBottom="8dp" |
||||
android:gravity="end|center_vertical" |
||||
android:imeOptions="actionDone" |
||||
android:inputType="numberDecimal" |
||||
android:lines="1" |
||||
android:textColor="@color/white" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
@ -0,0 +1,32 @@ |
||||
<?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"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatButton |
||||
android:id="@+id/startDate" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginBottom="16dp" |
||||
android:text="Set start date" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatButton |
||||
android:id="@+id/endDate" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginEnd="16dp" |
||||
android:layout_marginBottom="16dp" |
||||
android:text="Set end date" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
@ -0,0 +1,19 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="horizontal"> |
||||
|
||||
<androidx.recyclerview.widget.RecyclerView |
||||
android:id="@+id/gameTypeRecyclerView" |
||||
android:layout_width="80dp" |
||||
android:layout_height="wrap_content" |
||||
android:minHeight="200dp" /> |
||||
|
||||
<androidx.recyclerview.widget.RecyclerView |
||||
android:id="@+id/gameNameRecyclerView" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:minHeight="200dp" /> |
||||
|
||||
</LinearLayout> |
||||
@ -0,0 +1,13 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="horizontal"> |
||||
|
||||
<androidx.recyclerview.widget.RecyclerView |
||||
android:id="@+id/locationRecyclerView" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:minHeight="200dp" /> |
||||
|
||||
</LinearLayout> |
||||
@ -0,0 +1,13 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="horizontal"> |
||||
|
||||
<androidx.recyclerview.widget.RecyclerView |
||||
android:id="@+id/locationRecyclerView" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:minHeight="200dp" /> |
||||
|
||||
</LinearLayout> |
||||
@ -0,0 +1,28 @@ |
||||
<?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:background="#222222"> |
||||
|
||||
<androidx.appcompat.widget.Toolbar |
||||
android:id="@+id/bottomSheetToolbar" |
||||
style="@style/BottomSheetToolbar" |
||||
android:layout_width="0dp" |
||||
android:layout_height="?actionBarSize" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:title="Test" /> |
||||
|
||||
<FrameLayout |
||||
android:id="@+id/bottomSheetContainer" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toBottomOf="@+id/bottomSheetToolbar" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
@ -1,45 +0,0 @@ |
||||
<?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" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:background="#222222"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/appCompatTextView" |
||||
android:layout_width="0dp" |
||||
android:layout_height="220dp" |
||||
android:gravity="center" |
||||
android:text="Bottom sheet fragment" |
||||
android:textColor="#FFFFFF" |
||||
android:textSize="18sp" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView |
||||
android:id="@+id/close" |
||||
android:layout_width="32dp" |
||||
android:layout_height="32dp" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="8dp" |
||||
android:background="?selectableItemBackgroundBorderless" |
||||
android:scaleType="centerInside" |
||||
android:src="@drawable/ic_close_24dp" |
||||
android:tint="@color/white" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintTop_toTopOf="@+id/appCompatTextView" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText |
||||
android:id="@+id/editText" |
||||
android:layout_width="180dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="8dp" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="8dp" |
||||
android:textColor="@color/white" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
@ -0,0 +1,23 @@ |
||||
<?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" |
||||
xmlns:tools="http://schemas.android.com/tools"> |
||||
<item |
||||
android:id="@+id/actionClear" |
||||
android:orderInCategory="100" |
||||
android:title="@string/app_name" |
||||
android:icon="@drawable/ic_close_white_24dp" |
||||
app:showAsAction="always" /> |
||||
<item |
||||
android:id="@+id/actionAdd" |
||||
android:icon="@drawable/ic_add_white_24dp" |
||||
android:orderInCategory="200" |
||||
android:title="Search" |
||||
app:showAsAction="ifRoom" /> |
||||
<item |
||||
android:id="@+id/actionSave" |
||||
android:icon="@drawable/ic_check_white_24dp" |
||||
android:orderInCategory="300" |
||||
android:title="User" |
||||
app:showAsAction="ifRoom" /> |
||||
</menu> |
||||
@ -1,17 +1,52 @@ |
||||
package net.pokeranalytics.android |
||||
|
||||
import net.pokeranalytics.android.calculus.* |
||||
import net.pokeranalytics.android.model.realm.TimeFrameGroup |
||||
import org.junit.Assert.fail |
||||
import org.junit.Test |
||||
|
||||
import org.junit.Assert.* |
||||
|
||||
/** |
||||
* Example local unit test, which will execute on the development machine (host). |
||||
* |
||||
* See [testing documentation](http://d.android.com/tools/testing). |
||||
*/ |
||||
|
||||
class ExampleUnitTest { |
||||
|
||||
class Grade(someValue: Double) : SessionInterface { |
||||
// override var serie: Serie = Serie(TimeFrame()) |
||||
override var value: Double = someValue |
||||
|
||||
override var serie: TimeFrameGroup = TimeFrameGroup() |
||||
override var estimatedHands: Double = 0.0 |
||||
override var bbNetResult: Double = 0.0 |
||||
override var bigBlindSessionCount: Int = 0 // 0 or 1 |
||||
override var buyin: Double = 0.0 |
||||
|
||||
} |
||||
|
||||
@Test |
||||
fun addition_isCorrect() { |
||||
assertEquals(4, 2 + 2) |
||||
fun testStats() { |
||||
|
||||
val grades: List<Grade> = listOf(Grade(someValue = 10.0), Grade(someValue = 20.0)) |
||||
val group = SessionGroup(name = "test", sessions = grades) |
||||
|
||||
val results: ComputedResults = Calculator.compute(group, Calculator.Options()) |
||||
|
||||
val sum = results.computedStat(Stat.NETRESULT) |
||||
if (sum != null) { |
||||
assert(sum.value == 30.0) |
||||
} else { |
||||
fail("No Net result stat") |
||||
} |
||||
|
||||
val average = results.computedStat(Stat.AVERAGE) |
||||
if (average != null) { |
||||
assert(average.value == 15.0) |
||||
} else { |
||||
fail("No AVERAGE stat") |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
Loading…
Reference in new issue