import android.widget.TextView
import com.stoutner.privacycell.R
+import com.stoutner.privacycell.dataclasses.Protocol
-class ProtocolArrayAdapter(context: Context, protocolArrayList: ArrayList<Pair<String, Boolean>>) : ArrayAdapter<Pair<String, Boolean>>(context, 0, protocolArrayList) {
+class ProtocolArrayAdapter(context: Context, protocolArrayList: ArrayList<Protocol>) : ArrayAdapter<Protocol>(context, 0, protocolArrayList) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
+ // Get a handle for the protocol.
+ val protocol = getItem(position)!!
+
// Create a populated view and inflate the layout.
- val populatedView = if (getItem(position)!!.second) { // The protocol is a header entry.
+ val populatedView = if (protocol.isHeader) { // The protocol is a header entry.
LayoutInflater.from(context).inflate(R.layout.protocol_header_textview, parent, false)
} else { // The protocol is not a header entry.
LayoutInflater.from(context).inflate(R.layout.protocol_item_textview, parent, false)
val textView = populatedView.findViewById<TextView>(R.id.textview)
// Populate the text view with the corresponding item from the protocol array list.
- textView.text = getItem(position)!!.first
+ textView.text = protocol.protocolName
+
+ // Change the text view background if the protocol is additional network info.
+ if (protocol.isAdditionalNetworkInfo) {
+ textView.setBackgroundColor(context.getColor(R.color.additional_network_info))
+ }
// Return the populated view.
return populatedView