Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we achieve different view types in this? #79

Closed
SkyTreasure opened this issue Oct 29, 2017 · 4 comments
Closed

How can we achieve different view types in this? #79

SkyTreasure opened this issue Oct 29, 2017 · 4 comments

Comments

@SkyTreasure
Copy link

I tried like this but my new view is null-

` slidePanel.setAdapter(new CardAdapter() {
@OverRide
public int getLayoutId(int index) {
if (dataList.get(index).imagePath == null) {
return R.layout.gads;
} else {
return R.layout.card_item;
}

        }

        @Override
        public int getCount() {
            return dataList.size();
        }

        @Override
        public void bindView(View view, int index) {
            if (dataList.get(index).imagePath == null) {
                AdViewHolder adViewHolder;
                adViewHolder = new AdViewHolder(view);
                AdRequest request = new AdRequest.Builder().build();
                if (adViewHolder.adView != null) {
                    adViewHolder.adView.loadAd(request);
                    adViewHolder.adView.setAdListener(new AdListener() {
                        @Override
                        public void onAdFailedToLoad(int i) {
                            super.onAdFailedToLoad(i);
                        }

                        @Override
                        public void onAdLeftApplication() {
                            super.onAdLeftApplication();
                        }

                        @Override
                        public void onAdLoaded() {
                            super.onAdLoaded();
                        }
                    });
                }

            } else {
                Object tag = view.getTag();
                ViewHolder viewHolder;
                if (null != tag) {
                    viewHolder = (ViewHolder) tag;
                } else {
                viewHolder = new ViewHolder(view);
                    view.setTag(viewHolder);
                }

                viewHolder.bindData(dataList.get(index));
            }

        }

        @Override
        public Object getItem(int index) {
            return dataList.get(index);
        }

        @Override
        public Rect obtainDraggableArea(View view) {
            // 可滑动区域定制,该函数只会调用一次
            View contentView = view.findViewById(R.id.card_item_content);
            View topLayout = view.findViewById(R.id.card_top_layout);
            View bottomLayout = view.findViewById(R.id.card_bottom_layout);
            int left = view.getLeft() + contentView.getPaddingLeft() + topLayout.getPaddingLeft();
            int right = view.getRight() - contentView.getPaddingRight() - topLayout.getPaddingRight();
            int top = view.getTop() + contentView.getPaddingTop() + topLayout.getPaddingTop();
            int bottom = view.getBottom() - contentView.getPaddingBottom() - bottomLayout.getPaddingBottom();
            return new Rect(left, top, right, bottom);
        }
    });`
@xmuSistone
Copy link
Owner

sorry that is not supported.

@bozzmob
Copy link

bozzmob commented Oct 30, 2017

@xmuSistone is there a way to achieve this? I want to have ads inside of card view.

@xmuSistone
Copy link
Owner

@bozzmob the underlying recycle logic does not support this. You may search other github repositories for help. Sorry for that.

@bozzmob
Copy link

bozzmob commented Oct 30, 2017

@xmuSistone Thanks a lot for the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants