Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Ewout ter Hoeven
VLC-Android
Commits
ebc51ff8
Commit
ebc51ff8
authored
Apr 08, 2015
by
Geoffrey Métais
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix recommendations
parent
d64b1c07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
38 deletions
+28
-38
vlc-android/tv/src/org/videolan/vlc/gui/tv/RecommendationsService.java
...v/src/org/videolan/vlc/gui/tv/RecommendationsService.java
+28
-38
No files found.
vlc-android/tv/src/org/videolan/vlc/gui/tv/RecommendationsService.java
View file @
ebc51ff8
...
...
@@ -30,7 +30,6 @@ import android.net.Uri;
import
android.os.Message
;
import
android.preference.PreferenceManager
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.app.TaskStackBuilder
;
import
android.text.TextUtils
;
import
org.videolan.vlc.MediaDatabase
;
...
...
@@ -41,18 +40,17 @@ import org.videolan.vlc.gui.PreferencesActivity;
import
org.videolan.vlc.gui.video.VideoPlayerActivity
;
import
org.videolan.vlc.util.WeakHandler
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
public
class
RecommendationsService
extends
IntentService
{
private
static
final
String
TAG
=
"VLC/RecommendationsService"
;
private
static
final
int
NUM_RECOMMANDATIONS
=
4
;
private
static
final
int
NUM_RECOMMANDATIONS
=
3
;
private
static
NotificationManager
s
NotificationManager
;
private
static
MediaDatabase
s
MediaDatabase
=
MediaDatabase
.
getInstance
();
private
static
Context
s
Context
;
private
NotificationManager
m
NotificationManager
;
private
MediaDatabase
m
MediaDatabase
=
MediaDatabase
.
getInstance
();
private
Context
m
Context
;
public
RecommendationsService
()
{
super
(
"RecommendationsService"
);
...
...
@@ -61,7 +59,7 @@ public class RecommendationsService extends IntentService {
@Override
public
void
onCreate
()
{
super
.
onCreate
();
s
Context
=
this
;
m
Context
=
this
;
}
@Override
...
...
@@ -71,13 +69,13 @@ public class RecommendationsService extends IntentService {
MediaLibrary
.
getInstance
().
loadMediaItems
();
}
}
private
static
void
buildRecommendation
(
MediaWrapper
movie
,
int
id
,
int
priority
)
{
private
void
buildRecommendation
(
MediaWrapper
movie
,
int
id
,
int
priority
)
{
if
(
movie
==
null
)
return
;
if
(
s
NotificationManager
==
null
)
{
s
NotificationManager
=
(
NotificationManager
)
s
Context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
if
(
m
NotificationManager
==
null
)
{
m
NotificationManager
=
(
NotificationManager
)
m
Context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
}
//TODO
...
...
@@ -87,47 +85,39 @@ public class RecommendationsService extends IntentService {
// build the recommendation as a Notification object
Notification
notification
=
new
NotificationCompat
.
BigPictureStyle
(
new
NotificationCompat
.
Builder
(
s
Context
)
new
NotificationCompat
.
Builder
(
m
Context
)
.
setContentTitle
(
movie
.
getTitle
())
.
setContentText
(
movie
.
getDescription
())
.
setContentInfo
(
"VLC"
)
// .setSortKey("0.8")
.
setContentInfo
(
getString
(
R
.
string
.
app_name
))
.
setPriority
(
priority
)
.
setLocalOnly
(
true
)
.
setOngoing
(
true
)
.
setColor
(
s
Context
.
getResources
().
getColor
(
R
.
color
.
orange500
))
.
setColor
(
m
Context
.
getResources
().
getColor
(
R
.
color
.
orange500
))
.
setCategory
(
"recommendation"
)
.
setLargeIcon
(
s
MediaDatabase
.
getPicture
(
s
Context
,
movie
.
getLocation
()))
.
setLargeIcon
(
m
MediaDatabase
.
getPicture
(
m
Context
,
movie
.
getLocation
()))
.
setSmallIcon
(
R
.
drawable
.
icon
)
.
setContentIntent
(
buildPendingIntent
(
movie
))
.
setContentIntent
(
buildPendingIntent
(
movie
,
id
))
).
build
();
// post the recommendation to the NotificationManager
s
NotificationManager
.
notify
(
id
,
notification
);
s
NotificationManager
=
null
;
m
NotificationManager
.
notify
(
id
,
notification
);
m
NotificationManager
=
null
;
}
private
static
PendingIntent
buildPendingIntent
(
MediaWrapper
M
ediaWrapper
)
{
Intent
intent
=
new
Intent
(
s
Context
,
VideoPlayerActivity
.
class
);
private
PendingIntent
buildPendingIntent
(
MediaWrapper
m
ediaWrapper
,
int
id
)
{
Intent
intent
=
new
Intent
(
m
Context
,
VideoPlayerActivity
.
class
);
intent
.
setAction
(
VideoPlayerActivity
.
PLAY_FROM_VIDEOGRID
);
intent
.
putExtra
(
"itemLocation"
,
MediaWrapper
.
getLocation
());
intent
.
putExtra
(
"itemTitle"
,
MediaWrapper
.
getTitle
());
intent
.
putExtra
(
"dontParse"
,
false
);
intent
.
putExtra
(
"fromStart"
,
false
);
intent
.
putExtra
(
"itemPosition"
,
-
1
);
TaskStackBuilder
stackBuilder
=
TaskStackBuilder
.
create
(
sContext
);
stackBuilder
.
addParentStack
(
VideoPlayerActivity
.
class
);
stackBuilder
.
addNextIntent
(
intent
);
PendingIntent
pi
=
stackBuilder
.
getPendingIntent
(
0
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
intent
.
putExtra
(
VideoPlayerActivity
.
PLAY_EXTRA_ITEM_LOCATION
,
mediaWrapper
.
getLocation
());
intent
.
putExtra
(
VideoPlayerActivity
.
PLAY_EXTRA_ITEM_TITLE
,
mediaWrapper
.
getTitle
());
intent
.
putExtra
(
VideoPlayerActivity
.
PLAY_EXTRA_FROM_START
,
false
);
PendingIntent
pi
=
PendingIntent
.
getActivity
(
this
,
id
,
intent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
return
pi
;
}
RecommendationsHandler
mHandler
=
new
RecommendationsHandler
(
this
);
private
static
class
RecommendationsHandler
extends
WeakHandler
<
RecommendationsService
>
{
private
class
RecommendationsHandler
extends
WeakHandler
<
RecommendationsService
>
{
public
RecommendationsHandler
(
RecommendationsService
owner
)
{
super
(
owner
);
}
...
...
@@ -138,8 +128,8 @@ public class RecommendationsService extends IntentService {
}
}
private
static
boolean
doRecommendations
()
{
String
last
=
Uri
.
decode
(
PreferenceManager
.
getDefaultSharedPreferences
(
s
Context
).
getString
(
PreferencesActivity
.
VIDEO_LAST
,
null
));
private
boolean
doRecommendations
()
{
String
last
=
Uri
.
decode
(
PreferenceManager
.
getDefaultSharedPreferences
(
m
Context
).
getString
(
PreferencesActivity
.
VIDEO_LAST
,
null
));
int
id
=
0
;
if
(
last
!=
null
)
{
buildRecommendation
(
MediaLibrary
.
getInstance
().
getMediaItem
(
last
),
id
,
Notification
.
PRIORITY_HIGH
);
...
...
@@ -152,11 +142,11 @@ public class RecommendationsService extends IntentService {
for
(
MediaWrapper
mediaWrapper
:
videoList
){
if
(
TextUtils
.
equals
(
mediaWrapper
.
getLocation
(),
last
))
continue
;
pic
=
s
MediaDatabase
.
getPicture
(
s
Context
,
mediaWrapper
.
getLocation
());
pic
=
m
MediaDatabase
.
getPicture
(
m
Context
,
mediaWrapper
.
getLocation
());
if
(
pic
!=
null
&&
pic
.
getByteCount
()
>
4
&&
mediaWrapper
.
getTime
()
==
0
)
{
buildRecommendation
(
mediaWrapper
,
++
id
,
Notification
.
PRIORITY_DEFAULT
);
}
if
(
id
==
3
)
if
(
id
==
NUM_RECOMMANDATIONS
)
return
true
;
}
return
false
;
...
...
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