Redesign ExternalPlayerFragment
This commit is contained in:
parent
0a7d054aad
commit
cbb310080e
|
@ -34,7 +34,9 @@ public class ViewPagerBottomSheetBehavior<V extends View> extends BottomSheetBeh
|
||||||
if (view instanceof ViewPager) {
|
if (view instanceof ViewPager) {
|
||||||
ViewPager viewPager = (ViewPager) view;
|
ViewPager viewPager = (ViewPager) view;
|
||||||
View currentViewPagerChild = viewPager.getChildAt(viewPager.getCurrentItem());
|
View currentViewPagerChild = viewPager.getChildAt(viewPager.getCurrentItem());
|
||||||
return findScrollingChild(currentViewPagerChild);
|
if (currentViewPagerChild != null) {
|
||||||
|
return findScrollingChild(currentViewPagerChild);
|
||||||
|
}
|
||||||
} else if (view instanceof ViewGroup) {
|
} else if (view instanceof ViewGroup) {
|
||||||
ViewGroup group = (ViewGroup) view;
|
ViewGroup group = (ViewGroup) view;
|
||||||
for (int i = 0, count = group.getChildCount(); i < count; i++) {
|
for (int i = 0, count = group.getChildCount(); i < count; i++) {
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||||
public class ExternalPlayerFragment extends Fragment {
|
public class ExternalPlayerFragment extends Fragment {
|
||||||
public static final String TAG = "ExternalPlayerFragment";
|
public static final String TAG = "ExternalPlayerFragment";
|
||||||
|
|
||||||
private ViewGroup fragmentLayout;
|
|
||||||
private ImageView imgvCover;
|
private ImageView imgvCover;
|
||||||
private TextView txtvTitle;
|
private TextView txtvTitle;
|
||||||
private ImageButton butPlay;
|
private ImageButton butPlay;
|
||||||
|
@ -56,16 +55,14 @@ public class ExternalPlayerFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View root = inflater.inflate(R.layout.external_player_fragment,
|
View root = inflater.inflate(R.layout.external_player_fragment, container, false);
|
||||||
container, false);
|
|
||||||
fragmentLayout = root.findViewById(R.id.fragmentLayout);
|
|
||||||
imgvCover = root.findViewById(R.id.imgvCover);
|
imgvCover = root.findViewById(R.id.imgvCover);
|
||||||
txtvTitle = root.findViewById(R.id.txtvTitle);
|
txtvTitle = root.findViewById(R.id.txtvTitle);
|
||||||
butPlay = root.findViewById(R.id.butPlay);
|
butPlay = root.findViewById(R.id.butPlay);
|
||||||
mFeedName = root.findViewById(R.id.txtvAuthor);
|
mFeedName = root.findViewById(R.id.txtvAuthor);
|
||||||
mProgressBar = root.findViewById(R.id.episodeProgress);
|
mProgressBar = root.findViewById(R.id.episodeProgress);
|
||||||
|
|
||||||
fragmentLayout.setOnClickListener(v -> {
|
root.findViewById(R.id.fragmentLayout).setOnClickListener(v -> {
|
||||||
Log.d(TAG, "layoutInfo was clicked");
|
Log.d(TAG, "layoutInfo was clicked");
|
||||||
|
|
||||||
if (controller != null && controller.getMedia() != null) {
|
if (controller != null && controller.getMedia() != null) {
|
||||||
|
@ -175,9 +172,7 @@ public class ExternalPlayerFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playbackDone() {
|
private void playbackDone() {
|
||||||
if (fragmentLayout != null) {
|
clearUi();
|
||||||
fragmentLayout.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
controller.release();
|
controller.release();
|
||||||
}
|
}
|
||||||
|
@ -214,10 +209,22 @@ public class ExternalPlayerFragment extends Fragment {
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(media -> updateUi((Playable) media),
|
.subscribe(media -> updateUi((Playable) media),
|
||||||
error -> Log.e(TAG, Log.getStackTraceString(error)),
|
error -> Log.e(TAG, Log.getStackTraceString(error)),
|
||||||
() -> fragmentLayout.setVisibility(View.GONE));
|
this::clearUi);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clearUi() {
|
||||||
|
if (txtvTitle == null || mFeedName == null || mProgressBar == null || butPlay == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
txtvTitle.setText(R.string.no_media_playing_label);
|
||||||
|
mFeedName.setText("");
|
||||||
|
butPlay.setVisibility(View.GONE);
|
||||||
|
mProgressBar.setProgress(0);
|
||||||
|
Glide.with(getActivity()).clear(imgvCover);
|
||||||
|
((MainActivity) getActivity()).getBottomSheet().setLocked(true);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateUi(Playable media) {
|
private void updateUi(Playable media) {
|
||||||
if (media != null) {
|
if (media != null) {
|
||||||
txtvTitle.setText(media.getEpisodeTitle());
|
txtvTitle.setText(media.getEpisodeTitle());
|
||||||
|
@ -233,8 +240,6 @@ public class ExternalPlayerFragment extends Fragment {
|
||||||
.fitCenter()
|
.fitCenter()
|
||||||
.dontAnimate())
|
.dontAnimate())
|
||||||
.into(imgvCover);
|
.into(imgvCover);
|
||||||
|
|
||||||
fragmentLayout.setVisibility(View.VISIBLE);
|
|
||||||
if (controller != null && controller.isPlayingVideoLocally()) {
|
if (controller != null && controller.isPlayingVideoLocally()) {
|
||||||
butPlay.setVisibility(View.GONE);
|
butPlay.setVisibility(View.GONE);
|
||||||
((MainActivity) getActivity()).getBottomSheet().setLocked(true);
|
((MainActivity) getActivity()).getBottomSheet().setLocked(true);
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<gradient
|
|
||||||
android:startColor="@android:color/transparent"
|
|
||||||
android:endColor="#40000000"
|
|
||||||
android:angle="90" />
|
|
||||||
</shape>
|
|
|
@ -1,87 +1,84 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
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:id="@+id/fragmentLayout"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/fragmentLayout"
|
||||||
android:layout_height="@dimen/external_player_height"
|
android:layout_width="match_parent"
|
||||||
android:visibility="gone"
|
|
||||||
android:background="?attr/selectableItemBackground">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imgvCover"
|
|
||||||
android:contentDescription="@string/cover_label"
|
|
||||||
android:layout_width="@dimen/external_player_height"
|
|
||||||
android:layout_height="@dimen/external_player_height"
|
android:layout_height="@dimen/external_player_height"
|
||||||
android:adjustViewBounds="true"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:cropToPadding="true"
|
android:orientation="vertical">
|
||||||
android:scaleType="centerCrop"
|
|
||||||
tools:src="@drawable/ic_drag_vertical_white_48dp"
|
<View
|
||||||
tools:background="@android:color/holo_green_dark"
|
android:layout_width="match_parent"
|
||||||
android:transitionName="coverTransition"
|
android:layout_height="1dp"
|
||||||
android:layout_alignParentTop="true"
|
android:background="?android:attr/dividerHorizontal" />
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true"/>
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imgvCover"
|
||||||
|
android:contentDescription="@string/cover_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:cropToPadding="true"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
tools:src="@tools:sample/avatars"/>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginStart="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtvTitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/Base.TextAppearance.AppCompat.Body1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
tools:text="Episode title that is too long and will cause the text to wrap"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtvAuthor"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/TextAppearance.AppCompat.Body1"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
tools:text="Episode author that is too long and will cause the text to wrap"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/butPlay"
|
||||||
|
android:layout_width="52dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:contentDescription="@string/pause_label"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
app:srcCompat="?attr/av_play"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:padding="8dp"
|
||||||
|
tools:src="@drawable/ic_play_arrow_white_36dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/episodeProgress"
|
android:id="@+id/episodeProgress"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="4dp"
|
android:layout_height="4dp"
|
||||||
android:layout_toRightOf="@id/imgvCover"
|
style="?attr/progressBarTheme"
|
||||||
android:layout_toEndOf="@id/imgvCover"
|
android:indeterminate="false"
|
||||||
android:layout_alignParentTop="true"
|
tools:progress="100"/>
|
||||||
style="?attr/progressBarTheme"
|
|
||||||
android:indeterminate="false"
|
|
||||||
tools:progress="100"/>
|
|
||||||
|
|
||||||
<ImageButton
|
</LinearLayout>
|
||||||
android:id="@+id/butPlay"
|
|
||||||
android:layout_width="52dp"
|
|
||||||
android:layout_height="52dp"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_below="@id/episodeProgress"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:contentDescription="@string/pause_label"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
app:srcCompat="?attr/av_play"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
android:padding="8dp"
|
|
||||||
tools:src="@drawable/ic_play_arrow_white_36dp"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/txtvTitle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_marginBottom="26dp"
|
|
||||||
android:layout_toRightOf="@id/imgvCover"
|
|
||||||
android:layout_toEndOf="@id/imgvCover"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_toLeftOf="@id/butPlay"
|
|
||||||
android:layout_toStartOf="@id/butPlay"
|
|
||||||
style="@style/Base.TextAppearance.AppCompat.Body1"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:maxLines="1"
|
|
||||||
tools:text="Episode title that is too long and will cause the text to wrap"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/txtvAuthor"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/episodeProgress"
|
|
||||||
android:layout_marginTop="26dp"
|
|
||||||
android:layout_toRightOf="@id/imgvCover"
|
|
||||||
android:layout_toEndOf="@id/imgvCover"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_toLeftOf="@id/butPlay"
|
|
||||||
android:layout_toStartOf="@id/butPlay"
|
|
||||||
style="@style/TextAppearance.AppCompat.Body1"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:maxLines="1"
|
|
||||||
tools:text="Episode author that is too long and will cause the text to wrap"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<dimen name="widget_margin">0dp</dimen>
|
<dimen name="widget_margin">0dp</dimen>
|
||||||
<dimen name="thumbnail_length">70dp</dimen>
|
<dimen name="thumbnail_length">70dp</dimen>
|
||||||
<dimen name="external_player_height">56dp</dimen>
|
<dimen name="external_player_height">64dp</dimen>
|
||||||
<dimen name="enc_icons_size">20dp</dimen>
|
<dimen name="enc_icons_size">20dp</dimen>
|
||||||
<dimen name="text_size_micro">12sp</dimen>
|
<dimen name="text_size_micro">12sp</dimen>
|
||||||
<dimen name="text_size_small">14sp</dimen>
|
<dimen name="text_size_small">14sp</dimen>
|
||||||
|
|
Loading…
Reference in New Issue