gpt4 book ai didi

android 服务器消息未显示在聊天屏幕上

转载 作者:行者123 更新时间:2023-11-30 02:59:12 26 4
gpt4 key购买 nike

我正在制作一个聊天应用程序(使用 asmack 库)。

它在客户端正常工作;当客户端或用户 1 向服务器发送消息时,服务器接收消息。

但是当服务器响应该客户端时,该值仅显示在 logcat 中,而不显示在聊天屏幕上。

这是图片

enter image description here

服务器收到消息。

The message is received by the server

当服务器回复客户端时,客户端不会得到任何输出。 An image of logcat

但它没有显示在客户端屏幕上。

这是我的代码

servicexmpp.java

PacketFilter filter;       

commanInstance.connection.addPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
chat = (Message) packet;
System.out.println("<--- msg " + chat.getBody());
String name = StringUtils.parseBareAddress(chat.getFrom());
commanInstance.setProperJID(name);
final String fromName=removeAtTheRateFromString(name);
boolean listExistOrNot;
listExistOrNot=commanInstance.listExistOrNot(fromName);
imageName= "patientchat";
jid=fromName;
messagePacketID=chat.getPacketID();
}
}, filter);

适配器.java

 public class MyListAdapterTwoLine extends BaseAdapter {
//-----------------------------------------------------------------------------------------------------------------------------
private List<ItemTwoLine> mListe;
private LayoutInflater inflater;
Context context;
String checkNameOfView;

SharedPreferences myPrefs;
SharedPreferences.Editor prefsEditor;
XMPPObjectPass commanInstance;//chatScreen
//-----------------------------------------------------------------------------------------------------------------------------
public MyListAdapterTwoLine(Context context, List<ItemTwoLine> mListe,String nameOfView) {
inflater = LayoutInflater.from(context);
this.mListe = mListe;
this.context=context;
this.checkNameOfView=nameOfView;
myPrefs = this.context.getSharedPreferences("myPrefs", this.context.MODE_WORLD_READABLE);
prefsEditor = myPrefs.edit();
commanInstance=(XMPPObjectPass)context.getApplicationContext();
}//public MyListAdapterTwoLine(Context context, List<ItemTwoLine> mListe,String nameOfView) {
//-----------------------------------------------------------------------------------------------------------------------------
@Override
public int getCount() {
return mListe.size();
}//public int getCount()
//-----------------------------------------------------------------------------------------------------------------------------
@Override
public Object getItem(int position) {
return mListe.get(position);
}//public Object getItem(int position)
//-----------------------------------------------------------------------------------------------------------------------------
@Override
public long getItemId(int position) {
return position;
}//public long getItemId(int position) {
//-----------------------------------------------------------------------------------------------------------------------------
static class ViewHolder {
TextView text;
ImageView doctorStatus;
}//static class ViewHolder {
//-----------------------------------------------------------------------------------------------------------------------------
public Drawable getRegistredImage() {

return context.getResources().getDrawable(R.drawable.register);
}//public Drawable getGreenImage()
//-----------------------------------------------------------------------------------------------------------------------------

public Drawable getRestrictedImage() {

return context.getResources().getDrawable(R.drawable.restrict);
}//public Drawable getRedImage()
//-----------------------------------------------------------------------------------------------------------------------------

@Override
public View getView(final int position, View convertView, ViewGroup parent)
{

ImageView doctorStatus,myImage1;
TextView nameOfChatter, Msg,TimeDate;
ImageView deliver;
if(checkNameOfView.equals("GroupChatTalkScreen"))
{

// if(mListe.get(position).getTexte2().contains("Me"))
// {
// convertView = inflater.inflate(R.layout.leftchat,null);
//
// doctorStatus= (ImageView) convertView.findViewById(R.id.myImage);
// doctorStatus.setImageDrawable(mListe.get(position).getImage());
// myImage1= (ImageView) convertView.findViewById(R.id.myImage1);
//
//
// nameOfChatter = (TextView) convertView.findViewById(R.id.nameOfChatter);
// if(mListe.get(position).getTexte1().contains("#:#"))
// {
// String nameAndText[]=mListe.get(position).getTexte1().split("#:#");
// //DoctorName.setText(mListe.get(position).getTexte1());
// String nameOfChatterProper[]=null;
// if(nameAndText[0].contains("@"))
// {
// nameOfChatterProper=nameAndText[0].split("@");
// nameOfChatter.setText(Html.fromHtml("<b>" + nameOfChatterProper[0] + "</b>"));
// }
// else
// {
// nameOfChatter.setText(Html.fromHtml("<b>" + nameAndText[0] + "</b>"));
// }
//
// Msg = (TextView) convertView.findViewById(R.id.Msg);
// Msg.setText(Html.fromHtml(nameAndText[1] ));
//
// TimeDate = (TextView) convertView.findViewById(R.id.TimeDate);
// if(mListe.get(position).getTexte2().contains("#:#"))
// {
// String str[]=mListe.get(position).getTexte2().split("#:#");
// TimeDate.setText(Html.fromHtml(str[1]));
// }
// else
// {
// TimeDate.setText(Html.fromHtml(getCurrentTime()));
// }
// deliver = (ImageView) convertView.findViewById(R.id.deliver);
// deliver.setImageResource(R.drawable.sent_group_chat);
// }
// }
// else if(mListe.get(position).getTexte2().contains("You"))
// {
//
// convertView = inflater.inflate(R.layout.rightchat,null);
// doctorStatus= (ImageView) convertView.findViewById(R.id.myImage);
// doctorStatus.setImageDrawable(mListe.get(position).getImage());
//
// myImage1= (ImageView) convertView.findViewById(R.id.myImage1);
//
//
// nameOfChatter = (TextView) convertView.findViewById(R.id.nameOfChatter);
// String nameAndText[]=mListe.get(position).getTexte1().split("#:#");
// //DoctorName.setText(mListe.get(position).getTexte1());
// String nameOfChatterProper[]=null;
// if(nameAndText[0].contains("@"))
// {
// nameOfChatterProper=nameAndText[0].split("@");
// nameOfChatter.setText(Html.fromHtml("<b>" + nameOfChatterProper[0] + "</b>"));
// }
// else
// {
// nameOfChatter.setText(Html.fromHtml("<b>" + nameAndText[0] + "</b>"));
// }
//
// DatabaseHandler db = new DatabaseHandler(context);
// List<Contact> contacts = db.getProfilePicData(nameAndText[0].toLowerCase()+"@imyourdoc.com");
// for(Contact cn : contacts)
// {
// doctorStatus.setImageBitmap(convertByteArrayToBitmap(cn.get_profilePic()));
// }
// db.close();
//
// Msg = (TextView) convertView.findViewById(R.id.Msg);
// Msg.setText(Html.fromHtml(nameAndText[1] ));
//
// TimeDate = (TextView) convertView.findViewById(R.id.TimeDate);
// if(mListe.get(position).getTexte2().contains("#:#"))
// {
// String str[]=mListe.get(position).getTexte2().split("#:#");
// TimeDate.setText(Html.fromHtml(str[1]));
// }
// else
// {
// TimeDate.setText(Html.fromHtml(getCurrentTime()));
// }
//
//
// deliver = (ImageView) convertView.findViewById(R.id.deliver);
// deliver.setBackgroundResource(R.drawable.received);
//
// }

}
else if(mListe.get(position).getTexte2().contains("Me"))
{
convertView = inflater.inflate(R.layout.leftchat,null);

doctorStatus= (ImageView) convertView.findViewById(R.id.myImage);
doctorStatus.setImageBitmap(mListe.get(position).getImageBtimap());

myImage1= (ImageView) convertView.findViewById(R.id.myImage1);


nameOfChatter = (TextView) convertView.findViewById(R.id.nameOfChatter);
if(mListe.get(position).getTexte1().contains("#:#"))
{
String nameAndText[]=mListe.get(position).getTexte1().split("#:#");
String nameOfChatterProper[]=null;
if(nameAndText[0].contains("@"))
{
nameOfChatterProper=nameAndText[0].split("@");
nameOfChatter.setText(Html.fromHtml("<b>" + nameOfChatterProper[0] + "</b>"));
}
else
{
nameOfChatter.setText(Html.fromHtml("<b>" + nameAndText[0] + "</b>"));
}

Msg = (TextView) convertView.findViewById(R.id.Msg);
Msg.setText(Html.fromHtml(nameAndText[1] ));

TimeDate = (TextView) convertView.findViewById(R.id.TimeDate);
if(mListe.get(position).getTexte2().contains("#:#"))
{
String str[]=mListe.get(position).getTexte2().split("#:#");
TimeDate.setText(Html.fromHtml(str[1]));
}
else
{
TimeDate.setText(Html.fromHtml(getCurrentTime()));
}
deliver = (ImageView) convertView.findViewById(R.id.deliver);
//deliver.setText(Html.fromHtml(nameAndText[2] ));
deliver.setImageDrawable(mListe.get(position).getImageStatus());
}
}
else if(mListe.get(position).getTexte2().contains("You"))
{

convertView = inflater.inflate(R.layout.rightchat,null);
doctorStatus= (ImageView) convertView.findViewById(R.id.myImage);

myImage1= (ImageView) convertView.findViewById(R.id.myImage1);


nameOfChatter = (TextView) convertView.findViewById(R.id.nameOfChatter);
String nameAndText[]=mListe.get(position).getTexte1().split("#:#");
String nameOfChatterProper[]=null;
if(nameAndText[0].contains("@"))
{
nameOfChatterProper=nameAndText[0].split("@");
nameOfChatter.setText(Html.fromHtml("<b>" + nameOfChatterProper[0] + "</b>"));
}
else
{
nameOfChatter.setText(Html.fromHtml("<b>" + nameAndText[0] + "</b>"));
}

// DatabaseHandler db = new DatabaseHandler(context);
// List<Contact> contacts = db.getProfilePicData(nameAndText[0].toLowerCase()+"@imyourdoc.com");
// for(Contact cn : contacts)
// {
// doctorStatus.setImageBitmap(convertByteArrayToBitmap(cn.get_profilePic()));
// }

// db.close();

Msg = (TextView) convertView.findViewById(R.id.Msg);
Msg.setText(Html.fromHtml(nameAndText[1] ));

TimeDate = (TextView) convertView.findViewById(R.id.TimeDate);
if(mListe.get(position).getTexte2().contains("#:#"))
{
String str[]=mListe.get(position).getTexte2().split("#:#");
TimeDate.setText(Html.fromHtml(str[1]));
}
else
{
TimeDate.setText(Html.fromHtml(getCurrentTime()));
}


deliver = (ImageView) convertView.findViewById(R.id.deliver);
//deliver.setText(Html.fromHtml(nameAndText[2] ));
deliver.setBackgroundResource(R.drawable.received);

}
else if(mListe.get(position).getTexte2().contains("FileGet"))
{
// convertView = inflater.inflate(R.layout.file_get,null);
//
//
//
// final ImageView att_img= (ImageView) convertView.findViewById(R.id.att_img);
// att_img.setVisibility(View.GONE);
// String unerNameTemp = "",urlTemp="",thumbTemp="",time="";
//
//
// if(mListe.get(position).getTexte1().contains("#:#"))
// {
// String[] data=mListe.get(position).getTexte1().split("#:#");
// unerNameTemp=data[0];
// urlTemp=data[1];
// thumbTemp=data[2];
// }
//
// //final String url = urlTemp;
// final String thumb = thumbTemp;
// final String userName = unerNameTemp;
// if(mListe.get(position).getTexte2().contains("#:#"))
// {
// String[] data=mListe.get(position).getTexte2().split("#:#");
// time=data[1];
// }
//
// final TextView UserName = (TextView) convertView.findViewById(R.id.nameOfChatter);
// UserName.setText(Html.fromHtml("<b>" + unerNameTemp + "</b>"));
//
//
// final TextView file_Name = (TextView) convertView.findViewById(R.id.Msg);
// file_Name.setText(mListe.get(position).getDownloadingTxtAndFileSize());
//
// final TextView timeDate = (TextView) convertView.findViewById(R.id.TimeDate);
// timeDate.setText(time);
//
//
// final ImageView myImage= (ImageView) convertView.findViewById(R.id.myImage);
//
// DatabaseHandler db = new DatabaseHandler(context);
// List<Contact> contacts = db.getProfilePicData(unerNameTemp.toLowerCase()+"@imyourdoc.com");
// for(Contact cn : contacts)
// {
// myImage.setImageBitmap(convertByteArrayToBitmap(cn.get_profilePic()));
// }
// db.close();
//
//
// att_img.setOnClickListener(new OnClickListener()
// {
// @Override
// public void onClick(View v)
// {
// Intent intent = new Intent("com.doctor.download.Start");
// intent.putExtra("position", String.valueOf(position));
// intent.putExtra("userNameMe", commanInstance.getUserName());
// intent.putExtra("userNameYou", userName.toLowerCase());
// context.sendBroadcast(intent);
// }
// });
//
//
// ProgressBar progressBar1 = (ProgressBar) convertView.findViewById(R.id.progressBar1);
// progressBar1.setProgress(mListe.get(position).getDownloadProgress());
// progressBar1.setMax(mListe.get(position).getMaxValue());
// progressBar1.setVisibility(View.GONE);
// final Button accept = (Button) convertView.findViewById(R.id.accept);
// final Button denai = (Button) convertView.findViewById(R.id.denai);
// //Button view = (Button) convertView.findViewById(R.id.view);
//
// final ImageView Deliver= (ImageView) convertView.findViewById(R.id.deliver);
// final ImageView myImage1FileGet= (ImageView) convertView.findViewById(R.id.myImage1);
//
// accept.setOnClickListener(new OnClickListener()
// {
// @Override
// public void onClick(View v)
// {
// att_img.setVisibility(View.VISIBLE);
// try {
// byte[] decodedString = Base64.decode(thumb);
// Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
// att_img.setImageBitmap(decodedByte);
// } catch (Exception e) {
// // TODO: handle exception
// e.printStackTrace();
// }
// file_Name.setText("Tab Image for show in full screen.");
// accept.setVisibility(View.GONE);
// denai.setVisibility(View.GONE);
//
// }
// });
// denai.setOnClickListener(new OnClickListener()
// {
// @Override
// public void onClick(View v)
// {
// Intent intent = new Intent("com.doctor.download.Decline");
// intent.putExtra("position", String.valueOf(position));
// context.sendBroadcast(intent);
// }
// });
// String FileGetStatus=mListe.get(position).getFileGetStatus();
// if(FileGetStatus.equals("Complete"))
// {
// att_img.setVisibility(View.VISIBLE);
// att_img.setVisibility(View.VISIBLE);
// try {
// byte[] decodedString = Base64.decode(thumb);
// Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
// att_img.setImageBitmap(decodedByte);
// } catch (Exception e) {
// // TODO: handle exception
// e.printStackTrace();
// }
// accept.setVisibility(View.GONE);
// denai.setVisibility(View.GONE);
// }


}
else if(mListe.get(position).getTexte2().contains("FileSend"))
{
// convertView = inflater.inflate(R.layout.file_send,null);
//
//
// final ImageView att_img= (ImageView) convertView.findViewById(R.id.att_img);
// String unerNameTemp = "",urlTemp="",thumbTemp="",time="";
//
// final String imagePathForIntent;
//
// if(mListe.get(position).getTexte1().contains("#:#"))
// {
// String[] data=mListe.get(position).getTexte1().split("#:#");
// unerNameTemp=data[0];
// urlTemp=data[1];
// thumbTemp=data[2];
// }
// imagePathForIntent=urlTemp;
//
// //final String url = urlTemp;
// final String thumb = thumbTemp;
// final String userName = unerNameTemp;
//
//
// if(mListe.get(position).getTexte2().contains("#:#"))
// {
// String[] data=mListe.get(position).getTexte2().split("#:#");
// time=data[1];
// }
//
// final TextView UserName = (TextView) convertView.findViewById(R.id.nameOfChatter);
// UserName.setText(Html.fromHtml("<b>" + unerNameTemp + "</b>"));
//
//
// final TextView file_Name = (TextView) convertView.findViewById(R.id.Msg);
//
// if(mListe.get(position).getFileSendStatus().equals("Sending_Complete"))
// {
// file_Name.setText("File Sent");
// }
// else if(mListe.get(position).getFileSendStatus().equals("Complete"))
// {
// file_Name.setText("File Sent");
// }
// else if(mListe.get(position).getFileSendStatus().equals("Sending_Complete_delivered"))
// {
// file_Name.setText("File Delivered");
// }
// else if( mListe.get(position).getFileSendStatus().equals("Sending_Complete_Seen"))
// {
// file_Name.setText("File Seen");
// }
//
//
// final TextView timeDate = (TextView) convertView.findViewById(R.id.TimeDate);
// timeDate.setText(time);
//
//
// final ImageView myImage= (ImageView) convertView.findViewById(R.id.myImage);
// final ImageView Deliver= (ImageView) convertView.findViewById(R.id.deliver);
// Deliver.setImageDrawable(mListe.get(position).getImageStatus());
// final ImageView myImage1FileGet= (ImageView) convertView.findViewById(R.id.myImage1);
//
//
//
// myImage.setImageBitmap(mListe.get(position).getImageBtimap());
//
// try {
// //byte[] decodedString = Base64.decode("/9j/4A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fVdSTTbNpyu4g4Cg4zTvttw8W9iMOOorL1y3XULExtIUKncCPXFck2nKxtFaFKHxdDM+MbT3Rjz+Bq3/bdr/fP5V53d2s1pdMk/AHIYDIP0pn2hxx50n4SCiVK7LTQ+NiDHg9xU7OwYkHFFFdJyjFdieWNT3XMak9cUUVQF3VXYeDNNwx/1sv9K5NXbd940UURKJYJH3/ePSug0M5EkhwWUrgkdOtFFN7DR3lu7fYkGeNxH8v8TVHU3ZIGKnBxRRXL/wAvEax+E5S7YzwHzfmz1yKoRW0LRIxiUkqCTiiiqW7HLZH/2Q==");
// byte[] decodedString = Base64.decode(thumb);
// Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
// att_img.setImageBitmap(decodedByte);
// } catch (Exception e) {
// // TODO: handle exception
// e.printStackTrace();
// }
// att_img.setOnClickListener(new OnClickListener()
// {
// @Override
// public void onClick(View v)
// {
// Intent intent = new Intent("com.doctor.download.Start");
// intent.putExtra("position", String.valueOf(position));
// intent.putExtra("userNameMe", commanInstance.getUserName());
// intent.putExtra("userNameYou",commanInstance.getListKyeName());
//
// context.sendBroadcast(intent);
// }
// });
//
// Button retry=(Button) convertView.findViewById(R.id.retry);
// Button cancel=(Button) convertView.findViewById(R.id.cancel);
//
// if(mListe.get(position).getFileSendStatus().equals("Sending_Complete") || mListe.get(position).getFileSendStatus().equals("Complete")
// || mListe.get(position).getFileSendStatus().equals("Sending_Complete_delivered") || mListe.get(position).getFileSendStatus().equals("Sending_Complete_Seen"))
// {
// retry.setVisibility(View.GONE);
// cancel.setVisibility(View.GONE);
// }
// else if(mListe.get(position).getFileSendStatus().equals("Processing"))
// {
// retry.setVisibility(View.GONE);
// cancel.setVisibility(View.GONE);
// }
// else if(mListe.get(position).getFileSendStatus().equals("Error") || mListe.get(position).getFileSendStatus().equals("Cancel"))
// {
// retry.setVisibility(View.VISIBLE);
// cancel.setVisibility(View.VISIBLE);
// }
// retry.setOnClickListener(new OnClickListener()
// {
// @Override
// public void onClick(View v)
// {
// Intent intent = new Intent("com.doctor.upload.Start");
// intent.putExtra("position", String.valueOf(position));
// intent.putExtra("ImagePath", imagePathForIntent);
// context.sendBroadcast(intent);
// }
// });
// cancel.setOnClickListener(new OnClickListener()
// {
// @Override
// public void onClick(View v)
// {
// Intent intent = new Intent("com.doctor.upload.cancel");
// intent.putExtra("position", String.valueOf(position));
// context.sendBroadcast(intent);
// }
// });
}



return convertView;
}//public View getView(final int position, View convertView, ViewGroup parent)
//-----------------------------------------------------------------------------------------------------------------------------
public String getUserName(String name)
{
String nameUser[] = null;
if(name.contains("@"))
{
nameUser=name.split("@");
return nameUser[0];
}
else
{
return name;
}


}//public String getUserName(String name)
//-----------------------------------------------------------------------------------------------------------------------------
public String changeNameToCapital(String name)
{
if (name!=null && name.length() > 0) {
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
else
return name;

}//public String changeNameToCapital(String name)
//-----------------------------------------------------------------------------------------------------------------------------
public String getCurrentTime()
{
String currentTime = null;

Date now=new Date();

final String time = now.getHours()+":"+now.getMinutes();

try {
final SimpleDateFormat sdf = new SimpleDateFormat("H:mm");
final Date dateObj = sdf.parse(time);
currentTime=new SimpleDateFormat("K:mm").format(dateObj);
} catch (final ParseException e) {
e.printStackTrace();
}

Calendar cal = Calendar.getInstance();
if (cal.get(Calendar.AM_PM) == Calendar.AM)
{
currentTime=currentTime+" AM";
}
else
{ // == Calendar.PM
currentTime=currentTime+" PM";
}

Calendar c = Calendar.getInstance();

SimpleDateFormat df = new SimpleDateFormat("MMMM dd, yyyy");
String formattedDate = df.format(c.getTime());

currentTime=currentTime+" | "+formattedDate;
return currentTime;

}//public String getCurrentTime()
//-----------------------------------------------------------------------------------------------------------------------------
public static Bitmap convertByteArrayToBitmap(byte[] byteArrayToBeCOnvertedIntoBitMap)
{
Bitmap bitMapImage = BitmapFactory.decodeByteArray(
byteArrayToBeCOnvertedIntoBitMap, 0,
byteArrayToBeCOnvertedIntoBitMap.length);
return bitMapImage;
}
}

提前致谢。

最佳答案

你做错了比较..,只需在你的适配器类中更改这一行

用这个

else if(mListe.get(position).getTexte2().contains("You"))

安装这个

else if(mListe.get(position).getTexte2().contains("you"))

您使用的是小写字母。但在您的回答中您的值是“您”。

它会工作....:)

关于android 服务器消息未显示在聊天屏幕上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22804098/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com