Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
529
Issue boards
Milestones
Wiki
Code
Merge requests
15
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
7f3cacbe
Commit
7f3cacbe
authored
8 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Limit scan notification rate to 1Hz
parent
ad378e80
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vlc-android/src/org/videolan/vlc/MediaParsingService.java
+40
-21
40 additions, 21 deletions
vlc-android/src/org/videolan/vlc/MediaParsingService.java
with
40 additions
and
21 deletions
vlc-android/src/org/videolan/vlc/MediaParsingService.java
+
40
−
21
View file @
7f3cacbe
...
...
@@ -33,12 +33,13 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
public
final
static
String
ACTION_DISCOVER
=
"medialibrary_discover"
;
public
final
static
String
EXTRA_PATH
=
"extra_path"
;
public
static
final
long
NOTIFICATION_DELAY
=
1000L
;
private
final
IBinder
mBinder
=
new
LocalBinder
();
private
Medialibrary
mMedialibrary
;
private
int
mParsing
=
0
;
private
String
mCurrentProgress
=
null
;
private
StringBuilder
sb
=
new
StringBuilder
()
;
private
long
mLastNotificationTime
=
0
;
@Nullable
@Override
...
...
@@ -110,29 +111,47 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
}
private
void
showNotification
()
{
sb
.
setLength
(
0
);
if
(
mParsing
>
0
)
sb
.
append
(
getString
(
R
.
string
.
ml_parse_media
)).
append
(
' '
).
append
(
mParsing
).
append
(
"%"
);
else
if
(
mCurrentProgress
!=
null
)
sb
.
append
(
getString
(
R
.
string
.
ml_discovering
)).
append
(
' '
).
append
(
Uri
.
decode
(
Strings
.
removeFileProtocole
(
mCurrentProgress
)));
else
sb
.
append
(
getString
(
R
.
string
.
ml_parse_media
));
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
MediaParsingService
.
this
)
.
setSmallIcon
(
R
.
drawable
.
ic_notif_scan
)
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PUBLIC
)
.
setContentTitle
(
getString
(
R
.
string
.
ml_scanning
))
.
setContentText
(
sb
.
toString
())
.
setAutoCancel
(
false
)
.
setOngoing
(
true
);
Notification
notification
=
builder
.
build
();
try
{
NotificationManagerCompat
.
from
(
MediaParsingService
.
this
).
notify
(
43
,
notification
);
}
catch
(
IllegalArgumentException
ignored
)
{}
final
long
currentTime
=
System
.
currentTimeMillis
();
synchronized
(
this
)
{
if
(
mLastNotificationTime
==
-
1L
||
currentTime
-
mLastNotificationTime
<
NOTIFICATION_DELAY
)
return
;
mLastNotificationTime
=
currentTime
;
}
VLCApplication
.
runBackground
(
new
Runnable
()
{
final
StringBuilder
sb
=
new
StringBuilder
();
@Override
public
void
run
()
{
if
(
mParsing
>
0
)
sb
.
append
(
getString
(
R
.
string
.
ml_parse_media
)).
append
(
' '
).
append
(
mParsing
).
append
(
"%"
);
else
if
(
mCurrentProgress
!=
null
)
sb
.
append
(
getString
(
R
.
string
.
ml_discovering
)).
append
(
' '
).
append
(
Uri
.
decode
(
Strings
.
removeFileProtocole
(
mCurrentProgress
)));
else
sb
.
append
(
getString
(
R
.
string
.
ml_parse_media
));
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
MediaParsingService
.
this
)
.
setSmallIcon
(
R
.
drawable
.
ic_notif_scan
)
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PUBLIC
)
.
setContentTitle
(
getString
(
R
.
string
.
ml_scanning
))
.
setContentText
(
sb
.
toString
())
.
setAutoCancel
(
false
)
.
setOngoing
(
true
);
final
Notification
notification
=
builder
.
build
();
synchronized
(
MediaParsingService
.
this
)
{
if
(
mLastNotificationTime
!=
-
1L
)
{
try
{
NotificationManagerCompat
.
from
(
MediaParsingService
.
this
).
notify
(
43
,
notification
);
}
catch
(
IllegalArgumentException
ignored
)
{}
}
}
}
});
}
private
void
hideNotification
()
{
NotificationManagerCompat
.
from
(
MediaParsingService
.
this
).
cancel
(
43
);
synchronized
(
this
)
{
mLastNotificationTime
=
-
1L
;
NotificationManagerCompat
.
from
(
MediaParsingService
.
this
).
cancel
(
43
);
}
}
@Override
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment