use of com.mxt.anitrend.view.fragment.youtube.YoutubePlayerFragment in project anitrend-app by AniTrend.
the class MediaOverviewFragment method updateUI.
/**
* Is automatically called in the @onStart Method if overridden in list implementation
*/
@Override
protected void updateUI() {
if (!TextUtils.isEmpty(model.getTrailer())) {
if (youtubePlayerFragment == null) {
youtubePlayerFragment = YoutubePlayerFragment.newInstance(model.getTrailer());
getChildFragmentManager().beginTransaction().replace(R.id.youtube_view, youtubePlayerFragment).commit();
}
} else
binding.youtubeView.setVisibility(View.GONE);
binding.setPresenter(getPresenter());
binding.setModel(model);
if (genreAdapter == null) {
genreAdapter = new GenreAdapter(getPresenter().buildGenres(model), getContext());
genreAdapter.setClickListener(new ItemClickListener<Genre>() {
@Override
public void onItemClick(View target, Genre data) {
switch(target.getId()) {
case R.id.container:
Bundle args = new Bundle();
Intent intent = new Intent(getActivity(), MediaBrowseActivity.class);
args.putParcelable(KeyUtil.arg_graph_params, GraphUtil.getDefaultQuery(true).putVariable(KeyUtil.arg_id, mediaId).putVariable(KeyUtil.arg_type, mediaType).putVariable(KeyUtil.arg_genres, data.getGenre()));
args.putString(KeyUtil.arg_activity_tag, data.getGenre());
args.putBoolean(KeyUtil.arg_media_compact, true);
intent.putExtras(args);
startActivity(intent);
break;
}
}
@Override
public void onItemLongClick(View target, Genre data) {
}
});
}
binding.genreRecycler.setAdapter(genreAdapter);
if (tagAdapter == null) {
tagAdapter = new TagAdapter(model.getTags(), getContext());
tagAdapter.setClickListener(new ItemClickListener<MediaTag>() {
@Override
public void onItemClick(View target, MediaTag data) {
switch(target.getId()) {
case R.id.container:
DialogUtil.createMessage(getActivity(), data.getName(), data.getDescription(), R.string.More, R.string.Close, (dialog, which) -> {
switch(which) {
case POSITIVE:
Bundle args = new Bundle();
Intent intent = new Intent(getActivity(), MediaBrowseActivity.class);
args.putParcelable(KeyUtil.arg_graph_params, GraphUtil.getDefaultQuery(true).putVariable(KeyUtil.arg_id, mediaId).putVariable(KeyUtil.arg_type, mediaType).putVariable(KeyUtil.arg_tags, data.getName()));
args.putString(KeyUtil.arg_activity_tag, data.getName());
args.putBoolean(KeyUtil.arg_media_compact, true);
intent.putExtras(args);
startActivity(intent);
break;
}
});
break;
}
}
@Override
public void onItemLongClick(View target, MediaTag data) {
}
});
}
binding.tagsRecycler.setAdapter(tagAdapter);
binding.stateLayout.showContent();
}
Aggregations