Search in sources :

Example 1 with HorizontalImageAdapter

use of me.zhanghai.android.douya.ui.HorizontalImageAdapter in project Douya by DreaminginCodeZH.

the class BaseItemDataAdapter method bindPhotoListHolder.

protected void bindPhotoListHolder(RecyclerView.ViewHolder holder, T item, List<Photo> photoList, boolean excludeFirstPhoto) {
    PhotoListHolder photoListHolder = (PhotoListHolder) holder;
    List<Photo> originalPhotoList = photoList;
    if (excludeFirstPhoto) {
        photoList = photoList.subList(1, photoList.size());
    }
    ViewUtils.setVisibleOrGone(photoListHolder.photoList, !photoList.isEmpty());
    HorizontalImageAdapter adapter = (HorizontalImageAdapter) photoListHolder.photoList.getAdapter();
    adapter.replace(photoList);
    Context context = RecyclerViewUtils.getContext(holder);
    adapter.setOnItemClickListener((parent, itemView, item_, photoPosition) -> {
        if (excludeFirstPhoto) {
            ++photoPosition;
        }
        // TODO: Use PhotoAlbumGalleryActivity instead.
        context.startActivity(GalleryActivity.makeImageListIntent(originalPhotoList, photoPosition, context));
    });
    photoListHolder.viewMoreButton.setOnClickListener(view -> {
        // TODO
        UriHandler.open(item.url + "photos", context);
    });
}
Also used : Context(android.content.Context) HorizontalImageAdapter(me.zhanghai.android.douya.ui.HorizontalImageAdapter) Photo(me.zhanghai.android.douya.network.api.info.frodo.Photo)

Example 2 with HorizontalImageAdapter

use of me.zhanghai.android.douya.ui.HorizontalImageAdapter in project Douya by DreaminginCodeZH.

the class BroadcastLayout method init.

private void init() {
    setOrientation(VERTICAL);
    ViewUtils.inflateInto(R.layout.broadcast_layout, this);
    ButterKnife.bind(this);
    ViewCompat.setBackground(mImageListDescriptionLayout, DrawableUtils.makeScrimDrawable());
    mImageList.setHasFixedSize(true);
    mImageList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
    mImageList.addItemDecoration(new DividerItemDecoration(DividerItemDecoration.HORIZONTAL, R.drawable.transparent_divider_vertical_2dp, getContext()));
    mImageListAdapter = new HorizontalImageAdapter();
    mImageList.setAdapter(mImageListAdapter);
    mImageList.addOnScrollListener(new OnHorizontalScrollListener() {

        private boolean mShowingDescription = true;

        @Override
        public void onScrolledLeft() {
            if (!mShowingDescription) {
                mShowingDescription = true;
                ViewUtils.fadeIn(mImageListDescriptionLayout);
            }
        }

        @Override
        public void onScrolledRight() {
            if (mShowingDescription) {
                mShowingDescription = false;
                ViewUtils.fadeOut(mImageListDescriptionLayout);
            }
        }
    });
    ViewUtils.setTextViewLinkClickable(mTextText);
    ViewUtils.setTextViewLinkClickable(mRebroadcastedTextText);
    TooltipUtils.setup(mLikeButton);
    TooltipUtils.setup(mCommentButton);
// Handled by the OnLongClickListener set in bind().
// TooltipUtils.setup(mRebroadcastButton);
}
Also used : HorizontalImageAdapter(me.zhanghai.android.douya.ui.HorizontalImageAdapter) OnHorizontalScrollListener(me.zhanghai.android.douya.ui.OnHorizontalScrollListener) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(me.zhanghai.android.douya.ui.DividerItemDecoration)

Example 3 with HorizontalImageAdapter

use of me.zhanghai.android.douya.ui.HorizontalImageAdapter in project Douya by DreaminginCodeZH.

the class BaseItemDataAdapter method createPhotoListHolder.

protected PhotoListHolder createPhotoListHolder(ViewGroup parent) {
    PhotoListHolder holder = new PhotoListHolder(ViewUtils.inflate(R.layout.item_fragment_photo_list, parent));
    holder.photoList.setHasFixedSize(true);
    holder.photoList.setLayoutManager(new LinearLayoutManager(parent.getContext(), LinearLayoutManager.HORIZONTAL, false));
    holder.photoList.addItemDecoration(new DividerItemDecoration(DividerItemDecoration.HORIZONTAL, R.drawable.transparent_divider_vertical_4dp, holder.photoList.getContext()));
    holder.photoList.setAdapter(new HorizontalImageAdapter());
    return holder;
}
Also used : HorizontalImageAdapter(me.zhanghai.android.douya.ui.HorizontalImageAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(me.zhanghai.android.douya.ui.DividerItemDecoration)

Aggregations

HorizontalImageAdapter (me.zhanghai.android.douya.ui.HorizontalImageAdapter)3 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 DividerItemDecoration (me.zhanghai.android.douya.ui.DividerItemDecoration)2 Context (android.content.Context)1 Photo (me.zhanghai.android.douya.network.api.info.frodo.Photo)1 OnHorizontalScrollListener (me.zhanghai.android.douya.ui.OnHorizontalScrollListener)1