commit
58284b7e6b
@ -0,0 +1,46 @@ |
|||||||
|
package net.pokeranalytics.android.ui.activity |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import android.content.Intent |
||||||
|
import android.os.Bundle |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.util.PokerAnalyticsActivity |
||||||
|
|
||||||
|
class DataManagementActivity: PokerAnalyticsActivity() { |
||||||
|
|
||||||
|
companion object { |
||||||
|
fun newInstance(context: Context, dataType: Int) { |
||||||
|
val intent = Intent(context, DataManagementActivity::class.java) |
||||||
|
intent.putExtra("dataType", dataType) |
||||||
|
context.startActivity(intent) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) { |
||||||
|
super.onCreate(savedInstanceState) |
||||||
|
// setContentView(R.layout.activity_data_management) |
||||||
|
|
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init UI |
||||||
|
*/ |
||||||
|
private fun initUI() { |
||||||
|
|
||||||
|
val isTournament = intent.getIntExtra("dataType", 0) |
||||||
|
// val fragment = newSessionFragment as NewSessionFragment |
||||||
|
// fragment.setData(isTournament) |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init data |
||||||
|
*/ |
||||||
|
private fun initData() { |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,48 @@ |
|||||||
|
package net.pokeranalytics.android.ui.activity |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import android.content.Intent |
||||||
|
import android.os.Bundle |
||||||
|
import kotlinx.android.synthetic.main.activity_new_session.* |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.fragment.NewSessionFragment |
||||||
|
import net.pokeranalytics.android.util.PokerAnalyticsActivity |
||||||
|
|
||||||
|
class NewSessionActivity: PokerAnalyticsActivity() { |
||||||
|
|
||||||
|
companion object { |
||||||
|
fun newInstance(context: Context, isTournament: Boolean) { |
||||||
|
val intent = Intent(context, NewSessionActivity::class.java) |
||||||
|
intent.putExtra("is_tournament", isTournament) |
||||||
|
context.startActivity(intent) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) { |
||||||
|
super.onCreate(savedInstanceState) |
||||||
|
setContentView(R.layout.activity_new_session) |
||||||
|
|
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init UI |
||||||
|
*/ |
||||||
|
private fun initUI() { |
||||||
|
|
||||||
|
val isTournament = intent.getBooleanExtra("is_tournament", false) |
||||||
|
val fragment = newSessionFragment as NewSessionFragment |
||||||
|
fragment.setData(isTournament) |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init data |
||||||
|
*/ |
||||||
|
private fun initData() { |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,53 @@ |
|||||||
|
package net.pokeranalytics.android.ui.adapter |
||||||
|
|
||||||
|
import android.view.LayoutInflater |
||||||
|
import android.view.View |
||||||
|
import android.view.ViewGroup |
||||||
|
import androidx.recyclerview.widget.RecyclerView |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.model.realm.Session |
||||||
|
import timber.log.Timber |
||||||
|
|
||||||
|
class NewSessionAdapter(private var session: Session) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { |
||||||
|
|
||||||
|
companion object { |
||||||
|
const val ROW_SESSION: Int = 100 |
||||||
|
} |
||||||
|
|
||||||
|
//var onClickOnSession: ((position: Int) -> Unit)? = null |
||||||
|
|
||||||
|
inner class RowSessionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { |
||||||
|
fun bind() { |
||||||
|
Timber.d("Bind session") |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { |
||||||
|
when (viewType) { |
||||||
|
ROW_SESSION -> return RowSessionViewHolder( |
||||||
|
LayoutInflater.from(parent.context).inflate( |
||||||
|
R.layout.row_history_session, |
||||||
|
parent, |
||||||
|
false |
||||||
|
) |
||||||
|
) |
||||||
|
else -> throw IllegalStateException("Need to implement type $viewType in NewSessionAdapter") |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { |
||||||
|
when (getItemViewType(position)) { |
||||||
|
ROW_SESSION -> (holder as NewSessionAdapter.RowSessionViewHolder).bind() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun getItemCount(): Int { |
||||||
|
return 2 |
||||||
|
} |
||||||
|
|
||||||
|
override fun getItemViewType(position: Int): Int { |
||||||
|
return ROW_SESSION |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,79 @@ |
|||||||
|
package net.pokeranalytics.android.ui.adapter |
||||||
|
|
||||||
|
import android.view.LayoutInflater |
||||||
|
import android.view.View |
||||||
|
import android.view.ViewGroup |
||||||
|
import androidx.recyclerview.widget.RecyclerView |
||||||
|
import kotlinx.android.synthetic.main.row_data_cell.view.* |
||||||
|
import kotlinx.android.synthetic.main.row_history_session.view.* |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
|
||||||
|
class SettingsAdapter() : RecyclerView.Adapter<RecyclerView.ViewHolder>() { |
||||||
|
|
||||||
|
companion object { |
||||||
|
const val ROW_DATA: Int = 100 |
||||||
|
enum class DataType { |
||||||
|
BANKROLL { |
||||||
|
override fun localizedName(): String { |
||||||
|
return "Bankroll" |
||||||
|
} |
||||||
|
}, |
||||||
|
GAME { |
||||||
|
override fun localizedName(): String { |
||||||
|
return "Game" |
||||||
|
} |
||||||
|
}, |
||||||
|
LOCATION { |
||||||
|
override fun localizedName(): String { |
||||||
|
return "Location" |
||||||
|
} |
||||||
|
}, |
||||||
|
TOURNAMENT_TYPE { |
||||||
|
override fun localizedName(): String { |
||||||
|
return "Tournament Type" |
||||||
|
} |
||||||
|
}, |
||||||
|
TRANSACTION_TYPE { |
||||||
|
override fun localizedName(): String { |
||||||
|
return "Transaction" |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
abstract fun localizedName(): String |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
var onClickOnData: ((position: Int, dataType: DataType) -> Unit)? = null |
||||||
|
|
||||||
|
inner class RowDataViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { |
||||||
|
fun bind(dataType: DataType) { |
||||||
|
itemView.dataRow.setData(dataType.localizedName()) |
||||||
|
itemView.dataRow.setOnClickListener { |
||||||
|
onClickOnData?.invoke(adapterPosition, dataType) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { |
||||||
|
when (viewType) { |
||||||
|
ROW_DATA -> return RowDataViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.row_data_cell, parent, false)) |
||||||
|
else -> throw IllegalStateException("Need to implement type $viewType in Settings Adapter") |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { |
||||||
|
when (getItemViewType(position)) { |
||||||
|
ROW_DATA -> (holder as SettingsAdapter.RowDataViewHolder).bind(enumValues<DataType>()[position]) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun getItemCount(): Int { |
||||||
|
return enumValues<DataType>().count() |
||||||
|
} |
||||||
|
|
||||||
|
override fun getItemViewType(position: Int): Int { |
||||||
|
return ROW_DATA |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,56 @@ |
|||||||
|
package net.pokeranalytics.android.ui.fragment |
||||||
|
|
||||||
|
import android.os.Bundle |
||||||
|
import android.view.LayoutInflater |
||||||
|
import android.view.View |
||||||
|
import android.view.ViewGroup |
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager |
||||||
|
import kotlinx.android.synthetic.main.fragment_new_session.* |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.model.realm.Session |
||||||
|
import net.pokeranalytics.android.ui.adapter.NewSessionAdapter |
||||||
|
import net.pokeranalytics.android.util.PokerAnalyticsFragment |
||||||
|
|
||||||
|
class NewSessionFragment: PokerAnalyticsFragment() { |
||||||
|
|
||||||
|
private lateinit var newSession: Session |
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
||||||
|
return inflater.inflate(R.layout.fragment_new_session, container, false) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||||
|
super.onViewCreated(view, savedInstanceState) |
||||||
|
|
||||||
|
initData() |
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
private fun initData() { |
||||||
|
newSession = Session() |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init UI |
||||||
|
*/ |
||||||
|
private fun initUI() { |
||||||
|
|
||||||
|
val viewManager = LinearLayoutManager(requireContext()) |
||||||
|
val newSessionAdapter = NewSessionAdapter(newSession) |
||||||
|
|
||||||
|
recyclerView.apply { |
||||||
|
setHasFixedSize(true) |
||||||
|
layoutManager = viewManager |
||||||
|
adapter = newSessionAdapter |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Set fragment data |
||||||
|
*/ |
||||||
|
fun setData(isTournament: Boolean) { |
||||||
|
title.text = if (isTournament) "New tournament" else "New cash game" |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,55 @@ |
|||||||
|
package net.pokeranalytics.android.ui.view |
||||||
|
|
||||||
|
import android.widget.FrameLayout |
||||||
|
import android.content.Context |
||||||
|
import android.util.AttributeSet |
||||||
|
import android.view.LayoutInflater |
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout |
||||||
|
import kotlinx.android.synthetic.main.row_data_cell.view.* |
||||||
|
import kotlinx.android.synthetic.main.row_data_content_view.view.* |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
|
||||||
|
|
||||||
|
class DataRowView : FrameLayout { |
||||||
|
|
||||||
|
private lateinit var rowDataCell: ConstraintLayout |
||||||
|
|
||||||
|
/** |
||||||
|
* Constructors |
||||||
|
*/ |
||||||
|
constructor(context: Context) : super(context) { |
||||||
|
init() |
||||||
|
} |
||||||
|
|
||||||
|
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { |
||||||
|
init() |
||||||
|
} |
||||||
|
|
||||||
|
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { |
||||||
|
init() |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init |
||||||
|
* |
||||||
|
* @param attrs |
||||||
|
*/ |
||||||
|
private fun init() { |
||||||
|
val layoutInflater = LayoutInflater.from(context) |
||||||
|
rowDataCell = layoutInflater.inflate(R.layout.row_data_content_view, this, false) as ConstraintLayout |
||||||
|
val layoutParams = FrameLayout.LayoutParams( |
||||||
|
FrameLayout.LayoutParams.MATCH_PARENT, |
||||||
|
FrameLayout.LayoutParams.WRAP_CONTENT |
||||||
|
) |
||||||
|
|
||||||
|
addView(rowDataCell, layoutParams) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the session data to the view |
||||||
|
*/ |
||||||
|
fun setData(title: String) { |
||||||
|
rowDataCell.rowTitle.text = title |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:orientation="vertical" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
|
||||||
|
<fragment |
||||||
|
android:id="@+id/newSessionFragment" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:name="net.pokeranalytics.android.ui.fragment.NewSessionFragment" /> |
||||||
|
|
||||||
|
</LinearLayout> |
||||||
@ -0,0 +1,31 @@ |
|||||||
|
<?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="match_parent"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/title" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:text="New session" |
||||||
|
android:layout_marginTop="8dp" |
||||||
|
app:layout_constraintTop_toTopOf="parent" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
android:layout_marginEnd="8dp" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
android:layout_marginStart="8dp"/> |
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView |
||||||
|
android:id="@+id/recyclerView" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="0dp" |
||||||
|
app:layout_constraintTop_toBottomOf="@+id/title" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintBottom_toBottomOf="parent" |
||||||
|
android:layout_marginTop="8dp"/> |
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<FrameLayout |
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content"> |
||||||
|
|
||||||
|
<net.pokeranalytics.android.ui.view.DataRowView |
||||||
|
android:id="@+id/dataRow" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" /> |
||||||
|
|
||||||
|
</FrameLayout> |
||||||
@ -0,0 +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.appcompat.widget.AppCompatTextView |
||||||
|
android:id="@+id/rowTitle" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
android:layout_marginEnd="8dp" |
||||||
|
android:layout_marginTop="8dp" |
||||||
|
android:textSize="20sp" |
||||||
|
tools:text="Data Type Title" |
||||||
|
app:layout_constraintTop_toTopOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
android:layout_marginStart="8dp" |
||||||
|
android:layout_marginBottom="8dp" |
||||||
|
app:layout_constraintBottom_toBottomOf="parent"/> |
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
||||||
Loading…
Reference in new issue