|
|
|
|
@ -1,21 +1,76 @@ |
|
|
|
|
package net.pokeranalytics.android.ui.fragment |
|
|
|
|
|
|
|
|
|
import android.app.DatePickerDialog |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_bottom_sheet_container.* |
|
|
|
|
import android.content.Context |
|
|
|
|
import android.content.DialogInterface |
|
|
|
|
import android.view.* |
|
|
|
|
import android.view.inputmethod.InputMethodManager |
|
|
|
|
|
|
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout |
|
|
|
|
import kotlinx.android.synthetic.main.bottom_sheet_blinds.* |
|
|
|
|
import kotlinx.android.synthetic.main.bottom_sheet_date.* |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_bottom_sheet.* |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.components.DynamicRowInterface |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.components.EditableDataDelegate |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.BottomSheetType |
|
|
|
|
import timber.log.Timber |
|
|
|
|
import android.widget.DatePicker |
|
|
|
|
import net.pokeranalytics.android.util.DatePickerFragment |
|
|
|
|
import net.pokeranalytics.android.util.TimePickerFragment |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BottomSheetFragment : BottomSheetDialogFragment() { |
|
|
|
|
|
|
|
|
|
private var row: DynamicRowInterface? = null |
|
|
|
|
private var valueDelegate: EditableDataDelegate? = null |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
row?.let { |
|
|
|
|
when (it.bottomSheetType) { |
|
|
|
|
BottomSheetType.BANKROLL -> inflater.inflate( |
|
|
|
|
net.pokeranalytics.android.R.layout.bottom_sheet_bankroll, |
|
|
|
|
view.bottomSheetContainer, |
|
|
|
|
true |
|
|
|
|
) |
|
|
|
|
BottomSheetType.BLINDS -> inflater.inflate( |
|
|
|
|
net.pokeranalytics.android.R.layout.bottom_sheet_blinds, |
|
|
|
|
view.bottomSheetContainer, |
|
|
|
|
true |
|
|
|
|
) |
|
|
|
|
BottomSheetType.DATE -> inflater.inflate( |
|
|
|
|
net.pokeranalytics.android.R.layout.bottom_sheet_date, |
|
|
|
|
view.bottomSheetContainer, |
|
|
|
|
true |
|
|
|
|
) |
|
|
|
|
BottomSheetType.GAME -> inflater.inflate( |
|
|
|
|
net.pokeranalytics.android.R.layout.bottom_sheet_game, |
|
|
|
|
view.bottomSheetContainer, |
|
|
|
|
true |
|
|
|
|
) |
|
|
|
|
BottomSheetType.LOCATION -> inflater.inflate( |
|
|
|
|
net.pokeranalytics.android.R.layout.bottom_sheet_location, |
|
|
|
|
view.bottomSheetContainer, |
|
|
|
|
true |
|
|
|
|
) |
|
|
|
|
BottomSheetType.TABLE_SIZE -> inflater.inflate( |
|
|
|
|
net.pokeranalytics.android.R.layout.bottom_sheet_table_size, |
|
|
|
|
view.bottomSheetContainer, |
|
|
|
|
true |
|
|
|
|
) |
|
|
|
|
else -> { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return inflater.inflate(net.pokeranalytics.android.R.layout.fragment_bottom_sheet_container, container, false) |
|
|
|
|
return view |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
|
@ -23,46 +78,80 @@ class BottomSheetFragment : BottomSheetDialogFragment() { |
|
|
|
|
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 onStart() { |
|
|
|
|
super.onStart() |
|
|
|
|
|
|
|
|
|
// Open the keyboard |
|
|
|
|
/* |
|
|
|
|
val inputMethodManager = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager |
|
|
|
|
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0) |
|
|
|
|
editText.requestFocus() |
|
|
|
|
*/ |
|
|
|
|
row?.let { |
|
|
|
|
when (it.bottomSheetType) { |
|
|
|
|
BottomSheetType.BLINDS -> { |
|
|
|
|
smallBlind.requestFocus() |
|
|
|
|
} |
|
|
|
|
else -> { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Actions: |
|
|
|
|
* - Add / Add ? |
|
|
|
|
* - Clear / Garbage ? |
|
|
|
|
* - Done / Check ? |
|
|
|
|
* - |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
override fun onDismiss(dialog: DialogInterface?) { |
|
|
|
|
super.onDismiss(dialog) |
|
|
|
|
val inputMethodManager = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager |
|
|
|
|
inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0) |
|
|
|
|
|
|
|
|
|
// Return the value |
|
|
|
|
row?.let { |
|
|
|
|
valueDelegate?.setValue("Test", it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Init UI |
|
|
|
|
*/ |
|
|
|
|
private fun initUI() { |
|
|
|
|
close.setOnClickListener { |
|
|
|
|
dismiss() |
|
|
|
|
|
|
|
|
|
row?.let { |
|
|
|
|
//bottomSheetToolbar.title = row?.localizedTitle(requireContext()) |
|
|
|
|
bottomSheetToolbar.inflateMenu(net.pokeranalytics.android.R.menu.bottom_sheet_menu) |
|
|
|
|
bottomSheetToolbar.setOnMenuItemClickListener { |
|
|
|
|
false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
row?.let { |
|
|
|
|
when (it.bottomSheetType) { |
|
|
|
|
BottomSheetType.DATE -> initDateUI() |
|
|
|
|
else -> {} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* Init date UI |
|
|
|
|
*/ |
|
|
|
|
fun displayDataForRow() { |
|
|
|
|
private fun initDateUI() { |
|
|
|
|
|
|
|
|
|
startDate.setOnClickListener { |
|
|
|
|
val dateFragment = DatePickerFragment() |
|
|
|
|
dateFragment.show(fragmentManager, "datePicker") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
endDate.setOnClickListener { |
|
|
|
|
val timeFragment = TimePickerFragment() |
|
|
|
|
timeFragment.show(fragmentManager, "timePicker") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Init |
|
|
|
|
*/ |
|
|
|
|
fun init(row: DynamicRowInterface, valueDelegate: EditableDataDelegate) { |
|
|
|
|
this.row = row |
|
|
|
|
this.valueDelegate = valueDelegate |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |