parent
97dc033d23
commit
75248ffdec
@ -1,15 +1,70 @@ |
|||||||
package net.pokeranalytics.android.model.realm |
package net.pokeranalytics.android.model.realm |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import io.realm.Realm |
||||||
import io.realm.RealmObject |
import io.realm.RealmObject |
||||||
import io.realm.annotations.PrimaryKey |
import io.realm.annotations.PrimaryKey |
||||||
|
import net.pokeranalytics.android.model.interfaces.Deletable |
||||||
|
import net.pokeranalytics.android.model.interfaces.DeleteValidityStatus |
||||||
|
import net.pokeranalytics.android.model.interfaces.NameManageable |
||||||
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
||||||
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SimpleRow |
||||||
|
import net.pokeranalytics.android.util.NULL_TEXT |
||||||
import java.util.* |
import java.util.* |
||||||
|
|
||||||
open class Player : RealmObject() { |
open class Player : RealmObject(), NameManageable, Deletable, StaticRowRepresentableDataSource, RowRepresentable { |
||||||
|
|
||||||
|
companion object { |
||||||
|
val rowRepresentation: List<RowRepresentable> by lazy { |
||||||
|
val rows = ArrayList<RowRepresentable>() |
||||||
|
rows.add(SimpleRow.NAME) |
||||||
|
rows |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
@PrimaryKey |
@PrimaryKey |
||||||
var id = UUID.randomUUID().toString() |
override var id = UUID.randomUUID().toString() |
||||||
|
|
||||||
// The name of the player |
// The name of the player |
||||||
var name: String = "" |
override var name: String = "" |
||||||
|
|
||||||
|
|
||||||
|
override fun isValidForDelete(realm: Realm): Boolean { |
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
||||||
|
} |
||||||
|
|
||||||
|
override fun getFailedDeleteMessage(status: DeleteValidityStatus): Int { |
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
||||||
|
} |
||||||
|
|
||||||
|
override fun adapterRows(): List<RowRepresentable>? { |
||||||
|
return rowRepresentation |
||||||
|
} |
||||||
|
|
||||||
|
override fun getDisplayName(context: Context): String { |
||||||
|
return this.name |
||||||
} |
} |
||||||
|
|
||||||
|
override fun stringForRow(row: RowRepresentable): String { |
||||||
|
return when (row) { |
||||||
|
SimpleRow.NAME -> if (this.name.isNotEmpty()) this.name else NULL_TEXT |
||||||
|
else -> return super.stringForRow(row) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun editDescriptors(row: RowRepresentable): ArrayList<RowRepresentableEditDescriptor>? { |
||||||
|
return when (row) { |
||||||
|
SimpleRow.NAME -> row.editingDescriptors(mapOf("defaultValue" to this.name)) |
||||||
|
else -> null |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun updateValue(value: Any?, row: RowRepresentable) { |
||||||
|
when (row) { |
||||||
|
SimpleRow.NAME -> this.name = value as String? ?: "" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,9 @@ |
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:width="24dp" |
||||||
|
android:height="24dp" |
||||||
|
android:viewportWidth="24" |
||||||
|
android:viewportHeight="24"> |
||||||
|
<path |
||||||
|
android:fillColor="#FFFFFFFF" |
||||||
|
android:pathData="M9,13.75c-2.34,0 -7,1.17 -7,3.5L2,19h14v-1.75c0,-2.33 -4.66,-3.5 -7,-3.5zM4.34,17c0.84,-0.58 2.87,-1.25 4.66,-1.25s3.82,0.67 4.66,1.25L4.34,17zM9,12c1.93,0 3.5,-1.57 3.5,-3.5S10.93,5 9,5 5.5,6.57 5.5,8.5 7.07,12 9,12zM9,7c0.83,0 1.5,0.67 1.5,1.5S9.83,10 9,10s-1.5,-0.67 -1.5,-1.5S8.17,7 9,7zM16.04,13.81c1.16,0.84 1.96,1.96 1.96,3.44L18,19h4v-1.75c0,-2.02 -3.5,-3.17 -5.96,-3.44zM15,12c1.93,0 3.5,-1.57 3.5,-3.5S16.93,5 15,5c-0.54,0 -1.04,0.13 -1.5,0.35 0.63,0.89 1,1.98 1,3.15s-0.37,2.26 -1,3.15c0.46,0.22 0.96,0.35 1.5,0.35z"/> |
||||||
|
</vector> |
||||||
Loading…
Reference in new issue