diff --git a/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt b/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt index e2a338a9..942b323c 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt @@ -6,18 +6,39 @@ import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor import org.w3c.dom.Text +/** + * Base Interface to provide the RowRepresentable to the adapter + */ interface RowRepresentableDataSource: EditableDataSource, DisplayableDataSource { + /** - * Returns a list of rows + * Returns a prebuild list of rows */ fun adapterRows(): List? + /** + * Returns a [RowRepresentable] at position [Int] + */ fun rowRepresentableForPosition(position:Int): RowRepresentable? + + /** + * Returns the number of [RowRepresentable] to display + */ fun numberOfRows(): Int + + /** + * Returns the ordinal value of [RowViewType] at position [Int] + */ fun viewTypeForPosition(position:Int): Int + + //TODO should be removed fun indexForRow(row: RowRepresentable): Int } +/** + * Interface extending [RowRepresentableDataSource] to guide the implementation of a prebuild list of [RowRepresentable] + * To do that, this interface overrides and provides a default implementation to specific methods of [RowRepresentableDataSource] + */ interface StaticRowRepresentableDataSource: RowRepresentableDataSource { override fun rowRepresentableForPosition(position:Int): RowRepresentable? { this.adapterRows()?.let { @@ -48,12 +69,19 @@ interface StaticRowRepresentableDataSource: RowRepresentableDataSource { } } +/** + * Interface extending [RowRepresentableDataSource] to guide the implementation of a live list of [RowRepresentable] + * To do that, this interface overrides and provides a default implementation to specific methods of [RowRepresentableDataSource] + */ interface LiveRowRepresentableDataSource: RowRepresentableDataSource { override fun adapterRows(): List? { return null } } +/** + * Custom class providing the value to display and how to display them + */ class DisplayDescriptor( var boolValue: Boolean? = null, var stringValue: String? = null, @@ -115,6 +143,9 @@ interface DisplayableDataSource { } +/** + * An interface providing a way to describe how the edition of a [RowRepresentable] will be displayed + */ interface EditableDataSource { /** * A list of [RowRepresentableEditDescriptor] object specifying the way the edition will be handled