Пример #1
0
		void HandleSectionItemClick (object sender, AdapterView.ItemClickEventArgs e)
		{
			switch (e.Position) {
			case 0:
				if (mapFragment == null)
					mapFragment = new HubwayMapFragment (this);
				SwitchTo (mapFragment);
				break;
			case 1:
				if (favoriteFragment == null) {
					favoriteFragment = new FavoriteFragment (this, id => {
						SwitchTo (mapFragment);
						mapFragment.CenterAndOpenStationOnMap (id,
						                                       zoom: 17,
						                                       animDurationID: Android.Resource.Integer.ConfigLongAnimTime);
					});
				}
				SwitchTo (favoriteFragment);
				break;
			case 2:
				if (rentalFragment == null)
					rentalFragment = new RentalFragment (this);
				SwitchTo (rentalFragment);
				break;
			default:
				return;
			}
			SetSelectedMenuIndex (e.Position);
			drawerMenu.SetItemChecked (e.Position, true);
			drawer.CloseDrawers ();
		}
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            AndroidExtensions.Initialize(this);
            SetContentView(Resource.Layout.Main);

            this.drawer       = FindViewById <DrawerLayout> (Resource.Id.drawer_layout);
            this.drawerToggle = new MoyeuActionBarToggle(this,
                                                         drawer,
                                                         Resource.Drawable.ic_drawer,
                                                         Resource.String.open_drawer,
                                                         Resource.String.close_drawer)
            {
                OpenCallback = () => {
                    ActionBar.Title = Title;
                    CurrentFragment.HasOptionsMenu = false;
                    InvalidateOptionsMenu();
                },
                CloseCallback = () => {
                    var currentFragment = CurrentFragment;
                    if (currentFragment != null)
                    {
                        ActionBar.Title = ((IMoyeuSection)currentFragment).Title;
                        currentFragment.HasOptionsMenu = true;
                    }
                    InvalidateOptionsMenu();
                },
            };
            drawer.SetDrawerShadow(Resource.Drawable.drawer_shadow, (int)GravityFlags.Left);
            drawer.SetDrawerListener(drawerToggle);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);

            Hubway.Instance.Subscribe(this);
            FavoriteManager.FavoritesChanged += (sender, e) => aroundAdapter.Refresh();

            drawerMenu = FindViewById <ListView> (Resource.Id.left_drawer);
            drawerMenu.AddFooterView(new Space(this));
            drawerMenu.ItemClick += HandleSectionItemClick;
            menuNormalTf          = Typeface.Create(Resources.GetString(Resource.String.menu_item_fontFamily),
                                                    TypefaceStyle.Normal);
            menuHighlightTf = Typeface.Create(Resources.GetString(Resource.String.menu_item_fontFamily),
                                              TypefaceStyle.Bold);
            drawerMenu.Adapter = new DrawerMenuAdapter(this);

            drawerAround            = FindViewById <ListView> (Resource.Id.left_drawer_around);
            drawerAround.ItemClick += HandleAroundItemClick;
            drawerAround.Adapter    = aroundAdapter = new DrawerAroundAdapter(this);

            drawerMenu.SetItemChecked(0, true);
            if (CheckGooglePlayServices())
            {
                client = CreateApiClient();
                SwitchTo(mapFragment = new HubwayMapFragment(this));
                ActionBar.Title      = ((IMoyeuSection)mapFragment).Title;
            }
        }
Пример #3
0
 void PostCheckGooglePlayServices()
 {
     if (client == null)
     {
         client = CreateApiClient();
     }
     SwitchTo(mapFragment   = new HubwayMapFragment());
     SupportActionBar.Title = ((IMoyeuSection)mapFragment).Title;
     CheckForSearchTermInIntent(Intent);
 }
Пример #4
0
		internal async void LoadStreetView (LatLng location, HubwayMapFragment frag, long stationID, ProgressBar spinner, ImageView img)
		{
			var url = MakeStreetViewUrl (img, location);
			var bmp = await LoadInternal (url, StreetViewCache);
			if (bmp != null && frag.CurrentShownId == stationID) {
				img.SetImageDrawable (new RoundCornerDrawable (bmp, cornerRadius: 3));
				img.Visibility = Android.Views.ViewStates.Visible;
				spinner.AlphaAnimate (0, duration: 250);
				img.AlphaAnimate (1, duration: 250);
			}
		}
Пример #5
0
		protected override void OnActivityResult (int requestCode, Result resultCode, Intent data)
		{
			if (requestCode == ConnectionFailureResolutionRequest) {
				if (resultCode == Result.Ok && CheckGooglePlayServices ()) {
					if (client == null) {
						client = CreateApiClient ();
						client.Connect ();
					}
					SwitchTo (mapFragment = new HubwayMapFragment (this));
				} else
					Finish ();
			} else {
				base.OnActivityResult (requestCode, resultCode, data);
			}
		}
Пример #6
0
        void SwitchToSectionPosition(int position)
        {
            switch (position)
            {
            case 0:
                if (mapFragment == null)
                {
                    mapFragment = new HubwayMapFragment();
                }
                SwitchTo(mapFragment);
                break;

            case 1:
                if (favoriteFragment == null)
                {
                    favoriteFragment = new FavoriteFragment();
                }
                SwitchTo(favoriteFragment);
                break;

            case 2:
                if (rentalFragment == null)
                {
                    rentalFragment = new RentalMaterialFragment();
                }
                SwitchTo(rentalFragment);
                break;

            default:
                return;
            }
            var item = drawerMenu.Menu.GetItem(position);

            if (item != null)
            {
                item.SetChecked(true);
            }
            drawer.CloseDrawers();
        }
Пример #7
0
 void PostCheckGooglePlayServices()
 {
     SwitchTo(mapFragment   = new HubwayMapFragment());
     SupportActionBar.Title = ((IMoyeuSection)mapFragment).Title;
     CheckForSearchTermInIntent(Intent);
 }