use of com.mxt.anitrend.model.entity.anilist.Genre 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();
}
use of com.mxt.anitrend.model.entity.anilist.Genre in project anitrend-app by AniTrend.
the class TagGenreService method onHandleIntent.
@Override
protected void onHandleIntent(@Nullable Intent intent) {
try {
initAnalytics();
BasePresenter basePresenter = new BasePresenter(getApplicationContext());
BaseModel baseModel = WebFactory.createService(BaseModel.class, getApplicationContext());
if (basePresenter.getDatabase().getBoxStore(MediaTag.class).count() < 1) {
Response<List<MediaTag>> tagsResponse = baseModel.getTags(GraphUtil.getDefaultQuery(false)).execute();
if (tagsResponse.isSuccessful() && tagsResponse.body() != null)
basePresenter.getDatabase().saveMediaTags(tagsResponse.body());
else
Log.e(ServiceName, ErrorUtil.getError(tagsResponse));
}
if (basePresenter.getDatabase().getBoxStore(Genre.class).count() < 1) {
Response<List<String>> genreResponse = baseModel.getGenres(GraphUtil.getDefaultQuery(false)).execute();
List<String> genres;
if (genreResponse.isSuccessful() && (genres = genreResponse.body()) != null) {
List<Genre> genreList = Stream.of(genres).map(Genre::new).toList();
basePresenter.getDatabase().saveGenreCollection(genreList);
} else
Log.e(ServiceName, ErrorUtil.getError(genreResponse));
}
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations