private async Task <string> addingToWishListFromDB_for_map() { //declaring path for RETRIEVING DATA string dbPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ormdemo.db3"); var db = new SQLiteConnection(dbPath); var wishlist_table = db.Table <ORM.Wishlist>(); //creating wishlist table dbr.CreateWishlistTable(); //checking if the place of interest exists foreach (var item in wishlist_table) { if (!String.IsNullOrWhiteSpace(item.lat) && !String.IsNullOrWhiteSpace(item.lng)) { RecyclerViewSample.Activities.Wishlist.wishlistClassForRecycler.Add(new WishlistClassForRecycler { _name = item.name, _id_public = item.id_public, _price = item.price, picData = item.picData, _description = item.description, _location = item.location, _duration = item.duration, _min_capacity = item.min_capacity, _max_capacity = item.max_capacity, _lat = item.lat, _lng = item.lng }); } } await addingMyExperiencesToListForMap(); return(""); }
public void OnMapReady(GoogleMap map) { _map = map; if (_map != null) { _map.UiSettings.ZoomControlsEnabled = true; _map.UiSettings.CompassEnabled = true; _map.MoveCamera(cameraUpdate); _map.SetOnMapLongClickListener(this); //adding current_users_location_marker MarkerOptions current_users_location_marker = new MarkerOptions(); if (ChangeDestination.changedDestinationIndicator == false) { current_users_location_marker.SetPosition(new LatLng(Convert.ToDouble(lat_temp_NEW_start_activity, (CultureInfo.InvariantCulture)), Convert.ToDouble(lng_temp_NEW_start_activity, (CultureInfo.InvariantCulture)))); current_users_location_marker.SetTitle("Your current location"); } else if (ChangeDestination.changedDestinationIndicator == true) { current_users_location_marker.SetPosition(new LatLng(ChangeDestination.lat, ChangeDestination.lng)); current_users_location_marker.SetTitle("Your target location"); } BitmapDescriptor image = BitmapDescriptorFactory.FromResource(Resource.Drawable.currentLocation); current_users_location_marker.SetIcon(image); if (Tours_detail.searchOrMovieAdapterIndicator == "MovieAdapter") { if (MovieAdapter.moviesStatic != null) { foreach (var i in MovieAdapter.moviesStatic) { if (!String.IsNullOrWhiteSpace(i.lat) && !String.IsNullOrWhiteSpace(i.lng)) { foreach (char c in i.lat) { if (c == ',') { lat_tmp += "."; } else { lat_tmp += c; } } foreach (char c in i.lng) { if (c == ',') { lng_tmp += "."; } else { lng_tmp += c; } } MarkerOptions place_of_interest_marker = new MarkerOptions(); place_of_interest_marker.SetPosition(new LatLng(Convert.ToDouble(lat_tmp, (CultureInfo.InvariantCulture)), Convert.ToDouble(lng_tmp, (CultureInfo.InvariantCulture)))); lat_tmp = ""; lng_tmp = ""; long_title_indicator = false; //making title shorter int count_char_in_title = 0; string short_title = ""; foreach (char c in i.title) { count_char_in_title++; short_title += c; if (count_char_in_title == 32) { long_title_indicator = true; break; } } //making title shorter ENDED if (long_title_indicator == false) { place_of_interest_marker.SetTitle(short_title + ". Price: " + i.price + "$"); } else if (long_title_indicator == true) { place_of_interest_marker.SetTitle(short_title + "... Price: " + i.price + "$"); } _map.AddMarker(place_of_interest_marker); } } } } else if (Tours_detail.searchOrMovieAdapterIndicator == "SearchAdapter") { foreach (var i in SearchAdapter.experiencesStatic) { if (!String.IsNullOrWhiteSpace(i.lat) && !String.IsNullOrWhiteSpace(i.lng)) { foreach (char c in i.lat) { if (c == ',') { lat_tmp += "."; } else { lat_tmp += c; } } foreach (char c in i.lng) { if (c == ',') { lng_tmp += "."; } else { lng_tmp += c; } } MarkerOptions place_of_interest_marker = new MarkerOptions(); place_of_interest_marker.SetPosition(new LatLng(Convert.ToDouble(lat_tmp, (CultureInfo.InvariantCulture)), Convert.ToDouble(lng_tmp, (CultureInfo.InvariantCulture)))); lat_tmp = ""; lng_tmp = ""; long_title_indicator = false; //making title shorter int count_char_in_title = 0; string short_title = ""; foreach (char c in i.title) { count_char_in_title++; short_title += c; if (count_char_in_title == 32) { long_title_indicator = true; break; } } //making title shorter ENDED if (long_title_indicator == false) { place_of_interest_marker.SetTitle(short_title + ". Price: " + i.price + "$"); } else if (long_title_indicator == true) { place_of_interest_marker.SetTitle(short_title + "... Price: " + i.price + "$"); } _map.AddMarker(place_of_interest_marker); } } current_users_location_marker.SetPosition(new LatLng(lat_search_target_users_position, lng_search_target_users_position)); current_users_location_marker.SetTitle("Your target location"); } _map.AddMarker(current_users_location_marker); //adding placesOfInterestMarker from items of the recycler list ENDED //adding myExperiences markers to map foreach (var i in MyBookings.myExpListClassForRecycler) { if (!String.IsNullOrWhiteSpace(i._lat) && !String.IsNullOrWhiteSpace(i._lng)) { foreach (char c in i._lat) { if (c == ',') { lat_tmp += "."; } else { lat_tmp += c; } } foreach (char c in i._lng) { if (c == ',') { lng_tmp += "."; } else { lng_tmp += c; } } MarkerOptions my_experience_marker = new MarkerOptions(); my_experience_marker.SetPosition(new LatLng(Convert.ToDouble(lat_tmp, (CultureInfo.InvariantCulture)), Convert.ToDouble(lng_tmp, (CultureInfo.InvariantCulture)))); lat_tmp = ""; lng_tmp = ""; long_title_indicator = false; //making title shorter int count_char_in_title = 0; string short_title = ""; foreach (char c in i._name) { count_char_in_title++; short_title += c; if (count_char_in_title == 32) { long_title_indicator = true; break; } } //making title shorter ENDED if (long_title_indicator == false) { my_experience_marker.SetTitle(short_title + ". Price: " + i._price + "$"); } else if (long_title_indicator == true) { my_experience_marker.SetTitle(short_title + "... Price: " + i._price + "$"); } BitmapDescriptor my_experience_image = BitmapDescriptorFactory.FromResource(Resource.Drawable.myExpMarker); my_experience_marker.SetIcon(my_experience_image); _map.AddMarker(my_experience_marker); //_map.AddMarker(my_experience_marker); } } //adding myExperiences markers to map ENDED //adding wishlist markers to map //declaring path for RETRIEVING DATA ORM.DBRepository dbr = new ORM.DBRepository(); string dbPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ormdemo.db3"); var db = new SQLiteConnection(dbPath); var wishlist_table = db.Table <ORM.Wishlist>(); //creating wishlist table dbr.CreateWishlistTable(); foreach (var i in wishlist_table) { if (!String.IsNullOrWhiteSpace(i.lat) && !String.IsNullOrWhiteSpace(i.lng)) { foreach (char c in i.lat) { if (c == ',') { lat_tmp += "."; } else { lat_tmp += c; } } foreach (char c in i.lng) { if (c == ',') { lng_tmp += "."; } else { lng_tmp += c; } } MarkerOptions wishlist_item_marker = new MarkerOptions(); wishlist_item_marker.SetPosition(new LatLng(Convert.ToDouble(lat_tmp, (CultureInfo.InvariantCulture)), Convert.ToDouble(lng_tmp, (CultureInfo.InvariantCulture)))); lat_tmp = ""; lng_tmp = ""; long_title_indicator = false; //making title shorter int count_char_in_title = 0; string short_title = ""; foreach (char c in i.name) { count_char_in_title++; short_title += c; if (count_char_in_title == 32) { long_title_indicator = true; break; } } //making title shorter ENDED if (long_title_indicator == false) { wishlist_item_marker.SetTitle(short_title + ". Price: " + i.price + "$"); } else if (long_title_indicator == true) { wishlist_item_marker.SetTitle(short_title + "... Price: " + i.price + "$"); } BitmapDescriptor wishlist_image = BitmapDescriptorFactory.FromResource(Resource.Drawable.wishMarker); wishlist_item_marker.SetIcon(wishlist_image); _map.AddMarker(wishlist_item_marker); } } //adding wishlist markers to map } }
protected override async void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Wishlist); var repository = new MoviesRepository(); var films = await repository.GetAllFilms(GettingJSON.content); recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); layoutManager = new LinearLayoutManager(this, LinearLayoutManager.Vertical, false); recyclerView.SetLayoutManager(layoutManager); var wishlistAdapter = new WishlistAdapter(wishlistClassForRecycler, this); recyclerView.SetAdapter(wishlistAdapter); ImageButton back = FindViewById <ImageButton>(Resource.Id.back); back.Click += async delegate { if (Fragments.SearchFragment.searchByWordIndicator == true) { FindViewById <ProgressBar>(Resource.Id.activityIndicatorWishlist).Visibility = ViewStates.Visible; string dbPath1 = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ormdemo.db3"); var db1 = new SQLiteConnection(dbPath1); var placesOfInterestTable = db1.Table <ORM.PlacesOfInterestTable>(); try { foreach (var item in placesOfInterestTable) { dbr1.RemovePlacesOfInterestRecord(item.Id); } } catch { } try { MovieAdapter.moviesStatic.Clear(); } catch { } //SearchByWordResultActivity searchByWordResultActivity = new SearchByWordResultActivity(); //await SearchByWord(Fragments.SearchFragment.searchWord); await searchFunction(Fragments.SearchFragment.searchWord); } else if (Fragments.SearchFragment.searchByWordIndicator == false) { StartActivity(typeof(MainActivity)); } }; //declaring path for RETRIEVING DATA ORM.DBRepository dbr = new ORM.DBRepository(); string dbPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ormdemo.db3"); var db = new SQLiteConnection(dbPath); var wishlist_table = db.Table <ORM.Wishlist>(); //creating wishlist table dbr.CreateWishlistTable(); wishlistClassForRecycler.Clear(); count_data_rows_in_wishlist_table = 0; //checking if the place of interest exists // .AsEnumerable().Reverse() IS TO DISPLAY ITEMS OF RECYCLER FROM REVERSE foreach (var item in wishlist_table.AsEnumerable().Reverse()) { count_data_rows_in_wishlist_table = 1; wishlistClassForRecycler.Add(new WishlistClassForRecycler { _name = item.name, _id_public = item.id_public, _price = item.price, picData = item.picData, _description = item.description, _location = item.location, _duration = item.duration, _min_capacity = item.min_capacity, _max_capacity = item.max_capacity, _lat = item.lat, _isMyExperience = item.isMyExperience }); } if (count_data_rows_in_wishlist_table > 0) { FindViewById <TextView>(Resource.Id.messageTV).Visibility = ViewStates.Gone; } //declaring path for RETRIEVING DATA ENDED } catch { } }