public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Android.OS.Bundle savedInstanceState) { var view = new PostingDetailsView(this.Activity); view.PostingTitle.Text = Posting.PostTitle; if (Posting.ImageLink != "-1") { view.CurrentImage = Posting.ImageLink; } imageHelper = new ListingImageDownloader(Posting.Link, Posting.ImageLink); var connected = imageHelper.GetAllImagesAsync(); if (!connected) { var builder = new Android.Support.V7.App.AlertDialog.Builder(this.Activity); builder.SetTitle("No internet connection") .SetMessage("Please connect and try again") .SetPositiveButton("Ok", delegate { Console.WriteLine("Not connected"); }); builder.Create().Show(); } imageHelper.loadingComplete += (sender, e) => { if (imageHelper.PostingImagesFound) { view.SetImageCollection(imageHelper.images); } if (imageHelper.PostingBodyAdded) { view.PostingDescription.Text = imageHelper.postingDescription; } if (imageHelper.PostingMapFound) { SupportMapFragment _myMapFragment = SupportMapFragment.NewInstance(); view.mapFrame.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, Convert.ToInt16(Activity.Resources.DisplayMetrics.HeightPixels * 0.5)); var tx = Activity.SupportFragmentManager.BeginTransaction(); tx.Replace(view.mapFrame.Id, _myMapFragment); tx.Commit(); SetUpGoogleMap(_myMapFragment); this.MapReady += (s, ev) => { if (map != null) { //To initialize the map map.MapType = GoogleMap.MapTypeNormal; //select the map type CameraPosition.Builder builder = CameraPosition.InvokeBuilder(); builder.Target(imageHelper.postingCoordinates); //Target to some location hardcoded builder.Zoom(10); //Zoom multiplier CameraPosition cameraPosition = builder.Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); //map.AnimateCamera(cameraUpdate); map.MoveCamera(cameraUpdate); MarkerOptions markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(imageHelper.postingCoordinates); markerOpt1.SetTitle("Here's your listing!"); map.AddMarker(markerOpt1); } }; } }; view.ImageClick += (sender, e) => { view.CurrentImage = imageHelper.images.ElementAt(e.Index); }; view.PostingDescription.Text = Posting.Description; view.PostingDate.Text = "Listed: " + Posting.Date.ToShortDateString() + " at " + Posting.Date.ToShortTimeString(); view.WebLink.Text = "Original Listing"; view.WebLink.Click += (sender, e) => { var transaction = Activity.SupportFragmentManager.BeginTransaction(); WebviewFragment webviewFragment = new WebviewFragment(); webviewFragment.Link = Posting.Link; transaction.Replace(Resource.Id.frameLayout, webviewFragment); transaction.AddToBackStack(null); transaction.Commit(); }; view.PostingImage.Click += (sender, e) => { var transaction = Activity.SupportFragmentManager.BeginTransaction(); ImageZoomFragment zoomFragment = new ImageZoomFragment(); zoomFragment.ImageUrl = view.CurrentImage; transaction.Replace(Resource.Id.frameLayout, zoomFragment); transaction.AddToBackStack(null); transaction.Commit(); }; ((MainActivity)this.Activity).OptionItemSelected += OnOptionItemSelected; ScrollView viewContainer = new ScrollView(this.Activity); viewContainer.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); viewContainer.AddView(view); return(viewContainer); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Android.OS.Bundle savedInstanceState) { var view = new PostingDetailsView(this.Activity); view.PostingTitle.Text = Posting.PostTitle; if (Posting.ImageLink != "-1") { view.CurrentImage = Posting.ImageLink; } imageHelper = new ListingImageDownloader(Posting.Link, Posting.ImageLink); var connected = imageHelper.GetAllImagesAsync(); if (!connected) { var builder = new Android.Support.V7.App.AlertDialog.Builder(this.Activity); builder.SetTitle("No internet connection") .SetMessage("Please connect and try again") .SetPositiveButton("Ok", delegate { Console.WriteLine("Not connected"); }); builder.Create().Show(); } imageHelper.loadingComplete += (sender, e) => { if (imageHelper.PostingImagesFound) { view.SetImageCollection(imageHelper.images); } if (imageHelper.PostingBodyAdded) view.PostingDescription.Text = imageHelper.postingDescription; if (imageHelper.PostingMapFound) { SupportMapFragment _myMapFragment = SupportMapFragment.NewInstance(); view.mapFrame.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, Convert.ToInt16(Activity.Resources.DisplayMetrics.HeightPixels * 0.5)); var tx = Activity.SupportFragmentManager.BeginTransaction(); tx.Replace(view.mapFrame.Id, _myMapFragment); tx.Commit(); SetUpGoogleMap(_myMapFragment); this.MapReady += (s, ev) => { if (map != null) { //To initialize the map map.MapType = GoogleMap.MapTypeNormal; //select the map type CameraPosition.Builder builder = CameraPosition.InvokeBuilder(); builder.Target(imageHelper.postingCoordinates); //Target to some location hardcoded builder.Zoom(10); //Zoom multiplier CameraPosition cameraPosition = builder.Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); //map.AnimateCamera(cameraUpdate); map.MoveCamera(cameraUpdate); MarkerOptions markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(imageHelper.postingCoordinates); markerOpt1.SetTitle("Here's your listing!"); map.AddMarker(markerOpt1); } }; } }; view.ImageClick += (sender, e) => { view.CurrentImage = imageHelper.images.ElementAt(e.Index); }; view.PostingDescription.Text = Posting.Description; view.PostingDate.Text = "Listed: " + Posting.Date.ToShortDateString() + " at " + Posting.Date.ToShortTimeString(); view.WebLink.Text = "Original Listing"; view.WebLink.Click += (sender, e) => { var transaction = Activity.SupportFragmentManager.BeginTransaction(); WebviewFragment webviewFragment = new WebviewFragment(); webviewFragment.Link = Posting.Link; transaction.Replace(Resource.Id.frameLayout, webviewFragment); transaction.AddToBackStack(null); transaction.Commit(); }; view.PostingImage.Click += (sender, e) => { var transaction = Activity.SupportFragmentManager.BeginTransaction(); ImageZoomFragment zoomFragment = new ImageZoomFragment(); zoomFragment.ImageUrl = view.CurrentImage; transaction.Replace(Resource.Id.frameLayout, zoomFragment); transaction.AddToBackStack(null); transaction.Commit(); }; ((MainActivity)this.Activity).OptionItemSelected += OnOptionItemSelected; ScrollView viewContainer = new ScrollView(this.Activity); viewContainer.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); viewContainer.AddView(view); return viewContainer; }