public static void BindHolder(Dialogue dialogue, TextView address, TextView msgText, TextView timeText, RelativeLayout readStateRL, TextView readStateCnt) { TextMessage lastMessage = dialogue[0]; //대화 중 가장 마지막 문자 //이름 혹은 연락처 표시, 문자 내용 표시 address.Text = dialogue.DisplayName; if (lastMessage.GetType() == typeof(MultiMediaMessage)) { MultiMediaMessage objMMS = lastMessage as MultiMediaMessage; switch (objMMS.MediaType) { case (int)MultiMediaMessage.MEDIA_TYPE.TEXT: msgText.Text = objMMS.Msg; break; case (int)MultiMediaMessage.MEDIA_TYPE.IMAGE: msgText.Text = objMMS.Msg != null ? objMMS.Msg : "이미지 MMS"; break; case (int)MultiMediaMessage.MEDIA_TYPE.VCF: msgText.Text = objMMS.Msg != null ? objMMS.Msg : "VCF MMS"; break; } } else { msgText.Text = lastMessage.Msg; } //날짜 표시 DateTimeUtillity dtu = new DateTimeUtillity(); if (dtu.GetNow().Year <= dtu.GetYear(lastMessage.Time)) //올해 메시지이면 { if (dtu.GetDatetime(lastMessage.Time) >= dtu.GetToday()) { timeText.Text = dtu.MilisecondToDateTimeStr(lastMessage.Time, "a hh:mm"); //오늘 메시지이면 } else { timeText.Text = dtu.MilisecondToDateTimeStr(lastMessage.Time, "MM월 dd일"); //올해인데 오늘 메시지가 아님 } } else { timeText.Text = dtu.MilisecondToDateTimeStr(lastMessage.Time, "yyyy년 MM월 dd일"); //올해 메시지가 아님 } //문자 읽음 여부에 따른 상태표시기 표시여부 및 카운트설정 if (dialogue.UnreadCnt > 0) { readStateRL.Visibility = ViewStates.Visible; readStateCnt.Text = dialogue.UnreadCnt.ToString(); } else { readStateRL.Visibility = ViewStates.Invisible; } }
//----------------------------------------------------------------- //대화(메세지 목록)을 리사이클러뷰에 넣기 알맞은 형태로 변환하고, 날짜별로 그룹화 및 헤더추가함. public List <RecyclerItem> GetRecyclerItem(Dialogue iDialogue) { string prevTime = "NULL"; List <RecyclerItem> recyclerItems = new List <RecyclerItem>(); if (iDialogue.Count <= 0) { return(recyclerItems); } for (int i = 0; i < iDialogue.Count; i++) { DateTimeUtillity dtu = new DateTimeUtillity(); string objTime = dtu.MilisecondToDateTimeStr(iDialogue[i].Time, "yyyy년 MM월 dd일 E요일"); if (prevTime != objTime) { if (prevTime != "NULL") { recyclerItems.Add(new HeaderItem(prevTime)); } prevTime = objTime; } recyclerItems.Add(new MessageItem(iDialogue[i])); } recyclerItems.Add(new HeaderItem(prevTime)); return(recyclerItems); }
public void Bind(List <RecyclerItem> list, int iPosition) { MessageItem obj = list[iPosition] as MessageItem; TextMessage message = obj.TextMessage; mMsg.Text = message.Msg; if (message.Msg != string.Empty && message.Msg != null) { mMsg.Visibility = ViewStates.Visible; } else { mMsg.Visibility = ViewStates.Gone; } DateTimeUtillity dtu = new DateTimeUtillity(); mTime.Text = dtu.MilisecondToDateTimeStr(message.Time, "a hh:mm"); if (message.GetType() == typeof(MultiMediaMessage)) { mMmsTag.Visibility = ViewStates.Visible; MultiMediaMessage mms = message as MultiMediaMessage; if (mms.MediaType == (int)MultiMediaMessage.MEDIA_TYPE.IMAGE) { if (mms.Bitmap != null) { mMmsImage.SetImageBitmap(mms.Bitmap); mMmsImage.Visibility = ViewStates.Visible; } else { mMmsImage.SetImageBitmap(null); mMmsImage.Visibility = ViewStates.Gone; } } else { mMmsImage.SetImageBitmap(null); mMmsImage.Visibility = ViewStates.Gone; } } else { mMmsImage.SetImageBitmap(null); mMmsTag.Visibility = ViewStates.Gone; mMmsImage.Visibility = ViewStates.Gone; } }
public void Bind(List <RecyclerItem> list, int iPosition, ContactData iContact) { MessageItem obj = list[iPosition] as MessageItem; TextMessage message = obj.TextMessage; //연락처에 있는 사람이면 if (iContact != null) { ////연락처에 사진이 있다면 사진으로 대체 if (iContact.PhotoThumnail_uri != null) { mProfileImage.SetImageURI(Android.Net.Uri.Parse(iContact.PhotoThumnail_uri)); } else { mProfileImage.SetImageResource(Resource.Drawable.profile_icon_256_background); } } else { //연락처에 사진이 없으면 기본사진으로 설정 mProfileImage.SetImageResource(Resource.Drawable.profile_icon_256_background); } mMsg.Text = message.Msg; if (message.Msg != string.Empty && message.Msg != null) { mMsg.Visibility = ViewStates.Visible; } else { mMsg.Visibility = ViewStates.Gone; } DateTimeUtillity dtu = new DateTimeUtillity(); mTime.Text = dtu.MilisecondToDateTimeStr(message.Time, "a hh:mm"); if (message.GetType() == typeof(MultiMediaMessage)) { mMmsTag.Visibility = ViewStates.Visible; MultiMediaMessage mms = message as MultiMediaMessage; if (mms.MediaType == (int)MultiMediaMessage.MEDIA_TYPE.IMAGE) { if (mms.Bitmap != null) { mMmsImage.SetImageBitmap(mms.Bitmap); mMmsImage.Visibility = ViewStates.Visible; } else { mMmsImage.SetImageBitmap(null); mMmsImage.Visibility = ViewStates.Gone; } } else { mMmsImage.SetImageBitmap(null); mMmsImage.Visibility = ViewStates.Gone; } } else { mMmsImage.SetImageBitmap(null); mMmsTag.Visibility = ViewStates.Gone; mMmsImage.Visibility = ViewStates.Gone; } }