/soc/2012/michael/android: 7826ef5ec1ae: Made blist redraw when ...
Michael Zangl
michael at soc.pidgin.im
Wed Jul 25 07:23:38 EDT 2012
Changeset: 7826ef5ec1ae1fedc3cc3e491a334eb18174ba2c
Author: Michael Zangl <michael at soc.pidgin.im>
Date: 2012-07-21 12:09 +0200
Branch: soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/7826ef5ec1ae
Description:
Made blist redraw when it is changed.
diffstat:
android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/blist/BlistAdapter.java | 43 +++++++++-
1 files changed, 40 insertions(+), 3 deletions(-)
diffs (83 lines):
diff --git a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/blist/BlistAdapter.java b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/blist/BlistAdapter.java
--- a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/blist/BlistAdapter.java
+++ b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/blist/BlistAdapter.java
@@ -2,8 +2,10 @@ package im.pidgin.libpurple.testclient.b
import im.pidgin.libpurple.blist.PurpleBlist;
import im.pidgin.libpurple.blist.PurpleBlistGroup;
+import im.pidgin.libpurple.blist.PurpleBlistListener;
import im.pidgin.libpurple.blist.PurpleBlistNode;
import im.pidgin.libpurple.blist.PurpleContact;
+import im.pidgin.libpurple.buddy.PurpleBuddy;
import im.pidgin.libpurple.core.PurpleInstance;
import im.pidgin.libpurple.testclient.R;
import im.pidgin.libpurple.testclient.core.ViewController;
@@ -15,10 +17,18 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
-public class BlistAdapter extends BaseAdapter {
-
+public class BlistAdapter extends BaseAdapter implements PurpleBlistListener {
private static final int VIEW_GROUP = 0;
private static final int VIEW_CONTACT = 1;
+
+ private final class NotifyDataChanged implements Runnable {
+ @Override
+ public void run() {
+ reloadGroups(blist.getRoot());
+ notifyDataSetChanged();
+ }
+ }
+
private final ViewController viewController;
private final PurpleBlist blist;
private final ArrayList<GroupEntry> groups = new ArrayList<GroupEntry>();
@@ -29,7 +39,8 @@ public class BlistAdapter extends BaseAd
PurpleInstance instance = viewController.getPurple();
blist = instance.getBlist();
reloadGroups(blist.getRoot());
- recomputeOffsets();
+
+ blist.addBlistListener(this);
}
private void recomputeOffsets() {
@@ -51,6 +62,7 @@ public class BlistAdapter extends BaseAd
if (root != null) {
addGroups(root);
}
+ recomputeOffsets();
}
private void addGroups(PurpleBlistNode node) {
@@ -138,4 +150,29 @@ public class BlistAdapter extends BaseAd
: VIEW_CONTACT;
}
+
+ private void notifyDataChangeAsync() {
+ viewController.runOnUiThread(new NotifyDataChanged());
+ }
+
+ @Override
+ public void nodeAdded(PurpleBlistNode node) {
+ notifyDataChangeAsync();
+ }
+
+ @Override
+ public void nodeRemoved(PurpleBlistNode node) {
+ notifyDataChangeAsync();
+ }
+
+ @Override
+ public void buddyAdded(PurpleBuddy node) {
+ notifyDataChangeAsync();
+ }
+
+ @Override
+ public void buddyRemoved(PurpleBuddy node) {
+ notifyDataChangeAsync();
+ }
+
}
More information about the Commits
mailing list