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
61382dc4
Commit
61382dc4
authored
Aug 06, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed shorts list parsing
parent
54dc1958
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
10 deletions
+70
-10
InMobiShortsSource/InMobiShortsSource.xcodeproj/project.pbxproj
+8
-0
InMobiShortsSource/InMobiShortsSource/InMobiShortSource.swift
+3
-8
InMobiShortsSource/InMobiShortsSource/Models/GlanceOverlayImage.swift
+2
-2
InMobiShortsSource/InMobiShortsSource/Models/GlancesList.swift
+13
-0
InMobiShortsSource/InMobiShortsSource/Models/LossyCodableList.swift
+44
-0
No files found.
InMobiShortsSource/InMobiShortsSource.xcodeproj/project.pbxproj
View file @
61382dc4
...
...
@@ -7,6 +7,8 @@
objects
=
{
/* Begin PBXBuildFile section */
CD2D4C6126BD65F80016A180
/* LossyCodableList.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD2D4C6026BD65F80016A180
/* LossyCodableList.swift */
;
};
CD2D4C6326BD67790016A180
/* GlancesList.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD2D4C6226BD67790016A180
/* GlancesList.swift */
;
};
CD427D1F266F657900B4350A
/* OneWeatherCore.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD427D1E266F657900B4350A
/* OneWeatherCore.framework */
;
};
CD427D23266F715900B4350A
/* OneWeatherAnalytics.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD427D22266F715900B4350A
/* OneWeatherAnalytics.framework */
;
};
CDAEC2092679F70600818A2A
/* GlanceOverlayImage.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDAEC2082679F70600818A2A
/* GlanceOverlayImage.swift */
;
};
...
...
@@ -33,6 +35,8 @@
/* Begin PBXFileReference section */
CD2C227E2670AC6D001ADA9A
/* InMobiShortsPG.playground */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.playground
;
path
=
InMobiShortsPG.playground
;
sourceTree
=
"<group>"
;
xcLanguageSpecificationIdentifier
=
xcode.lang.swift
;
};
CD2D4C6026BD65F80016A180
/* LossyCodableList.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LossyCodableList.swift
;
sourceTree
=
"<group>"
;
};
CD2D4C6226BD67790016A180
/* GlancesList.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
GlancesList.swift
;
sourceTree
=
"<group>"
;
};
CD427D1E266F657900B4350A
/* OneWeatherCore.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
path
=
OneWeatherCore.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
CD427D22266F715900B4350A
/* OneWeatherAnalytics.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
path
=
OneWeatherAnalytics.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
CDAEC2082679F70600818A2A
/* GlanceOverlayImage.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
GlanceOverlayImage.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -129,6 +133,8 @@
CDAEC2082679F70600818A2A
/* GlanceOverlayImage.swift */
,
CDFE3F2B266E519E00E72910
/* PeekData.swift */
,
CDFE3F2D266E51B400E72910
/* Peek.swift */
,
CD2D4C6026BD65F80016A180
/* LossyCodableList.swift */
,
CD2D4C6226BD67790016A180
/* GlancesList.swift */
,
);
path
=
Models
;
sourceTree
=
"<group>"
;
...
...
@@ -243,6 +249,8 @@
buildActionMask
=
2147483647
;
files
=
(
CDFE3F2E266E51B400E72910
/* Peek.swift in Sources */
,
CD2D4C6126BD65F80016A180
/* LossyCodableList.swift in Sources */
,
CD2D4C6326BD67790016A180
/* GlancesList.swift in Sources */
,
CDFE3F23266E453500E72910
/* InMobiShortSource.swift in Sources */
,
CDFE3F29266E489E00E72910
/* GlanceImage.swift in Sources */
,
CDFE3F25266E45B800E72910
/* Glance.swift in Sources */
,
...
...
InMobiShortsSource/InMobiShortsSource/InMobiShortSource.swift
View file @
61382dc4
...
...
@@ -74,15 +74,10 @@ public class InMobiShortSource: ShortSource {
}
let
decoder
=
JSONDecoder
()
decoder
.
keyDecodingStrategy
=
.
convertFromSnakeCase
decoder
.
keyDecodingStrategy
=
.
useDefaultKeys
do
{
let
glancesDict
=
try
decoder
.
decode
([
String
:[
GlanceDetails
]]
.
self
,
from
:
data
)
if
let
glanceDetailsArray
=
glancesDict
[
"glances"
]
{
completion
(
glanceDetailsArray
.
map
{
self
.
toAppModel
(
glanceDetails
:
$0
)},
nil
)
}
else
{
completion
(
nil
,
InMobiShortSourceError
.
dataEncodingError
(
"Failed to decode glance details array"
))
}
let
glancesList
=
try
decoder
.
decode
(
GlancesList
.
self
,
from
:
data
)
completion
(
glancesList
.
glances
.
map
{
self
.
toAppModel
(
glanceDetails
:
$0
)},
nil
)
}
catch
{
completion
(
nil
,
InMobiShortSourceError
.
dataEncodingError
(
error
.
localizedDescription
))
...
...
InMobiShortsSource/InMobiShortsSource/Models/GlanceOverlayImage.swift
View file @
61382dc4
...
...
@@ -8,6 +8,6 @@
import
Foundation
struct
GlanceOverlayImage
:
Codable
{
let
id
:
String
let
supportedImages
:
[
GlanceImageFormat
]
let
id
:
String
var
supportedImages
:
[
GlanceImageFormat
]
}
InMobiShortsSource/InMobiShortsSource/Models/GlancesList.swift
0 → 100644
View file @
61382dc4
//
// GlancesList.swift
// InMobiShortsSource
//
// Created by Dmitry Stepanets on 06.08.2021.
//
import
Foundation
struct
GlancesList
:
Codable
{
@LossyCodableList
var
glances
:
[
GlanceDetails
]
}
InMobiShortsSource/InMobiShortsSource/Models/LossyCodableList.swift
0 → 100644
View file @
61382dc4
//
// LossyCodableList.swift
// InMobiShortsSource
//
// Created by Dmitry Stepanets on 06.08.2021.
//
import
Foundation
@propertyWrapper
struct
LossyCodableList
<
Element
>
{
var
elements
:
[
Element
]
var
wrappedValue
:
[
Element
]
{
get
{
elements
}
set
{
elements
=
newValue
}
}
}
extension
LossyCodableList
:
Decodable
where
Element
:
Decodable
{
private
struct
ElementWrapper
:
Decodable
{
var
element
:
Element
?
init
(
from
decoder
:
Decoder
)
throws
{
let
container
=
try
decoder
.
singleValueContainer
()
element
=
try
?
container
.
decode
(
Element
.
self
)
}
}
init
(
from
decoder
:
Decoder
)
throws
{
let
container
=
try
decoder
.
singleValueContainer
()
let
wrappers
=
try
container
.
decode
([
ElementWrapper
]
.
self
)
elements
=
wrappers
.
compactMap
(
\
.
element
)
}
}
extension
LossyCodableList
:
Encodable
where
Element
:
Encodable
{
func
encode
(
to
encoder
:
Encoder
)
throws
{
var
container
=
encoder
.
unkeyedContainer
()
for
element
in
elements
{
try
?
container
.
encode
(
element
)
}
}
}
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