private async void InitComponent()
        {
            try
            {
                MapIcon = FindViewById <TextView>(Resource.Id.map_icon);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, MapIcon, IonIconsFonts.AndroidLocate);

                ListIcon = FindViewById <TextView>(Resource.Id.list_icon);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, ListIcon, IonIconsFonts.AndroidList);

                MapButton  = FindViewById <LinearLayout>(Resource.Id.map_button);
                ListButton = FindViewById <LinearLayout>(Resource.Id.list_button);

                SearchView = FindViewById <SearchView>(Resource.Id.searchView);
                SearchView.SetQuery("", false);
                SearchView.SetIconifiedByDefault(false);
                SearchView.OnActionViewExpanded();
                SearchView.Iconified = false;
                SearchView.ClearFocus();

                //Change text colors
                var editText = (EditText)SearchView.FindViewById(Resource.Id.search_src_text);
                editText.SetHintTextColor(Color.White);
                editText.SetTextColor(Color.White);
                editText.Hint = GetText(Resource.String.Lbl_SearchForPlace);

                //Change Color Icon Search
                ImageView searchViewIcon = (ImageView)SearchView.FindViewById(Resource.Id.search_mag_icon);
                searchViewIcon.SetColorFilter(Color.White);

                BtnSelect = FindViewById <FloatingActionButton>(Resource.Id.add_button);


                MAdapter            = new PlacesAdapter(this);
                MAdapter.ItemClick += MAdapterOnItemClick;

                var mapFrag = SupportMapFragment.NewInstance();
                SupportFragmentManager.BeginTransaction().Add(Resource.Id.map, mapFrag, mapFrag.Tag).Commit();
                mapFrag.GetMapAsync(this);

                if (!string.IsNullOrEmpty(UserDetails.Lat) || !string.IsNullOrEmpty(UserDetails.Lng))
                {
                    Lat = Convert.ToDouble(UserDetails.Lat);
                    Lng = Convert.ToDouble(UserDetails.Lng);

                    OnLocationChanged();
                }
                else
                {
                    await GetPosition();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #2
0
        private async void LoadData()
        {
            ServerResponse <GMapsResultColl> resp =
                await ServerUtils.Get <GMapsResultColl>(
                    string.Format("https://maps.googleapis.com/maps/api/place/nearbysearch/json?key={0}&location={1},{2}&radius=4000&type=park",
                                  Resources.GetString(Resource.String.MapsApiKey), targetLoc.Lat, targetLoc.Long));

            dialog.Dismiss();

            if (resp == null)
            {
                var suppress = AndroidUtils.ReturnToSignIn(this);
                Toast.MakeText(this, Resource.String.ForceSignOut, ToastLength.Long).Show();
                return;
            }

            if (!resp.Success)
            {
                Toast.MakeText(this, Resource.String.ConnectionError, ToastLength.Long).Show();
                return;
            }

            // Don't list places that have already been added
            List <GooglePlaceResult> final = new List <GooglePlaceResult>();

            foreach (GooglePlaceResult res in resp.Data.results)
            {
                if (previouslyChosen.All(p => p.GooglePlaceId != res.place_id))
                {
                    final.Add(res);
                }
            }

            adapter            = new PlacesAdapter(this, final);
            adapter.ItemClick += Adapter_ItemClick;;

            recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            recyclerView.SetAdapter(adapter);

            LinearLayoutManager layoutManager = new LinearLayoutManager(this);

            recyclerView.SetLayoutManager(layoutManager);
        }