diff --git a/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableAdapter.kt b/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableAdapter.kt index cd6f2623..3a51110b 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableAdapter.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableAdapter.kt @@ -1,102 +1,18 @@ package net.pokeranalytics.android.ui.adapter -import android.content.Context import android.os.Handler import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.RecyclerView -import kotlinx.android.synthetic.main.fragment_settings.* import net.pokeranalytics.android.ui.view.BindableHolder -import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowViewType -interface RowRepresentableDataSource : DisplayableDataSource { - fun rowRepresentableForPosition(position:Int): RowRepresentable { - if (this.numberOfRows() > position) { - return this.adapterRows()[position] - } else { - throw IllegalStateException("Need to implement Data Source") - } - } - - fun numberOfRows(): Int { - return this.adapterRows().size - } - - fun viewTypeForPosition(position:Int): Int { - return this.rowRepresentableForPosition(position).viewType - } - - fun indexForRow(row:RowRepresentable): Int { - return this.adapterRows().indexOf(row) - } - - /** - * A list of [RowRepresentableEditDescriptor] object specifying the way the edition will be handled - */ - fun editDescriptors(row: RowRepresentable): ArrayList { - return ArrayList() - } -} - interface RowRepresentableDelegate { fun onRowSelected(position: Int, row: RowRepresentable, fromAction:Boolean = false) {} fun onRowValueChanged(value: Any?, row: RowRepresentable) {} } -/** - * An interface used to provide RowRepresentableAdapter content and value in the form of rows - */ -interface DisplayableDataSource { - - /** - * Returns a list of rows - */ - fun adapterRows(): ArrayList { - return ArrayList() - } - - /** - * Returns a boolean for a specific row - */ - fun boolForRow(row: RowRepresentable): Boolean { - return false - } - - /** - * Returns a localized string for a specific row - */ - fun stringForRow(row: RowRepresentable, context: Context): String { - return stringForRow(row) - } - - /** - * Returns a string for a specific row - */ - fun stringForRow(row: RowRepresentable): String { - return "" - } - - - /** - * Returns an action icon identifier for a specific row - */ - fun actionIconForRow(row: RowRepresentable): Int? { - return 0 - } - - /** - * Manages: - * - label (string) - * - segmented control (live/online) - * - textfield (string) - * - switch (bool) - * - static content - * */ -} - /** * An adapter capable of displaying a list of RowRepresentables * @param dataSource the datasource providing rows 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 new file mode 100644 index 00000000..c15b90f1 --- /dev/null +++ b/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt @@ -0,0 +1,84 @@ +package net.pokeranalytics.android.ui.adapter + +import android.content.Context +import net.pokeranalytics.android.ui.view.RowRepresentable +import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor + + +interface RowRepresentableDataSource : DisplayableDataSource { + + fun rowRepresentableForPosition(position:Int): RowRepresentable { + if (this.numberOfRows() > position) { + return this.adapterRows()[position] + } else { + throw IllegalStateException("Need to implement Data Source") + } + } + + fun numberOfRows(): Int { + return this.adapterRows().size + } + + fun viewTypeForPosition(position:Int): Int { + return this.rowRepresentableForPosition(position).viewType + } + + fun indexForRow(row: RowRepresentable): Int { + return this.adapterRows().indexOf(row) + } + + /** + * A list of [RowRepresentableEditDescriptor] object specifying the way the edition will be handled + */ + fun editDescriptors(row: RowRepresentable): ArrayList { + return ArrayList() + } +} + +/** + * An interface used to provide RowRepresentableAdapter content and value in the form of rows + * + * Also returns the appropriate value for any RowRepresentable in the form of : + * - string + * - booleans + * - actionIcon + * to display the appropriate values in graphical components, such as labels, textfields, switchs... + */ +interface DisplayableDataSource { + + /** + * Returns a list of rows + */ + fun adapterRows(): ArrayList { + return ArrayList() + } + + /** + * Returns a boolean for a specific row + */ + fun boolForRow(row: RowRepresentable): Boolean { + return false + } + + /** + * Returns a localized string for a specific row + */ + fun stringForRow(row: RowRepresentable, context: Context): String { + return stringForRow(row) + } + + /** + * Returns a string for a specific row + */ + fun stringForRow(row: RowRepresentable): String { + return "" + } + + /** + * Returns an action icon identifier for a specific row + */ + fun actionIconForRow(row: RowRepresentable): Int? { + return 0 + } + +}