X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyCell.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Fadapters%2FProtocolArrayAdapter.kt;h=54bfd652f1320cf8fa558aba9733d1f9898f73a6;hp=77576ac1992317f5dd64599f9fa798a0fc2578f4;hb=b11b84b24c660fac3a69f2dbe4bd615d73811219;hpb=dc76c6f07fd9a5718049d160e079842fa60ff406 diff --git a/app/src/main/java/com/stoutner/privacycell/adapters/ProtocolArrayAdapter.kt b/app/src/main/java/com/stoutner/privacycell/adapters/ProtocolArrayAdapter.kt index 77576ac..54bfd65 100644 --- a/app/src/main/java/com/stoutner/privacycell/adapters/ProtocolArrayAdapter.kt +++ b/app/src/main/java/com/stoutner/privacycell/adapters/ProtocolArrayAdapter.kt @@ -27,11 +27,15 @@ import android.widget.ArrayAdapter import android.widget.TextView import com.stoutner.privacycell.R +import com.stoutner.privacycell.dataclasses.Protocol -class ProtocolArrayAdapter(context: Context, protocolArrayList: ArrayList>) : ArrayAdapter>(context, 0, protocolArrayList) { +class ProtocolArrayAdapter(context: Context, protocolArrayList: ArrayList) : ArrayAdapter(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) @@ -41,7 +45,12 @@ class ProtocolArrayAdapter(context: Context, protocolArrayList: ArrayList(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