public RequestBinder(APICall service) { this.service = service; }
public void OnServiceConnected(ComponentName name, IBinder service) { var ServiceBinder = service as RequestBinder; if (ServiceBinder != null) { activity.binder = ServiceBinder; activity.isBound = true; } activity.BDD.DBConnection(); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(activity); if (!prefs.GetBoolean("Install", false)) { activity.BDD.CreateTable(); // mark first time has runned. ISharedPreferencesEditor editor = prefs.Edit(); editor.PutBoolean("Install", true); editor.Commit(); } if (activity.CheckInternet()) { DateTime OldDate = activity.BDD.GetOldest(); TimeSpan difference = (DateTime.Now - OldDate); if ((DateTime.Now - OldDate) == (DateTime.Now - new DateTime()) || (difference.Days > 0 || (difference.Hours >= 3 && difference.Minutes > 0))) { APICall Rservice = activity.binder.GetService(); string json = Rservice.GetJson(); if (json == null) { activity.StartActivity(new Intent(activity, typeof(NoData))); } else { List <WeatherApp.JSON.Weather> temp = JSON.Parsing.JsonToWeather(json); activity.BDD.ClearTable(); activity.BDD.InsertList(temp); activity.StartActivity(new Intent(activity, typeof(CreateListView))); } } else { activity.StartActivity(new Intent(activity, typeof(CreateListView))); } } else { activity.StartActivity(new Intent(activity, typeof(CreateListView))); } activity.BDD.BDDConnection.Close(); }