diff --git a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs index 34a3edb2..d8aae007 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs @@ -58,7 +58,7 @@ namespace CampusAppWP8.Pages.PlaceNews protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + if (NavigationMode.Back == e.NavigationMode && this.places == null) { this.places = new PlacesFile(); @@ -67,6 +67,7 @@ namespace CampusAppWP8.Pages.PlaceNews } else { + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; Thread thread = new Thread(delegate() { this.InitializeApi(); @@ -132,6 +133,18 @@ namespace CampusAppWP8.Pages.PlaceNews this.pssApi.OnLoaded += new PssApi.OnIO(this.PssApiIsReady); this.pssApi.OnFailedLoad += new PssApi.OnFailed(this.ApiIsFail); } + + if (this.waitForApi < 1) + { + if (this.Dispatcher != null) + { + this.Dispatcher.BeginInvoke(new Action(() => this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed)); + } + else + { + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + } + } } /// Places file is fail. @@ -162,19 +175,7 @@ namespace CampusAppWP8.Pages.PlaceNews private void PssApiIsReady() { this.waitForApi--; - this.places.Model.AddPlaces(this.pssApi.Model.Places.ToList()); - - if (this.waitForApi < 1) - { - if (this.Dispatcher != null) - { - this.Dispatcher.BeginInvoke(new Action(() => this.SetupResultBox())); - } - else - { - this.SetupResultBox(); - } - } + this.places.Model.AddPlaces(this.pssApi.Model.Places.ToList()); } /// Pis API is ready. @@ -184,17 +185,7 @@ namespace CampusAppWP8.Pages.PlaceNews this.waitForApi--; this.places.Model.AddPlaces(this.pisApi.Model.Places.ToList()); - if (this.waitForApi < 1) - { - if (this.Dispatcher != null) - { - this.Dispatcher.BeginInvoke(new Action(() => this.SetupResultBox())); - } - else - { - this.SetupResultBox(); - }; - } + this.CheckedSetupResultBox(); } /// API is fail. @@ -234,17 +225,7 @@ namespace CampusAppWP8.Pages.PlaceNews this.waitForApi++; } - if (this.waitForApi < 1) - { - if (this.Dispatcher != null) - { - this.Dispatcher.BeginInvoke(new Action(() => this.SetupResultBox())); - } - else - { - this.SetupResultBox(); - } - } + this.CheckedSetupResultBox(); } /// Sets up the result box. @@ -293,5 +274,21 @@ namespace CampusAppWP8.Pages.PlaceNews private void ApplicationBarMenuItem_Click_1(object sender, EventArgs e) { } + + /// Checked setup result box. + /// Stubbfel, 10.09.2013. + private void CheckedSetupResultBox() { + if (this.waitForApi < 1) + { + if (this.Dispatcher != null) + { + this.Dispatcher.BeginInvoke(new Action(() => this.SetupResultBox())); + } + else + { + this.SetupResultBox(); + } + } + } } } \ No newline at end of file