parent
a3b00a0726
commit
b1116df47f
@ -0,0 +1,36 @@ |
|||||||
|
package net.pokeranalytics.android.model |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
|
||||||
|
class TableSize(var numberOfPlayer:Int): RowRepresentable { |
||||||
|
companion object { |
||||||
|
val all = Array(8, init = |
||||||
|
{ index -> TableSize(index+2)}) |
||||||
|
} |
||||||
|
|
||||||
|
override val resId: Int? |
||||||
|
get() { |
||||||
|
return if (this.numberOfPlayer == 2) { |
||||||
|
R.string.heads_up |
||||||
|
} else { |
||||||
|
R.string.max |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun localizedTitle(context: Context): String { |
||||||
|
this.resId?.let { |
||||||
|
return if (this.numberOfPlayer == 2) { |
||||||
|
context.getString(it) |
||||||
|
} else { |
||||||
|
"$this.numberOfPlayer$context.getString(it)" |
||||||
|
} |
||||||
|
} |
||||||
|
return super.localizedTitle(context) |
||||||
|
} |
||||||
|
|
||||||
|
override val viewType: Int |
||||||
|
get() = RowViewType.TITLE_GRID.ordinal |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package net.pokeranalytics.android.model.interfaces |
||||||
|
|
||||||
|
/** |
||||||
|
* An interface to easily handle the validity of any object we want to save |
||||||
|
*/ |
||||||
|
interface Savable { |
||||||
|
/** |
||||||
|
* A method to define if an object is safe for saving in database |
||||||
|
*/ |
||||||
|
fun isValidForSave(): Boolean { |
||||||
|
//TODO should be by default to false |
||||||
|
return true |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* A unique identifier getter |
||||||
|
*/ |
||||||
|
fun uniqueIdentifier(): String |
||||||
|
} |
||||||
@ -1,11 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.fragment.components.bottomsheet |
|
||||||
|
|
||||||
import android.text.InputType |
|
||||||
import io.realm.RealmResults |
|
||||||
|
|
||||||
class BottomSheetData( |
|
||||||
var defaultValue: Any? = null, |
|
||||||
var hint: Int? = null, |
|
||||||
var inputType: Int? = InputType.TYPE_CLASS_TEXT, |
|
||||||
var data: RealmResults<*>? = null |
|
||||||
) |
|
||||||
@ -1,8 +1,30 @@ |
|||||||
package net.pokeranalytics.android.ui.view |
package net.pokeranalytics.android.ui.view |
||||||
|
|
||||||
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetData |
import android.text.InputType |
||||||
|
import io.realm.RealmResults |
||||||
|
|
||||||
|
/** |
||||||
|
* An interface to describe how an object can be editable and to handle the update of the object |
||||||
|
*/ |
||||||
interface RowEditable { |
interface RowEditable { |
||||||
fun getBottomSheetData(row: RowRepresentable): ArrayList<BottomSheetData> |
/** |
||||||
|
* A list of [RowEditableDescriptor] object specifying the way the edition will be handled |
||||||
|
*/ |
||||||
|
fun rowEditableDescriptors(row: RowRepresentable): ArrayList<RowEditableDescriptor> |
||||||
|
|
||||||
|
/** |
||||||
|
* a method to handle the modification of the object. |
||||||
|
* Through [RowRepresentable] the object is able to update the right variable with the new value. |
||||||
|
*/ |
||||||
fun updateValue(value: Any?, row: RowRepresentable) |
fun updateValue(value: Any?, row: RowRepresentable) |
||||||
} |
} |
||||||
|
|
||||||
|
/** |
||||||
|
* An container class to describe the way an field of an object will be edited |
||||||
|
*/ |
||||||
|
class RowEditableDescriptor( |
||||||
|
var defaultValue: Any? = null, |
||||||
|
var hint: Int? = null, |
||||||
|
var inputType: Int? = InputType.TYPE_CLASS_TEXT, |
||||||
|
var data: RealmResults<*>? = null |
||||||
|
) |
||||||
Loading…
Reference in new issue