@ -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,52 @@ |
||||
package net.pokeranalytics.android.ui.activity |
||||
|
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import android.os.Bundle |
||||
import io.realm.Realm |
||||
import io.realm.kotlin.where |
||||
import kotlinx.android.synthetic.main.activity_data_list.* |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.model.realm.Session |
||||
import net.pokeranalytics.android.ui.fragment.DataListFragment |
||||
import net.pokeranalytics.android.util.PokerAnalyticsActivity |
||||
import net.pokeranalytics.android.util.data.sessionDao |
||||
import java.util.* |
||||
|
||||
class DataListActivity : PokerAnalyticsActivity() { |
||||
|
||||
companion object { |
||||
fun newInstance(context: Context, dataType: Int) { |
||||
val intent = Intent(context, DataListActivity::class.java) |
||||
intent.putExtra("dataType", dataType) |
||||
context.startActivity(intent) |
||||
} |
||||
} |
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) { |
||||
super.onCreate(savedInstanceState) |
||||
setContentView(R.layout.activity_data_list) |
||||
|
||||
initUI() |
||||
} |
||||
|
||||
/** |
||||
* Init UI |
||||
*/ |
||||
private fun initUI() { |
||||
|
||||
val dataType = intent.getIntExtra("dataType", 0) |
||||
val fragment = dataListFragment as DataListFragment |
||||
fragment.setData(dataType) |
||||
} |
||||
|
||||
/** |
||||
* Init data |
||||
*/ |
||||
private fun initData() { |
||||
|
||||
|
||||
|
||||
} |
||||
|
||||
} |
||||
@ -1,79 +0,0 @@ |
||||
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: Int) -> 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.ordinal) |
||||
} |
||||
} |
||||
} |
||||
|
||||
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,51 @@ |
||||
package net.pokeranalytics.android.ui.adapter.components |
||||
|
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import androidx.recyclerview.widget.RecyclerView |
||||
import kotlinx.android.synthetic.main.row_session.view.* |
||||
import net.pokeranalytics.android.R |
||||
|
||||
interface DataRowDelegate { |
||||
fun data(position: Int) : DisplayableData |
||||
fun size() : Int |
||||
} |
||||
|
||||
interface DataRowCallback { |
||||
fun onRowSelected(position: Int) |
||||
} |
||||
|
||||
interface DisplayableData { |
||||
var title: String |
||||
} |
||||
|
||||
class DataListAdapter(var delegate: DataRowDelegate, var callBackDelegate: DataRowCallback? = null) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { |
||||
|
||||
inner class DataViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { |
||||
fun bind(row: DisplayableData, listener: View.OnClickListener) { |
||||
itemView.title.text = row.title |
||||
itemView.container.setOnClickListener(listener) |
||||
} |
||||
} |
||||
|
||||
override fun getItemViewType(position: Int): Int { |
||||
return RowViewType.TITLE.ordinal |
||||
} |
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { |
||||
return DataViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.row_title, parent, false)) |
||||
} |
||||
|
||||
override fun getItemCount(): Int { |
||||
return delegate.size() |
||||
} |
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { |
||||
val listener = View.OnClickListener { |
||||
callBackDelegate?.onRowSelected(position) |
||||
} |
||||
(holder as DataViewHolder).bind(this.delegate.data(position), listener) |
||||
} |
||||
|
||||
} |
||||
@ -1,19 +1,67 @@ |
||||
package net.pokeranalytics.android.ui.adapter.components |
||||
|
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import android.widget.Toast |
||||
import androidx.recyclerview.widget.RecyclerView |
||||
import kotlinx.android.synthetic.main.row_session.view.* |
||||
import net.pokeranalytics.android.R |
||||
|
||||
interface DynamicHolder { |
||||
|
||||
fun bind(row: DynamicRowInterface, delegate: DynamicRowDelegate? = null, listener: View.OnClickListener) |
||||
|
||||
} |
||||
|
||||
enum class RowViewType { |
||||
HEADER, |
||||
TEXTFIELD; |
||||
EDIT_TEXT, |
||||
TITLE, |
||||
TITLE_VALUE; |
||||
|
||||
inner class FakeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), DynamicHolder { |
||||
override fun bind(row: DynamicRowInterface, delegate: DynamicRowDelegate?, listener: View.OnClickListener) { |
||||
} |
||||
} |
||||
|
||||
inner class PlaceholderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { |
||||
inner class TitleValueViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), DynamicHolder { |
||||
override fun bind(row: DynamicRowInterface, delegate: DynamicRowDelegate?, listener: View.OnClickListener) { |
||||
itemView.title.text = row.localizedTitle(itemView.context) |
||||
delegate?.let { |
||||
itemView.value.text = it.stringForRow(row) |
||||
} |
||||
itemView.container.setOnClickListener(listener) |
||||
} |
||||
} |
||||
|
||||
inner class TitleViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), DynamicHolder { |
||||
override fun bind(row: DynamicRowInterface, delegate: DynamicRowDelegate?, listener: View.OnClickListener) { |
||||
itemView.title.text = row.localizedTitle(itemView.context) |
||||
itemView.container.setOnClickListener(listener) |
||||
} |
||||
} |
||||
|
||||
fun viewHolder(parent: ViewGroup) : RecyclerView.ViewHolder { |
||||
return PlaceholderViewHolder(parent) |
||||
|
||||
fun viewHolder(parent: ViewGroup): RecyclerView.ViewHolder { |
||||
return when (this) { |
||||
TITLE_VALUE -> TitleValueViewHolder( |
||||
LayoutInflater.from(parent.context).inflate( |
||||
R.layout.row_session, |
||||
parent, |
||||
false |
||||
) |
||||
) |
||||
TITLE -> TitleViewHolder( |
||||
LayoutInflater.from(parent.context).inflate( |
||||
R.layout.row_title, |
||||
parent, |
||||
false |
||||
) |
||||
) |
||||
|
||||
else -> FakeViewHolder(parent) |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,83 @@ |
||||
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 io.realm.Realm |
||||
import io.realm.RealmObject |
||||
import io.realm.RealmResults |
||||
import io.realm.Sort |
||||
import kotlinx.android.synthetic.main.fragment_new_session.* |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.model.realm.* |
||||
import net.pokeranalytics.android.ui.adapter.components.* |
||||
import net.pokeranalytics.android.util.PokerAnalyticsFragment |
||||
import net.pokeranalytics.android.util.data.sessionDao |
||||
import java.util.* |
||||
import kotlin.collections.ArrayList |
||||
|
||||
class DataListFragment : PokerAnalyticsFragment(), DataRowDelegate, DataRowCallback { |
||||
|
||||
private lateinit var dataType: DataObjectRowType |
||||
|
||||
private lateinit var realmObjects: ArrayList<RealmObject> |
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
||||
return inflater.inflate(R.layout.fragment_data_list, container, false) |
||||
} |
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||
super.onViewCreated(view, savedInstanceState) |
||||
initData() |
||||
initUI() |
||||
} |
||||
|
||||
override fun data(position: Int): DisplayableData { |
||||
return (realmObjects[position] as DisplayableData) |
||||
} |
||||
|
||||
override fun onRowSelected(position: Int) { |
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
||||
} |
||||
|
||||
override fun size(): Int { |
||||
return realmObjects.size |
||||
} |
||||
|
||||
private fun initData() { |
||||
} |
||||
|
||||
/** |
||||
* Init UI |
||||
*/ |
||||
private fun initUI() { |
||||
|
||||
val viewManager = LinearLayoutManager(requireContext()) |
||||
val dataListAdapter = DataListAdapter(this, this) |
||||
|
||||
recyclerView.apply { |
||||
setHasFixedSize(true) |
||||
layoutManager = viewManager |
||||
adapter = dataListAdapter |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Set fragment data |
||||
*/ |
||||
fun setData(dataType: Int) { |
||||
this.dataType = DataObjectRowType.values()[dataType] |
||||
val realm = Realm.getDefaultInstance() |
||||
|
||||
realmObjects = ArrayList( when (DataObjectRowType.values()[dataType]) { |
||||
DataObjectRowType.BANKROLL -> realm.where(Bankroll::class.java).findAll().sort("name", Sort.DESCENDING) |
||||
DataObjectRowType.GAME-> realm.where(Game::class.java).findAll().sort("name", Sort.DESCENDING) |
||||
DataObjectRowType.LOCATION -> realm.where(Location::class.java).findAll().sort("name", Sort.DESCENDING) |
||||
DataObjectRowType.TOURNAMENT_TYPE -> realm.where(TournamentFeature::class.java).findAll().sort("name", Sort.DESCENDING) |
||||
DataObjectRowType.TRANSACTION_TYPE -> realm.where(TransactionType::class.java).findAll().sort("name", Sort.DESCENDING) |
||||
}) |
||||
} |
||||
} |
||||
@ -0,0 +1,57 @@ |
||||
package net.pokeranalytics.android.ui.fragment.components |
||||
|
||||
import android.os.Bundle |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.inputmethod.EditorInfo |
||||
import kotlinx.android.synthetic.main.bottom_sheet_blinds.* |
||||
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.model.realm.Session |
||||
|
||||
class BottomSheetBlindsFragment : BottomSheetFragment() { |
||||
|
||||
private var session: Session = Session() |
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||
super.onViewCreated(view, savedInstanceState) |
||||
initData() |
||||
initUI() |
||||
} |
||||
|
||||
override fun clickOnCheck() { |
||||
super.clickOnCheck() |
||||
valueDelegate.setValue(session, row) |
||||
dismiss() |
||||
} |
||||
|
||||
override fun onStart() { |
||||
super.onStart() |
||||
smallBlind.requestFocus() |
||||
} |
||||
|
||||
/** |
||||
* Init data |
||||
*/ |
||||
private fun initData() { |
||||
val data = getData() |
||||
session = if (data is Session) data else Session() |
||||
} |
||||
|
||||
/** |
||||
* Init UI |
||||
*/ |
||||
private fun initUI() { |
||||
|
||||
LayoutInflater.from(requireContext()).inflate(R.layout.bottom_sheet_blinds, view?.bottomSheetContainer, true) |
||||
|
||||
bigBlind.setOnEditorActionListener { v, actionId, event -> |
||||
if (actionId == EditorInfo.IME_ACTION_DONE) { |
||||
clickOnCheck() |
||||
} |
||||
true |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,61 @@ |
||||
package net.pokeranalytics.android.ui.fragment.components |
||||
|
||||
import android.os.Bundle |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import kotlinx.android.synthetic.main.bottom_sheet_date.* |
||||
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.model.realm.TimeFrame |
||||
import net.pokeranalytics.android.ui.fragment.components.BottomSheetFragment |
||||
import net.pokeranalytics.android.util.DatePickerFragment |
||||
import net.pokeranalytics.android.util.TimePickerFragment |
||||
|
||||
class BottomSheetDateFragment : BottomSheetFragment() { |
||||
|
||||
private var timeFrame: TimeFrame = TimeFrame() |
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||
super.onViewCreated(view, savedInstanceState) |
||||
initData() |
||||
initUI() |
||||
} |
||||
|
||||
override fun clickOnCheck() { |
||||
super.clickOnCheck() |
||||
valueDelegate.setValue(timeFrame, row) |
||||
dismiss() |
||||
} |
||||
|
||||
/** |
||||
* Init data |
||||
*/ |
||||
private fun initData() { |
||||
val data = getData() |
||||
timeFrame = if (data is TimeFrame) data else TimeFrame() |
||||
} |
||||
|
||||
/** |
||||
* Init UI |
||||
*/ |
||||
private fun initUI() { |
||||
|
||||
LayoutInflater.from(requireContext()).inflate(R.layout.bottom_sheet_date, view?.bottomSheetContainer, true) |
||||
|
||||
setAddButtonVisible(false) |
||||
|
||||
startDate.setOnClickListener { |
||||
val dateFragment = DatePickerFragment() |
||||
dateFragment.show(fragmentManager, "datePicker") |
||||
} |
||||
|
||||
endDate.setOnClickListener { |
||||
val timeFragment = TimePickerFragment() |
||||
timeFragment.show(fragmentManager, "timePicker") |
||||
} |
||||
|
||||
//data.startDate = Date() |
||||
//data.endDate = Date() |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,143 @@ |
||||
package net.pokeranalytics.android.ui.fragment.components |
||||
|
||||
import android.os.Bundle |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import android.view.WindowManager |
||||
import androidx.constraintlayout.widget.ConstraintLayout |
||||
import androidx.fragment.app.FragmentManager |
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment |
||||
import kotlinx.android.synthetic.main.fragment_bottom_sheet.* |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.ui.adapter.components.DynamicRowInterface |
||||
import net.pokeranalytics.android.ui.adapter.components.EditableDataDelegate |
||||
|
||||
enum class BottomSheetType { |
||||
NONE, |
||||
GAME, |
||||
BLINDS, |
||||
LOCATION, |
||||
BANKROLL, |
||||
TABLE_SIZE, |
||||
DATE |
||||
} |
||||
|
||||
interface BottomSheetInterface { |
||||
fun clickOnClear() |
||||
fun clickOnCheck() |
||||
fun clickOnAdd() |
||||
} |
||||
|
||||
open class BottomSheetFragment : BottomSheetDialogFragment(), BottomSheetInterface { |
||||
|
||||
lateinit var row: DynamicRowInterface |
||||
lateinit var valueDelegate: EditableDataDelegate |
||||
|
||||
private var data: Any? = null |
||||
|
||||
companion object { |
||||
fun create( fragmentManager: FragmentManager?, row: DynamicRowInterface, valueDelegate: EditableDataDelegate, data: Any?): BottomSheetFragment { |
||||
|
||||
val bottomSheetFragment = when (row.bottomSheetType) { |
||||
BottomSheetType.BLINDS -> BottomSheetBlindsFragment() |
||||
BottomSheetType.DATE -> BottomSheetDateFragment() |
||||
BottomSheetType.GAME -> BottomSheetGameFragment() |
||||
else -> BottomSheetFragment() |
||||
} |
||||
|
||||
bottomSheetFragment.show(fragmentManager, "bottomSheet") |
||||
bottomSheetFragment.row = row |
||||
bottomSheetFragment.valueDelegate = valueDelegate |
||||
bottomSheetFragment.data = data |
||||
return bottomSheetFragment |
||||
} |
||||
} |
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
||||
val view = inflater.inflate( |
||||
net.pokeranalytics.android.R.layout.fragment_bottom_sheet, |
||||
container, |
||||
false |
||||
) as ConstraintLayout |
||||
|
||||
return view |
||||
} |
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||
super.onViewCreated(view, savedInstanceState) |
||||
initUI() |
||||
} |
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) { |
||||
super.onActivityCreated(savedInstanceState) |
||||
|
||||
// To display correctly the keyboard |
||||
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) |
||||
} |
||||
|
||||
override fun clickOnClear() { |
||||
} |
||||
|
||||
override fun clickOnCheck() { |
||||
} |
||||
|
||||
override fun clickOnAdd() { |
||||
} |
||||
|
||||
/** |
||||
* Init UI |
||||
*/ |
||||
private fun initUI() { |
||||
row.let { |
||||
bottomSheetToolbar.title = row.localizedTitle(requireContext()) |
||||
bottomSheetToolbar.inflateMenu(net.pokeranalytics.android.R.menu.bottom_sheet_menu) |
||||
bottomSheetToolbar.setOnMenuItemClickListener { |
||||
false |
||||
} |
||||
} |
||||
|
||||
// Menu |
||||
bottomSheetToolbar.menu.findItem(R.id.actionClear).setOnMenuItemClickListener { |
||||
clickOnClear() |
||||
true |
||||
} |
||||
bottomSheetToolbar.menu.findItem(R.id.actionAdd).setOnMenuItemClickListener { |
||||
clickOnAdd() |
||||
true |
||||
} |
||||
bottomSheetToolbar.menu.findItem(R.id.actionCheck).setOnMenuItemClickListener { |
||||
clickOnCheck() |
||||
true |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Return the data object |
||||
*/ |
||||
fun getData() : Any? { |
||||
return data |
||||
} |
||||
|
||||
/** |
||||
* Set clear button visibility |
||||
*/ |
||||
fun setClearButtonVisibile(visible: Boolean) { |
||||
bottomSheetToolbar.menu.findItem(R.id.actionClear).isVisible = visible |
||||
} |
||||
|
||||
/** |
||||
* Set check button visibility |
||||
*/ |
||||
fun setCheckButtonVisibile(visible: Boolean) { |
||||
bottomSheetToolbar.menu.findItem(R.id.actionCheck).isVisible = visible |
||||
} |
||||
|
||||
/** |
||||
* Set add button visibility |
||||
*/ |
||||
fun setAddButtonVisible(visible: Boolean) { |
||||
bottomSheetToolbar.menu.findItem(R.id.actionAdd).isVisible = visible |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,77 @@ |
||||
package net.pokeranalytics.android.ui.fragment.components |
||||
|
||||
import android.content.Context |
||||
import android.os.Bundle |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import androidx.recyclerview.widget.LinearLayoutManager |
||||
import kotlinx.android.synthetic.main.bottom_sheet_game.* |
||||
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.model.realm.Game |
||||
import net.pokeranalytics.android.ui.adapter.components.DynamicListAdapter |
||||
import net.pokeranalytics.android.ui.adapter.components.DynamicRowDelegate |
||||
import net.pokeranalytics.android.ui.adapter.components.DynamicRowInterface |
||||
|
||||
|
||||
|
||||
class BottomSheetGameFragment : BottomSheetFragment(), DynamicRowDelegate { |
||||
|
||||
private var game: Game = Game() |
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||
super.onViewCreated(view, savedInstanceState) |
||||
initData() |
||||
initUI() |
||||
} |
||||
|
||||
override fun clickOnCheck() { |
||||
super.clickOnCheck() |
||||
valueDelegate.setValue(game, row) |
||||
dismiss() |
||||
} |
||||
|
||||
override fun adapterRows(): ArrayList<DynamicRowInterface> { |
||||
val array = ArrayList<DynamicRowInterface>() |
||||
array.add(TitleObject("Game 1")) |
||||
array.add(TitleObject("Game 2")) |
||||
array.add(TitleObject("Game 3")) |
||||
return array |
||||
} |
||||
|
||||
/** |
||||
* Init data |
||||
*/ |
||||
private fun initData() { |
||||
val data = getData() |
||||
game = if (data is Game) data else Game() |
||||
} |
||||
|
||||
/** |
||||
* Init UI |
||||
*/ |
||||
private fun initUI() { |
||||
LayoutInflater.from(requireContext()).inflate(R.layout.bottom_sheet_game, view?.bottomSheetContainer, true) |
||||
|
||||
val viewManager = LinearLayoutManager(requireContext()) |
||||
val dataAdapter = DynamicListAdapter(this) |
||||
|
||||
gameNameRecyclerView.apply { |
||||
setHasFixedSize(true) |
||||
layoutManager = viewManager |
||||
//adapter = dataAdapter |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
inner class TitleObject(var title: String) : DynamicRowInterface { |
||||
override fun localizedTitle(context: Context): String { |
||||
return title |
||||
} |
||||
|
||||
override var viewType: Int = 0 |
||||
override var bottomSheetType: BottomSheetType = BottomSheetType.NONE |
||||
} |
||||
|
||||
} |
||||
@ -1,55 +0,0 @@ |
||||
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,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,9 @@ |
||||
package net.pokeranalytics.android.util |
||||
|
||||
import timber.log.Timber |
||||
|
||||
class PokerAnalyticsLogs : Timber.DebugTree() { |
||||
override fun log(priority: Int, tag: String?, message: String, throwable: Throwable?) { |
||||
super.log(priority, "PokerAnalytics:$tag", message, throwable) |
||||
} |
||||
} |
||||
@ -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 |
||||
} |
||||
} |
||||
|
After Width: | Height: | Size: 593 B |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 819 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 478 B |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1016 B |
|
After Width: | Height: | Size: 358 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 260 B |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 746 B |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 280 KiB |
|
After Width: | Height: | Size: 116 B |
|
After Width: | Height: | Size: 824 B |
|
After Width: | Height: | Size: 411 B |
|
After Width: | Height: | Size: 472 B |
|
After Width: | Height: | Size: 378 B |
|
After Width: | Height: | Size: 401 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 801 B |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 468 B |
|
After Width: | Height: | Size: 211 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 151 B |
|
After Width: | Height: | Size: 701 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 212 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 376 B |
|
After Width: | Height: | Size: 121 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
@ -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,9 @@ |
||||
<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="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="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,16 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<shape |
||||
xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:shape="rectangle"> |
||||
|
||||
<solid |
||||
android:color="@color/green"/> |
||||
|
||||
<corners |
||||
android:radius="8dp" /> |
||||
|
||||
<size |
||||
android:width="32dp" |
||||
android:height="32dp"/> |
||||
|
||||
</shape> |
||||
@ -0,0 +1,14 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:color="?android:attr/colorControlHighlight"> |
||||
<item android:id="@android:id/mask"> |
||||
<shape android:shape="rectangle"> |
||||
<solid android:color="#000000" /> |
||||
<corners android:radius="8dp" /> |
||||
<size |
||||
android:width="32dp" |
||||
android:height="32dp" /> |
||||
</shape> |
||||
</item> |
||||
<item android:drawable="@drawable/rectangle_rounded_green" /> |
||||
</ripple> |
||||
@ -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/dataListFragment" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:name="net.pokeranalytics.android.ui.fragment.DataListFragment" /> |
||||
|
||||
</LinearLayout> |
||||
@ -1,31 +1,30 @@ |
||||
<?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" |
||||
tools:context=".ui.activity.HomeActivity"> |
||||
<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" |
||||
tools:context=".ui.activity.HomeActivity"> |
||||
|
||||
<FrameLayout |
||||
android:id="@+id/container" |
||||
android:layout_width="0dp" |
||||
android:layout_height="0dp" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintBottom_toTopOf="@+id/navigation" |
||||
app:layout_constraintTop_toTopOf="parent"/> |
||||
android:id="@+id/container" |
||||
android:layout_width="0dp" |
||||
android:layout_height="0dp" |
||||
app:layout_constraintBottom_toTopOf="@+id/navigation" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView |
||||
android:id="@+id/navigation" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginEnd="0dp" |
||||
android:layout_marginStart="0dp" |
||||
android:background="?android:attr/windowBackground" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintLeft_toLeftOf="parent" |
||||
app:layout_constraintRight_toRightOf="parent" |
||||
app:menu="@menu/navigation"/> |
||||
android:id="@+id/navigation" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="0dp" |
||||
android:layout_marginEnd="0dp" |
||||
android:background="?android:attr/windowBackground" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintLeft_toLeftOf="parent" |
||||
app:layout_constraintRight_toRightOf="parent" |
||||
app:menu="@menu/navigation" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
@ -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> |
||||