Add sub-channel details to video detail fragment
This commit is contained in:
parent
2060312dc1
commit
1429774487
9 changed files with 211 additions and 66 deletions
|
|
@ -172,9 +172,10 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
|||
private TextView videoUploadDateView;
|
||||
private TextView videoDescriptionView;
|
||||
|
||||
private View uploaderRootLayout;
|
||||
private TextView uploaderTextView;
|
||||
private ImageView uploaderThumb;
|
||||
private TextView parentChannelTextView;
|
||||
private ImageView parentChannelThumb;
|
||||
|
||||
private TextView thumbsUpTextView;
|
||||
private ImageView thumbsUpImageView;
|
||||
|
|
@ -418,19 +419,25 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
|||
this.openDownloadDialog();
|
||||
}
|
||||
break;
|
||||
case R.id.detail_uploader_root_layout:
|
||||
case R.id.detail_parent_channel_text_view:
|
||||
case R.id.detail_parent_channel_thumbnail_view:
|
||||
if (TextUtils.isEmpty(currentInfo.getParentChannelUrl())) {
|
||||
Log.w(TAG, "Can't open parent's channel because we got no channel URL");
|
||||
|
||||
if (!TextUtils.isEmpty(currentInfo.getUploaderUrl())) {
|
||||
openChannel(currentInfo.getUploaderUrl(), currentInfo.getUploaderName());
|
||||
}
|
||||
} else {
|
||||
openChannel(currentInfo.getParentChannelUrl(),
|
||||
currentInfo.getParentChannelName());
|
||||
}
|
||||
break;
|
||||
case R.id.detail_uploader_text_view:
|
||||
case R.id.detail_uploader_thumbnail_view:
|
||||
if (TextUtils.isEmpty(currentInfo.getUploaderUrl())) {
|
||||
Log.w(TAG, "Can't open channel because we got no channel URL");
|
||||
} else {
|
||||
try {
|
||||
NavigationHelper.openChannelFragment(
|
||||
getFragmentManager(),
|
||||
currentInfo.getServiceId(),
|
||||
currentInfo.getUploaderUrl(),
|
||||
currentInfo.getUploaderName());
|
||||
} catch (Exception e) {
|
||||
ErrorActivity.reportUiError((AppCompatActivity) getActivity(), e);
|
||||
}
|
||||
openChannel(currentInfo.getUploaderUrl(), currentInfo.getUploaderName());
|
||||
}
|
||||
break;
|
||||
case R.id.detail_thumbnail_root_layout:
|
||||
|
|
@ -447,6 +454,18 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
|||
}
|
||||
}
|
||||
|
||||
private void openChannel(final String parentChannelUrl, final String parentChannelName) {
|
||||
try {
|
||||
NavigationHelper.openChannelFragment(
|
||||
getFragmentManager(),
|
||||
currentInfo.getServiceId(),
|
||||
parentChannelUrl,
|
||||
parentChannelName);
|
||||
} catch (Exception e) {
|
||||
ErrorActivity.reportUiError((AppCompatActivity) getActivity(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(final View v) {
|
||||
if (isLoading.get() || currentInfo == null) {
|
||||
|
|
@ -522,9 +541,10 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
|||
thumbsDownImageView = rootView.findViewById(R.id.detail_thumbs_down_img_view);
|
||||
thumbsDisabledTextView = rootView.findViewById(R.id.detail_thumbs_disabled_view);
|
||||
|
||||
uploaderRootLayout = rootView.findViewById(R.id.detail_uploader_root_layout);
|
||||
uploaderTextView = rootView.findViewById(R.id.detail_uploader_text_view);
|
||||
uploaderThumb = rootView.findViewById(R.id.detail_uploader_thumbnail_view);
|
||||
parentChannelTextView = rootView.findViewById(R.id.detail_parent_channel_text_view);
|
||||
parentChannelThumb = rootView.findViewById(R.id.detail_parent_channel_thumbnail_view);
|
||||
|
||||
appBarLayout = rootView.findViewById(R.id.appbarlayout);
|
||||
viewPager = rootView.findViewById(R.id.viewpager);
|
||||
|
|
@ -554,8 +574,12 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
|||
protected void initListeners() {
|
||||
super.initListeners();
|
||||
|
||||
uploaderTextView.setOnClickListener(this);
|
||||
uploaderThumb.setOnClickListener(this);
|
||||
parentChannelTextView.setOnClickListener(this);
|
||||
parentChannelThumb.setOnClickListener(this);
|
||||
|
||||
videoTitleRoot.setOnClickListener(this);
|
||||
uploaderRootLayout.setOnClickListener(this);
|
||||
thumbnailBackgroundButton.setOnClickListener(this);
|
||||
detailControlsBackground.setOnClickListener(this);
|
||||
detailControlsPopup.setOnClickListener(this);
|
||||
|
|
@ -603,6 +627,11 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
|||
ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS, onFailListener);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(info.getParentChannelAvatarUrl())) {
|
||||
IMAGE_LOADER.displayImage(info.getParentChannelAvatarUrl(), parentChannelThumb,
|
||||
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(info.getUploaderAvatarUrl())) {
|
||||
IMAGE_LOADER.displayImage(info.getUploaderAvatarUrl(), uploaderThumb,
|
||||
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
|
||||
|
|
@ -964,7 +993,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
|||
@NonNull final StreamInfo info,
|
||||
@NonNull final Stream selectedStream) {
|
||||
NavigationHelper.playOnExternalPlayer(context, currentInfo.getName(),
|
||||
currentInfo.getUploaderName(), selectedStream);
|
||||
currentInfo.getParentChannelName(), selectedStream);
|
||||
|
||||
final HistoryRecordManager recordManager = new HistoryRecordManager(requireContext());
|
||||
disposables.add(recordManager.onViewed(info).onErrorComplete()
|
||||
|
|
@ -1097,9 +1126,9 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
|||
}
|
||||
|
||||
IMAGE_LOADER.cancelDisplayTask(thumbnailImageView);
|
||||
IMAGE_LOADER.cancelDisplayTask(uploaderThumb);
|
||||
IMAGE_LOADER.cancelDisplayTask(parentChannelThumb);
|
||||
thumbnailImageView.setImageBitmap(null);
|
||||
uploaderThumb.setImageBitmap(null);
|
||||
parentChannelThumb.setImageBitmap(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1127,13 +1156,17 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
|||
animateView(thumbnailPlayButton, true, 200);
|
||||
videoTitleTextView.setText(name);
|
||||
|
||||
if (!TextUtils.isEmpty(info.getUploaderName())) {
|
||||
uploaderTextView.setText(info.getUploaderName());
|
||||
uploaderTextView.setVisibility(View.VISIBLE);
|
||||
uploaderTextView.setSelected(true);
|
||||
if (!TextUtils.isEmpty(info.getParentChannelName())) {
|
||||
displayBothUploaderAndParentChannel(info);
|
||||
} else if (!TextUtils.isEmpty(info.getUploaderName())) {
|
||||
displayUploaderAsParentChannel(info);
|
||||
} else {
|
||||
parentChannelThumb.setVisibility(View.GONE);
|
||||
uploaderTextView.setVisibility(View.GONE);
|
||||
uploaderThumb.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
parentChannelThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy));
|
||||
uploaderThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy));
|
||||
|
||||
if (info.getViewCount() >= 0) {
|
||||
|
|
@ -1264,6 +1297,28 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
|||
viewPager.setVisibility(View.GONE);
|
||||
tabLayout.setVisibility(View.GONE);
|
||||
}
|
||||
private void displayUploaderAsParentChannel(final StreamInfo info) {
|
||||
parentChannelTextView.setText(info.getUploaderName());
|
||||
parentChannelTextView.setVisibility(View.VISIBLE);
|
||||
parentChannelTextView.setSelected(true);
|
||||
parentChannelThumb.setVisibility(View.GONE);
|
||||
uploaderTextView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void displayBothUploaderAndParentChannel(final StreamInfo info) {
|
||||
parentChannelTextView.setText(info.getParentChannelName());
|
||||
parentChannelTextView.setVisibility(View.VISIBLE);
|
||||
parentChannelTextView.setSelected(true);
|
||||
|
||||
if (!TextUtils.isEmpty(info.getUploaderName())) {
|
||||
uploaderTextView.setText("By " + info.getUploaderName());
|
||||
uploaderTextView.setVisibility(View.VISIBLE);
|
||||
uploaderTextView.setSelected(true);
|
||||
} else {
|
||||
uploaderTextView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void openDownloadDialog() {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue