|
|
|
|
@ -1,17 +1,26 @@ |
|
|
|
|
package net.pokeranalytics.android.ui.view.rowrepresentable |
|
|
|
|
|
|
|
|
|
import android.text.InputType |
|
|
|
|
import android.widget.Toast |
|
|
|
|
import androidx.fragment.app.Fragment |
|
|
|
|
import io.realm.RealmResults |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.model.TournamentType |
|
|
|
|
import net.pokeranalytics.android.model.extensions.SessionState |
|
|
|
|
import net.pokeranalytics.android.model.extensions.getState |
|
|
|
|
import net.pokeranalytics.android.model.realm.Bankroll |
|
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetFragment |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType |
|
|
|
|
import net.pokeranalytics.android.ui.helpers.DateTimePickerManager |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
|
import net.pokeranalytics.android.util.extensions.round |
|
|
|
|
import net.pokeranalytics.android.util.extensions.sorted |
|
|
|
|
import java.util.* |
|
|
|
|
import kotlin.collections.ArrayList |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum class SessionRow : RowRepresentable { |
|
|
|
|
@ -175,6 +184,54 @@ enum class SessionRow : RowRepresentable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun startEditing(dataSource: Any?, parent: Fragment?) { |
|
|
|
|
if (dataSource == null) return |
|
|
|
|
if (dataSource !is Session) return |
|
|
|
|
if (parent == null) return |
|
|
|
|
if (parent !is RowRepresentableDelegate) return |
|
|
|
|
|
|
|
|
|
when (this) { |
|
|
|
|
START_DATE -> DateTimePickerManager.create(parent.requireContext(), this, parent, dataSource.startDate) |
|
|
|
|
END_DATE -> { |
|
|
|
|
|
|
|
|
|
if (dataSource.startDate == null) { |
|
|
|
|
Toast.makeText(parent.context, R.string.session_missing_start_date, Toast.LENGTH_SHORT).show() |
|
|
|
|
} else { |
|
|
|
|
DateTimePickerManager.create( |
|
|
|
|
parent.requireContext(), |
|
|
|
|
this, |
|
|
|
|
parent, |
|
|
|
|
dataSource.endDate ?: dataSource.startDate ?: Date(), |
|
|
|
|
dataSource.startDate |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
BANKROLL -> { |
|
|
|
|
BottomSheetFragment.create(parent.fragmentManager, this, parent, this.editingData(dataSource), false, dataSource.currency) |
|
|
|
|
} |
|
|
|
|
else -> BottomSheetFragment.create( |
|
|
|
|
parent.fragmentManager, |
|
|
|
|
this, |
|
|
|
|
parent, |
|
|
|
|
this.editingData(dataSource), |
|
|
|
|
currentCurrency = dataSource.currency |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun editingData(session:Session): ArrayList<RowRepresentableEditDescriptor>? { |
|
|
|
|
return when (this) { |
|
|
|
|
BANKROLL -> { |
|
|
|
|
arrayListOf( |
|
|
|
|
RowRepresentableEditDescriptor(session.bankroll, data = session.realm.sorted<Bankroll>() as RealmResults<RowRepresentable>) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
else -> null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun editingDescriptors(map: Map<String, Any?>): ArrayList<RowRepresentableEditDescriptor>? { |
|
|
|
|
return when (this) { |
|
|
|
|
BLINDS -> { |
|
|
|
|
|