Commit 6c78ce32 authored by Geoffrey Métais's avatar Geoffrey Métais Committed by Jean-Baptiste Kempf

Remove tabs

parent 3b63bfef
......@@ -25,9 +25,9 @@ import android.app.Activity;
import android.os.Bundle;
public class DetailsActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tv_details);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tv_details);
}
}
......@@ -23,21 +23,21 @@ import android.support.v17.leanback.widget.AbstractDetailsDescriptionPresenter;
import android.util.Log;
public class DetailsDescriptionPresenter extends
AbstractDetailsDescriptionPresenter {
public static final String TAG ="DetailsDescriptionPresenter";
AbstractDetailsDescriptionPresenter {
public static final String TAG ="DetailsDescriptionPresenter";
protected void onBindDescription(ViewHolder viewHolder, Object itemData) {
Log.d(TAG, "itemData "+itemData);
MediaItemDetails details = (MediaItemDetails) itemData;
// In a production app, the itemData object contains the information
// needed to display details for the media item:
// viewHolder.getTitle().setText(details.getShortTitle());
protected void onBindDescription(ViewHolder viewHolder, Object itemData) {
Log.d(TAG, "itemData "+itemData);
MediaItemDetails details = (MediaItemDetails) itemData;
// In a production app, the itemData object contains the information
// needed to display details for the media item:
// viewHolder.getTitle().setText(details.getShortTitle());
// Here we provide static data for testing purposes:
viewHolder.getTitle().setText(details.getTitle());
viewHolder.getSubtitle().setText(details.getSubTitle());
viewHolder.getBody().setText(details.getBody());
}
// Here we provide static data for testing purposes:
viewHolder.getTitle().setText(details.getTitle());
viewHolder.getSubtitle().setText(details.getSubTitle());
viewHolder.getBody().setText(details.getBody());
}
}
......@@ -120,7 +120,7 @@ public class GridFragment extends VerticalGridFragment implements VideoBrowserIn
super.onPause();
mMediaLibrary.removeUpdateHandler(mHandler);
/* unregister from thumbnailer */
/* unregister from thumbnailer */
if (sThumbnailer != null)
sThumbnailer.setVideoBrowser(null);
mBarrier.reset();
......
......@@ -103,9 +103,9 @@ public class MainTvActivity extends Activity implements VideoBrowserInterface {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
* skip browser and show directly Audio Player if a song is playing
*/
/*
* skip browser and show directly Audio Player if a song is playing
*/
if (LibVLC.getExistingInstance() != null){
if (LibVLC.getExistingInstance().isPlaying()){
startActivity(new Intent(this, AudioPlayerActivity.class));
......@@ -148,7 +148,7 @@ public class MainTvActivity extends Activity implements VideoBrowserInterface {
super.onPause();
mMediaLibrary.removeUpdateHandler(mHandler);
/* Stop the thumbnailer */
/* Stop the thumbnailer */
if (sThumbnailer != null)
sThumbnailer.setVideoBrowser(null);
mBarrier.reset();
......@@ -235,7 +235,6 @@ public class MainTvActivity extends Activity implements VideoBrowserInterface {
protected Void doInBackground(Void... params) {
MediaDatabase mediaDatabase = MediaDatabase.getInstance();
ArrayList<Media> videoList = mMediaLibrary.getVideoItems();
// ArrayList<Media> audioList = mMediaLibrary.getAudioItems();
int size;
Media item;
Bitmap picture;
......
......@@ -24,60 +24,60 @@ import android.os.Parcelable;
public class MediaItemDetails implements Parcelable {
private String title, subTitle, body, location;
private String title, subTitle, body, location;
public MediaItemDetails(String title, String subTitle, String body, String location) {
this.title = title;
this.subTitle = subTitle;
this.body = body;
this.location = location;
}
public MediaItemDetails(String title, String subTitle, String body, String location) {
this.title = title;
this.subTitle = subTitle;
this.body = body;
this.location = location;
}
public String getTitle() {
return title;
}
public String getTitle() {
return title;
}
public String getSubTitle() {
return subTitle;
}
public String getSubTitle() {
return subTitle;
}
public String getBody() {
return body;
}
public String getBody() {
return body;
}
public String getLocation(){
return location;
}
public String getLocation(){
return location;
}
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(title);
dest.writeString(subTitle);
dest.writeString(body);
dest.writeString(location);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(title);
dest.writeString(subTitle);
dest.writeString(body);
dest.writeString(location);
}
public static final Parcelable.Creator<MediaItemDetails> CREATOR
= new Parcelable.Creator<MediaItemDetails>() {
public MediaItemDetails createFromParcel(Parcel in) {
return new MediaItemDetails(in);
}
public static final Parcelable.Creator<MediaItemDetails> CREATOR
= new Parcelable.Creator<MediaItemDetails>() {
public MediaItemDetails createFromParcel(Parcel in) {
return new MediaItemDetails(in);
}
public MediaItemDetails[] newArray(int size) {
return new MediaItemDetails[size];
}
};
public MediaItemDetails[] newArray(int size) {
return new MediaItemDetails[size];
}
};
private MediaItemDetails(Parcel in) {
title = in.readString();
subTitle = in.readString();
body = in.readString();
location = in.readString();
}
private MediaItemDetails(Parcel in) {
title = in.readString();
subTitle = in.readString();
body = in.readString();
location = in.readString();
}
}
......@@ -47,85 +47,85 @@ import android.support.v17.leanback.widget.OnActionClickedListener;
import android.util.Log;
public class MediaItemDetailsFragment extends DetailsFragment implements AudioServiceController.AudioServiceConnectionListener {
private static final String TAG = "MediaItemDetailsFragment";
private static final int ID_PLAY = 1;
private static final int ID_LISTEN = 2;
private ArrayObjectAdapter mRowsAdapter;
private static final String TAG = "MediaItemDetailsFragment";
private static final int ID_PLAY = 1;
private static final int ID_LISTEN = 2;
private ArrayObjectAdapter mRowsAdapter;
private AudioServiceController mAudioController;
private AudioPlayer mAudioPlayer;
private MediaItemDetails mMedia;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAudioController = AudioServiceController.getInstance();
buildDetails();
}
public void onResume(){
super.onResume();
}
public void onPause(){
super.onPause();
if (mAudioController.isPlaying()){
mAudioController.stop();
mAudioController.unbindAudioService(getActivity());
}
}
private void buildDetails() {
Bundle extras = getActivity().getIntent().getExtras();
mMedia = extras.getParcelable("item");
ClassPresenterSelector selector = new ClassPresenterSelector();
// Attach your media item details presenter to the row presenter:
DetailsOverviewRowPresenter rowPresenter =
new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
rowPresenter.setBackgroundColor(getResources().getColor(R.color.darkorange));
rowPresenter.setOnActionClickedListener(new OnActionClickedListener() {
@Override
public void onActionClicked(Action action) {
if (action.getId() == ID_LISTEN){
mAudioController.bindAudioService(getActivity(), MediaItemDetailsFragment.this);
} else if (action.getId() == ID_PLAY){
ArrayList<String> locations = new ArrayList<String>();
locations.add(mMedia.getLocation());
Intent intent = new Intent(getActivity(), AudioPlayerActivity.class);
intent.putExtra("locations", locations);
startActivity(intent);
}
}
});
selector.addClassPresenter(DetailsOverviewRow.class, rowPresenter);
selector.addClassPresenter(ListRow.class,
new ListRowPresenter());
mRowsAdapter = new ArrayObjectAdapter(selector);
Resources res = getActivity().getResources();
DetailsOverviewRow detailsOverview = new DetailsOverviewRow(mMedia);
// Add images and action buttons to the details view
Bitmap cover = AudioUtil.getCover(getActivity(), MediaLibrary.getInstance().getMediaItem(mMedia.getLocation()), 480);
if (cover == null)
detailsOverview.setImageDrawable(res.getDrawable(R.drawable.cone));
else
detailsOverview.setImageBitmap(getActivity(), cover);
detailsOverview.addAction(new Action(ID_PLAY, "Play"));
detailsOverview.addAction(new Action(ID_LISTEN, "Listen"));
mRowsAdapter.add(detailsOverview);
setAdapter(mRowsAdapter);
}
@Override
public void onConnectionSuccess() {
buildDetails();
}
public void onResume(){
super.onResume();
}
public void onPause(){
super.onPause();
if (mAudioController.isPlaying()){
mAudioController.stop();
mAudioController.unbindAudioService(getActivity());
}
}
private void buildDetails() {
Bundle extras = getActivity().getIntent().getExtras();
mMedia = extras.getParcelable("item");
ClassPresenterSelector selector = new ClassPresenterSelector();
// Attach your media item details presenter to the row presenter:
DetailsOverviewRowPresenter rowPresenter =
new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
rowPresenter.setBackgroundColor(getResources().getColor(R.color.darkorange));
rowPresenter.setOnActionClickedListener(new OnActionClickedListener() {
@Override
public void onActionClicked(Action action) {
if (action.getId() == ID_LISTEN){
mAudioController.bindAudioService(getActivity(), MediaItemDetailsFragment.this);
} else if (action.getId() == ID_PLAY){
ArrayList<String> locations = new ArrayList<String>();
locations.add(mMedia.getLocation());
Intent intent = new Intent(getActivity(), AudioPlayerActivity.class);
intent.putExtra("locations", locations);
startActivity(intent);
}
}
});
selector.addClassPresenter(DetailsOverviewRow.class, rowPresenter);
selector.addClassPresenter(ListRow.class,
new ListRowPresenter());
mRowsAdapter = new ArrayObjectAdapter(selector);
Resources res = getActivity().getResources();
DetailsOverviewRow detailsOverview = new DetailsOverviewRow(mMedia);
// Add images and action buttons to the details view
Bitmap cover = AudioUtil.getCover(getActivity(), MediaLibrary.getInstance().getMediaItem(mMedia.getLocation()), 480);
if (cover == null)
detailsOverview.setImageDrawable(res.getDrawable(R.drawable.cone));
else
detailsOverview.setImageBitmap(getActivity(), cover);
detailsOverview.addAction(new Action(ID_PLAY, "Play"));
detailsOverview.addAction(new Action(ID_LISTEN, "Listen"));
mRowsAdapter.add(detailsOverview);
setAdapter(mRowsAdapter);
}
@Override
public void onConnectionSuccess() {
mAudioController.load(mMedia.getLocation(), true);
}
}
@Override
public void onConnectionFailed() {}
@Override
public void onConnectionFailed() {}
}
......@@ -25,7 +25,7 @@ import android.app.Activity;
import android.os.Bundle;
public class SearchActivity extends Activity {
@Override
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
......
......@@ -38,9 +38,9 @@ import android.support.v17.leanback.widget.Row;
import android.text.TextUtils;
public class SearchFragment extends android.support.v17.leanback.app.SearchFragment
implements android.support.v17.leanback.app.SearchFragment.SearchResultProvider {
implements android.support.v17.leanback.app.SearchFragment.SearchResultProvider {
private static final String TAG = "SearchFragment";
private static final String TAG = "SearchFragment";
private ArrayObjectAdapter mRowsAdapter;
private Handler mHandler = new Handler();
......
......@@ -27,7 +27,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
public class StringPresenter extends Presenter {
private static final String TAG = "StringPresenter";
private static final String TAG = "StringPresenter";
public ViewHolder onCreateViewHolder(ViewGroup parent) {
TextView textView = new TextView(parent.getContext());
......
......@@ -23,7 +23,7 @@ import android.os.Parcel;
import android.os.Parcelable;
public class TvMedia implements Parcelable {
private long id;
private long id;
private String mediaUrl;
private String title;
private String description;
......@@ -33,45 +33,45 @@ public class TvMedia implements Parcelable {
private String cardImageUrl;
public TvMedia(long id, String title, String description, String bgImageUrl, String cardImageUrl, String mediaUrl) {
this.id = id;
this.title = title;
this.description = description;
this.bgImageUrl = bgImageUrl;
this.cardImageUrl = cardImageUrl;
this.mediaUrl = mediaUrl;
this.id = id;
this.title = title;
this.description = description;
this.bgImageUrl = bgImageUrl;
this.cardImageUrl = cardImageUrl;
this.mediaUrl = mediaUrl;
}
public TvMedia(long id, String title, String description, int bgImageId, int cardImageId, String mediaUrl) {
this.id = id;
this.title = title;
this.description = description;
this.bgImageId = bgImageId;
this.cardImageId = cardImageId;
this.mediaUrl = mediaUrl;
this.id = id;
this.title = title;
this.description = description;
this.bgImageId = bgImageId;
this.cardImageId = cardImageId;
this.mediaUrl = mediaUrl;
}
public long getId(){
return id;
return id;
}
public String getDescription(){
return description;
return description;
}
public String getBgImageUrl(){
return bgImageUrl;
return bgImageUrl;
}
public String getCardImageUrl(){
return cardImageUrl;
return cardImageUrl;
}
public String getVideoUrl(){
return mediaUrl;
return mediaUrl;
}
public String getTitle(){
return title;
return title;
}
public int getBackgroundImageId() {
......@@ -89,7 +89,7 @@ public class TvMedia implements Parcelable {
// }
public int getCardImageId() {
return cardImageId;
return cardImageId;
}
// public URI getCardImageURI() {
......@@ -112,44 +112,44 @@ public class TvMedia implements Parcelable {
'}';
}
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(mediaUrl);
dest.writeString(title);
dest.writeString(description);
dest.writeInt(bgImageId);
dest.writeInt(cardImageId);
dest.writeString(bgImageUrl);
dest.writeString(cardImageUrl);
}
public static final Parcelable.Creator<TvMedia> CREATOR
= new Parcelable.Creator<TvMedia>() {
public TvMedia createFromParcel(Parcel in) {
return new TvMedia(in);
}
public TvMedia[] newArray(int size) {
return new TvMedia[size];
}
};
private TvMedia(Parcel in) {
id = in.readLong();
mediaUrl = in.readString();
title = in.readString();
description = in.readString();
bgImageId = in.readInt();
cardImageId = in.readInt();
bgImageUrl = in.readString();
cardImageUrl = in.readString();
}
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(mediaUrl);
dest.writeString(title);
dest.writeString(description);
dest.writeInt(bgImageId);
dest.writeInt(cardImageId);
dest.writeString(bgImageUrl);
dest.writeString(cardImageUrl);
}
public static final Parcelable.Creator<TvMedia> CREATOR
= new Parcelable.Creator<TvMedia>() {
public TvMedia createFromParcel(Parcel in) {
return new TvMedia(in);
}
public TvMedia[] newArray(int size) {
return new TvMedia[size];
}
};
private TvMedia(Parcel in) {
id = in.readLong();
mediaUrl = in.readString();
title = in.readString();
description = in.readString();
bgImageId = in.readInt();
cardImageId = in.readInt();
bgImageUrl = in.readString();
cardImageUrl = in.readString();
}
}
......@@ -30,19 +30,19 @@ import android.support.v17.leanback.widget.Row;
public class TvUtil {
public static void openMedia(Activity activity, Media media, Row row){
if (media.getType() == Media.TYPE_VIDEO){
VideoPlayerActivity.start(activity, media.getLocation(), false);
} else if (media.getType() == Media.TYPE_AUDIO){
Intent intent = new Intent(activity,
DetailsActivity.class);
// pass the item information
intent.putExtra("item", (Parcelable)new MediaItemDetails(media.getTitle(), media.getArtist(), media.getAlbum(), media.getLocation()));
activity.startActivity(intent);
} else if (media.getType() == Media.TYPE_GROUP){
Intent intent = new Intent(activity, VerticalGridActivity.class);
intent.putExtra("id", row.getId());
activity.startActivity(intent);
}
}
public static void openMedia(Activity activity, Media media, Row row){
if (media.getType() == Media.TYPE_VIDEO){
VideoPlayerActivity.start(activity, media.getLocation(), false);
} else if (media.getType() == Media.TYPE_AUDIO){
Intent intent = new Intent(activity,
DetailsActivity.class);
// pass the item information
intent.putExtra("item", (Parcelable)new MediaItemDetails(media.getTitle(), media.getArtist(), media.getAlbum(), media.getLocation()));
activity.startActivity(intent);
} else if (media.getType() == Media.TYPE_GROUP){
Intent intent = new Intent(activity, VerticalGridActivity.class);
intent.putExtra("id", row.getId());
activity.startActivity(intent);
}
}
}
......@@ -43,7 +43,7 @@ import android.widget.ProgressBar;
import android.widget.TextView;
public class AudioPlayerActivity extends Activity implements AudioServiceController.AudioServiceConnectionListener, IAudioPlayer{
public static final String TAG = "VLC/AudioPlayerActivity";
public static final String TAG = "VLC/AudioPlayerActivity";
private AudioServiceController mAudioController;
private RecyclerView mRecyclerView;
......@@ -61,221 +61,207 @@ public class AudioPlayerActivity extends Activity implements AudioServiceControl
private ImageView mPlayPauseButton, mCover;
private ProgressBar mProgressBar;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tv_audio_player);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tv_audio_player);
mLocations = getIntent().getStringArrayListExtra("locations");
mRecyclerView = (RecyclerView) findViewById(R.id.playlist);
mLayoutManager = new LinearLayoutManager(this);
mLocations = getIntent().getStringArrayListExtra("locations");
mRecyclerView = (RecyclerView) findViewById(R.id.playlist);
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
if (mLocations == null)
mLocations = new ArrayList<String>();
else {
mAdapter = new PlaylistAdapter(mLocations);
mRecyclerView.setAdapter(mAdapter);
}
mAudioController = AudioServiceController.getInstance();
mTitleTv = (TextView)findViewById(R.id.media_title);
mArtistTv = (TextView)findViewById(R.id.media_artist);
mPlayPauseButton = (ImageView)findViewById(R.id.button_play);
mProgressBar = (ProgressBar)findViewById(R.id.media_progress);
mCover = (ImageView)findViewById(R.id.album_cover);
}
public void onStart(){
super.onStart();
mAudioController.bindAudioService(this, this);
mAudioController.addAudioPlayer(this);
}
public void onStop(){
super.onStop();
mAudioController.removeAudioPlayer(this);
mAudioController.unbindAudioService(this);
mLocations.clear();
}
protected void onResume() {
super.onResume();
mRecyclerView.post(new Runnable() {
@Override
public void run() {
update();
}
});
};
@Override
public void onConnectionSuccess() {
ArrayList<String> medialocations = (ArrayList<String>) mAudioController.getMediaLocations();
if (!mLocations.isEmpty() && !mLocations.equals(medialocations)) {
if (mLocations == null)
mLocations = new ArrayList<String>();
else {
mAdapter = new PlaylistAdapter(mLocations);
mRecyclerView.setAdapter(mAdapter);
}