mirror of
https://github.com/farcasclaudiu/myfriendsaround.git
synced 2026-06-29 13:02:05 +03:00
friends caching
small improvements
This commit is contained in:
@@ -52,13 +52,14 @@ namespace MyFriendsAround.WP7
|
||||
|
||||
//register ViewModelLocator
|
||||
Container.Instance.RegisterInstance(typeof(ViewModelLocator), "ViewModelLocator");
|
||||
Container.Instance.RegisterInstance<ILocationService>( new LocationService(), "LocationService");
|
||||
Container.Instance.RegisterInstance<ILocationService>(new LocationService(), "LocationService");
|
||||
}
|
||||
|
||||
|
||||
public static ILocationService LocationService
|
||||
{
|
||||
get {
|
||||
get
|
||||
{
|
||||
return Container.Instance.Resolve<ILocationService>("LocationService");
|
||||
}
|
||||
}
|
||||
@@ -137,12 +138,7 @@ namespace MyFriendsAround.WP7
|
||||
void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
//LittleWatson.ReportException(e.Exception, string.Empty);
|
||||
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
||||
{
|
||||
var exception = new ExceptionPrompt();
|
||||
exception.Show(e.Exception);
|
||||
}
|
||||
);
|
||||
ShowException(e.Exception);
|
||||
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
@@ -155,13 +151,7 @@ namespace MyFriendsAround.WP7
|
||||
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||
{
|
||||
//LittleWatson.ReportException(e.ExceptionObject, string.Empty);
|
||||
|
||||
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
||||
{
|
||||
var exception = new ExceptionPrompt();
|
||||
exception.Show(e.ExceptionObject);
|
||||
}
|
||||
);
|
||||
ShowException(e.ExceptionObject);
|
||||
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
@@ -172,6 +162,16 @@ namespace MyFriendsAround.WP7
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void ShowException(Exception ex)
|
||||
{
|
||||
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
||||
{
|
||||
Container.Instance.Resolve<ViewModelLocator>("ViewModelLocator").Main.IsBusy = false;
|
||||
var exception = new ExceptionPrompt();
|
||||
exception.Show(ex);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#region Phone application initialization
|
||||
|
||||
|
||||
@@ -16,9 +16,14 @@ namespace MyFriendsAround.WP7.Service
|
||||
|
||||
static ServiceAgent()
|
||||
{
|
||||
baseUrl = "http://myfriendsaround.cloudapp.net/myfriends";//live azure
|
||||
//baseUrl = "http://127.0.0.1:80/myfriends";//running in local azure emulator
|
||||
#if GPS_EMULATOR
|
||||
baseUrl = "http://127.0.0.1:80/myfriends";//running in local azure emulator
|
||||
//baseUrl = "http://localhost.:55672/myfriends";//for local asp.net mvc use
|
||||
#else
|
||||
baseUrl = "http://myfriendsaround.cloudapp.net/myfriends";//live azure
|
||||
//baseUrl = "http://localhost:80/myfriends";
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#region GetFriends
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Device.Location;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
@@ -57,8 +58,18 @@ namespace MyFriendsAround.WP7.ViewModel
|
||||
public MainViewModel()
|
||||
{
|
||||
GpsLocation = Location.Unknown;
|
||||
_SelectedFriend = null;
|
||||
|
||||
//
|
||||
MainLoadCommand = new RelayCommand(() => MainLoad());
|
||||
BackKeyPressCommand = new RelayCommand<CancelEventArgs>((args) =>
|
||||
{
|
||||
if (IsSelectFriend)
|
||||
{
|
||||
IsSelectFriend = !IsSelectFriend;
|
||||
args.Cancel = true;
|
||||
}
|
||||
});
|
||||
PublishLocationCommand = new RelayCommand(() => PublishLocationAction());
|
||||
NavigateToSettingsCommand = new RelayCommand(() => NavigateToSettings());
|
||||
RefreshFriendsCommand = new RelayCommand(() => RefreshFriends());
|
||||
@@ -194,12 +205,8 @@ namespace MyFriendsAround.WP7.ViewModel
|
||||
/// </summary>
|
||||
public const string SelectedFriendPropertyName = "SelectedFriend";
|
||||
|
||||
private PushPinModel _SelectedFriend = new PushPinModel()
|
||||
{
|
||||
Location = GeoCoordinate.Unknown,
|
||||
PinUserName = "Guest",
|
||||
PinImageUrl = string.Empty
|
||||
};
|
||||
private PushPinModel _SelectedFriend;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the SelectedFriend property.
|
||||
@@ -562,12 +569,6 @@ namespace MyFriendsAround.WP7.ViewModel
|
||||
|
||||
set
|
||||
{
|
||||
if (_isBusy == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var oldValue = _isBusy;
|
||||
_isBusy = value;
|
||||
|
||||
// Update bindings, no broadcast
|
||||
@@ -616,6 +617,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
||||
#region Commands
|
||||
|
||||
public ICommand MainLoadCommand { get; set; }
|
||||
public ICommand BackKeyPressCommand { get; set; }
|
||||
public ICommand PublishLocationCommand { get; set; }
|
||||
public ICommand NavigateToSettingsCommand { get; set; }
|
||||
public ICommand ShowMyLocationCommand { get; set; }
|
||||
@@ -876,7 +878,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
||||
result.Add(new PushPinModel()
|
||||
{
|
||||
PinSource = "/ApplicationIcon.png",
|
||||
Location = new GeoCoordinate(f.Latitude, f.Longitude),
|
||||
Location = new GeoCoordinate(f.Latitude, f.Longitude, 0),
|
||||
PinUserName = f.FriendName,
|
||||
PinImageUrl =
|
||||
string.Format(
|
||||
@@ -923,21 +925,21 @@ namespace MyFriendsAround.WP7.ViewModel
|
||||
{
|
||||
List<Friend> list = args.Friends;
|
||||
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
||||
{
|
||||
PopulatePushPins(list);
|
||||
IsBusy = false;
|
||||
}
|
||||
);
|
||||
{
|
||||
IsBusy = false;
|
||||
PopulatePushPins(list);
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
||||
{
|
||||
IsBusy = false;
|
||||
var exception = new ExceptionPrompt();
|
||||
exception.Show(args.Error);
|
||||
}
|
||||
);
|
||||
{
|
||||
IsBusy = false;
|
||||
var exception = new ExceptionPrompt();
|
||||
exception.Show(args.Error);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -958,6 +960,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
||||
{
|
||||
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
||||
{
|
||||
IsBusy = false;
|
||||
var message = new DialogMessage(
|
||||
"Communication error!", DialogMessageCallback)
|
||||
{
|
||||
@@ -1004,6 +1007,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
||||
{
|
||||
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
||||
{
|
||||
IsBusy = false;
|
||||
var message = new DialogMessage(
|
||||
"Communication error!", DialogMessageCallback)
|
||||
{
|
||||
|
||||
@@ -74,7 +74,11 @@
|
||||
<i:EventTrigger EventName="Loaded">
|
||||
<cmd:EventToCommand Command="{Binding MainLoadCommand}" />
|
||||
</i:EventTrigger>
|
||||
<i:EventTrigger EventName="BackKeyPress">
|
||||
<cmd:EventToCommand Command="{Binding BackKeyPressCommand}" PassEventArgsToCommand="True" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
|
||||
|
||||
<Grid x:Name="LayoutRoot"
|
||||
Background="Transparent">
|
||||
@@ -252,6 +256,31 @@
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
<Preview:BindableApplicationBar x:Name="AppBar"
|
||||
BarOpacity="0.8">
|
||||
<Preview:BindableApplicationBarIconButton Command="{Binding ShowMyLocationCommand}"
|
||||
IconUri="/icons/appbar.location.png"
|
||||
Text="{Binding AppBarTextMyLocation}" />
|
||||
<Preview:BindableApplicationBarIconButton Command="{Binding RefreshFriendsCommand}"
|
||||
IconUri="/icons/appbar.sync.rest.png"
|
||||
Text="{Binding AppBarTextRefresh}"
|
||||
IsEnabled="{Binding Path=IsBusy, Converter={StaticResource InvertValueConverter1}}" />
|
||||
<Preview:BindableApplicationBarIconButton Command="{Binding PublishLocationCommand}"
|
||||
IconUri="/icons/appbar.publish.png"
|
||||
Text="{Binding AppBarTextPublish}"
|
||||
IsEnabled="{Binding Path=IsBusy, Converter={StaticResource InvertValueConverter1}}" />
|
||||
<Preview:BindableApplicationBarIconButton Command="{Binding NavigateToSettingsCommand}"
|
||||
IconUri="/icons/appbar.feature.settings.rest.png"
|
||||
Text="{Binding AppBarTextSettings}" />
|
||||
|
||||
<Preview:BindableApplicationBar.MenuItems>
|
||||
<Preview:BindableApplicationBarMenuItem Text="{Binding AppBarTextAbout}"
|
||||
Command="{Binding ShowAboutCommand}" />
|
||||
</Preview:BindableApplicationBar.MenuItems>
|
||||
</Preview:BindableApplicationBar>
|
||||
|
||||
|
||||
<Grid Background="Transparent"
|
||||
VerticalAlignment="Stretch"
|
||||
Grid.RowSpan="2"
|
||||
@@ -320,28 +349,7 @@
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<Preview:BindableApplicationBar x:Name="AppBar"
|
||||
BarOpacity="0.8">
|
||||
<Preview:BindableApplicationBarIconButton Command="{Binding ShowMyLocationCommand}"
|
||||
IconUri="/icons/appbar.location.png"
|
||||
Text="{Binding AppBarTextMyLocation}" />
|
||||
<Preview:BindableApplicationBarIconButton Command="{Binding RefreshFriendsCommand}"
|
||||
IconUri="/icons/appbar.sync.rest.png"
|
||||
Text="{Binding AppBarTextRefresh}"
|
||||
IsEnabled="{Binding Path=IsBusy, Converter={StaticResource InvertValueConverter1}}" />
|
||||
<Preview:BindableApplicationBarIconButton Command="{Binding PublishLocationCommand}"
|
||||
IconUri="/icons/appbar.publish.png"
|
||||
Text="{Binding AppBarTextPublish}"
|
||||
IsEnabled="{Binding Path=IsBusy, Converter={StaticResource InvertValueConverter1}}" />
|
||||
<Preview:BindableApplicationBarIconButton Command="{Binding NavigateToSettingsCommand}"
|
||||
IconUri="/icons/appbar.feature.settings.rest.png"
|
||||
Text="{Binding AppBarTextSettings}" />
|
||||
|
||||
<Preview:BindableApplicationBar.MenuItems>
|
||||
<Preview:BindableApplicationBarMenuItem Text="{Binding AppBarTextAbout}"
|
||||
Command="{Binding ShowAboutCommand}" />
|
||||
</Preview:BindableApplicationBar.MenuItems>
|
||||
</Preview:BindableApplicationBar>
|
||||
|
||||
</Grid>
|
||||
|
||||
</phone:PhoneApplicationPage>
|
||||
Reference in New Issue
Block a user