add separate drawables for youtube and video links, better cover drawable

This commit is contained in:
Andrew Dolgov 2015-07-10 13:48:14 +03:00
parent b30de39dd5
commit a5da507b58
13 changed files with 76 additions and 5 deletions

View File

@ -74,6 +74,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class HeadlinesFragment extends Fragment implements OnItemClickListener, OnScrollListener {
public static enum ArticlesSelection { ALL, NONE, UNREAD }
@ -1032,6 +1034,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
if (article.articleDoc != null && holder.flavorVideoPlayView != null) {
Element video = article.articleDoc.select("video").first();
Element ytframe = article.articleDoc.select("iframe[src*=youtube.com/embed/]").first();
if (video != null) {
try {
@ -1040,7 +1043,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
final String streamUri = source.attr("src");
String posterUri = video.attr("poster");
if (streamUri != null && posterUri != null) {
Log.d(TAG, posterUri);
if (streamUri.length() > 0 && posterUri.length() > 0) {
if (!posterUri.equals(holder.flavorImageView.getTag())) {
holder.flavorImageView.setTag(posterUri);
@ -1055,6 +1060,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
holder.flavorImageLoadingBar.setVisibility(View.GONE);
holder.flavorImageView.setVisibility(View.VISIBLE);
holder.flavorVideoPlayView.setVisibility(View.VISIBLE);
holder.flavorVideoPlayView.setImageResource(R.drawable.flavor_video_play);
ViewCompat.setTransitionName(holder.flavorImageView, "TRANSITION:ARTICLE_VIDEO_PLAYER");
@ -1082,6 +1088,39 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
e.printStackTrace();
videoFound = false;
}
} else if (ytframe != null) {
// thumb: http://img.youtube.com/vi/{VID}/mqdefault.jpg
String srcEmbed = ytframe.attr("src");
if (srcEmbed.length() > 0) {
Pattern pattern = Pattern.compile("/embed/([\\w-]+)");
Matcher matcher = pattern.matcher(srcEmbed);
if (matcher.find()) {
String vid = matcher.group(1);
String thumbUri = "http://img.youtube.com/vi/"+vid+"/mqdefault.jpg";
final String videoUri = "https://youtu.be/" + vid;
videoFound = true;
holder.flavorImageLoadingBar.setVisibility(View.GONE);
holder.flavorImageView.setVisibility(View.VISIBLE);
holder.flavorVideoPlayView.setVisibility(View.VISIBLE);
holder.flavorVideoPlayView.setImageResource(R.drawable.flavor_video_play_youtube);
ImageAware imageAware = new ImageViewAware(holder.flavorImageView, false);
m_imageLoader.displayImage(thumbUri, imageAware, displayImageOptions);
holder.flavorImageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(videoUri));
startActivity(intent);
}
});
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 807 B

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<solid android:color="#90000000" />
</shape>
</item>
<item>
<bitmap android:src="@drawable/ic_play_circle"
android:gravity="center" />
</item>
</layer-list>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<solid android:color="#90000000" />
</shape>
</item>
<item>
<bitmap android:src="@drawable/ic_youtube_play"
android:gravity="center" />
</item>
</layer-list>

View File

@ -93,10 +93,11 @@
<ImageView
android:id="@+id/flavor_video_play"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="@drawable/ic_youtube_play"
android:scaleType="fitXY"
android:src="@drawable/flavor_video_play"
android:visibility="gone" />
<org.fox.ttrss.util.ArrowRight

View File

@ -98,7 +98,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="@drawable/ic_youtube_play"
android:scaleType="fitXY"
android:src="@drawable/flavor_video_play"
android:visibility="gone" />
<org.fox.ttrss.util.ArrowRight