Menu

OnChanged callback?

2014-11-29
2014-12-08
  • peter wilkinson

    peter wilkinson - 2014-11-29

    I have a MySql central database syncing with a number of android clients
    over the web - a change in any client propates to all the others. So far so
    good.

    What I can't figure out now is when to update the client displays - i.e. I
    don't know when the underlying client sqlite database has changed. It seems
    rather ugly to update the client display from the database on a timer. What
    is needed is some sort of OnChanged event - is there such?

    Regards

    Peter

    Regards

    Peter

    My PGP public key is available at http://pgp.mit.edu Key number 87ED3230
    https://pgp.mit.edu/pks/lookup?op=get&search=0x4678CD6787ED3230

     
  • Eric Long

    Eric Long - 2014-12-08

    You could use the ILoadSyncLifecycleListener, but you need access to the AndroidSymmetricEngine to register yourself as a listener. It would look like this:

    androidSymmetricEngine.getDataLoaderService().addLoadSyncLifecycleListener(
    new ILoadSyncLifecycleListener() {
    public void syncStarted(DataContext context) {
    }

    public void syncEnded(DataContext context,
            List<IncomingBatch> batchesProcessed, Throwable ex) {
    }
    

    });

    Your application code to run SymmetricDS probably has a line like this:

    Intent intent = new Intent(getContext(), SymmetricService.class);

    I think you'd need to replace SymmetricService with your own class that gives you access to the AndroidSymmetricEngine that it creates. There is an issue in the tracker to make this API better for callbacks, but that's what you have to do for now.

     

Log in to post a comment.