use of com.mxt.anitrend.model.entity.anilist.ExternalLink in project anitrend-app by AniTrend.
the class HubPageAdapter method getItem.
/**
* Return the Fragment associated with a specified position.
*
* @param position
*/
@Override
public Fragment getItem(int position) {
switch(position) {
case 0:
return SuggestionListFragment.newInstance(getParams());
case 1:
List<ExternalLink> externalLinks = new ArrayList<>(1);
externalLinks.add(new ExternalLink(BuildConfig.FEEDS_LINK, null));
return WatchListFragment.newInstance(externalLinks, true);
}
return null;
}
use of com.mxt.anitrend.model.entity.anilist.ExternalLink 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.model.entity.anilist.ExternalLink in project anitrend-app by AniTrend.
the class EpisodeUtilTests method episodeSupport_givenCrunchyrollUrl_shouldReturnTheFeedUrl.
@Test
public void episodeSupport_givenCrunchyrollUrl_shouldReturnTheFeedUrl() {
String show = "my-hero-academia";
ExternalLink link = mock(ExternalLink.class);
when(link.getUrl()).thenReturn(BuildConfig.CRUNCHY_LINK + show);
List<ExternalLink> links = Collections.singletonList(link);
assertThat(EpisodeUtil.INSTANCE.episodeSupport(links), equalTo(show + ".rss"));
}
use of com.mxt.anitrend.model.entity.anilist.ExternalLink in project anitrend-app by AniTrend.
the class EpisodeUtilTests method episodeSupport_notGivenASupportedLink_shouldReturnNull.
@Test
public void episodeSupport_notGivenASupportedLink_shouldReturnNull() {
String website = "https://heroaca.com/";
String twitter = "https://twitter.com/heroaca_anime";
ExternalLink link1 = mock(ExternalLink.class);
ExternalLink link2 = mock(ExternalLink.class);
when(link1.getUrl()).thenReturn(website);
when(link2.getUrl()).thenReturn(twitter);
List<ExternalLink> links = Arrays.asList(link1, link2);
assertThat(EpisodeUtil.INSTANCE.episodeSupport(links), nullValue());
}
use of com.mxt.anitrend.model.entity.anilist.ExternalLink in project anitrend-app by AniTrend.
the class EpisodeUtilTests method episodeSupport_givenFeedUrl_shouldReturnTheSameLink.
@Test
public void episodeSupport_givenFeedUrl_shouldReturnTheSameLink() {
String url = BuildConfig.FEEDS_LINK + "my-hero-academia.rss";
ExternalLink link = mock(ExternalLink.class);
when(link.getUrl()).thenReturn(url);
List<ExternalLink> links = Collections.singletonList(link);
assertThat(EpisodeUtil.INSTANCE.episodeSupport(links), equalTo(url));
}
Aggregations