Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ dependencies {
compile "com.google.android.gms:play-services:${playServicesVersion}"
compile "com.google.android.gms:play-services-cast-framework:${playServicesVersion}"
compile "com.android.support:appcompat-v7:${supportLibVersion}"

compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile 'com.googlecode.android-query:android-query:0.25.9'

//compile 'com.googlecode.android-query:android-query:0.25.9'
compile 'com.github.bumptech.glide:glide:3.7.0'
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon May 09 13:33:54 PDT 2016
#Fri Dec 30 21:08:38 WET 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
33 changes: 14 additions & 19 deletions res/layout/browse_row.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2015 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,36 +13,37 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingTop="8dp"
xmlns:android="http://schemas.android.com/apk/res/android" >
android:paddingTop="8dp">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="wrap_content">

<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="180dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:scaleType="centerInside"
android:src="@drawable/default_video" />

<LinearLayout
android:id="@+id/text_container"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/menu"
android:layout_marginLeft="10dp"
android:layout_toLeftOf="@+id/menu"
android:layout_toRightOf="@+id/imageView1"
android:orientation="vertical" >
android:orientation="vertical">

<TextView
android:id="@+id/textView1"
Expand Down Expand Up @@ -73,17 +73,12 @@
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="1dp"
android:background="?attr/selectableItemBackground"
android:paddingRight="@dimen/browse_row_popup_menu_margin_right"
android:visibility="visible"
android:src="@drawable/ic_more_vert_grey600_24dp"
android:background="?attr/selectableItemBackground"/>
android:visibility="visible" />

</RelativeLayout>

<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground" />

</FrameLayout>

9 changes: 7 additions & 2 deletions src/com/google/sample/cast/refplayer/CastOptionsProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
import com.google.android.gms.cast.framework.OptionsProvider;
import com.google.android.gms.cast.framework.SessionProvider;
import com.google.android.gms.cast.framework.media.CastMediaOptions;
import com.google.android.gms.cast.framework.media.ImageHints;
import com.google.android.gms.cast.framework.media.ImagePicker;
import com.google.android.gms.cast.framework.media.MediaIntentReceiver;
import com.google.android.gms.cast.framework.media.NotificationOptions;
import com.google.android.gms.common.images.WebImage;
import com.google.sample.cast.refplayer.expandedcontrols.ExpandedControlsActivity;

import android.content.Context;
import android.support.annotation.NonNull;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -64,15 +66,18 @@ public List<SessionProvider> getAdditionalSessionProviders(Context appContext) {
private static class ImagePickerImpl extends ImagePicker {

@Override
public WebImage onPickImage(MediaMetadata mediaMetadata, int type) {
public WebImage onPickImage(MediaMetadata mediaMetadata, @NonNull ImageHints imageHints) {
if ((mediaMetadata == null) || !mediaMetadata.hasImages()) {
return null;
}

List<WebImage> images = mediaMetadata.getImages();

if (images.size() == 1) {
return images.get(0);
} else {
if (type == ImagePicker.IMAGE_TYPE_MEDIA_ROUTE_CONTROLLER_DIALOG_BACKGROUND) {
if (imageHints.getType()
== ImagePicker.IMAGE_TYPE_MEDIA_ROUTE_CONTROLLER_DIALOG_BACKGROUND) {
return images.get(0);
} else {
return images.get(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public VideoBrowserFragment() {

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
@Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.video_browser_fragment, container, false);
}

Expand All @@ -89,7 +89,7 @@ public void itemClicked(View view, MediaInfo item, int position) {
} else {
String transitionName = getString(R.string.transition_image);
VideoListAdapter.ViewHolder viewHolder =
(VideoListAdapter.ViewHolder) mRecyclerView.findViewHolderForPosition(position);
(VideoListAdapter.ViewHolder) mRecyclerView.findViewHolderForAdapterPosition(position);
Pair<View, String> imagePair = Pair
.create((View) viewHolder.getImageView(), transitionName);
ActivityOptionsCompat options = ActivityOptionsCompat
Expand Down Expand Up @@ -134,7 +134,6 @@ public void onStop() {
}



private class MySessionManagerListener implements SessionManagerListener<CastSession> {

@Override
Expand Down
14 changes: 4 additions & 10 deletions src/com/google/sample/cast/refplayer/browser/VideoListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@

package com.google.sample.cast.refplayer.browser;

import com.bumptech.glide.Glide;
import com.google.android.gms.cast.MediaInfo;
import com.google.android.gms.cast.MediaMetadata;
import com.google.android.gms.cast.framework.CastContext;
import com.google.android.gms.cast.framework.CastSession;
import com.google.sample.cast.refplayer.R;

import com.androidquery.AQuery;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -104,7 +103,6 @@ public static class ViewHolder extends RecyclerView.ViewHolder {
private final View mParent;
private final View mMenu;
private final View mTextContainer;
private AQuery mAquery;
private TextView mTitleView;
private TextView mDescriptionView;
private ImageView mImgView;
Expand All @@ -115,21 +113,18 @@ public static ViewHolder newInstance(View parent) {
TextView descriptionView = (TextView) parent.findViewById(R.id.textView2);
View menu = parent.findViewById(R.id.menu);
View textContainer = parent.findViewById(R.id.text_container);
AQuery aQuery = new AQuery(parent);
return new ViewHolder(parent, imgView, textContainer, titleView, descriptionView, menu,
aQuery);
return new ViewHolder(parent, imgView, textContainer, titleView, descriptionView, menu);
}

private ViewHolder(View parent, ImageView imgView, View textContainer, TextView titleView,
TextView descriptionView, View menu, AQuery aQuery) {
TextView descriptionView, View menu) {
super(parent);
mParent = parent;
mImgView = imgView;
mTextContainer = textContainer;
mMenu = menu;
mTitleView = titleView;
mDescriptionView = descriptionView;
mAquery = aQuery;
}

public void setTitle(String title) {
Expand All @@ -141,8 +136,7 @@ public void setDescription(String description) {
}

public void setImage(String imgUrl) {
mAquery.id(mImgView).width(114).image(imgUrl,
true, true, 0, R.drawable.default_video, null, 0, ASPECT_RATIO);
Glide.with(itemView.getContext()).load(imgUrl).into(mImgView);
}

public void setOnClickListener(View.OnClickListener listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.google.sample.cast.refplayer.mediaplayer;

import com.bumptech.glide.Glide;
import com.google.android.gms.cast.MediaInfo;
import com.google.android.gms.cast.MediaMetadata;
import com.google.android.gms.cast.framework.CastButtonFactory;
Expand All @@ -31,8 +32,6 @@
import com.google.sample.cast.refplayer.settings.CastPreference;
import com.google.sample.cast.refplayer.utils.Utils;

import com.androidquery.AQuery;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.res.Configuration;
Expand Down Expand Up @@ -95,7 +94,6 @@ public class LocalPlayerActivity extends AppCompatActivity {
private PlaybackState mPlaybackState;
private final Handler mHandler = new Handler();
private final float mAspectRatio = 72f / 128;
private AQuery mAquery;
private MediaInfo mSelectedMedia;
private boolean mControllersVisible;
private int mDuration;
Expand Down Expand Up @@ -125,7 +123,6 @@ public enum PlaybackState {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.player_activity);
mAquery = new AQuery(this);
loadViews();
setupControlsCallbacks();
setupCastListener();
Expand Down Expand Up @@ -366,14 +363,13 @@ public void onSendingRemoteMediaRequest() {
}



});
remoteMediaClient.load(mSelectedMedia, autoPlay, position);
}

private void setCoverArtStatus(String url) {
if (url != null) {
mAquery.id(mCoverArt).image(url);
Glide.with(this).load(url).into(mCoverArt);
mCoverArt.setVisibility(View.VISIBLE);
mVideoView.setVisibility(View.INVISIBLE);
} else {
Expand Down Expand Up @@ -603,7 +599,7 @@ public void onStartTrackingTouch(SeekBar seekBar) {

@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
boolean fromUser) {
mStartText.setText(Utils.formatMillis(progress));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

package com.google.sample.cast.refplayer.queue.ui;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.google.android.gms.cast.MediaInfo;
import com.google.android.gms.cast.MediaMetadata;
import com.google.android.gms.cast.MediaQueueItem;
Expand All @@ -26,8 +30,6 @@
import com.google.sample.cast.refplayer.R;
import com.google.sample.cast.refplayer.queue.QueueDataProvider;

import com.androidquery.AQuery;

import android.content.Context;
import android.support.annotation.IntDef;
import android.support.v4.view.MotionEventCompat;
Expand Down Expand Up @@ -139,11 +141,27 @@ public void onBindViewHolder(final QueueItemViewHolder holder, int position) {
MediaMetadata metaData = info.getMetadata();
holder.mTitleView.setText(metaData.getString(MediaMetadata.KEY_TITLE));
holder.mDescriptionView.setText(metaData.getString(MediaMetadata.KEY_SUBTITLE));
AQuery aq = new AQuery(holder.itemView);
if (!metaData.getImages().isEmpty()) {
aq.id(holder.mImageView).width(IMAGE_THUMBNAIL_WIDTH)
.image(metaData.getImages().get(0).getUrl().toString(), true, true, 0,
R.drawable.default_video, null, 0, ASPECT_RATIO);
Glide.with(holder.itemView.getContext())
.load(metaData.getImages().get(0).getUrl().toString())
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model,
Target<GlideDrawable> target,
boolean isFirstResource) {
holder.mImageView.setImageResource(R.drawable.default_video);
return false;
}

@Override
public boolean onResourceReady(GlideDrawable resource, String model,
Target<GlideDrawable> target,
boolean isFromMemoryCache,
boolean isFirstResource) {
return false;
}
})
.into(holder.mImageView);
}

holder.mDragHandle.setOnTouchListener(new View.OnTouchListener() {
Expand Down