I'm working up some new code that uses Javascript binding, described here:

http://developer.android.com/guide/webapps/webview.html#BindingJavaScript


1) Is there any way to speed it up?  There's about a 2-3 second delay
before a click executes my Javascript clickContact() function in my
activity.  I'm attaching to my <tr> with jQuery, like this:

$.each($('tr[class=contact]'), function(i, obj) {
  $(obj).click(function() {
    Android.clickContact($(obj).attr('id'));
  });
});

I tried attached to my <a> tags, but that's just as slow.


My Android code:

public class ContactsJS
{
  private final Contacts con;
  private final Context c;

  public ContactsJS( final Contacts contacts, final Context context )
  {
    con = contacts;
    c = context;
  }

  public void clickContact( final String contact_id )
  {
    con.clickContact( contact_id );
  }
}


WebView contacts = (WebView) findViewById( R.id.contacts );
contacts.addJavascriptInterface( new ContactsJS( this, this ), "Android" );


It works, but it's really slow.


2) How can I get WebKit to provide some sort of click feedback?  Since
I have problem #1, described above, I really need to provide some
click/tap feedback.  My jQuery code below works great in Chrome and
Firefox, highlights red like expected, but in the Android browser it
doesn't do anything.  I had some debug code in there, mousedown and
mouseup never fire.

$.each($('a[class=click]'), function(i, obj) {
  $(obj).mousedown(function() {
    $(obj).parent().css("background-color", '#f00');
  }).mouseup(function() {
    $(obj).parent().css("background-color", 'transparent');
  });
});

I also tried the other mouse events described here:

http://api.jquery.com/category/events/mouse-events/

And I tried attaching to the <tr>s and <td>s instead of my <a>s, can't
get anything to fire in the Android browser.

How can I provide some click feedback for my slow Javascript binding?


Thanks,


-- 
Greg Donald

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to