|
|
|
@ -1,6 +1,7 @@ |
|
|
|
package net.pokeranalytics.android.model.realm |
|
|
|
package net.pokeranalytics.android.model.realm |
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
|
|
|
|
import android.text.InputType |
|
|
|
import io.realm.Realm |
|
|
|
import io.realm.Realm |
|
|
|
import io.realm.RealmList |
|
|
|
import io.realm.RealmList |
|
|
|
import io.realm.RealmObject |
|
|
|
import io.realm.RealmObject |
|
|
|
@ -11,6 +12,7 @@ import net.pokeranalytics.android.model.interfaces.DeleteValidityStatus |
|
|
|
import net.pokeranalytics.android.model.interfaces.NameManageable |
|
|
|
import net.pokeranalytics.android.model.interfaces.NameManageable |
|
|
|
import net.pokeranalytics.android.model.interfaces.SaveValidityStatus |
|
|
|
import net.pokeranalytics.android.model.interfaces.SaveValidityStatus |
|
|
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
|
|
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
@ -58,13 +60,16 @@ open class CustomField : RealmObject(), NameManageable, StaticRowRepresentableDa |
|
|
|
updateRowRepresentation() |
|
|
|
updateRowRepresentation() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun localizedTitle(context: Context): String { |
|
|
|
|
|
|
|
return this.name |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun getDisplayName(context: Context): String { |
|
|
|
override fun getDisplayName(context: Context): String { |
|
|
|
return this.name |
|
|
|
return this.name |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
@Ignore |
|
|
|
override val viewType: Int = RowViewType.TITLE_VALUE_ARROW.ordinal |
|
|
|
override var viewType: Int = RowViewType.TITLE_VALUE_ARROW.ordinal |
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
@Ignore |
|
|
|
private var rowRepresentation: List<RowRepresentable> = mutableListOf() |
|
|
|
private var rowRepresentation: List<RowRepresentable> = mutableListOf() |
|
|
|
@ -105,6 +110,14 @@ open class CustomField : RealmObject(), NameManageable, StaticRowRepresentableDa |
|
|
|
return R.string.relationship_error |
|
|
|
return R.string.relationship_error |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override val bottomSheetType: BottomSheetType |
|
|
|
|
|
|
|
get() { |
|
|
|
|
|
|
|
return when (type) { |
|
|
|
|
|
|
|
Type.LIST.uniqueIdentifier -> BottomSheetType.LIST_STATIC |
|
|
|
|
|
|
|
else -> BottomSheetType.EDIT_TEXT |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun editDescriptors(row: RowRepresentable): ArrayList<RowRepresentableEditDescriptor>? { |
|
|
|
override fun editDescriptors(row: RowRepresentable): ArrayList<RowRepresentableEditDescriptor>? { |
|
|
|
return when (row) { |
|
|
|
return when (row) { |
|
|
|
is CustomFieldEntry -> row.editingDescriptors( |
|
|
|
is CustomFieldEntry -> row.editingDescriptors( |
|
|
|
@ -116,6 +129,28 @@ open class CustomField : RealmObject(), NameManageable, StaticRowRepresentableDa |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun editingDescriptors(map: Map<String, Any?>): ArrayList<RowRepresentableEditDescriptor>? { |
|
|
|
|
|
|
|
return when (type) { |
|
|
|
|
|
|
|
Type.LIST.uniqueIdentifier -> { |
|
|
|
|
|
|
|
val defaultValue: Any? by map |
|
|
|
|
|
|
|
val data: RealmList<CustomFieldEntry>? by map |
|
|
|
|
|
|
|
arrayListOf( |
|
|
|
|
|
|
|
RowRepresentableEditDescriptor(defaultValue, staticData = data) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> { |
|
|
|
|
|
|
|
val defaultValue: String? by map |
|
|
|
|
|
|
|
arrayListOf( |
|
|
|
|
|
|
|
RowRepresentableEditDescriptor( |
|
|
|
|
|
|
|
defaultValue, inputType = InputType.TYPE_CLASS_NUMBER |
|
|
|
|
|
|
|
or InputType.TYPE_NUMBER_FLAG_DECIMAL |
|
|
|
|
|
|
|
or InputType.TYPE_NUMBER_FLAG_SIGNED |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Update the row representation |
|
|
|
* Update the row representation |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -160,6 +195,7 @@ open class CustomField : RealmObject(), NameManageable, StaticRowRepresentableDa |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun addEntry(): CustomFieldEntry { |
|
|
|
fun addEntry(): CustomFieldEntry { |
|
|
|
val entry = CustomFieldEntry() |
|
|
|
val entry = CustomFieldEntry() |
|
|
|
|
|
|
|
entry.customField = this |
|
|
|
entries.add(entry) |
|
|
|
entries.add(entry) |
|
|
|
sortEntries() |
|
|
|
sortEntries() |
|
|
|
updateRowRepresentation() |
|
|
|
updateRowRepresentation() |
|
|
|
@ -175,5 +211,4 @@ open class CustomField : RealmObject(), NameManageable, StaticRowRepresentableDa |
|
|
|
updateRowRepresentation() |
|
|
|
updateRowRepresentation() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |