Search in sources :

Example 1 with RecyclerItem

use of com.mxt.anitrend.model.entity.group.RecyclerItem in project anitrend-app by AniTrend.

the class MediaRecommendationsFragment method onChanged.

@Override
public void onChanged(@Nullable ConnectionContainer<PageContainer<RecommendationBase>> content) {
    if (content != null) {
        if (!content.isEmpty()) {
            if (content.getConnection().hasPageInfo())
                getPresenter().setPageInfo(content.getConnection().getPageInfo());
            ArrayList<RecyclerItem> entityMap = new ArrayList<>();
            for (RecommendationBase recommendation : content.getConnection().getPageData()) {
                if (recommendation.getMediaRecommendation() != null)
                    entityMap.add(recommendation.getMediaRecommendation());
            }
            onPostProcessed(entityMap);
        }
    } else
        onPostProcessed(Collections.emptyList());
    if (mAdapter.getItemCount() < 1)
        onPostProcessed(null);
}
Also used : RecommendationBase(com.mxt.anitrend.model.entity.base.RecommendationBase) ArrayList(java.util.ArrayList) RecyclerItem(com.mxt.anitrend.model.entity.group.RecyclerItem)

Example 2 with RecyclerItem

use of com.mxt.anitrend.model.entity.group.RecyclerItem in project anitrend-app by AniTrend.

the class CharacterActorsFragment method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        queryContainer = GraphUtil.INSTANCE.getDefaultQuery(true).putVariable(KeyUtil.arg_id, getArguments().getLong(KeyUtil.arg_id));
    }
    mColumnSize = R.integer.grid_giphy_x3;
    isPager = true;
    mAdapter = new GroupActorAdapter(getContext());
    setPresenter(new MediaPresenter(getContext()));
    setViewModel(true);
    ((GroupActorAdapter) mAdapter).setMediaClickListener(new ItemClickListener<RecyclerItem>() {

        /**
         * When the target view from {@link View.OnClickListener}
         * is clicked from a view holder this method will be called
         *
         * @param target view that has been clicked
         * @param data   the model that at the clicked index
         */
        @Override
        public void onItemClick(View target, IntPair<RecyclerItem> data) {
            switch(target.getId()) {
                case R.id.container:
                    Intent intent = new Intent(getActivity(), MediaActivity.class);
                    intent.putExtra(KeyUtil.arg_id, ((MediaBase) data.getSecond()).getId());
                    intent.putExtra(KeyUtil.arg_mediaType, ((MediaBase) data.getSecond()).getType());
                    CompatUtil.INSTANCE.startRevealAnim(getActivity(), target, intent);
                    break;
            }
        }

        /**
         * When the target view from {@link View.OnLongClickListener}
         * is clicked from a view holder this method will be called
         *
         * @param target view that has been long clicked
         * @param data   the model that at the long clicked index
         */
        @Override
        public void onItemLongClick(View target, IntPair<RecyclerItem> data) {
            switch(target.getId()) {
                case R.id.container:
                    if (getPresenter().getSettings().isAuthenticated()) {
                        mediaActionUtil = new MediaActionUtil.Builder().setId(((MediaBase) data.getSecond()).getId()).build(getActivity());
                        mediaActionUtil.startSeriesAction();
                    } else
                        NotifyUtil.INSTANCE.makeText(getContext(), R.string.info_login_req, R.drawable.ic_group_add_grey_600_18dp, Toast.LENGTH_SHORT).show();
                    break;
            }
        }
    });
}
Also used : GroupActorAdapter(com.mxt.anitrend.adapter.recycler.group.GroupActorAdapter) QueryContainerBuilder(io.github.wax911.library.model.request.QueryContainerBuilder) RecyclerItem(com.mxt.anitrend.model.entity.group.RecyclerItem) Intent(android.content.Intent) MediaActivity(com.mxt.anitrend.view.activity.detail.MediaActivity) MediaBase(com.mxt.anitrend.model.entity.base.MediaBase) View(android.view.View) MediaPresenter(com.mxt.anitrend.presenter.fragment.MediaPresenter)

Aggregations

RecyclerItem (com.mxt.anitrend.model.entity.group.RecyclerItem)2 Intent (android.content.Intent)1 View (android.view.View)1 GroupActorAdapter (com.mxt.anitrend.adapter.recycler.group.GroupActorAdapter)1 MediaBase (com.mxt.anitrend.model.entity.base.MediaBase)1 RecommendationBase (com.mxt.anitrend.model.entity.base.RecommendationBase)1 MediaPresenter (com.mxt.anitrend.presenter.fragment.MediaPresenter)1 MediaActivity (com.mxt.anitrend.view.activity.detail.MediaActivity)1 QueryContainerBuilder (io.github.wax911.library.model.request.QueryContainerBuilder)1 ArrayList (java.util.ArrayList)1