Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1weather
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
1weather
Commits
2c5ac8c1
Commit
2c5ac8c1
authored
Mar 30, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix current location deletion.
parent
c7d6b24e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
9 deletions
+11
-9
1Weather/Model/DeviceLocationMonitor.swift
+2
-2
1Weather/Model/LocationManager.swift
+6
-4
1Weather/UI/View controllers/Locations/LocationViewController.swift
+2
-2
1Weather/UI/View controllers/Locations/LocationsViewModel.swift
+1
-1
No files found.
1Weather/Model/DeviceLocationMonitor.swift
View file @
2c5ac8c1
...
...
@@ -225,12 +225,12 @@ extension DeviceLocationMonitor: CLLocationManagerDelegate {
guard
let
clError
=
error
as?
CLError
else
{
return
}
switch
clError
{
case
CLError
.
denied
:
log
.
error
(
"
error: u
ser denied access"
)
log
.
error
(
"
U
ser denied access"
)
DispatchQueue
.
main
.
async
{
self
.
delegate
?
.
deviceLocationMonitor
(
self
,
authorizationStatusChanged
:
false
)
}
default
:
log
.
error
(
"error:
\(
error
)
"
)
log
.
error
(
"
Unknown
error:
\(
error
)
"
)
}
}
}
1Weather/Model/LocationManager.swift
View file @
2c5ac8c1
...
...
@@ -39,7 +39,6 @@ public class LocationManager {
didSet
{
log
.
info
(
"Locations list updated:
\(
locations
.
map
{
$0
.
description
}
.
joined
(
separator
:
", "
)
)
"
)
let
newValue
=
locations
DispatchQueue
.
main
.
async
{
if
let
selectedIndex
=
self
.
selectedLocationIndex
,
selectedIndex
>=
newValue
.
count
{
self
.
selectedLocationIndex
=
newValue
.
count
>
0
?
0
:
nil
}
...
...
@@ -55,7 +54,6 @@ public class LocationManager {
}
}
}
private
var
selectedLocationIndex
:
Int
?
{
didSet
{
...
...
@@ -304,12 +302,16 @@ public class LocationManager {
// MARK: - DeviceLocationMonitorDelegate implementation
extension
LocationManager
:
DeviceLocationMonitorDelegate
{
func
deviceLocationMonitor
(
_
monitor
:
DeviceLocationMonitor
,
didUpdateLocation
newLocation
:
PartialLocation
)
{
log
.
debug
(
"device location updated: (
\(
newLocation
.
lat
??
"-"
)
;
\(
newLocation
.
lon
??
"-"
)
)"
)
addIfNeeded
(
partialLocation
:
newLocation
,
selectLocation
:
false
)
}
func
deviceLocationMonitor
(
_
monitor
:
DeviceLocationMonitor
,
authorizationStatusChanged
locationIsAllowed
:
Bool
)
{
if
!
locationIsAllowed
&&
locations
.
first
?
.
deviceLocation
==
true
{
locations
=
[
Location
](
locations
.
suffix
(
from
:
1
))
DispatchQueue
.
main
.
async
{
if
!
locationIsAllowed
&&
self
.
locations
.
first
?
.
deviceLocation
==
true
{
self
.
log
.
debug
(
"device location: remove due to error"
)
self
.
locations
=
[
Location
](
self
.
locations
.
suffix
(
from
:
1
))
}
}
}
}
1Weather/UI/View controllers/Locations/LocationViewController.swift
View file @
2c5ac8c1
...
...
@@ -241,7 +241,7 @@ extension LocationViewController: LocationsViewModelDelegate {
}
}
//MARK: UItableView Data Source
//MARK:
-
UItableView Data Source
extension
LocationViewController
:
UITableViewDataSource
{
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
return
locationsViewModel
.
cities
.
count
...
...
@@ -281,7 +281,7 @@ extension LocationViewController: UITableViewDataSource {
}
}
//MARK: UITableView Delegate
//MARK:
-
UITableView Delegate
extension
LocationViewController
:
UITableViewDelegate
{
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
let
container
=
UIView
()
...
...
1Weather/UI/View controllers/Locations/LocationsViewModel.swift
View file @
2c5ac8c1
...
...
@@ -226,6 +226,7 @@ public class LocationsViewModel {
}
}
// MARK: - LocationManagerDelegate implementation
extension
LocationsViewModel
:
LocationManagerDelegate
{
public
func
locationManager
(
_
locationManager
:
LocationManager
,
changedSelectedLocation
newLocation
:
Location
?)
{
DispatchQueue
.
main
.
async
{
...
...
@@ -237,7 +238,6 @@ extension LocationsViewModel: LocationManagerDelegate {
}
public
func
locationManager
(
_
locationManager
:
LocationManager
,
updatedLocationsList
newList
:
[
Location
])
{
self
.
delegate
?
.
viewModelDidChange
(
model
:
self
)
DispatchQueue
.
main
.
async
{
self
.
delegate
?
.
viewModelDidChange
(
model
:
self
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment