Skip to content

Commit

Permalink
fix get location in iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor authored and Igor committed Jan 19, 2014
1 parent a30982d commit d60fb1e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
26 changes: 16 additions & 10 deletions Locator.Mobile/Locator.Mobile.Droid/Locator.Mobile.Droid.userprefs
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="../Locator.Mobile.Client/ClientImpl/RestWebClient.cs">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release" />
<MonoDevelop.Ide.Workbench ActiveDocument="Locator.Mobile.Droid/Activities/Friends/FriendsFragment.cs">
<Files>
<File FileName="Locator.Mobile.Droid/Notifications/GCMIntentService.cs" Line="97" Column="58" />
<File FileName="Locator.Mobile.Droid/Notifications/GCMIntentService.cs" Line="95" Column="1" />
<File FileName="Locator.Mobile.Droid/Activities/Home/FragmentTabs.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.Droid/Activities/Location/LocationActivity.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.Droid/Activities/Location/LocationActivity.cs" Line="29" Column="1" />
<File FileName="Locator.Mobile.Droid/Base/Navigations.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.Droid/Base/Activity/ViewController.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.Droid/Activities/Locations/LocationsFragment.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.Droid/Base/Activity/BaseFragment.cs" Line="1" Column="1" />
<File FileName="../Locator.Mobile.Client/ClientImpl/RestWebClient.cs" Line="61" Column="1" />
<File FileName="Locator.Mobile.Droid/Base/LocationHelper.cs" Line="1" Column="1" />
<File FileName="../Locator.Mobile.Presentation/AppController.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.Droid/Activities/Friends/FriendsFragment.cs" Line="46" Column="35" />
<File FileName="../Locator.Mobile.Presentation/Friends/FriendsPresenter.cs" Line="37" Column="10" />
<File FileName="Locator.Mobile.Droid/Activities/Friends/FriendsFragment.cs" Line="85" Column="1" />
<File FileName="../Locator.Mobile.Presentation/Friends/FriendsPresenter.cs" Line="1" Column="1" />
<File FileName="../Locator.Mobile.Client/Bootstrapper.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.Droid/Properties/AssemblyInfo.cs" Line="41" Column="66" />
<File FileName="Locator.Mobile.Droid/Properties/AndroidManifest.xml" Line="8" Column="12" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore>
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.BL/Client/RequestClient.cs" line="29" column="1" />
<Breakpoint file="/var/folders/04/xk_24dtx1rnfyl4n89kzf2gr0000gn/T/__layoutFile" line="22" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Droid/Locator.Mobile.Droid/Base/LocationHelper.cs" line="52" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Droid/Locator.Mobile.Droid/Base/LocationHelper.cs" line="50" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Droid/Locator.Mobile.Droid/Notifications/GCMIntentService.cs" line="95" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Client/ClientImpl/RestWebClient.cs" line="59" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Client/ClientImpl/RestWebClient.cs" line="61" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Droid/Locator.Mobile.Droid/Activities/Location/LocationActivity.cs" line="29" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Droid/Locator.Mobile.Droid/Base/LocationHelper.cs" line="55" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Droid/Locator.Mobile.Droid/Base/LocationHelper.cs" line="59" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Droid/Locator.Mobile.Droid/Base/LocationHelper.cs" line="63" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Droid/Locator.Mobile.Droid/Base/LocationHelper.cs" line="67" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Droid/Locator.Mobile.Droid/Base/LocationHelper.cs" line="79" column="1" />
<Breakpoint file="/Users/Igor/Projects/Locator/Locator.Mobile/Locator.Mobile.Droid/Locator.Mobile.Droid/Base/LocationHelper.cs" line="43" column="75" />
</BreakpointStore>
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|iPhone" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.iPad Igor" />
<MonoDevelop.Ide.Workbench ActiveDocument="Locator.Mobile.iOS/AppDelegate.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="Locator.Mobile.iOS/Controllers/Friends/FriendsController.cs">
<Files>
<File FileName="Locator.Mobile.iOS/Controllers/Location/LocationController.cs" Line="1" Column="1" />
<File FileName="../Locator.Mobile.Presentation/Locations/LocationsPresenter.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.iOS/Base/Navigations.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.iOS/Base/Controller/ViewController.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.iOS/AppDelegate.cs" Line="79" Column="1" />
<File FileName="Locator.Mobile.iOS/AppDelegate.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.iOS/Controllers/RootController.cs" Line="1" Column="1" />
<File FileName="../Locator.Mobile.Client/ClientImpl/RestWebClient.cs" Line="29" Column="55" />
<File FileName="../Locator.Mobile.Client/ClientImpl/RestWebClient.cs" Line="1" Column="1" />
<File FileName="../Locator.Mobile.Client/Bootstrapper.cs" Line="1" Column="1" />
<File FileName="../Locator.Mobile.BL/UserSettings.cs" Line="8" Column="1" />
<File FileName="../Locator.Mobile.BL/UserSettings.cs" Line="1" Column="1" />
<File FileName="Locator.Mobile.iOS/Controllers/Friends/FriendsController.cs" Line="54" Column="6" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ private void SetFriends(List<Item> items)
var item = n as FriendItem;
if (item != null)
{
//GetLocation(item.Friend.ID);
SendLocation(item.Friend.ID, 20, 20);
GetLocation(item.Friend.ID);
}
}
};
Expand All @@ -76,19 +75,26 @@ private void GetLocation(long friendId)
{
var locationManager = new CLLocationManager ();
locationManager.StartUpdatingLocation();

if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) {
locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
EventHandler<CLLocationsUpdatedEventArgs> handler = null;
handler = (s, e) => {
locationManager.LocationsUpdated -= handler;
var location = e.Locations [e.Locations.Length - 1].Coordinate;
SendLocation(friendId, location.Latitude, location.Longitude);
locationManager.StopUpdatingLocation();
};
locationManager.LocationsUpdated += handler;
} else {
// this won't be called on iOS 6 (deprecated)
locationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => {
EventHandler<CLLocationUpdatedEventArgs> handler = null;
handler = (s, e) => {
locationManager.UpdatedLocation -= handler;
var location = e.NewLocation.Coordinate;
SendLocation(friendId, location.Latitude, location.Longitude);
locationManager.StopUpdatingLocation();
};
locationManager.UpdatedLocation += handler;
}
}
}
Expand Down

0 comments on commit d60fb1e

Please sign in to comment.