Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2022-10-21 14:37:41 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a1befabb84188d55c16d3df13e025adda7f984ac
a1befabb
1 parent
bac84e71
fix cached images issue at gfy, mfy
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
4 deletions
SwiftWarplyFramework/SwiftWarplyFramework/InboxTableViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/MFYInboxTableViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/ViewControllerExtensions.swift
SwiftWarplyFramework/SwiftWarplyFramework/InboxTableViewCell.swift
View file @
a1befab
...
...
@@ -13,6 +13,24 @@ import UIKit
@IBOutlet
weak
var
newBadgeImage
:
UIImageView
!
@IBOutlet
weak
var
campaignTitleLabel
:
UILabel
!
var
postImageURL
:
String
?
{
didSet
{
if
let
url
=
postImageURL
{
self
.
campaignImage
.
image
=
UIImage
()
// UIImage(named: "loading")
UIImage
.
loadImageUsingCacheWithUrlString
(
url
)
{
image
in
// set the image only when we are still displaying the content for the image we finished downloading
if
url
==
self
.
postImageURL
{
self
.
campaignImage
.
image
=
image
}
}
}
else
{
self
.
campaignImage
.
image
=
nil
}
}
}
public
override
func
awakeFromNib
()
{
super
.
awakeFromNib
()
...
...
@@ -43,7 +61,8 @@ import UIKit
func
configureCell
(
campaign
:
swiftApi
.
CampaignItemModel
)
{
campaignImage
.
load
(
link
:
campaign
.
logo_url
??
""
,
placeholder
:
UIImage
(),
cache
:
URLCache
())
// campaignImage.load(link: campaign.logo_url ?? "", placeholder: UIImage(), cache: URLCache())
self
.
postImageURL
=
campaign
.
logo_url
??
""
campaignTitleLabel
.
text
=
campaign
.
title
??
""
...
...
@@ -55,7 +74,8 @@ import UIKit
}
func
configureCell
(
ccms
:
swiftApi
.
LoyaltyContextualOfferModel
)
{
campaignImage
.
load
(
link
:
ccms
.
_imageUrl
,
placeholder
:
UIImage
(),
cache
:
URLCache
())
// campaignImage.load(link: ccms._imageUrl , placeholder: UIImage(), cache: URLCache())
self
.
postImageURL
=
ccms
.
_imageUrl
campaignTitleLabel
.
text
=
ccms
.
_title
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MFYInboxTableViewCell.swift
View file @
a1befab
...
...
@@ -16,6 +16,24 @@ import UIKit
@IBOutlet
weak
var
subtitleLabel
:
UILabel
!
@IBOutlet
weak
var
descriptionLabel
:
UILabel
!
var
postImageURL
:
String
?
{
didSet
{
if
let
url
=
postImageURL
{
self
.
campaignImage
.
image
=
UIImage
()
// UIImage(named: "loading")
UIImage
.
loadImageUsingCacheWithUrlString
(
url
)
{
image
in
// set the image only when we are still displaying the content for the image we finished downloading
if
url
==
self
.
postImageURL
{
self
.
campaignImage
.
image
=
image
}
}
}
else
{
self
.
campaignImage
.
image
=
nil
}
}
}
public
override
func
awakeFromNib
()
{
super
.
awakeFromNib
()
...
...
@@ -43,7 +61,8 @@ import UIKit
func
configureCell
(
campaign
:
swiftApi
.
CampaignItemModel
)
{
campaignImage
.
load
(
link
:
campaign
.
logo_url
??
""
,
placeholder
:
UIImage
(),
cache
:
URLCache
())
// campaignImage.load(link: campaign.logo_url ?? "", placeholder: UIImage(), cache: URLCache())
self
.
postImageURL
=
campaign
.
logo_url
??
""
campaignTitleLabel
.
text
=
campaign
.
title
??
""
campaignTitleLabel
.
font
=
UIFont
(
name
:
"PFSquareSansPro-BoldItalic"
,
size
:
18
)
...
...
@@ -60,7 +79,8 @@ import UIKit
}
func
configureCell
(
ccms
:
swiftApi
.
LoyaltyContextualOfferModel
)
{
campaignImage
.
load
(
link
:
ccms
.
_imageUrl
,
placeholder
:
UIImage
(),
cache
:
URLCache
())
// campaignImage.load(link: ccms._imageUrl , placeholder: UIImage(), cache: URLCache())
self
.
postImageURL
=
ccms
.
_imageUrl
campaignTitleLabel
.
text
=
ccms
.
_title
campaignTitleLabel
.
font
=
UIFont
(
name
:
"PFSquareSansPro-BoldItalic"
,
size
:
18
)
...
...
SwiftWarplyFramework/SwiftWarplyFramework/ViewControllerExtensions.swift
View file @
a1befab
...
...
@@ -225,6 +225,33 @@ extension UIImageView {
}
}
let
imageCache
=
NSCache
<
NSString
,
AnyObject
>
()
extension
UIImage
{
static
func
loadImageUsingCacheWithUrlString
(
_
urlString
:
String
,
completion
:
@escaping
(
UIImage
)
->
Void
)
{
if
let
cachedImage
=
imageCache
.
object
(
forKey
:
urlString
as
NSString
)
as?
UIImage
{
completion
(
cachedImage
)
}
else
{
//No cache, so create new one and set image
let
url
=
URL
(
string
:
urlString
)
URLSession
.
shared
.
dataTask
(
with
:
url
!
,
completionHandler
:
{
(
data
,
response
,
error
)
in
if
let
error
=
error
{
print
(
error
)
return
}
DispatchQueue
.
main
.
async
(
execute
:
{
if
let
downloadedImage
=
UIImage
(
data
:
data
!
)
{
imageCache
.
setObject
(
downloadedImage
,
forKey
:
urlString
as
NSString
)
completion
(
downloadedImage
)
}
})
})
.
resume
()
}
}
}
typealias
GradientPoints
=
(
startPoint
:
CGPoint
,
endPoint
:
CGPoint
)
enum
GradientOrientation
{
...
...
Please
register
or
login
to post a comment