java - how do i get notified from buddy image change Xmpp android -
i trying develop xmpp client , displaying buddylist images.i storing images in cache directory quick retrieval , unnesscary network usuage.the problem here if buddy has changed image how notified fetch new image server ,not local cache. please suggest.
im using asmack api.
private static xmppconnection connection; // if changes occured in buddylist connection.getroster().addrosterlistener(new rosterlistener() { @override public void presencechanged(presence arg0) { } @override public void entriesupdated(collection<string> arg0) { } @override public void entriesdeleted(collection<string> arg0) { } @override public void entriesadded(collection<string> arg0) { } });
fetch userlist
private arraylist<hashmap<string, string>> getuserlist() throws exception { arraylist<hashmap<string, string>> userlist = new arraylist<hashmap<string, string>>(); if (isconnectionalive() || reconnectandauth()) { roster roster = connection.getroster(); collection<rosterentry> entries = roster.getentries(); (rosterentry entry : entries) { string avatarpath = ""; vcard vcard = new vcard(); try { vcard.load(connection, entry.getuser()); vcard.getextensions(); byte[] b = vcard.getavatar(); bitmap avatar = bitmapfactory.decodebytearray(vcard.getavatar(), 0, b.length); avatarpath = savaavatar(avatar, entry.getuser()); } catch (exception e) { } hashmap<string, string> user = new hashmap<string, string>(); user.put("name", entry.getname()); user.put("userid", entry.getuser()); user.put("statusmsg", "" + entry.getstatus()); user.put("user_avatar", avatarpath); user.put("status", "" + connection.getroster().getpresence(entry.getuser()).isavailable()); userlist.add(user); } } return userlist; }
Comments
Post a Comment