Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
528
Issue boards
Milestones
Wiki
Code
Merge requests
14
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
f4a56cd0
Commit
f4a56cd0
authored
7 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
TV: Use databinding in audio player
parent
0b3b05b5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vlc-android/res/layout/tv_audio_player.xml
+191
-180
191 additions, 180 deletions
vlc-android/res/layout/tv_audio_player.xml
vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
+64
-70
64 additions, 70 deletions
.../videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
with
255 additions
and
250 deletions
vlc-android/res/layout/tv_audio_player.xml
+
191
−
180
View file @
f4a56cd0
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ImageView
android:id=
"@+id/background"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:scaleType=
"centerCrop"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
/>
<ImageView
android:id=
"@+id/album_cover"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_margin=
"@dimen/half_default_margin"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toLeftOf=
"@+id/playlist"
app:layout_constraintBottom_toTopOf=
"@+id/media_title"
app:layout_constraintVertical_chainStyle=
"spread"
app:layout_constraintHorizontal_chainStyle=
"spread"
android:scaleType=
"centerCrop"
android:src=
"@drawable/icon"
/>
<layout>
<data>
<variable
name=
"progress"
type=
"org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity.Progress"
/>
</data>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ImageView
android:id=
"@+id/background"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:scaleType=
"centerCrop"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
/>
<ImageView
android:id=
"@+id/album_cover"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_margin=
"@dimen/half_default_margin"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toLeftOf=
"@+id/playlist"
app:layout_constraintBottom_toTopOf=
"@+id/media_title"
app:layout_constraintVertical_chainStyle=
"spread"
app:layout_constraintHorizontal_chainStyle=
"spread"
android:scaleType=
"centerCrop"
android:src=
"@drawable/icon"
/>
<TextView
android:id=
"@+id/media_title"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/album_cover"
app:layout_constraintRight_toLeftOf=
"@+id/playlist"
app:layout_constraintBottom_toTopOf=
"@+id/media_artist"
tools:text=
"Title"
android:gravity=
"center_horizontal"
android:textAppearance=
"@style/TextAppearance.AppCompat.SearchResult.Title"
/>
<TextView
android:id=
"@+id/media_title"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/album_cover"
app:layout_constraintRight_toLeftOf=
"@+id/playlist"
app:layout_constraintBottom_toTopOf=
"@+id/media_artist"
tools:text=
"Title"
android:gravity=
"center_horizontal"
android:textAppearance=
"@style/TextAppearance.AppCompat.SearchResult.Title"
/>
<TextView
android:id=
"@+id/media_artist"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/media_title"
app:layout_constraintRight_toLeftOf=
"@+id/playlist"
app:layout_constraintBottom_toTopOf=
"@+id/media_progress"
tools:text=
"Artist"
android:gravity=
"center_horizontal"
android:textAppearance=
"@style/TextAppearance.AppCompat.SearchResult.Subtitle"
/>
<TextView
android:id=
"@+id/media_artist"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/media_title"
app:layout_constraintRight_toLeftOf=
"@+id/playlist"
app:layout_constraintBottom_toTopOf=
"@+id/media_progress"
tools:text=
"Artist"
android:gravity=
"center_horizontal"
android:textAppearance=
"@style/TextAppearance.AppCompat.SearchResult.Subtitle"
/>
<TextView
android:id=
"@+id/media_time"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toLeftOf=
"@+id/album_cover"
app:layout_constraintTop_toTopOf=
"@+id/media_progress"
app:layout_constraintRight_toLeftOf=
"@+id/media_progress"
app:layout_constraintBottom_toBottomOf=
"@+id/media_progress"
tools:text=
"0:30"
/>
<TextView
android:id=
"@+id/media_time"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toLeftOf=
"@+id/album_cover"
app:layout_constraintTop_toTopOf=
"@+id/media_progress"
app:layout_constraintRight_toLeftOf=
"@+id/media_progress"
app:layout_constraintBottom_toBottomOf=
"@+id/media_progress"
android:text=
"@{progress.strTime}"
tools:text=
"0:30"
/>
<ProgressBar
android:id=
"@+id/media_progress"
style=
"?android:attr/progressBarStyleHorizontal"
android:layout_width=
"0dp"
android:layout_height=
"2dp"
android:layout_margin=
"@dimen/half_default_margin"
app:layout_constraintLeft_toRightOf=
"@+id/media_time"
app:layout_constraintTop_toBottomOf=
"@+id/media_artist"
app:layout_constraintRight_toLeftOf=
"@+id/media_length"
app:layout_constraintBottom_toTopOf=
"@+id/button_play"
android:focusable=
"true"
android:indeterminate=
"false"
android:nextFocusDown=
"@+id/button_play"
android:nextFocusUp=
"@+id/playlist"
android:background=
"@drawable/background_item"
android:progressDrawable=
"@drawable/tv_audioprogressbar"
/>
<ProgressBar
android:id=
"@+id/media_progress"
style=
"?android:attr/progressBarStyleHorizontal"
android:layout_width=
"0dp"
android:layout_height=
"2dp"
android:layout_margin=
"@dimen/half_default_margin"
app:layout_constraintLeft_toRightOf=
"@+id/media_time"
app:layout_constraintTop_toBottomOf=
"@+id/media_artist"
app:layout_constraintRight_toLeftOf=
"@+id/media_length"
app:layout_constraintBottom_toTopOf=
"@+id/button_play"
android:progress=
"@{progress.time}"
android:max=
"@{progress.length}"
android:focusable=
"true"
android:indeterminate=
"false"
android:nextFocusDown=
"@+id/button_play"
android:nextFocusUp=
"@+id/playlist"
android:background=
"@drawable/background_item"
android:progressDrawable=
"@drawable/tv_audioprogressbar"
/>
<TextView
android:id=
"@+id/media_length"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toRightOf=
"@+id/media_progress"
app:layout_constraintTop_toTopOf=
"@+id/media_progress"
app:layout_constraintRight_toRightOf=
"@+id/album_cover"
app:layout_constraintBottom_toBottomOf=
"@+id/media_progress"
tools:text=
"3:52"
/>
<TextView
android:id=
"@+id/media_length"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toRightOf=
"@+id/media_progress"
app:layout_constraintTop_toTopOf=
"@+id/media_progress"
app:layout_constraintRight_toRightOf=
"@+id/album_cover"
app:layout_constraintBottom_toBottomOf=
"@+id/media_progress"
android:text=
"@{progress.strLength}"
tools:text=
"3:52"
/>
<ImageView
android:id=
"@+id/button_repeat"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toLeftOf=
"@+id/album_cover"
app:layout_constraintTop_toBottomOf=
"@+id/media_progress"
app:layout_constraintRight_toLeftOf=
"@+id/button_previous"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintHorizontal_chainStyle=
"spread"
android:clickable=
"true"
android:focusable=
"true"
android:nextFocusDown=
"@+id/playlist"
android:nextFocusUp=
"@+id/media_progress"
android:onClick=
"onClick"
android:src=
"@drawable/ic_repeat_w"
tools:src=
"@drawable/ic_repeat"
/>
<ImageView
android:id=
"@+id/button_repeat"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toLeftOf=
"@+id/album_cover"
app:layout_constraintTop_toBottomOf=
"@+id/media_progress"
app:layout_constraintRight_toLeftOf=
"@+id/button_previous"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintHorizontal_chainStyle=
"spread"
android:clickable=
"true"
android:focusable=
"true"
android:nextFocusDown=
"@+id/playlist"
android:nextFocusUp=
"@+id/media_progress"
android:onClick=
"onClick"
android:src=
"@drawable/ic_repeat_w"
tools:src=
"@drawable/ic_repeat"
/>
<ImageView
android:id=
"@+id/button_previous"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toRightOf=
"@+id/button_repeat"
app:layout_constraintTop_toBottomOf=
"@+id/media_progress"
app:layout_constraintRight_toLeftOf=
"@+id/button_play"
app:layout_constraintBottom_toBottomOf=
"parent"
android:clickable=
"true"
android:focusable=
"true"
android:nextFocusDown=
"@+id/playlist"
android:nextFocusUp=
"@+id/media_progress"
android:onClick=
"onClick"
android:src=
"@drawable/ic_previous_w"
tools:src=
"@drawable/ic_previous"
/>
<ImageView
android:id=
"@+id/button_previous"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toRightOf=
"@+id/button_repeat"
app:layout_constraintTop_toBottomOf=
"@+id/media_progress"
app:layout_constraintRight_toLeftOf=
"@+id/button_play"
app:layout_constraintBottom_toBottomOf=
"parent"
android:clickable=
"true"
android:focusable=
"true"
android:nextFocusDown=
"@+id/playlist"
android:nextFocusUp=
"@+id/media_progress"
android:onClick=
"onClick"
android:src=
"@drawable/ic_previous_w"
tools:src=
"@drawable/ic_previous"
/>
<ImageView
android:id=
"@+id/button_play"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toRightOf=
"@+id/button_previous"
app:layout_constraintTop_toBottomOf=
"@+id/media_progress"
app:layout_constraintRight_toLeftOf=
"@+id/button_next"
app:layout_constraintBottom_toBottomOf=
"parent"
android:clickable=
"true"
android:focusable=
"true"
android:nextFocusDown=
"@+id/playlist"
android:nextFocusUp=
"@+id/media_progress"
android:onClick=
"onClick"
android:src=
"@drawable/ic_play_w"
tools:src=
"@drawable/ic_play"
>
<requestFocus/>
</ImageView>
<ImageView
android:id=
"@+id/button_play"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toRightOf=
"@+id/button_previous"
app:layout_constraintTop_toBottomOf=
"@+id/media_progress"
app:layout_constraintRight_toLeftOf=
"@+id/button_next"
app:layout_constraintBottom_toBottomOf=
"parent"
android:clickable=
"true"
android:focusable=
"true"
android:nextFocusDown=
"@+id/playlist"
android:nextFocusUp=
"@+id/media_progress"
android:onClick=
"onClick"
android:src=
"@drawable/ic_play_w"
tools:src=
"@drawable/ic_play"
>
<requestFocus/>
</ImageView>
<ImageView
android:id=
"@+id/button_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toRightOf=
"@+id/button_play"
app:layout_constraintTop_toBottomOf=
"@+id/media_progress"
app:layout_constraintRight_toLeftOf=
"@+id/button_shuffle"
app:layout_constraintBottom_toBottomOf=
"parent"
android:clickable=
"true"
android:focusable=
"true"
android:nextFocusDown=
"@+id/playlist"
android:nextFocusUp=
"@+id/media_progress"
android:onClick=
"onClick"
android:src=
"@drawable/ic_next_w"
tools:src=
"@drawable/ic_next"
/>
<ImageView
android:id=
"@+id/button_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toRightOf=
"@+id/button_play"
app:layout_constraintTop_toBottomOf=
"@+id/media_progress"
app:layout_constraintRight_toLeftOf=
"@+id/button_shuffle"
app:layout_constraintBottom_toBottomOf=
"parent"
android:clickable=
"true"
android:focusable=
"true"
android:nextFocusDown=
"@+id/playlist"
android:nextFocusUp=
"@+id/media_progress"
android:onClick=
"onClick"
android:src=
"@drawable/ic_next_w"
tools:src=
"@drawable/ic_next"
/>
<ImageView
android:id=
"@+id/button_shuffle"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toRightOf=
"@+id/button_next"
app:layout_constraintTop_toBottomOf=
"@+id/media_progress"
app:layout_constraintRight_toRightOf=
"@+id/album_cover"
app:layout_constraintBottom_toBottomOf=
"parent"
android:clickable=
"true"
android:focusable=
"true"
android:nextFocusDown=
"@+id/playlist"
android:nextFocusRight=
"@id/playlist"
android:nextFocusUp=
"@+id/media_progress"
android:onClick=
"onClick"
android:src=
"@drawable/ic_shuffle_w"
tools:src=
"@drawable/ic_shuffle"
/>
<ImageView
android:id=
"@+id/button_shuffle"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toRightOf=
"@+id/button_next"
app:layout_constraintTop_toBottomOf=
"@+id/media_progress"
app:layout_constraintRight_toRightOf=
"@+id/album_cover"
app:layout_constraintBottom_toBottomOf=
"parent"
android:clickable=
"true"
android:focusable=
"true"
android:nextFocusDown=
"@+id/playlist"
android:nextFocusRight=
"@id/playlist"
android:nextFocusUp=
"@+id/media_progress"
android:onClick=
"onClick"
android:src=
"@drawable/ic_shuffle_w"
tools:src=
"@drawable/ic_shuffle"
/>
<!-- Playlist -->
<android.support.v7.widget.RecyclerView
android:id=
"@+id/playlist"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintRight_toRightOf=
"@+id/background"
app:layout_constraintLeft_toRightOf=
"@+id/album_cover"
android:focusable=
"true"
android:nextFocusUp=
"@+id/playlist"
android:nextFocusLeft=
"@+id/button_shuffle"
android:nextFocusRight=
"@+id/button_play"
android:nextFocusDown=
"@+id/playlist"
android:scrollbars=
"vertical"
android:layout_margin=
"@dimen/half_default_margin"
/>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<!-- Playlist -->
<android.support.v7.widget.RecyclerView
android:id=
"@+id/playlist"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintRight_toRightOf=
"@+id/background"
app:layout_constraintLeft_toRightOf=
"@+id/album_cover"
android:focusable=
"true"
android:nextFocusUp=
"@+id/playlist"
android:nextFocusLeft=
"@+id/button_shuffle"
android:nextFocusRight=
"@+id/button_play"
android:nextFocusDown=
"@+id/playlist"
android:scrollbars=
"vertical"
android:layout_margin=
"@dimen/half_default_margin"
/>
</android.support.constraint.ConstraintLayout>
</layout>
This diff is collapsed.
Click to expand it.
vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
+
64
−
70
View file @
f4a56cd0
...
...
@@ -22,6 +22,9 @@ package org.videolan.vlc.gui.tv.audioplayer;
import
android.annotation.TargetApi
;
import
android.content.SharedPreferences
;
import
android.databinding.DataBindingUtil
;
import
android.databinding.ObservableField
;
import
android.databinding.ObservableInt
;
import
android.graphics.Bitmap
;
import
android.net.Uri
;
import
android.os.Build
;
...
...
@@ -29,15 +32,11 @@ import android.os.Bundle;
import
android.preference.PreferenceManager
;
import
android.support.v7.widget.DividerItemDecoration
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.RecyclerView
;
import
android.text.TextUtils
;
import
android.view.InputDevice
;
import
android.view.KeyEvent
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.ProgressBar
;
import
android.widget.TextView
;
import
org.videolan.libvlc.Media
;
import
org.videolan.libvlc.MediaPlayer
;
...
...
@@ -46,6 +45,7 @@ import org.videolan.medialibrary.media.MediaWrapper;
import
org.videolan.vlc.PlaybackService
;
import
org.videolan.vlc.R
;
import
org.videolan.vlc.VLCApplication
;
import
org.videolan.vlc.databinding.TvAudioPlayerBinding
;
import
org.videolan.vlc.gui.helpers.AudioUtil
;
import
org.videolan.vlc.gui.helpers.MediaComparators
;
import
org.videolan.vlc.gui.helpers.UiTools
;
...
...
@@ -64,10 +64,11 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
public
static
final
String
MEDIA_LIST
=
"media_list"
;
public
static
final
String
MEDIA_POSITION
=
"media_position"
;
private
RecyclerView
mRecyclerView
;
private
TvAudioPlayerBinding
mBinding
;
private
PlaylistAdapter
mAdapter
;
private
LinearLayoutManager
mLayoutManager
;
private
ArrayList
<
MediaWrapper
>
mMediaList
;
final
private
Progress
mProgress
=
new
Progress
();
//PAD navigation
private
static
final
int
JOYSTICK_INPUT_DELAY
=
300
;
...
...
@@ -76,44 +77,26 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
private
boolean
mShuffling
=
false
;
private
String
mCurrentCoverArt
;
private
TextView
mTitleTv
,
mArtistTv
,
mTime
,
mLength
;
private
ImageView
mPlayPauseButton
,
mCover
,
mNext
,
mShuffle
,
mRepeat
,
mBackground
;
private
ProgressBar
mProgressBar
;
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
tv_audio_player
);
mBinding
=
DataBindingUtil
.
setContentView
(
this
,
R
.
layout
.
tv_audio_player
);
mBinding
.
setProgress
(
mProgress
);
mMediaList
=
getIntent
().
getParcelableArrayListExtra
(
MEDIA_LIST
);
mCurrentlyPlaying
=
getIntent
().
getIntExtra
(
MEDIA_POSITION
,
0
);
mRecyclerView
=
(
RecyclerView
)
findViewById
(
R
.
id
.
playlist
);
mLayoutManager
=
new
LinearLayoutManager
(
this
);
m
RecyclerView
.
setLayoutManager
(
mLayoutManager
);
m
RecyclerView
.
addItemDecoration
(
new
DividerItemDecoration
(
this
,
DividerItemDecoration
.
VERTICAL
));
m
RecyclerView
.
setOnFocusChangeListener
(
this
);
m
Binding
.
playlist
.
setLayoutManager
(
mLayoutManager
);
m
Binding
.
playlist
.
addItemDecoration
(
new
DividerItemDecoration
(
this
,
DividerItemDecoration
.
VERTICAL
));
m
Binding
.
playlist
.
setOnFocusChangeListener
(
this
);
if
(
mMediaList
==
null
)
mMediaList
=
new
ArrayList
<>();
// if (getIntent().getData() != null)
// mMediaList.add(getIntent().getDataString());
mAdapter
=
new
PlaylistAdapter
(
this
,
mMediaList
);
mRecyclerView
.
setAdapter
(
mAdapter
);
mTitleTv
=
(
TextView
)
findViewById
(
R
.
id
.
media_title
);
mTime
=
(
TextView
)
findViewById
(
R
.
id
.
media_time
);
mLength
=
(
TextView
)
findViewById
(
R
.
id
.
media_length
);
mArtistTv
=
(
TextView
)
findViewById
(
R
.
id
.
media_artist
);
mNext
=
(
ImageView
)
findViewById
(
R
.
id
.
button_next
);
mPlayPauseButton
=
(
ImageView
)
findViewById
(
R
.
id
.
button_play
);
mShuffle
=
(
ImageView
)
findViewById
(
R
.
id
.
button_shuffle
);
mRepeat
=
(
ImageView
)
findViewById
(
R
.
id
.
button_repeat
);
mProgressBar
=
(
ProgressBar
)
findViewById
(
R
.
id
.
media_progress
);
mCover
=
(
ImageView
)
findViewById
(
R
.
id
.
album_cover
);
mBackground
=
(
ImageView
)
findViewById
(
R
.
id
.
background
);
mBinding
.
playlist
.
setAdapter
(
mAdapter
);
}
protected
void
onResume
()
{
super
.
onResume
();
m
RecyclerView
.
post
(
new
Runnable
()
{
m
Binding
.
playlist
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
update
();
...
...
@@ -134,7 +117,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
super
.
onConnected
(
service
);
mService
.
addCallback
(
this
);
ArrayList
<
MediaWrapper
>
medias
=
(
ArrayList
<
MediaWrapper
>)
mService
.
getMedias
();
ArrayList
<
MediaWrapper
>
medias
=
mService
.
getMedias
();
if
(!
mMediaList
.
isEmpty
()
&&
!
mMediaList
.
equals
(
medias
))
{
mService
.
load
(
mMediaList
,
mCurrentlyPlaying
);
}
else
{
...
...
@@ -143,7 +126,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
mService
.
playIndex
(
mCurrentlyPlaying
);
update
();
mAdapter
=
new
PlaylistAdapter
(
this
,
mMediaList
);
m
RecyclerView
.
setAdapter
(
mAdapter
);
m
Binding
.
playlist
.
setAdapter
(
mAdapter
);
}
}
...
...
@@ -162,7 +145,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
public
void
update
()
{
if
(
mService
==
null
)
return
;
m
PlayPauseB
utton
.
setImageResource
(
mService
.
isPlaying
()
?
R
.
drawable
.
ic_pause_w
:
R
.
drawable
.
ic_play_w
);
m
Binding
.
b
utton
Play
.
setImageResource
(
mService
.
isPlaying
()
?
R
.
drawable
.
ic_pause_w
:
R
.
drawable
.
ic_play_w
);
if
(
mService
.
hasMedia
())
{
SharedPreferences
mSettings
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
if
(
mSettings
.
getBoolean
(
PreferencesActivity
.
VIDEO_RESTORE
,
false
))
{
...
...
@@ -172,11 +155,9 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
finish
();
return
;
}
mTitleTv
.
setText
(
mService
.
getTitle
());
mArtistTv
.
setText
(
mService
.
getArtist
());
mTime
.
setText
(
Tools
.
millisToString
(
mService
.
getTime
()));
mLength
.
setText
(
Tools
.
millisToString
(
mService
.
getLength
()));
mProgressBar
.
setMax
((
int
)
mService
.
getLength
());
mBinding
.
mediaTitle
.
setText
(
mService
.
getTitle
());
mBinding
.
mediaArtist
.
setText
(
mService
.
getArtist
());
mProgress
.
update
(
mService
.
getTime
(),
mService
.
getLength
());
mCurrentlyPlaying
=
mService
.
getCurrentMediaPosition
();
selectItem
(
mCurrentlyPlaying
);
final
MediaWrapper
mw
=
mService
.
getCurrentMediaWrapper
();
...
...
@@ -186,19 +167,19 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
VLCApplication
.
runBackground
(
new
Runnable
()
{
@Override
public
void
run
()
{
final
Bitmap
cover
=
AudioUtil
.
readCoverBitmap
(
Uri
.
decode
(
mCurrentCoverArt
),
mCover
.
getWidth
());
final
Bitmap
cover
=
AudioUtil
.
readCoverBitmap
(
Uri
.
decode
(
mCurrentCoverArt
),
mBinding
.
albu
mCover
.
getWidth
());
final
Bitmap
blurredCover
=
cover
!=
null
?
UiTools
.
blurBitmap
(
cover
)
:
null
;
VLCApplication
.
runOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
cover
==
null
)
{
mCover
.
setImageResource
(
R
.
drawable
.
ic_tv_icon_big
);
mBackground
.
clearColorFilter
();
mBackground
.
setImageResource
(
0
);
mBinding
.
albu
mCover
.
setImageResource
(
R
.
drawable
.
ic_tv_icon_big
);
mB
inding
.
b
ackground
.
clearColorFilter
();
mB
inding
.
b
ackground
.
setImageResource
(
0
);
}
else
{
mCover
.
setImageBitmap
(
cover
);
mBackground
.
setColorFilter
(
UiTools
.
getColorFromAttribute
(
mBackground
.
getContext
(),
R
.
attr
.
audio_player_background_tint
));
mBackground
.
setImageBitmap
(
blurredCover
);
mBinding
.
albu
mCover
.
setImageBitmap
(
cover
);
mB
inding
.
b
ackground
.
setColorFilter
(
UiTools
.
getColorFromAttribute
(
mB
inding
.
b
ackground
.
getContext
(),
R
.
attr
.
audio_player_background_tint
));
mB
inding
.
b
ackground
.
setImageBitmap
(
blurredCover
);
}
}
});
...
...
@@ -210,18 +191,14 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
@Override
public
void
updateProgress
()
{
if
(
mService
!=
null
)
mProgress
Bar
.
setProgress
((
int
)
mService
.
getTime
());
mProgress
.
updateTime
(
mService
.
getTime
());
}
@Override
public
void
onMediaEvent
(
Media
.
Event
event
)
{
}
public
void
onMediaEvent
(
Media
.
Event
event
)
{}
@Override
public
void
onMediaPlayerEvent
(
MediaPlayer
.
Event
event
)
{
}
public
void
onMediaPlayerEvent
(
MediaPlayer
.
Event
event
)
{}
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
){
switch
(
keyCode
){
...
...
@@ -242,13 +219,13 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
goNext
();
return
true
;
case
KeyEvent
.
KEYCODE_DPAD_RIGHT
:
if
(
mProgress
Bar
.
hasFocus
())
{
if
(
m
Binding
.
media
Progress
.
hasFocus
())
{
seek
(
10000
);
return
true
;
}
else
return
false
;
case
KeyEvent
.
KEYCODE_DPAD_LEFT
:
if
(
mProgress
Bar
.
hasFocus
())
{
if
(
m
Binding
.
media
Progress
.
hasFocus
())
{
seek
(-
10000
);
return
true
;
}
else
...
...
@@ -267,19 +244,19 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
* Playlist navigation
*/
case
KeyEvent
.
KEYCODE_DPAD_UP
:
if
(
m
RecyclerView
.
hasFocus
())
{
if
(
m
Binding
.
playlist
.
hasFocus
())
{
selectPrevious
();
return
true
;
}
else
return
false
;
case
KeyEvent
.
KEYCODE_DPAD_DOWN
:
if
(
m
RecyclerView
.
hasFocus
())
{
if
(
m
Binding
.
playlist
.
hasFocus
())
{
selectNext
();
return
true
;
}
else
return
false
;
case
KeyEvent
.
KEYCODE_DPAD_CENTER
:
if
(
m
RecyclerView
.
hasFocus
())
{
if
(
m
Binding
.
playlist
.
hasFocus
())
{
playSelection
();
return
true
;
}
else
...
...
@@ -356,14 +333,13 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
if
(
mService
==
null
)
return
;
mShuffling
=
shuffle
;
mShuffle
.
setImageResource
(
shuffle
?
R
.
drawable
.
ic_shuffle_on
:
m
Binding
.
button
Shuffle
.
setImageResource
(
shuffle
?
R
.
drawable
.
ic_shuffle_on
:
R
.
drawable
.
ic_shuffle_w
);
ArrayList
<
MediaWrapper
>
medias
=
(
ArrayList
<
MediaWrapper
>)
mService
.
getMedias
();
if
(
shuffle
)
{
ArrayList
<
MediaWrapper
>
medias
=
mService
.
getMedias
();
if
(
shuffle
)
Collections
.
shuffle
(
medias
);
}
else
{
else
Collections
.
sort
(
medias
,
MediaComparators
.
byTrackNumber
);
}
mService
.
load
(
medias
,
0
);
mAdapter
.
updateList
(
medias
);
update
();
...
...
@@ -375,13 +351,13 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
int
type
=
mService
.
getRepeatType
();
if
(
type
==
PlaybackService
.
REPEAT_NONE
){
mService
.
setRepeatType
(
PlaybackService
.
REPEAT_ALL
);
mRepeat
.
setImageResource
(
R
.
drawable
.
ic_repeat_all
);
m
Binding
.
button
Repeat
.
setImageResource
(
R
.
drawable
.
ic_repeat_all
);
}
else
if
(
type
==
PlaybackService
.
REPEAT_ALL
)
{
mService
.
setRepeatType
(
PlaybackService
.
REPEAT_ONE
);
mRepeat
.
setImageResource
(
R
.
drawable
.
ic_repeat_one
);
m
Binding
.
button
Repeat
.
setImageResource
(
R
.
drawable
.
ic_repeat_one
);
}
else
if
(
type
==
PlaybackService
.
REPEAT_ONE
)
{
mService
.
setRepeatType
(
PlaybackService
.
REPEAT_NONE
);
mRepeat
.
setImageResource
(
R
.
drawable
.
ic_repeat_w
);
m
Binding
.
button
Repeat
.
setImageResource
(
R
.
drawable
.
ic_repeat_w
);
}
}
...
...
@@ -408,7 +384,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
private
void
selectNext
()
{
if
(
mAdapter
.
getmSelectedItem
()
>=
mAdapter
.
getItemCount
()-
1
)
{
mProgress
Bar
.
requestFocus
();
m
Binding
.
media
Progress
.
requestFocus
();
selectItem
(-
1
);
return
;
}
...
...
@@ -417,7 +393,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
private
void
selectPrevious
()
{
if
(
mAdapter
.
getmSelectedItem
()
<
1
){
m
PlayPauseB
utton
.
requestFocus
();
m
Binding
.
b
utton
Play
.
requestFocus
();
selectItem
(-
1
);
return
;
}
...
...
@@ -427,13 +403,13 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
private
void
selectItem
(
final
int
position
)
{
if
(
position
>=
mMediaList
.
size
())
return
;
m
RecyclerView
.
post
(
new
Runnable
()
{
m
Binding
.
playlist
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
position
!=
-
1
&&
(
position
>
mLayoutManager
.
findLastCompletelyVisibleItemPosition
()
||
position
<
mLayoutManager
.
findFirstCompletelyVisibleItemPosition
()))
{
m
RecyclerView
.
stopScroll
();
m
RecyclerView
.
smoothScrollToPosition
(
position
);
m
Binding
.
playlist
.
stopScroll
();
m
Binding
.
playlist
.
smoothScrollToPosition
(
position
);
}
mAdapter
.
setSelection
(
position
);
}
...
...
@@ -450,4 +426,22 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
selectItem
(-
1
);
}
}
public
class
Progress
{
public
ObservableInt
time
=
new
ObservableInt
(
0
);
public
ObservableInt
length
=
new
ObservableInt
(
0
);
public
ObservableField
<
String
>
strTime
=
new
ObservableField
<>(
""
);
public
ObservableField
<
String
>
strLength
=
new
ObservableField
<>(
""
);
void
updateTime
(
long
time
)
{
strTime
.
set
(
Tools
.
millisToString
(
time
));
this
.
time
.
set
((
int
)
time
);
}
void
update
(
long
time
,
long
length
)
{
updateTime
(
time
);
this
.
length
.
set
((
int
)
length
);
strLength
.
set
(
Tools
.
millisToString
(
length
));
}
}
}
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