protected override void OnNavigatedTo(NavigationEventArgs e)
    {
      base.OnNavigatedTo(e);

      if (e.NavigationMode != NavigationMode.Back)
      {
        var source = new PropertyDataSource(new JsonWebPropertySearch(new MarshalInvokeService()));
        var geolocationService = new GeoLocationService();

        var statePersistence = new StatePersistenceService();
        PropertyFinderPersistentState state = statePersistence.LoadState();

        _presenter = new PropertyFinderPresenter(state, source,
          new NavigationService(NavigationService), geolocationService);
        _presenter.SetView(this);
      }
    }
Ejemplo n.º 2
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);

              navigationController = new UINavigationController ();

              var source = new PropertyDataSource (new JsonWebPropertySearch (new MarshalInvokeService()));
              var geolocationService = new GeoLocationService ();

              var statePersistence = new StatePersistenceService ();
              PropertyFinderPersistentState state = statePersistence.LoadState ();

              var presenter = new PropertyFinderPresenter (state, source,
              new NavigationService (navigationController), geolocationService);
              		var controller = new PropertyFinderViewController (presenter);

              navigationController.PushViewController(controller, false);
            window.RootViewController = navigationController;

            // make the window visible
            window.MakeKeyAndVisible ();

            return true;
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            var app = (PropertyFinderApplication)Application;
            app.CurrentActivity = this;

            var uiMarshal = new MarshalInvokeService(app);
            var source = new PropertyDataSource(new JsonWebPropertySearch(uiMarshal));
            geoLocationService = new GeoLocationService((LocationManager)GetSystemService(Context.LocationService), uiMarshal);
            var stateService = new StatePersistenceService(app);
            PropertyFinderPersistentState state = stateService.LoadState();

            SetContentView (Resource.Layout.PropertyFinderView);
            searchText = (EditText) FindViewById(Resource.Id.search);
            searchText.TextChanged += SearchText_Changed;

            myLocationButton = (Button) FindViewById(Resource.Id.use_location);
            myLocationButton.Click += LocationButton_Clicked;

            startSearchButton = (Button) FindViewById(Resource.Id.do_search);
            startSearchButton.Click += StartSearchButton_Clicked;

            messageText = (TextView) FindViewById(Resource.Id.mainview_message);

            recentSearchList = (ListView) FindViewById(Resource.Id.recentsearches_list);
            recentSearchList.ItemClick += RecentSearchItem_Clicked;
            adapter = new RecentSearchAdapter(this, new List<RecentSearch>());
            recentSearchList.Adapter = adapter;

            presenter =
                new PropertyFinderPresenter(state,
                                            source,
                                            new NavigationService(app),
                                            geoLocationService);
            presenter.SetView(this);

            app.Presenter = presenter;
        }