Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
VLC-iOS
Commits
086b4fef
Commit
086b4fef
authored
Aug 03, 2013
by
Felix Paul Kühne
Browse files
Factorize idle timer handling
parent
ee606932
Changes
5
Hide whitespace changes
Inline
Side-by-side
AspenProject/VLCAppDelegate.h
View file @
086b4fef
...
...
@@ -16,6 +16,8 @@
@interface
VLCAppDelegate
:
UIResponder
<
UIApplicationDelegate
>
-
(
void
)
updateMediaList
;
-
(
void
)
disableIdleTimer
;
-
(
void
)
activateIdleTimer
;
@property
(
nonatomic
,
readonly
)
VLCPlaylistViewController
*
playlistViewController
;
@property
(
nonatomic
,
readonly
)
VLCDropboxTableViewController
*
dropboxTableViewController
;
...
...
AspenProject/VLCAppDelegate.m
View file @
086b4fef
...
...
@@ -23,6 +23,7 @@
@interface
VLCAppDelegate
()
<
PAPasscodeViewControllerDelegate
,
VLCMediaFileDiscovererDelegate
>
{
PAPasscodeViewController
*
_passcodeLockController
;
VLCDropboxTableViewController
*
_dropboxTableViewController
;
int
_idleCounter
;
}
@property
(
nonatomic
)
BOOL
passcodeValidated
;
...
...
@@ -249,4 +250,19 @@
// TODO handle error attempts
}
#pragma mark - idle timer preventer
-
(
void
)
disableIdleTimer
{
_idleCounter
++
;
if
([
UIApplication
sharedApplication
].
idleTimerDisabled
==
NO
)
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
YES
;
}
-
(
void
)
activateIdleTimer
{
_idleCounter
--
;
if
(
_idleCounter
<
1
)
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
NO
;
}
@end
AspenProject/VLCDropboxController.m
View file @
086b4fef
...
...
@@ -172,7 +172,7 @@
_outstandingNetworkRequests
++
;
if
(
_outstandingNetworkRequests
==
1
)
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
YES
;
[(
VLCAppDelegate
*
)
[
UIApplication
sharedApplication
].
delegate
disableIdleTimer
]
;
}
}
...
...
@@ -181,7 +181,7 @@
_outstandingNetworkRequests
--
;
if
(
_outstandingNetworkRequests
==
0
)
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
NO
;
[(
VLCAppDelegate
*
)
[
UIApplication
sharedApplication
].
delegate
activateIdleTimer
]
;
}
}
...
...
AspenProject/VLCHTTPFileDownloader.m
View file @
086b4fef
...
...
@@ -44,7 +44,7 @@
}
else
{
_downloadInProgress
=
YES
;
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
YES
;
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
YES
;
[(
VLCAppDelegate
*
)
[
UIApplication
sharedApplication
].
delegate
disableIdleTimer
]
;
}
}
...
...
@@ -129,7 +129,7 @@
{
_downloadInProgress
=
NO
;
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
NO
;
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
NO
;
[(
VLCAppDelegate
*
)
[
UIApplication
sharedApplication
].
delegate
activateIdleTimer
]
;
[
self
.
delegate
downloadEnded
];
}
...
...
AspenProject/VLCHTTPUploaderController.m
View file @
086b4fef
...
...
@@ -284,7 +284,7 @@ static const int httpLogLevel = HTTP_LOG_LEVEL_VERBOSE; // | HTTP_LOG_FLAG_TRACE
storeFile
=
[
NSFileHandle
fileHandleForWritingAtPath
:
filePath
];
[
uploadedFiles
addObject
:
[
NSString
stringWithFormat
:
@"/upload/%@"
,
filename
]];
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
YES
;
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
YES
;
[(
VLCAppDelegate
*
)
[
UIApplication
sharedApplication
].
delegate
disableIdleTimer
]
;
}
}
...
...
@@ -302,7 +302,7 @@ static const int httpLogLevel = HTTP_LOG_LEVEL_VERBOSE; // | HTTP_LOG_FLAG_TRACE
[
storeFile
closeFile
];
storeFile
=
nil
;
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
NO
;
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
NO
;
[(
VLCAppDelegate
*
)
[
UIApplication
sharedApplication
].
delegate
activateIdleTimer
]
;
/* update media library when file upload was completed */
VLCAppDelegate
*
appDelegate
=
[
UIApplication
sharedApplication
].
delegate
;
...
...
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