Search in sources :

Example 1 with MediaBase

use of com.mxt.anitrend.model.entity.base.MediaBase in project anitrend-app by AniTrend.

the class CommentFragment method onItemClick.

/**
 * 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 click index
 */
@Override
public void onItemClick(View target, FeedReply data) {
    Intent intent;
    switch(target.getId()) {
        case R.id.series_image:
            MediaBase mediaBase = feedList.getMedia();
            intent = new Intent(getActivity(), MediaActivity.class);
            intent.putExtra(KeyUtil.arg_id, mediaBase.getId());
            intent.putExtra(KeyUtil.arg_mediaType, mediaBase.getType());
            CompatUtil.startRevealAnim(getActivity(), target, intent);
            break;
        case R.id.widget_mention:
            composerWidget.mentionUserFrom(data);
            break;
        case R.id.widget_edit:
            composerWidget.setModel(data, KeyUtil.MUT_SAVE_FEED_REPLY);
            composerWidget.setText(data.getReply());
            break;
        case R.id.widget_users:
            List<UserBase> likes = data.getLikes();
            if (likes.size() > 0) {
                mBottomSheet = new BottomSheetUsers.Builder().setModel(likes).setTitle(R.string.title_bottom_sheet_likes).build();
                showBottomSheet();
            } else
                NotifyUtil.makeText(getActivity(), R.string.text_no_likes, Toast.LENGTH_SHORT).show();
            break;
        case R.id.user_avatar:
            intent = new Intent(getActivity(), ProfileActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra(KeyUtil.arg_id, data.getUser().getId());
            CompatUtil.startRevealAnim(getActivity(), target, intent);
            break;
    }
}
Also used : UserBase(com.mxt.anitrend.model.entity.base.UserBase) ProfileActivity(com.mxt.anitrend.view.activity.detail.ProfileActivity) QueryContainerBuilder(com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder) Intent(android.content.Intent) MediaBase(com.mxt.anitrend.model.entity.base.MediaBase) MediaActivity(com.mxt.anitrend.view.activity.detail.MediaActivity)

Example 2 with MediaBase

use of com.mxt.anitrend.model.entity.base.MediaBase in project anitrend-app by AniTrend.

the class CharacterActorsFragment method updateUI.

@Override
protected void updateUI() {
    if (mAdapter == null) {
        mAdapter = new GroupActorAdapter(model, getContext());
        ((GroupActorAdapter) mAdapter).setMediaClickListener(new ItemClickListener<EntityGroup>() {

            /**
             * 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 click index
             */
            @Override
            public void onItemClick(View target, EntityGroup data) {
                switch(target.getId()) {
                    case R.id.container:
                        Intent intent = new Intent(getActivity(), MediaActivity.class);
                        intent.putExtra(KeyUtil.arg_id, ((MediaBase) data).getId());
                        intent.putExtra(KeyUtil.arg_mediaType, ((MediaBase) data).getType());
                        CompatUtil.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 click index
             */
            @Override
            public void onItemLongClick(View target, EntityGroup data) {
                switch(target.getId()) {
                    case R.id.container:
                        if (getPresenter().getApplicationPref().isAuthenticated()) {
                            mediaActionUtil = new MediaActionUtil.Builder().setModel((MediaBase) data).build(getActivity());
                            mediaActionUtil.startSeriesAction();
                        } else
                            NotifyUtil.makeText(getContext(), R.string.info_login_req, R.drawable.ic_group_add_grey_600_18dp, Toast.LENGTH_SHORT).show();
                        break;
                }
            }
        });
    }
    setSwipeRefreshLayoutEnabled(false);
    injectAdapter();
}
Also used : GroupActorAdapter(com.mxt.anitrend.adapter.recycler.group.GroupActorAdapter) EntityGroup(com.mxt.anitrend.model.entity.group.EntityGroup) QueryContainerBuilder(com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder) Intent(android.content.Intent) MediaActivity(com.mxt.anitrend.view.activity.detail.MediaActivity) MediaBase(com.mxt.anitrend.model.entity.base.MediaBase) View(android.view.View)

Example 3 with MediaBase

use of com.mxt.anitrend.model.entity.base.MediaBase in project anitrend-app by AniTrend.

the class FeedListFragment method onItemClick.

/**
 * 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 click index
 */
@Override
public void onItemClick(View target, FeedList data) {
    Intent intent;
    switch(target.getId()) {
        case R.id.series_image:
            MediaBase series = data.getMedia();
            intent = new Intent(getActivity(), MediaActivity.class);
            intent.putExtra(KeyUtil.arg_id, series.getId());
            intent.putExtra(KeyUtil.arg_mediaType, series.getType());
            CompatUtil.startRevealAnim(getActivity(), target, intent);
            break;
        case R.id.widget_comment:
            intent = new Intent(getActivity(), CommentActivity.class);
            intent.putExtra(KeyUtil.arg_model, data);
            CompatUtil.startRevealAnim(getActivity(), target, intent);
            break;
        case R.id.widget_edit:
            mBottomSheet = new BottomSheetComposer.Builder().setUserActivity(data).setRequestMode(KeyUtil.MUT_SAVE_TEXT_FEED).setTitle(R.string.edit_status_title).build();
            showBottomSheet();
            break;
        case R.id.widget_users:
            List<UserBase> likes = data.getLikes();
            if (likes.size() > 0) {
                mBottomSheet = new BottomSheetUsers.Builder().setModel(likes).setTitle(R.string.title_bottom_sheet_likes).build();
                showBottomSheet();
            } else
                NotifyUtil.makeText(getActivity(), R.string.text_no_likes, Toast.LENGTH_SHORT).show();
            break;
        case R.id.user_avatar:
            if (data.getUser() != null) {
                intent = new Intent(getActivity(), ProfileActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.putExtra(KeyUtil.arg_id, data.getUser().getId());
                CompatUtil.startRevealAnim(getActivity(), target, intent);
            }
            break;
    }
}
Also used : UserBase(com.mxt.anitrend.model.entity.base.UserBase) ProfileActivity(com.mxt.anitrend.view.activity.detail.ProfileActivity) QueryContainerBuilder(com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder) CommentActivity(com.mxt.anitrend.view.activity.detail.CommentActivity) Intent(android.content.Intent) MediaBase(com.mxt.anitrend.model.entity.base.MediaBase) MediaActivity(com.mxt.anitrend.view.activity.detail.MediaActivity) BottomSheetComposer(com.mxt.anitrend.view.sheet.BottomSheetComposer)

Example 4 with MediaBase

use of com.mxt.anitrend.model.entity.base.MediaBase in project anitrend-app by AniTrend.

the class GroupSeriesListAdapter method getFilter.

@Override
public Filter getFilter() {
    return new Filter() {

        @Override
        protected FilterResults performFiltering(CharSequence constraint) {
            String filter = constraint.toString();
            if (filter.isEmpty()) {
                data = clone;
            } else {
                data = new ArrayList<>();
                for (EntityGroup model : clone) {
                    if (model instanceof MediaList) {
                        MediaBase mediaBase = ((MediaList) model).getMedia();
                        if (mediaBase.getTitle().getEnglish().toLowerCase(Locale.getDefault()).contains(filter) || mediaBase.getTitle().getRomaji().toLowerCase(Locale.getDefault()).contains(filter) || mediaBase.getTitle().getOriginal().toLowerCase(Locale.getDefault()).contains(filter))
                            data.add(model);
                    }
                }
            }
            FilterResults results = new FilterResults();
            results.values = data;
            return results;
        }

        @Override
        @SuppressWarnings("unchecked")
        protected void publishResults(CharSequence constraint, FilterResults results) {
            data = new ArrayList<>((List<EntityGroup>) results.values);
            notifyDataSetChanged();
        }
    };
}
Also used : MediaList(com.mxt.anitrend.model.entity.anilist.MediaList) Filter(android.widget.Filter) EntityGroup(com.mxt.anitrend.model.entity.group.EntityGroup) MediaList(com.mxt.anitrend.model.entity.anilist.MediaList) ArrayList(java.util.ArrayList) List(java.util.List) MediaBase(com.mxt.anitrend.model.entity.base.MediaBase)

Example 5 with MediaBase

use of com.mxt.anitrend.model.entity.base.MediaBase in project anitrend-app by AniTrend.

the class ReviewFragment method onItemClick.

/**
 * 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 click index
 */
@Override
public void onItemClick(View target, Review data) {
    Intent intent;
    switch(target.getId()) {
        case R.id.series_image:
            MediaBase mediaBase = data.getMedia();
            intent = new Intent(getActivity(), MediaActivity.class);
            intent.putExtra(KeyUtil.arg_id, mediaBase.getId());
            intent.putExtra(KeyUtil.arg_mediaType, mediaBase.getType());
            CompatUtil.startRevealAnim(getActivity(), target, intent);
            break;
        case R.id.user_avatar:
            if (getPresenter().getApplicationPref().isAuthenticated()) {
                intent = new Intent(getActivity(), ProfileActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.putExtra(KeyUtil.arg_id, data.getUser().getId());
                CompatUtil.startRevealAnim(getActivity(), target, intent);
            } else
                NotifyUtil.makeText(getActivity(), R.string.info_login_req, R.drawable.ic_warning_white_18dp, Toast.LENGTH_SHORT).show();
            break;
        case R.id.review_read_more:
            mBottomSheet = new BottomReviewReader.Builder().setReview(data).setTitle(R.string.drawer_title_reviews).build();
            showBottomSheet();
            break;
    }
}
Also used : ProfileActivity(com.mxt.anitrend.view.activity.detail.ProfileActivity) QueryContainerBuilder(com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder) Intent(android.content.Intent) MediaBase(com.mxt.anitrend.model.entity.base.MediaBase) MediaActivity(com.mxt.anitrend.view.activity.detail.MediaActivity)

Aggregations

MediaBase (com.mxt.anitrend.model.entity.base.MediaBase)8 Intent (android.content.Intent)5 QueryContainerBuilder (com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder)4 MediaActivity (com.mxt.anitrend.view.activity.detail.MediaActivity)4 EntityGroup (com.mxt.anitrend.model.entity.group.EntityGroup)3 ProfileActivity (com.mxt.anitrend.view.activity.detail.ProfileActivity)3 UserBase (com.mxt.anitrend.model.entity.base.UserBase)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 TextUtils (android.text.TextUtils)1 View (android.view.View)1 Filter (android.widget.Filter)1 Collectors (com.annimon.stream.Collectors)1 Stream (com.annimon.stream.Stream)1 GroupActorAdapter (com.mxt.anitrend.adapter.recycler.group.GroupActorAdapter)1 MediaList (com.mxt.anitrend.model.entity.anilist.MediaList)1 CharacterEdge (com.mxt.anitrend.model.entity.anilist.edge.CharacterEdge)1 MediaEdge (com.mxt.anitrend.model.entity.anilist.edge.MediaEdge)1