Search in sources :

Example 1 with TagAdapter

use of com.mxt.anitrend.adapter.recycler.detail.TagAdapter 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();
}
Also used : TagAdapter(com.mxt.anitrend.adapter.recycler.detail.TagAdapter) TagAdapter(com.mxt.anitrend.adapter.recycler.detail.TagAdapter) Bundle(android.os.Bundle) YoutubePlayerFragment(com.mxt.anitrend.view.fragment.youtube.YoutubePlayerFragment) ButterKnife(butterknife.ButterKnife) Intent(android.content.Intent) FragmentSeriesOverviewBinding(com.mxt.anitrend.databinding.FragmentSeriesOverviewBinding) NonNull(android.support.annotation.NonNull) Media(com.mxt.anitrend.model.entity.anilist.Media) ImagePreviewActivity(com.mxt.anitrend.view.activity.base.ImagePreviewActivity) OnClick(butterknife.OnClick) StudioBase(com.mxt.anitrend.model.entity.base.StudioBase) QueryContainerBuilder(com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder) GraphUtil(com.mxt.anitrend.util.GraphUtil) Genre(com.mxt.anitrend.model.entity.anilist.Genre) MediaTag(com.mxt.anitrend.model.entity.anilist.MediaTag) ItemClickListener(com.mxt.anitrend.base.interfaces.event.ItemClickListener) R(com.mxt.anitrend.R) View(android.view.View) ConnectionContainer(com.mxt.anitrend.model.entity.container.body.ConnectionContainer) FragmentBase(com.mxt.anitrend.base.custom.fragment.FragmentBase) MediaBrowseActivity(com.mxt.anitrend.view.activity.detail.MediaBrowseActivity) GenreAdapter(com.mxt.anitrend.adapter.recycler.detail.GenreAdapter) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) CompatUtil(com.mxt.anitrend.util.CompatUtil) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) ViewGroup(android.view.ViewGroup) DialogUtil(com.mxt.anitrend.util.DialogUtil) StudioActivity(com.mxt.anitrend.view.activity.detail.StudioActivity) Nullable(android.support.annotation.Nullable) KeyUtil(com.mxt.anitrend.util.KeyUtil) MediaPresenter(com.mxt.anitrend.presenter.fragment.MediaPresenter) Bundle(android.os.Bundle) Intent(android.content.Intent) Genre(com.mxt.anitrend.model.entity.anilist.Genre) View(android.view.View) MediaBrowseActivity(com.mxt.anitrend.view.activity.detail.MediaBrowseActivity) GenreAdapter(com.mxt.anitrend.adapter.recycler.detail.GenreAdapter) MediaTag(com.mxt.anitrend.model.entity.anilist.MediaTag)

Aggregations

Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 TextUtils (android.text.TextUtils)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ButterKnife (butterknife.ButterKnife)1 OnClick (butterknife.OnClick)1 R (com.mxt.anitrend.R)1 GenreAdapter (com.mxt.anitrend.adapter.recycler.detail.GenreAdapter)1 TagAdapter (com.mxt.anitrend.adapter.recycler.detail.TagAdapter)1 FragmentBase (com.mxt.anitrend.base.custom.fragment.FragmentBase)1 ItemClickListener (com.mxt.anitrend.base.interfaces.event.ItemClickListener)1 FragmentSeriesOverviewBinding (com.mxt.anitrend.databinding.FragmentSeriesOverviewBinding)1 Genre (com.mxt.anitrend.model.entity.anilist.Genre)1 Media (com.mxt.anitrend.model.entity.anilist.Media)1 MediaTag (com.mxt.anitrend.model.entity.anilist.MediaTag)1