mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 17:10:33 +00:00
made ui handle missing information on search
This commit is contained in:
parent
d7e75e6011
commit
1a2840b33f
@ -41,8 +41,10 @@ class VideoInfoItemViewCreator {
|
|||||||
this.inflater = inflater;
|
this.inflater = inflater;
|
||||||
}
|
}
|
||||||
|
|
||||||
public View getViewFromVideoInfoItem(View convertView, ViewGroup parent, StreamPreviewInfo info, Context context) {
|
public View getViewFromVideoInfoItem(View convertView, ViewGroup parent, StreamPreviewInfo info) {
|
||||||
ViewHolder holder;
|
ViewHolder holder;
|
||||||
|
|
||||||
|
// generate holder
|
||||||
if(convertView == null) {
|
if(convertView == null) {
|
||||||
convertView = inflater.inflate(R.layout.video_item, parent, false);
|
convertView = inflater.inflate(R.layout.video_item, parent, false);
|
||||||
holder = new ViewHolder();
|
holder = new ViewHolder();
|
||||||
@ -57,20 +59,41 @@ class VideoInfoItemViewCreator {
|
|||||||
holder = (ViewHolder) convertView.getTag();
|
holder = (ViewHolder) convertView.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fill with information
|
||||||
|
|
||||||
|
/*
|
||||||
if(info.thumbnail == null) {
|
if(info.thumbnail == null) {
|
||||||
holder.itemThumbnailView.setImageResource(R.drawable.dummy_thumbnail);
|
holder.itemThumbnailView.setImageResource(R.drawable.dummy_thumbnail);
|
||||||
} else {
|
} else {
|
||||||
holder.itemThumbnailView.setImageBitmap(info.thumbnail);
|
holder.itemThumbnailView.setImageBitmap(info.thumbnail);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
holder.itemVideoTitleView.setText(info.title);
|
holder.itemVideoTitleView.setText(info.title);
|
||||||
holder.itemUploaderView.setText(info.uploader);
|
if(info.uploader != null && !info.uploader.isEmpty()) {
|
||||||
holder.itemDurationView.setText(info.duration);
|
holder.itemUploaderView.setText(info.uploader);
|
||||||
holder.itemViewCountView.setText(shortViewCount(info.view_count));
|
} else {
|
||||||
|
holder.itemDurationView.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
if(info.duration != null && !info.duration.isEmpty()) {
|
||||||
|
holder.itemDurationView.setText(info.duration);
|
||||||
|
} else {
|
||||||
|
holder.itemDurationView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
if(info.view_count >= 0) {
|
||||||
|
holder.itemViewCountView.setText(shortViewCount(info.view_count));
|
||||||
|
} else {
|
||||||
|
holder.itemViewCountView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
if(!info.upload_date.isEmpty()) {
|
if(!info.upload_date.isEmpty()) {
|
||||||
holder.itemUploadDateView.setText(info.upload_date+" • ");
|
holder.itemUploadDateView.setText(info.upload_date+" • ");
|
||||||
}
|
}
|
||||||
|
|
||||||
imageLoader.displayImage(info.thumbnail_url, holder.itemThumbnailView, displayImageOptions);
|
if(info.thumbnail_url != null && !info.thumbnail_url.isEmpty()) {
|
||||||
|
imageLoader.displayImage(info.thumbnail_url, holder.itemThumbnailView, displayImageOptions);
|
||||||
|
} else {
|
||||||
|
holder.itemThumbnailView.setImageResource(R.drawable.dummy_thumbnail);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
View nextVideoView = null;
|
View nextVideoView = null;
|
||||||
if(info.next_video != null) {
|
if(info.next_video != null) {
|
||||||
nextVideoView = videoItemViewCreator
|
nextVideoView = videoItemViewCreator
|
||||||
.getViewFromVideoInfoItem(null, nextVideoFrame, info.next_video, getContext());
|
.getViewFromVideoInfoItem(null, nextVideoFrame, info.next_video);
|
||||||
} else {
|
} else {
|
||||||
activity.findViewById(R.id.detailNextVidButtonAndContentLayout).setVisibility(View.GONE);
|
activity.findViewById(R.id.detailNextVidButtonAndContentLayout).setVisibility(View.GONE);
|
||||||
activity.findViewById(R.id.detailNextVideoTitle).setVisibility(View.GONE);
|
activity.findViewById(R.id.detailNextVideoTitle).setVisibility(View.GONE);
|
||||||
@ -672,7 +672,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
ArrayList<StreamPreviewInfo> similar = new ArrayList<>(info.related_videos);
|
ArrayList<StreamPreviewInfo> similar = new ArrayList<>(info.related_videos);
|
||||||
for (final StreamPreviewInfo item : similar) {
|
for (final StreamPreviewInfo item : similar) {
|
||||||
View similarView = videoItemViewCreator
|
View similarView = videoItemViewCreator
|
||||||
.getViewFromVideoInfoItem(null, similarLayout, item, getContext());
|
.getViewFromVideoInfoItem(null, similarLayout, item);
|
||||||
|
|
||||||
similarView.setClickable(true);
|
similarView.setClickable(true);
|
||||||
similarView.setFocusable(true);
|
similarView.setFocusable(true);
|
||||||
|
@ -78,7 +78,7 @@ class VideoListAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
convertView = viewCreator.getViewFromVideoInfoItem(convertView, parent, videoList.get(position), context);
|
convertView = viewCreator.getViewFromVideoInfoItem(convertView, parent, videoList.get(position));
|
||||||
|
|
||||||
if(listView.isItemChecked(position)) {
|
if(listView.isItemChecked(position)) {
|
||||||
convertView.setBackgroundColor(ContextCompat.getColor(context,R.color.light_youtube_primary_color));
|
convertView.setBackgroundColor(ContextCompat.getColor(context,R.color.light_youtube_primary_color));
|
||||||
|
Loading…
Reference in New Issue
Block a user