parent
54de3f4c80
commit
982ded7e66
@ -0,0 +1,7 @@ |
|||||||
|
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
||||||
|
|
||||||
|
import android.graphics.Canvas |
||||||
|
|
||||||
|
class ChipCanvas : Canvas() { |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,34 @@ |
|||||||
|
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import android.graphics.Canvas |
||||||
|
import net.pokeranalytics.android.model.handhistory.Street |
||||||
|
import net.pokeranalytics.android.model.realm.handhistory.HandHistory |
||||||
|
import net.pokeranalytics.android.ui.modules.handhistory.model.ActionList |
||||||
|
|
||||||
|
interface HandStep { |
||||||
|
|
||||||
|
fun draw(configuration: ReplayerConfiguration, canvas: Canvas, context: Context) |
||||||
|
|
||||||
|
companion object { |
||||||
|
|
||||||
|
fun build(handHistory: HandHistory): List<HandStep> { |
||||||
|
|
||||||
|
val actionList = ActionList() |
||||||
|
actionList.load(handHistory) |
||||||
|
|
||||||
|
val steps = mutableListOf<HandStep>() |
||||||
|
Street.values().forEach { street -> |
||||||
|
steps.add(street) |
||||||
|
|
||||||
|
val streetActions = actionList.filter { it.street == street } |
||||||
|
for (action in streetActions) { |
||||||
|
steps.add(action) |
||||||
|
} |
||||||
|
} |
||||||
|
return steps |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
||||||
|
|
||||||
|
import android.graphics.Canvas |
||||||
|
import net.pokeranalytics.android.model.realm.Player |
||||||
|
import net.pokeranalytics.android.model.realm.handhistory.Card |
||||||
|
|
||||||
|
class PlayerCanvas : Canvas() { |
||||||
|
|
||||||
|
fun setPlayer(player: Player) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun setRemainingStack(stack: Double) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun setPicture(file: String) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun setCards(cards: List<Card>) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun showCards(show: Boolean) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun fold() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
||||||
|
|
||||||
|
import net.pokeranalytics.android.model.realm.handhistory.HandHistory |
||||||
|
|
||||||
|
class ReplayerConfiguration(var handHistory: HandHistory) { |
||||||
|
|
||||||
|
val speed: Double = 1.0 |
||||||
|
|
||||||
|
val showVillainHands: Boolean = true |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,56 @@ |
|||||||
|
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
||||||
|
|
||||||
|
import android.os.Bundle |
||||||
|
import android.view.LayoutInflater |
||||||
|
import android.view.View |
||||||
|
import android.view.ViewGroup |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.BaseFragment |
||||||
|
|
||||||
|
class ReplayerFragment : BaseFragment() { |
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
||||||
|
super.onCreateView(inflater, container, savedInstanceState) |
||||||
|
return inflater.inflate(R.layout.fragment_replayer, container, false) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||||
|
super.onViewCreated(view, savedInstanceState) |
||||||
|
initData() |
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
private fun initData() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private fun initUI() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun play() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun resume() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun nextAction() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun previousAction() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun nextHand() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun previousHand() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import android.graphics.Canvas |
||||||
|
import android.util.AttributeSet |
||||||
|
import android.view.View |
||||||
|
import timber.log.Timber |
||||||
|
|
||||||
|
class ReplayerView(context: Context, attrs: AttributeSet) : View(context, attrs) { |
||||||
|
|
||||||
|
lateinit var replayerConfiguration: ReplayerConfiguration |
||||||
|
|
||||||
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { |
||||||
|
Timber.d("ReplayerView > onMeasure") |
||||||
|
} |
||||||
|
|
||||||
|
override fun onDraw(canvas: Canvas?) { |
||||||
|
Timber.d("ReplayerView > onDraw") |
||||||
|
|
||||||
|
canvas?.let { |
||||||
|
// TableCanvas.draw(this.replayerConfiguration, it, context) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,51 @@ |
|||||||
|
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import android.graphics.Bitmap |
||||||
|
import android.graphics.Canvas |
||||||
|
import android.graphics.Paint |
||||||
|
import android.graphics.RectF |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.model.handhistory.Street |
||||||
|
import net.pokeranalytics.android.model.realm.handhistory.HandHistory |
||||||
|
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction |
||||||
|
|
||||||
|
class TableCanvas(bitmap: Bitmap) : Canvas(bitmap) { |
||||||
|
|
||||||
|
companion object { |
||||||
|
const val STROKE_WIDTH = 20.0f |
||||||
|
|
||||||
|
fun initializeTable(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun drawStreet(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun drawAction(action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
//////// |
||||||
|
fun setPot(pot: Double, totalPot: Double) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fun load(context: Context) { |
||||||
|
// create canvasses |
||||||
|
|
||||||
|
val paint = Paint() |
||||||
|
paint.color = context.getColor(R.color.green) |
||||||
|
paint.style = Paint.Style.STROKE |
||||||
|
paint.strokeWidth = STROKE_WIDTH |
||||||
|
paint.isAntiAlias = true |
||||||
|
|
||||||
|
val rect = RectF(10f, 10f, 10f, 10.0f) |
||||||
|
drawRoundRect(rect, 8f, 8f, paint) |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
||||||
|
|
||||||
|
import android.graphics.Bitmap |
||||||
|
import android.os.Bundle |
||||||
|
import kotlinx.android.synthetic.main.activity_test.* |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.activity.components.BaseActivity |
||||||
|
|
||||||
|
class TestActivity : BaseActivity() { |
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) { |
||||||
|
super.onCreate(savedInstanceState) |
||||||
|
setContentView(R.layout.activity_test) |
||||||
|
|
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
fun initUI() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
override fun onStart() { |
||||||
|
super.onStart() |
||||||
|
val bm = Bitmap.createBitmap( |
||||||
|
this.container.width, |
||||||
|
this.container.height, |
||||||
|
Bitmap.Config.ARGB_8888) |
||||||
|
|
||||||
|
val tc = TableCanvas(bm) |
||||||
|
tc.load(this) |
||||||
|
|
||||||
|
this.image_view.setImageBitmap(bm) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:id="@+id/container" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
|
||||||
|
<ImageView |
||||||
|
android:id="@+id/image_view" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:contentDescription="test" /> |
||||||
|
|
||||||
|
</FrameLayout> |
||||||
@ -0,0 +1,36 @@ |
|||||||
|
<?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="match_parent"> |
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout |
||||||
|
android:id="@+id/appBar" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:theme="@style/PokerAnalyticsTheme.Toolbar.Session" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent"> |
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar |
||||||
|
android:id="@+id/toolbar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="?attr/actionBarSize" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent" |
||||||
|
app:title="@string/more" /> |
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout> |
||||||
|
|
||||||
|
<net.pokeranalytics.android.ui.modules.handhistory.replayer.ReplayerView |
||||||
|
android:id="@+id/replayer" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="0dp" |
||||||
|
app:layout_constraintBottom_toBottomOf="parent" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toBottomOf="@+id/appBar" /> |
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
||||||
Loading…
Reference in new issue