public PropertyFinderPersistentState LoadState() { PropertyFinderPersistentState state = null; try { using(var stream = application.CurrentActivity.OpenFileInput(FileName)) using(var reader = new StreamReader(stream)) { if(!reader.EndOfStream) { XmlSerializer serializer = new XmlSerializer(typeof(PropertyFinderPersistentState)); state = (PropertyFinderPersistentState) serializer.Deserialize(reader); state.PersistenceService = this; } } } catch { } if(state == null) state = new PropertyFinderPersistentState(this); return state; }
public PropertyFinderPersistentState LoadState() { PropertyFinderPersistentState state = null; try { // load from isolated storage using (var store = IsolatedStorageFile.GetUserStoreForApplication()) using (var stream = new IsolatedStorageFileStream("data.txt", FileMode.OpenOrCreate, FileAccess.Read, store)) using (var reader = new StreamReader(stream)) { if (!reader.EndOfStream) { var serializer = new XmlSerializer(typeof(PropertyFinderPersistentState)); state = (PropertyFinderPersistentState)serializer.Deserialize(reader); // set the persistence service for the newly loaded state state.PersistenceService = this; } } } catch { } // if we cannot retrieve the state, create a new state object if (state == null) { state = new PropertyFinderPersistentState(this); } return state; }
public PropertyFinderPresenter(PropertyFinderPersistentState state, PropertyDataSource dataSource, INavigationService navigationService, IGeoLocationService geolocationService) { _propertyDataSource = dataSource; _navigationService = navigationService; _state = state; _geolocationService = geolocationService; }
public void SaveState(PropertyFinderPersistentState state) { using(var stream = application.CurrentActivity.OpenFileOutput(FileName, FileCreationMode.Private)) { XmlSerializer serializer = new XmlSerializer(typeof(PropertyFinderPersistentState)); serializer.Serialize(stream, state); } }
public void SaveState(PropertyFinderPersistentState state) { using (var writer = new StreamWriter(_filepath)) { var serializer = new XmlSerializer(typeof(PropertyFinderPersistentState)); serializer.Serialize(writer, state); } }
public SearchResultsPresenter(INavigationService navigationService, PropertyFinderPersistentState state, PropertyListingsResult results, SearchItemBase searchItem, PropertyDataSource dataSource) { _state = state; _navigationService = navigationService; _searchItem = searchItem; _dataSource = dataSource; _properties = results.Data; _totalResult = results.TotalResult; _totalPages = results.TotalPages; }
public void SaveState(PropertyFinderPersistentState state) { // persist the data using isolated storage using (var store = IsolatedStorageFile.GetUserStoreForApplication()) using (var stream = new IsolatedStorageFileStream("data.txt", FileMode.Create, FileAccess.Write, store)) { var serializer = new XmlSerializer(typeof(PropertyFinderPersistentState)); serializer.Serialize(stream, state); } }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { var source = new PropertyDataSource(new JsonWebPropertySearch()); var geolocationService = new GeoLocationService(); var statePersistence = new StatePersistenceService(); PropertyFinderPersistentState state = statePersistence.LoadState(); var viewModel = new PropertyFinderViewModel(state, source, new NavigationService(null), geolocationService); RootFrame.DataContext = viewModel; }
public PropertyFinderViewModel(PropertyFinderPersistentState stateFactory, PropertyDataSource dataSource, IGeoLocationService geolocationService) { _state = stateFactory; _dataSource = dataSource; _geolocationService = geolocationService; SearchCommand = new MvxCommand(DoSearch); UseLocationCommand = new MvxCommand(DoUseLocation); ShowFavouritesCommand = new MvxCommand(DoShowFavourites); RecentSearchSelectedCommand = new MvxCommand <RecentSearch>(DoRecentSearchSelected); LocationSelectedCommand = new MvxCommand <Location>(DoLocationSelected); SuggestedLocations = new ObservableCollection <Location>(); RecentSearches = new ObservableCollection <RecentSearch>(); LoadRecentSearches(); }
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); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var app = PropertyFinderApplication.GetApplication(this); app.CurrentActivity = this; var uiMarshal = new MarshalInvokeService(app); var source = new PropertyDataSource(new JsonWebPropertySearch(uiMarshal)); geoLocationService = new GeoLocationService((Android.Locations.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; searchText.SetOnEditorActionListener(this); 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); resultsHeader = (TextView)FindViewById(Resource.Id.results_header); resultsList = (ListView)FindViewById(Resource.Id.results_list); resultsList.ItemClick += ResultsListItem_Clicked; resultsList.Adapter = new RecentSearchAdapter(this, new List <RecentSearch>()); loadingAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.loading_rotate); loadingAnimation.RepeatMode = RepeatMode.Restart; presenter = new PropertyFinderPresenter(state, source, new NavigationService(app), geoLocationService); presenter.SetView(this); app.Presenter = presenter; }
public PropertyFinderPersistentState LoadState() { PropertyFinderPersistentState state = null; try { using (var reader = new StreamReader(_filepath)) { var serializer = new XmlSerializer(typeof(PropertyFinderPersistentState)); state = (PropertyFinderPersistentState)serializer.Deserialize(reader); state.PersistenceService = this; } } catch { } if (state == null) { state = new PropertyFinderPersistentState(this); } return state; }
// // 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); }
public PropertyFinderPersistentState LoadState() { PropertyFinderPersistentState state = null; try { using (var reader = new StreamReader(_filepath)) { var serializer = new XmlSerializer(typeof(PropertyFinderPersistentState)); state = (PropertyFinderPersistentState)serializer.Deserialize(reader); state.PersistenceService = this; } } catch { } if (state == null) { state = new PropertyFinderPersistentState(this); } return(state); }
public FavouritesPresenter(INavigationService navigationService, PropertyFinderPersistentState state) { _state = state; _navigationService = navigationService; }
public PropertyPresenter(PropertyFinderPersistentState state, Property property) { _state = state; _property = property; }
public PropertyViewModel(PropertyFinderPersistentState state, Property property) { _state = state; Init(property); }
public PropertyViewModel(PropertyFinderPersistentState state) { _state = state; }