EmoryM/Android_Pusher — pull request #3 by linki (2012-01-11 22:09:36+00:00)
Title: added bind() and bindAll(), updated API to be similar to javascript lib

hi emorym,

i added bind() and bindAll() methods to the channels as well as the pusher instance. bind() accepts an event name as well as a callback which will be triggered when the event fires. bindAll()-callbacks will fire on any event.

i also updated the api for creating an instance of pusher to be more like the javascript lib:

Pusher pusher = new Pusher( "pusher_key" );
Channel channel = pusher.subscribe( "chat-channel" );
channel.bind( "new_message" , new PusherCallback() {
public void onEvent(JSONObject eventData) {
Log.d( "Pusher", eventData.toString() );
}
});

the implementation is fully backwards compatible to your style of doing it. new Pusher(mHandler) will just work fine with your example handler, nevertheless i added some deprecation annotations to those methods. I updated your PusherSampleApp.java to use the bind()/bindAll() versions but kept the old version, which works fine as well.

I can't tell anything about performance but it works quite well for me.

I hope you'll like it.

Best regards
linki