PolyBooks/sdp_polyBooks

View on GitHub
app/src/main/java/com/github/polybooks/adapter/SortingParameterAdapter.kt

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
package com.github.polybooks.adapter

import android.content.Context
import com.github.polybooks.utils.FieldWithName

/**
 * An adapter for an sorting parameter
 *
 * @param itemViewId   view id in the xml layout of a value item
 * @param enumInstance any instance of class T (needed to be able to use methods of T)
 * @see   ParameterAdapter
 */
class SortingParameterAdapter<T: FieldWithName>(itemViewId: Int, enumInstance: T):
    ParameterAdapter<T>(
        itemViewId,
        enumInstance.javaClass.enumConstants.drop(1)
    ) {

    override fun getItemViewType(): Int {
        return ViewTypes.VIEW_TYPE_RADIOBOX
    }

    override fun getValueName(value: T, context: Context?): String {
        return value.fieldName(context)
    }
}