mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 11:42:15 -05:00
improved logging for avatar fetches
This commit is contained in:
parent
b8d289a932
commit
34228d0e78
@ -789,7 +789,8 @@ public class XmppConnectionService extends Service {
|
|||||||
populateWithOrderedConversations(list, true);
|
populateWithOrderedConversations(list, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateWithOrderedConversations(List<Conversation> list, boolean includeConferences) {
|
public void populateWithOrderedConversations(List<Conversation> list,
|
||||||
|
boolean includeConferences) {
|
||||||
list.clear();
|
list.clear();
|
||||||
if (includeConferences) {
|
if (includeConferences) {
|
||||||
list.addAll(getConversations());
|
list.addAll(getConversations());
|
||||||
@ -1362,13 +1363,14 @@ public class XmppConnectionService extends Service {
|
|||||||
|
|
||||||
public void fetchAvatar(Account account, final Avatar avatar,
|
public void fetchAvatar(Account account, final Avatar avatar,
|
||||||
final UiCallback<Avatar> callback) {
|
final UiCallback<Avatar> callback) {
|
||||||
Log.d(Config.LOGTAG, account.getJid() + ": retrieving avatar for "
|
|
||||||
+ avatar.owner);
|
|
||||||
IqPacket packet = this.mIqGenerator.retrieveAvatar(avatar);
|
IqPacket packet = this.mIqGenerator.retrieveAvatar(avatar);
|
||||||
sendIqPacket(account, packet, new OnIqPacketReceived() {
|
sendIqPacket(account, packet, new OnIqPacketReceived() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket result) {
|
public void onIqPacketReceived(Account account, IqPacket result) {
|
||||||
|
final String ERROR = account.getJid()
|
||||||
|
+ ": fetching avatar for " + avatar.owner + " failed ";
|
||||||
|
if (result.getType() == IqPacket.TYPE_RESULT) {
|
||||||
avatar.image = mIqParser.avatarData(result);
|
avatar.image = mIqParser.avatarData(result);
|
||||||
if (avatar.image != null) {
|
if (avatar.image != null) {
|
||||||
if (getFileBackend().save(avatar)) {
|
if (getFileBackend().save(avatar)) {
|
||||||
@ -1377,19 +1379,34 @@ public class XmppConnectionService extends Service {
|
|||||||
databaseBackend.updateAccount(account);
|
databaseBackend.updateAccount(account);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Contact contact = account.getRoster().getContact(
|
Contact contact = account.getRoster()
|
||||||
avatar.owner);
|
.getContact(avatar.owner);
|
||||||
contact.setAvatar(avatar.getFilename());
|
contact.setAvatar(avatar.getFilename());
|
||||||
}
|
}
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.success(avatar);
|
callback.success(avatar);
|
||||||
}
|
}
|
||||||
|
Log.d(Config.LOGTAG, account.getJid()
|
||||||
|
+ ": succesfully fetched avatar for "
|
||||||
|
+ avatar.owner);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
Log.d(Config.LOGTAG, ERROR + "(parsing error)");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Element error = result.findChild("error");
|
||||||
|
if (error==null) {
|
||||||
|
Log.d(Config.LOGTAG, ERROR + "(server error)");
|
||||||
|
} else {
|
||||||
|
Log.d(Config.LOGTAG, ERROR + error.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.error(0, null);
|
callback.error(0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user