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) {
|
||||
ViewPager viewPager = (ViewPager) view;
|
||||
View currentViewPagerChild = viewPager.getChildAt(viewPager.getCurrentItem());
|
||||
if (currentViewPagerChild != null) {
|
||||
return findScrollingChild(currentViewPagerChild);
|
||||
}
|
||||
} else if (view instanceof ViewGroup) {
|
||||
ViewGroup group = (ViewGroup) view;
|
||||
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 static final String TAG = "ExternalPlayerFragment";
|
||||
|
||||
private ViewGroup fragmentLayout;
|
||||
private ImageView imgvCover;
|
||||
private TextView txtvTitle;
|
||||
private ImageButton butPlay;
|
||||
|
@ -56,16 +55,14 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View root = inflater.inflate(R.layout.external_player_fragment,
|
||||
container, false);
|
||||
fragmentLayout = root.findViewById(R.id.fragmentLayout);
|
||||
View root = inflater.inflate(R.layout.external_player_fragment, container, false);
|
||||
imgvCover = root.findViewById(R.id.imgvCover);
|
||||
txtvTitle = root.findViewById(R.id.txtvTitle);
|
||||
butPlay = root.findViewById(R.id.butPlay);
|
||||
mFeedName = root.findViewById(R.id.txtvAuthor);
|
||||
mProgressBar = root.findViewById(R.id.episodeProgress);
|
||||
|
||||
fragmentLayout.setOnClickListener(v -> {
|
||||
root.findViewById(R.id.fragmentLayout).setOnClickListener(v -> {
|
||||
Log.d(TAG, "layoutInfo was clicked");
|
||||
|
||||
if (controller != null && controller.getMedia() != null) {
|
||||
|
@ -175,9 +172,7 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void playbackDone() {
|
||||
if (fragmentLayout != null) {
|
||||
fragmentLayout.setVisibility(View.GONE);
|
||||
}
|
||||
clearUi();
|
||||
if (controller != null) {
|
||||
controller.release();
|
||||
}
|
||||
|
@ -214,10 +209,22 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(media -> updateUi((Playable) media),
|
||||
error -> Log.e(TAG, Log.getStackTraceString(error)),
|
||||
() -> fragmentLayout.setVisibility(View.GONE));
|
||||
this::clearUi);
|
||||
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) {
|
||||
if (media != null) {
|
||||
txtvTitle.setText(media.getEpisodeTitle());
|
||||
|
@ -233,8 +240,6 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
.fitCenter()
|
||||
.dontAnimate())
|
||||
.into(imgvCover);
|
||||
|
||||
fragmentLayout.setVisibility(View.VISIBLE);
|
||||
if (controller != null && controller.isPlayingVideoLocally()) {
|
||||
butPlay.setVisibility(View.GONE);
|
||||
((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,66 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/fragmentLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/external_player_height"
|
||||
android:visibility="gone"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/dividerHorizontal" />
|
||||
|
||||
<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="@dimen/external_player_height"
|
||||
android:layout_height="@dimen/external_player_height"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:adjustViewBounds="true"
|
||||
android:cropToPadding="true"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/ic_drag_vertical_white_48dp"
|
||||
tools:background="@android:color/holo_green_dark"
|
||||
android:transitionName="coverTransition"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"/>
|
||||
tools:src="@tools:sample/avatars"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/episodeProgress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="4dp"
|
||||
android:layout_toRightOf="@id/imgvCover"
|
||||
android:layout_toEndOf="@id/imgvCover"
|
||||
android:layout_alignParentTop="true"
|
||||
style="?attr/progressBarTheme"
|
||||
android:indeterminate="false"
|
||||
tools:progress="100"/>
|
||||
|
||||
<ImageButton
|
||||
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"/>
|
||||
<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"
|
||||
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"
|
||||
|
@ -70,18 +52,33 @@
|
|||
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"/>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<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
|
||||
android:id="@+id/episodeProgress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="4dp"
|
||||
style="?attr/progressBarTheme"
|
||||
android:indeterminate="false"
|
||||
tools:progress="100"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<dimen name="widget_margin">0dp</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="text_size_micro">12sp</dimen>
|
||||
<dimen name="text_size_small">14sp</dimen>
|
||||
|
|
Loading…
Reference in New Issue