public override View GetView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; TextView lblTop = null; TextView lblBottom = null; TextView lblTime = null; ViewGroup rowView = (ViewGroup)convertView; if (rowView == null) { rowView = (ViewGroup)vi.Inflate(Resource.Layout.row, null); lblTop = (TextView)rowView.FindViewById(Resource.Id.toptext); lblBottom = (TextView)rowView.FindViewById(Resource.Id.bottomtext); lblTime = (TextView)rowView.FindViewById(Resource.Id.text_date_time); holder = new ViewHolder(); holder.lblTop = lblTop; holder.lblBottom = lblBottom; holder.lblTime = lblTime; rowView.Tag = holder; } else { holder = rowView.Tag as ViewHolder; lblTop = holder.lblTop; lblBottom = holder.lblBottom; lblTime = holder.lblTime; lblBottom.Visibility = ViewStates.Visible; lblBottom.Text = ""; lblTop.SetTextColor(rowView.Context.Resources.GetColor( Resource.Color.log_regular_text_color)); lblTop.Text = ""; } LogMessage rpcObj = items[position]; if (rpcObj != null) { lblBottom.Visibility = ViewStates.Gone; if (rpcObj is StringLogMessage) { StringLogMessage myStringLog = (StringLogMessage)rpcObj; lblTop.Text = myStringLog.getMessage(); lblTime.Text = rpcObj.getDate(); lblTop.SetTextColor(Color.Black); } else if (rpcObj is RpcLogMessage) { RpcMessage func = ((RpcLogMessage)rpcObj).getMessage(); if (func.getRpcMessageType() == RpcMessageType.REQUEST) { lblTop.SetTextColor(ContextCompat.GetColorStateList(rowView.Context, Resource.Color.log_request_text_color)); lblTop.Text = rpcObj.getPrependComment() + ((RpcRequest)func).method + " (" + func.getRpcMessageFlow().ToString().ToLower() + " " + func.getRpcMessageType().ToString().ToLower() + ")"; } else if (func.getRpcMessageType() == RpcMessageType.RESPONSE) { lblBottom.Visibility = ViewStates.Visible; HmiApiLib.Common.Enums.Result resultCode = (HmiApiLib.Common.Enums.Result)((HmiApiLib.Base.Result)((RpcResponse)func).result).code; lblTop.Text = rpcObj.getPrependComment() + ((HmiApiLib.Base.Result)((RpcResponse)func).result).method + " (" + func.getRpcMessageFlow().ToString().ToLower() + " " + func.getRpcMessageType().ToString().ToLower() + ")"; if ((resultCode == HmiApiLib.Common.Enums.Result.SUCCESS) || (resultCode == HmiApiLib.Common.Enums.Result.WARNINGS)) { lblTop.SetTextColor(ContextCompat.GetColorStateList(rowView.Context, Resource.Color.log_response_success_text_color)); lblBottom.SetTextColor(ContextCompat.GetColorStateList(rowView.Context, Resource.Color.log_response_success_text_color)); } else { lblTop.SetTextColor(ContextCompat.GetColorStateList(rowView.Context, Resource.Color.log_response_failure_text_color)); lblBottom.SetTextColor(ContextCompat.GetColorStateList(rowView.Context, Resource.Color.log_response_failure_text_color)); } lblBottom.Text = (resultCode).ToString(); } else if ((func.getRpcMessageType() == RpcMessageType.NOTIFICATION) || (func.getRpcMessageType() == RpcMessageType.REQUEST_NOTIFY)) { if (func.getRpcMessageType() == RpcMessageType.NOTIFICATION) { lblTop.Text = rpcObj.getPrependComment() + ((RpcNotification)func).method + " (" + func.getRpcMessageFlow().ToString().ToLower() + " " + func.getRpcMessageType().ToString().ToLower() + ")"; } else { lblTop.Text = rpcObj.getPrependComment() + ((RequestNotifyMessage)func).method + " (" + func.getRpcMessageFlow().ToString().ToLower() + " " + func.getRpcMessageType().ToString().ToLower() + ")"; } lblTop.SetTextColor(ContextCompat.GetColorStateList(rowView.Context, Resource.Color.log_notification_text_color)); } lblTime.Text = rpcObj.getDate(); } } return(rowView); }
public void handleQueueingError(string info, Exception ex) { LogMessage logMessage = new StringLogMessage(info); addMessageToUI(logMessage); }