Example #1
0
        public void SynchronizeDatabase(Action runAfterSuccess)
        {
            var filestorage = App.Kp2a.GetFileStorage(App.Kp2a.CurrentDb.Ioc);
            RunnableOnFinish task;
            OnFinish         onFinish = new ActionOnFinish(_activity, (success, message, activity) =>
            {
                if (!String.IsNullOrEmpty(message))
                {
                    Toast.MakeText(activity, message, ToastLength.Long).Show();
                }

                // Tell the adapter to refresh it's list
                BaseAdapter adapter = (activity as GroupBaseActivity)?.ListAdapter;
                adapter?.NotifyDataSetChanged();

                if (App.Kp2a.CurrentDb?.OtpAuxFileIoc != null)
                {
                    var task2           = new SyncOtpAuxFile(_activity, App.Kp2a.CurrentDb.OtpAuxFileIoc);
                    task2.OnFinishToRun = new ActionOnFinish(_activity, (b, s, activeActivity) =>
                    {
                        runAfterSuccess();
                    });
                    new ProgressTask(App.Kp2a, activity, task2).Run(true);
                }
                else
                {
                    runAfterSuccess();
                }
            });

            if (filestorage is CachingFileStorage)
            {
                task = new SynchronizeCachedDatabase(_activity, App.Kp2a, onFinish);
            }
            else
            {
                task = new CheckDatabaseForChanges(_activity, App.Kp2a, onFinish);
            }



            var progressTask = new ProgressTask(App.Kp2a, _activity, task);

            progressTask.Run();
        }
Example #2
0
        private void Synchronize()
        {
            var filestorage = App.Kp2a.GetFileStorage(App.Kp2a.GetDb().Ioc);
            RunnableOnFinish task;
            OnFinish         onFinish = new ActionOnFinish(this, (success, message, activity) =>
            {
                if (!String.IsNullOrEmpty(message))
                {
                    Toast.MakeText(activity, message, ToastLength.Long).Show();
                }

                // Tell the adapter to refresh it's list
                BaseAdapter adapter = (BaseAdapter)((GroupBaseActivity)activity)?.ListAdapter;
                adapter?.NotifyDataSetChanged();

                if (App.Kp2a.GetDb().OtpAuxFileIoc != null)
                {
                    var task2 = new SyncOtpAuxFile(this, App.Kp2a.GetDb().OtpAuxFileIoc);
                    new ProgressTask(App.Kp2a, activity, task2).Run(true);
                }
            });

            if (filestorage is CachingFileStorage)
            {
                task = new SynchronizeCachedDatabase(this, App.Kp2a, onFinish);
            }
            else
            {
                task = new CheckDatabaseForChanges(this, App.Kp2a, onFinish);
            }



            var progressTask = new ProgressTask(App.Kp2a, this, task);

            progressTask.Run();
        }
Example #3
0
        private void Synchronize()
        {
            var filestorage = App.Kp2a.GetFileStorage(App.Kp2a.GetDb().Ioc);
            RunnableOnFinish task;
            OnFinish onFinish = new ActionOnFinish((success, message) =>
            {
                if (!String.IsNullOrEmpty(message))
                    Toast.MakeText(this, message, ToastLength.Long).Show();

                // Tell the adapter to refresh it's list
                BaseAdapter adapter = (BaseAdapter)ListAdapter;
                adapter.NotifyDataSetChanged();

                if (App.Kp2a.GetDb().OtpAuxFileIoc != null)
                {
                    var task2 = new SyncOtpAuxFile(App.Kp2a.GetDb().OtpAuxFileIoc);
                    new ProgressTask(App.Kp2a, this, task2).Run();
                }
            });

            if (filestorage is CachingFileStorage)
            {

                task = new SynchronizeCachedDatabase(this, App.Kp2a, onFinish);
            }
            else
            {

                task = new CheckDatabaseForChanges(this, App.Kp2a, onFinish);
            }

            var progressTask = new ProgressTask(App.Kp2a, this, task);
            progressTask.Run();
        }
 private void Synchronize(TestKp2aApp app, out bool wasSuccessful, out string resultMessage)
 {
     bool success = false;
     string result = null;
     var sync = new SynchronizeCachedDatabase(Application.Context, app, new ActionOnFinish((_success, _result) =>
         {
             success = _success;
             result = _result;
         }));
     sync.Run();
     sync.JoinWorkerThread();
     wasSuccessful = success;
     resultMessage = result;
 }