use of com.mxt.anitrend.util.media.MediaBrowseUtil 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();
}
use of com.mxt.anitrend.util.media.MediaBrowseUtil in project anitrend-app by AniTrend.
the class MediaBrowseFragment method onCreate.
/**
* Override and set presenter, mColumnSize, and fetch argument/s
*
* @param savedInstanceState
*/
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
queryContainer = getArguments().getParcelable(KeyUtil.arg_graph_params);
mediaBrowseUtil = getArguments().getParcelable(KeyUtil.arg_media_util);
}
if (mediaBrowseUtil == null)
mediaBrowseUtil = new MediaBrowseUtil(true);
isPager = true;
isFilterable = mediaBrowseUtil.isFilterEnabled();
mAdapter = new MediaAdapter(getContext(), mediaBrowseUtil.isCompactType());
setPresenter(new MediaPresenter(getContext()));
setViewModel(true);
if (mediaBrowseUtil.isCompactType()) {
mColumnSize = R.integer.grid_giphy_x3;
} else {
if (getPresenter().getSettings().getMediaListStyle() == KeyUtil.LIST_VIEW_STYLE_COMPACT_X1) {
mColumnSize = R.integer.single_list_x1;
} else {
mColumnSize = R.integer.grid_list_x2;
}
}
}
Aggregations