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
baa6d846
Commit
baa6d846
authored
Sep 09, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused class
parent
a94bc89a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
179 deletions
+0
-179
1Weather/Ads/AdCacheManager.swift
+0
-179
No files found.
1Weather/Ads/AdCacheManager.swift
deleted
100644 → 0
View file @
a94bc89a
//
// AdCacheManager.swift
// BaconReader
//
// Created by Steve Pint on 4/24/19.
// Copyright © 2019 OneLouder Apps. All rights reserved.
//
import
UIKit
import
FBAudienceNetwork
import
OneWeatherCore
import
OneWeatherAnalytics
class
AdCacheManager
:
NSObject
{
@objc
static
let
shared
=
AdCacheManager
()
@objc
enum
AdPlacementKey
:
Int
{
case
sidebarBanner
case
stickyBannerList
case
stickyBannerDetail
var
name
:
String
{
switch
self
{
case
.
sidebarBanner
:
return
"sidebar_banner"
case
.
stickyBannerList
:
return
"sticky_banner_list"
case
.
stickyBannerDetail
:
return
"sticky_banner_detail"
}
}
}
private
var
sidebarBannerViews
=
[
AdView
]()
private
var
stickyAdViewList
:
AdView
?
private
var
stickyAdViewDetail
:
AdView
?
private
let
log
=
AdLogger
(
componentName
:
"AdViewCache"
)
internal
override
init
()
{
super
.
init
()
// No need to handle config change notification, because AdViews and Interstitials will take care of reinitializing themselves.
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
changedToPro
)
,
name
:
NSNotification
.
Name
(
rawValue
:
kEventInAppPurchasedCompleted
),
object
:
nil
)
// In Debug mode we allow the user to change the environment
#if DEBUG
EnvironmentManager
.
shared
.
environment
=
Settings
.
shared
.
adTestEnvironment
?
.
test
:
.
production
if
EnvironmentManager
.
shared
.
environment
==
Environment
.
test
{
FBAdSettings
.
addTestDevice
(
FBAdSettings
.
testDeviceHash
())
}
else
{
FBAdSettings
.
clearTestDevice
(
FBAdSettings
.
testDeviceHash
())
}
#else
EnvironmentManager
.
shared
.
environment
=
.
production
#endif
}
deinit
{
NotificationCenter
.
default
.
removeObserver
(
self
)
}
// TODO: This needs to be moved to AdManager
@objc
var
adsEnabled
:
Bool
{
// TODO: see previous implementation. How should we handle this here?
return
true
}
private
func
initAdCache
()
{
pushAd
(
adPlacement
:
.
stickyBannerList
,
placement
:
AdPlacementKey
.
stickyBannerList
.
name
)
pushAd
(
adPlacement
:
.
stickyBannerDetail
,
placement
:
AdPlacementKey
.
stickyBannerDetail
.
name
)
pushAd
(
adPlacement
:
.
sidebarBanner
,
placement
:
AdPlacementKey
.
sidebarBanner
.
name
)
}
var
loggingAliasCounter
=
1
private
func
pushAd
(
adPlacement
:
AdPlacementKey
,
placement
:
String
)
{
let
adView
=
AdView
()
adView
.
loggingAlias
=
"
\(
placement
)
-
\(
loggingAliasCounter
)
"
loggingAliasCounter
+=
1
adView
.
set
(
placementName
:
placement
,
adType
:
.
banner
)
adView
.
requestAd
(
startAutorefresh
:
false
)
switch
adPlacement
{
case
.
sidebarBanner
:
sidebarBannerViews
.
append
(
adView
)
case
.
stickyBannerList
:
stickyAdViewList
=
adView
case
.
stickyBannerDetail
:
stickyAdViewDetail
=
adView
}
log
.
info
(
"cache adView (
\(
placement
)
)"
)
}
@objc
func
popAd
(
adPlacement
:
AdPlacementKey
)
->
AdView
?
{
if
AdConfigManager
.
shared
.
adConfig
.
placements
!=
nil
&&
AdConfigManager
.
shared
.
adConfig
.
placement
(
named
:
adPlacement
.
name
)
==
nil
{
log
.
error
(
"placement not found in the config:
\(
adPlacement
.
name
)
"
)
}
switch
adPlacement
{
case
.
sidebarBanner
:
pushAd
(
adPlacement
:
adPlacement
,
placement
:
adPlacement
.
name
)
case
.
stickyBannerList
:
//There is only one sticky banner! Do not create new
if
stickyAdViewList
==
nil
{
pushAd
(
adPlacement
:
adPlacement
,
placement
:
adPlacement
.
name
)
}
case
.
stickyBannerDetail
:
//There is only one sticky banner! Do not create new
if
stickyAdViewDetail
==
nil
{
pushAd
(
adPlacement
:
adPlacement
,
placement
:
adPlacement
.
name
)
}
}
log
.
info
(
"use adView (
\(
adPlacement
.
name
)
)"
)
// add a new one for each one that gets removed
var
result
:
AdView
?
=
nil
switch
adPlacement
{
case
.
sidebarBanner
:
result
=
sidebarBannerViews
.
removeFirst
()
result
?
.
start
()
case
.
stickyBannerList
:
result
=
stickyAdViewList
case
.
stickyBannerDetail
:
result
=
stickyAdViewDetail
}
return
result
}
/* //TODO :- Update this method when Interstitial is introduced.
@objc
func popInterstitialAd() -> Interstitial? {
guard let placement = AdConfigManager.shared.adConfig.placement(named: "brint") else {
if AdConfigManager.shared.adConfig.placements != nil {
// config is not empty, but the placement is missing
analytics(log: .kFlurryAdConfigPlacementNotFound)
}
return nil
}
log.info("use interstitial (\(placement.name))")
let loggingAlias = "\(placement.name)-\(loggingAliasCounter)"
loggingAliasCounter += 1
return Interstitial(placementName: placement.name, delegate: nil, loggingAlias: loggingAlias)
}
*/
@objc
func
setupAds
()
{
// Ads setup
if
adsEnabled
{
if
let
_
=
AdConfigManager
.
shared
.
adConfig
.
placement
(
named
:
AdPlacementKey
.
sidebarBanner
.
name
)
{
clearCache
()
initAdCache
()
}
else
{
// analytics(log: .kFlurryAdConfigPlacementNotFound)
}
}
}
private
func
clearCache
()
{
sidebarBannerViews
.
removeAll
()
}
// MARK: - notifications
@objc
func
changedToPro
(
_
notification
:
Notification
)
{
NotificationCenter
.
default
.
removeObserver
(
self
)
clearCache
()
}
}
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