Results 1 to 3 of 3

Thread: PhoneGap onlinechange Event - A solution

  1. #1
    Sencha User
    Join Date
    Feb 2011
    Location
    Dsseldorf, Germany
    Posts
    594
    Vote Rating
    33
      0  

    Default PhoneGap onlinechange Event - A solution

    Hi there,

    if you do a native build with Sencha you can listen to the 'onlinechange event'.

    With PhoneGap you either ask for the current status or you have to add your own solution.
    I have written a few lines to add to 'Ext.device.connection.PhoneGap' and you have the same event being fired.

    Code:
    Ext.define('Ext.device.connection.PhoneGap', {
        extend: 'Ext.device.connection.Abstract',
    
    
        constructor: function() {
            this.callSuper(arguments);
            document.addEventListener("online",  Ext.bind(this.onConnectionChange, this, [true]), false);
            document.addEventListener("offline", Ext.bind(this.onConnectionChange, this, [false]), false);
        },
    
    
        onConnectionChange: function(online) {
            this.fireEvent('onlinechange', online);
        },
    
    
        syncOnline: function() {
    ...
    For more detailed information you can exchange the 'online' param for.
    this.getOnline(), this.getType()

    Add this to app.js launch:
    Code:
    Ext.device.Connection.on('onlinechange', this.onlineCallback);
    
    onlineCallback: function(online){
        // Do your stuff
    }

  2. #2
    Sencha User
    Join Date
    Aug 2010
    Posts
    311
    Vote Rating
    5
      0  

    Default

    ????, you have the online / offline events in Phonegap too:
    http://docs.phonegap.com/en/2.7.0/co...md.html#Events

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Location
    Dsseldorf, Germany
    Posts
    594
    Vote Rating
    33
      0  

    Default Exactly

    Exactly - that's what I implemented, so that you do not have to add this to each project again and again. Thats whay I am adding it to Ext.device.connection.PhoneGap.

    If you look at line 2 and 3 of the constructor you will see the PhoneGap listeners.
    If you have the skill to add it on your own and you prefer to add it seperately, there is not need for you to use it.

    But for convenient reasons I added them for everyone in the place where Sencha handles these things.

    I hope it still helps

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •