Exemplo n.º 1
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad();

			placeViews = new List<PlaceView> ();

			coffeeAnimation = CoffeeAnimationView.GetView(this);

			NavigationController.NavigationBar.TintColor = tintColor;

			var appearance = UIBarButtonItem.AppearanceWhenContainedIn(typeof(UINavigationBar));

			appearance.SetTitleTextAttributes(new UITextAttributes {
				TextColor = tintColor,
				Font = UIFont.FromName("HelveticaNeue-Light", 20f)
			}, UIControlState.Normal);

			MapView.ShowsUserLocation = true;

			try {
				viewModel = ServiceContainer.Resolve<CoffeeFilterViewModel>();
			} catch {
				viewModel = new CoffeeFilterViewModel ();
				ServiceContainer.Register<CoffeeFilterViewModel>(viewModel);
			}


			var searchButton = NavigationItem.RightBarButtonItem;
			var navigationButton = new UIBarButtonItem (UIImage.FromBundle("near"), UIBarButtonItemStyle.Plain, OpenMaps);
			NavigationItem.SetRightBarButtonItems(new [] { searchButton, navigationButton }, false);

			RefreshData(true);
		}
Exemplo n.º 2
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			#if DEBUG
			Xamarin.Insights.Initialize("ef02f98fd6fb47ce8624862ab7625b933b6fb21d", this);
			#else
			Xamarin.Insights.Initialize ("8da86f8b3300aa58f3dc9bbef455d0427bb29086", this);
			#endif

			mapView = FindViewById<MapView> (Resource.Id.map);
			mapView.OnCreate (bundle);

			mapView.Visibility = ViewStates.Invisible;
			viewModel = new CoffeeFilterViewModel ();
			ServiceContainer.Register<CoffeeFilterViewModel> (viewModel);
			adapter = new PlacesPagerAdapter (SupportFragmentManager, viewModel);
			pager = FindViewById<ViewPager> (Resource.Id.pager);
			pager.Adapter = adapter;
			progressBar = FindViewById<ImageView> (Resource.Id.progressBar);
			errorImage = FindViewById<ImageView> (Resource.Id.error);
			coffeeProgress = (AnimationDrawable)progressBar.Background;
			progressBar.Visibility = ViewStates.Gone;

			pager.PageSelected += (sender, e) => UpdateMap (e.Position);
			pager.PageScrollStateChanged += (sender, e) => {
				if (e.State == (int)ScrollState.TouchScroll)
					refresher.Enabled = false;
				else
					refresher.Enabled = true;
			};

			refresher = FindViewById<SwipeRefreshLayout> (Resource.Id.refresher);
			refresher.SetColorSchemeColors (Resource.Color.accent);
			refresher.Refresh += (sender, args) => {
				RefreshData (true);
				refresher.PostDelayed (() => {
					refresher.Refreshing = false;
				}, 250);
			};

			SupportActionBar.SetDisplayHomeAsUpEnabled (false);
			SupportActionBar.SetHomeButtonEnabled (false);
			mapView.GetMapAsync (this);
			CheckGooglePlayServices ();

			// No savedInstanceState, so it is the first launch of this activity
			if (bundle == null && AppInviteReferral.HasReferral(Intent)) {
				// In this case the referral data is in the intent launching the MainActivity,
				// which means this user already had the app installed. We do not have to
				// register the Broadcast Receiver to listen for Play Store Install information
				LaunchDeepLinkActivity(Intent);

			}
		}
Exemplo n.º 3
0
		public PlacesPagerAdapter (Android.Support.V4.App.FragmentManager fm, CoffeeFilterViewModel vm) : base (fm)
		{
			ViewModel = vm;
		}