Add sub-channel details to channel fragment

This commit is contained in:
Roy Yosef 2020-04-13 23:40:58 +03:00 committed by wb9688
parent 1429774487
commit 2d0bc05488
3 changed files with 109 additions and 22 deletions

View File

@ -21,6 +21,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import com.jakewharton.rxbinding2.view.RxView;
@ -38,6 +39,7 @@ import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
import org.schabi.newpipe.local.subscription.SubscriptionManager;
import org.schabi.newpipe.player.playqueue.ChannelPlayQueue;
import org.schabi.newpipe.player.playqueue.PlayQueue;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.util.AnimationUtils;
import org.schabi.newpipe.util.ExtractorHelper;
@ -65,7 +67,8 @@ import static org.schabi.newpipe.util.AnimationUtils.animateBackgroundColor;
import static org.schabi.newpipe.util.AnimationUtils.animateTextColor;
import static org.schabi.newpipe.util.AnimationUtils.animateView;
public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
implements View.OnClickListener {
private static final int BUTTON_DEBOUNCE_INTERVAL = 100;
private final CompositeDisposable disposables = new CompositeDisposable();
private Disposable subscribeButtonMonitor;
@ -79,6 +82,8 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
private ImageView headerChannelBanner;
private ImageView headerAvatarView;
private TextView headerTitleView;
private ImageView headerParentChannelAvatarView;
private TextView headerParentChannelTitleView;
private TextView headerSubscribersTextView;
private Button headerSubscribeButton;
private View playlistCtrl;
@ -156,7 +161,10 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
headerSubscribersTextView = headerRootLayout.findViewById(R.id.channel_subscriber_view);
headerSubscribeButton = headerRootLayout.findViewById(R.id.channel_subscribe_button);
playlistCtrl = headerRootLayout.findViewById(R.id.playlist_control);
headerParentChannelAvatarView =
headerRootLayout.findViewById(R.id.parent_channel_avatar_view);
headerParentChannelTitleView =
headerRootLayout.findViewById(R.id.parent_channel_title_view);
headerPlayAllButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_all_button);
headerPopupButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_popup_button);
@ -165,6 +173,12 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
return headerRootLayout;
}
@Override
protected void initListeners() {
headerParentChannelTitleView.setOnClickListener(this);
headerParentChannelAvatarView.setOnClickListener(this);
}
/*//////////////////////////////////////////////////////////////////////////
// Menu
//////////////////////////////////////////////////////////////////////////*/
@ -394,6 +408,36 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
return ExtractorHelper.getChannelInfo(serviceId, url, forceLoad);
}
/*//////////////////////////////////////////////////////////////////////////
// OnClick
//////////////////////////////////////////////////////////////////////////*/
@Override
public void onClick(final View v) {
if (isLoading.get() || currentInfo == null) {
return;
}
switch (v.getId()) {
case R.id.parent_channel_avatar_view:
case R.id.parent_channel_title_view:
if (TextUtils.isEmpty(currentInfo.getParentChannelUrl())) {
Log.w(TAG, "Can't open parent's channel because we got no channel URL");
} else {
try {
NavigationHelper.openChannelFragment(
getFragmentManager(),
currentInfo.getServiceId(),
currentInfo.getParentChannelUrl(),
currentInfo.getParentChannelName());
} catch (Exception e) {
ErrorActivity.reportUiError((AppCompatActivity) getActivity(), e);
}
}
break;
}
}
/*//////////////////////////////////////////////////////////////////////////
// Contract
//////////////////////////////////////////////////////////////////////////*/
@ -404,6 +448,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
IMAGE_LOADER.cancelDisplayTask(headerChannelBanner);
IMAGE_LOADER.cancelDisplayTask(headerAvatarView);
IMAGE_LOADER.cancelDisplayTask(headerParentChannelAvatarView);
animateView(headerSubscribeButton, false, 100);
}
@ -416,6 +461,8 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
ImageDisplayConstants.DISPLAY_BANNER_OPTIONS);
IMAGE_LOADER.displayImage(result.getAvatarUrl(), headerAvatarView,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
IMAGE_LOADER.displayImage(result.getParentChannelAvatarUrl(), headerParentChannelAvatarView,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
headerSubscribersTextView.setVisibility(View.VISIBLE);
if (result.getSubscriberCount() >= 0) {
@ -425,6 +472,15 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
headerSubscribersTextView.setText(R.string.subscribers_count_not_available);
}
if (!TextUtils.isEmpty(currentInfo.getParentChannelName())) {
headerParentChannelTitleView.setText(
"Created by " + currentInfo.getParentChannelName());
headerParentChannelTitleView.setVisibility(View.VISIBLE);
} else {
headerParentChannelTitleView.setVisibility(View.GONE);
headerParentChannelAvatarView.setVisibility(View.GONE);
}
if (menuRssButton != null) {
menuRssButton.setVisible(!TextUtils.isEmpty(result.getFeedUrl()));
}

View File

@ -711,7 +711,8 @@ public class Mp4FromDashWriter {
for (int i = 0; i < tracks.length; i++) {
if (tracks[i].trak.tkhd.matrix.length != 36) {
throw new RuntimeException("bad track matrix length (expected 36) in track n°" + i);
throw
new RuntimeException("bad track matrix length (expected 36) in track n°" + i);
}
makeTrak(i, durations[i], defaultMediaTime[i], tablesInfo[i], is64);
}

View File

@ -23,17 +23,32 @@
android:src="@drawable/channel_banner"
tools:ignore="ContentDescription"/>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/channel_avatar_view"
android:layout_width="@dimen/channel_avatar_size"
android:layout_height="@dimen/channel_avatar_size"
android:layout_alignTop="@id/channel_banner_image"
<FrameLayout
android:id="@+id/avatars_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="50dp"
android:src="@drawable/buddy"
app:civ_border_color="#ffffff"
app:civ_border_width="2dp"
tools:ignore="RtlHardcoded"/>
android:layout_marginTop="50dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/channel_avatar_view"
android:layout_width="@dimen/channel_avatar_size"
android:layout_height="@dimen/channel_avatar_size"
android:src="@drawable/buddy"
app:civ_border_color="#ffffff"
app:civ_border_width="2dp"
tools:ignore="RtlHardcoded" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/parent_channel_avatar_view"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_gravity="bottom|right"
android:src="@drawable/buddy"
app:civ_border_color="#ffffff"
app:civ_border_width="2dp"
tools:ignore="RtlHardcoded" />
</FrameLayout>
<TextView
android:id="@+id/channel_title_view"
@ -41,32 +56,47 @@
android:layout_height="wrap_content"
android:layout_below="@id/channel_banner_image"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="6dp"
android:layout_toLeftOf="@+id/channel_subscribe_button"
android:layout_toRightOf="@+id/channel_avatar_view"
android:layout_marginRight="8dp"
android:layout_toLeftOf="@id/channel_subscribe_button"
android:layout_toRightOf="@id/avatars_layout"
android:ellipsize="end"
android:lines="1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/video_item_detail_title_text_size"
tools:ignore="RtlHardcoded"
tools:text="Lorem ipsum dolor"/>
tools:text="Lorem ipsum dolor" />
<TextView
android:id="@+id/parent_channel_title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/channel_title_view"
android:layout_alignLeft="@id/channel_title_view"
android:layout_alignRight="@id/channel_title_view"
android:ellipsize="end"
android:gravity="center|left"
android:lines="1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="12dp"
tools:ignore="RtlHardcoded"
tools:layout_below="@id/channel_title_view"
tools:text="Lorem ipsum dolor" />
<TextView
android:id="@+id/channel_subscriber_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/channel_title_view"
android:layout_alignRight="@+id/channel_title_view"
android:layout_below="@+id/channel_title_view"
android:layout_below="@id/parent_channel_title_view"
android:layout_alignLeft="@id/channel_title_view"
android:layout_alignRight="@id/channel_title_view"
android:ellipsize="end"
android:gravity="left|center"
android:maxLines="2"
android:textSize="@dimen/channel_subscribers_text_size"
android:visibility="gone"
tools:ignore="RtlHardcoded"
tools:text="123,141,411 subscribers"
tools:visibility="visible"/>
tools:visibility="visible" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/channel_subscribe_button"