예제 #1
0
		public async void DownloadVehiclesListAsync(){
			VELService service = new VELService ();
			if (!service.isConnected (activity)) {
				Toast toast = Toast.MakeText (activity, "Not conntected to internet. Please check your device network settings.", ToastLength.Short);
				toast.Show ();
				vehListData = DBManager.Instance.GetVehicleListFromCache ();
			} else {
				progressBar.Visibility = ViewStates.Visible;
				vehListData = await service.GetVehListAsync ();

				//Clear cache data
				DBManager.Instance.ClearVEHCache ();

				//Save updated Vehicle data
				DBManager.Instance.InsertAll (vehListData);
				progressBar.Visibility = ViewStates.Gone;
			}

			vehListAdapter = new VEHListViewAdapter (activity, vehListData);
			this.ListAdapter = vehListAdapter;
			ListView.Post(() =>{ListView.SetSelection (scrollPostion);
			});
		}
예제 #2
0
		public async void DeleteVEHAsync(){
			VELService service = new VELService ();
			if (!service.isConnected(activity)) {
				Toast toast = Toast.MakeText (activity, "Not conntected to internet. Please check your device network settings.", ToastLength.Short);
				toast.Show ();
				return;
			}

			string response = await service.DeleteVEHAsync (_vehInfo.Id);
			if (!string.IsNullOrEmpty	(response)) {
				Toast toast = Toast.MakeText (activity, String.Format ("{0} deleted.", _vehInfo.Registration), ToastLength.Short);
				toast.Show();

				DBManager.Instance.DeleteVeh (_vehInfo.Id);

				if(!DVELActivity.isDualMode)
					activity.Finish ();
			} else {
				Toast toast = Toast.MakeText (activity, "Something went Wrong!", ToastLength.Short);
				toast.Show();
			}
		}
예제 #3
0
		private async void CreateOrUpdateTripAsync(TripInfo trip){
			VELService service = new VELService ();
			if (!service.isConnected(activity)) {
				Toast toast = Toast.MakeText (activity, "Not conntected to internet. Please check your device network settings.", ToastLength.Short);
				toast.Show ();
				return;
			}

			string response = await service.CreateOrUpdateTripAsync(_tripInfo);
			if (!string.IsNullOrEmpty (response)) {
				Toast toast = Toast.MakeText (activity, String.Format ("{0} saved.", _tripInfo.VehicleInfo.Registration), ToastLength.Short);
				toast.Show();

				DBManager.Instance.SaveTrips(trip);

				if(!DVELActivity.isDualMode)
					activity.Finish ();
			} else {
				Toast toast = Toast.MakeText (activity, "Something went Wrong!", ToastLength.Short);
				toast.Show();
			}
		}