use of com.mxt.anitrend.adapter.recycler.detail.RankAdapter in project anitrend-app by AniTrend.
the class MediaStatsFragment method updateUI.
/**
* Is automatically called in the @onStart Method if overridden in list implementation
*/
@Override
protected void updateUI() {
binding.setModel(model);
if (rankAdapter == null) {
rankAdapter = new RankAdapter(getContext());
rankAdapter.onItemsInserted(model.getRankings());
rankAdapter.setClickListener(new ItemClickListener<MediaRank>() {
@Override
public void onItemClick(View target, IntPair<MediaRank> data) {
Intent intent = new Intent(getActivity(), MediaBrowseActivity.class);
Bundle args = new Bundle();
QueryContainerBuilder queryContainer = GraphUtil.INSTANCE.getDefaultQuery(true).putVariable(KeyUtil.arg_type, mediaType).putVariable(KeyUtil.arg_format, data.getSecond().getFormat());
if (MediaUtil.isAnimeType(model))
queryContainer.putVariable(KeyUtil.arg_season, data.getSecond().getSeason());
if (!data.getSecond().isAllTime()) {
if (MediaUtil.isAnimeType(model))
queryContainer.putVariable(KeyUtil.arg_seasonYear, data.getSecond().getYear());
else
queryContainer.putVariable(KeyUtil.arg_startDateLike, String.format(Locale.getDefault(), "%d%%", data.getSecond().getYear()));
}
switch(data.getSecond().getType()) {
case KeyUtil.RATED:
queryContainer.putVariable(KeyUtil.arg_sort, KeyUtil.SCORE + KeyUtil.DESC);
break;
case KeyUtil.POPULAR:
queryContainer.putVariable(KeyUtil.arg_sort, KeyUtil.POPULARITY + KeyUtil.DESC);
break;
}
args.putParcelable(KeyUtil.arg_graph_params, queryContainer);
args.putParcelable(KeyUtil.arg_media_util, new MediaBrowseUtil().setCompactType(true).setFilterEnabled(false));
args.putString(KeyUtil.arg_activity_tag, data.getSecond().getTypeHtmlPlainTitle());
intent.putExtras(args);
startActivity(intent);
}
@Override
public void onItemLongClick(View target, IntPair<MediaRank> data) {
}
});
}
if (linkAdapter == null) {
linkAdapter = new LinkAdapter(getContext());
linkAdapter.onItemsInserted(model.getExternalLinks());
linkAdapter.setClickListener(new ItemClickListener<ExternalLink>() {
@Override
public void onItemClick(View target, IntPair<ExternalLink> data) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(data.getSecond().getUrl()));
startActivity(intent);
}
@Override
public void onItemLongClick(View target, IntPair<ExternalLink> data) {
}
});
}
binding.stateLayout.showContent();
binding.linksRecycler.setAdapter(linkAdapter);
binding.rankingRecycler.setAdapter(rankAdapter);
showStatusDistribution();
showScoreDistribution();
}
Aggregations