parent
5b6615ee53
commit
7fd812c25e
@ -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<RowRepresentableEditDescriptor> { |
||||||
|
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<RowRepresentable> { |
||||||
|
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 |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
Loading…
Reference in new issue