Search in sources :

Example 1 with BannerSupport

use of com.tmall.wireless.tangram3.support.BannerSupport in project Tangram-Android by alibaba.

the class BannerView method onPageSelected.

@Override
public void onPageSelected(int position) {
    currentItemPos = mUltraViewPager.getCurrentItem();
    mIndicator.setCurrItem(currentItemPos);
    if (cell != null && cell.extras != null) {
        cell.extras.put(CURRENT_POS, currentItemPos);
    }
    if (bannerSupport != null) {
        for (int j = 0; j < bannerSupport.getListeners().size(); j++) {
            BannerListener listener = bannerSupport.getListeners().get(j);
            listener.onPageSelected(currentItemPos);
        }
    }
    if (cell != null && cell.serviceManager != null) {
        BusSupport busSupport = cell.serviceManager.getService(BusSupport.class);
        if (busSupport != null) {
            EventContext eventContext = new EventContext();
            if (((BannerCell) cell).mCells != null && currentItemPos >= 0 && currentItemPos < ((BannerCell) cell).mCells.size()) {
                eventContext.producer = ((BannerCell) cell).mCells.get(currentItemPos);
            }
            busSupport.post(BusSupport.obtainEvent(BusSupport.EVENT_ON_EXPOSURE, cell.id, null, eventContext));
        }
    }
    if (bannerSupport != null) {
        List<BannerListener> listeners = bannerSupport.getSelectedListenerById(cell.id);
        if (listeners != null) {
            for (int i = 0; i < listeners.size(); i++) {
                BannerListener listener = listeners.get(i);
                listener.onPageSelected(currentItemPos);
            }
        }
    }
}
Also used : EventContext(com.tmall.wireless.tangram3.eventbus.EventContext) BannerCell(com.tmall.wireless.tangram3.structure.cell.BannerCell) BannerListener(com.tmall.wireless.tangram3.ext.BannerListener) BusSupport(com.tmall.wireless.tangram3.eventbus.BusSupport)

Example 2 with BannerSupport

use of com.tmall.wireless.tangram3.support.BannerSupport in project Tangram-Android by alibaba.

the class BannerView method onPageScrolled.

@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    if (bannerSupport != null) {
        for (int j = 0; j < bannerSupport.getListeners().size(); j++) {
            BannerListener listener = bannerSupport.getListeners().get(j);
            listener.onPageScrolled(currentItemPos, positionOffset, positionOffsetPixels, direction);
        }
    }
    if (bannerSupport != null) {
        List<BannerListener> listeners = bannerSupport.getScrolledListenerById(cell.id);
        if (listeners != null) {
            for (int i = 0; i < listeners.size(); i++) {
                BannerListener listener = listeners.get(i);
                listener.onPageScrolled(currentItemPos, positionOffset, positionOffsetPixels, direction);
            }
        }
    }
}
Also used : BannerListener(com.tmall.wireless.tangram3.ext.BannerListener)

Example 3 with BannerSupport

use of com.tmall.wireless.tangram3.support.BannerSupport in project Tangram-Android by alibaba.

the class BannerView method onPageScrollStateChanged.

@Override
public void onPageScrollStateChanged(int state) {
    if (bannerSupport != null) {
        for (int j = 0; j < bannerSupport.getListeners().size(); j++) {
            BannerListener listener = bannerSupport.getListeners().get(j);
            listener.onPageScrollStateChanged(state);
        }
    }
    if (bannerSupport != null) {
        List<BannerListener> listeners = bannerSupport.getScrollStateChangedListenerById(cell.id);
        if (listeners != null) {
            for (int i = 0; i < listeners.size(); i++) {
                BannerListener listener = listeners.get(i);
                listener.onPageScrollStateChanged(state);
            }
        }
    }
}
Also used : BannerListener(com.tmall.wireless.tangram3.ext.BannerListener)

Example 4 with BannerSupport

use of com.tmall.wireless.tangram3.support.BannerSupport in project Tangram-Android by alibaba.

the class BannerView method postBindView.

@Override
public void postBindView(BaseCell cell) {
    getContext().registerReceiver(mScreenBroadcastReceiver, filter);
    BannerCell bannerCell = (BannerCell) cell;
    bannerCell.initAdapter();
    if (cell.style != null) {
        setPadding(cell.style.padding[3], cell.style.padding[0], cell.style.padding[1], cell.style.padding[2]);
    }
    setBackgroundColor(bannerCell.mBgColor);
    setAdapter(bannerCell.mBannerWrapper);
    mUltraViewPager.setAutoMeasureHeight(true);
    this.ratio = bannerCell.mRatio;
    this.height = bannerCell.height;
    mUltraViewPager.setRatio(this.ratio);
    setAutoScroll(bannerCell.mAutoScrollInternal, bannerCell.mSpecialInterval);
    mUltraViewPager.setPageMargin(bannerCell.hGap);
    if (bannerCell.mCells.size() <= bannerCell.mInfiniteMinCount) {
        setInfiniteLoop(false);
    } else {
        setInfiniteLoop(bannerCell.mInfinite);
    }
    setIndicatorGravity(getIndicatorGravity(bannerCell.mIndicatorGravity));
    setIndicatorPos(bannerCell.mIndicatorPos);
    int indicatorGap = bannerCell.mIndicatorGap;
    if (indicatorGap < 0) {
        indicatorGap = mIndicatorGap;
    }
    setIndicatorGap(indicatorGap);
    int indicatorMargin = bannerCell.mIndicatorMargin;
    if (indicatorMargin <= 0) {
        indicatorMargin = mIndicatorMargin;
    }
    setIndicatorMargin(indicatorMargin);
    int indicatorHeight = bannerCell.mIndicatorHeight;
    setIndicatorHeight(indicatorHeight);
    if (bannerCell.itemMargin[0] > 0 || bannerCell.itemMargin[1] > 0) {
        setScrollMargin(bannerCell.itemMargin[0], bannerCell.itemMargin[1]);
        mUltraViewPager.setClipToPadding(false);
        mUltraViewPager.setClipChildren(false);
    } else {
        setScrollMargin(0, 0);
        mUltraViewPager.setClipToPadding(true);
        mUltraViewPager.setClipChildren(true);
    }
    VirtualLayoutManager.LayoutParams layoutParams = (VirtualLayoutManager.LayoutParams) getLayoutParams();
    layoutParams.setMargins(bannerCell.margin[3], bannerCell.margin[0], bannerCell.margin[1], bannerCell.margin[2]);
    mUltraViewPager.setItemRatio(bannerCell.itemRatio);
    currentItemPos = bannerCell.extras.getIntValue(CURRENT_POS);
    mUltraViewPager.setCurrentItem(currentItemPos);
    updateIndicators(bannerCell.mIndicatorFocus, bannerCell.mIndicatorNor, bannerCell.mIndicatorRadius, bannerCell.mIndicatorColor, bannerCell.mIndicatorDefaultColor);
    recycleView();
    bindHeaderView(bannerCell.mHeader);
    bindFooterView(bannerCell.mFooter);
    if (cell.serviceManager != null) {
        bannerSupport = cell.serviceManager.getService(BannerSupport.class);
    }
}
Also used : BannerCell(com.tmall.wireless.tangram3.structure.cell.BannerCell) BannerSupport(com.tmall.wireless.tangram3.support.BannerSupport) VirtualLayoutManager(com.alibaba.android.vlayout.VirtualLayoutManager)

Example 5 with BannerSupport

use of com.tmall.wireless.tangram3.support.BannerSupport in project Tangram-Android by alibaba.

the class BaseTangramEngine method destroy.

/**
 * Call this when your activity is ready to destory to clear inner resource.
 */
public void destroy() {
    if (mContentView != null) {
        if (mGroupBasicAdapter != null) {
            mGroupBasicAdapter.destroy();
        }
        mContentView.setAdapter(null);
        mContentView = null;
    }
    TimerSupport timerSupport = getService(TimerSupport.class);
    if (timerSupport != null) {
        timerSupport.clear();
    }
    SimpleClickSupport simpleClickSupport = getService(SimpleClickSupport.class);
    if (simpleClickSupport != null) {
        simpleClickSupport.destroy();
    }
    ExposureSupport exposureSupport = getService(ExposureSupport.class);
    if (exposureSupport != null) {
        exposureSupport.destroy();
    }
    BusSupport busSupport = getService(BusSupport.class);
    if (busSupport != null) {
        busSupport.shutdown();
    }
    BannerSupport bannerSupport = getService(BannerSupport.class);
    if (bannerSupport != null) {
        bannerSupport.destroy();
    }
    MVHelper mvHelper = getService(MVHelper.class);
    if (mvHelper != null) {
        mvHelper.renderManager().destroyRenderService();
    }
}
Also used : ExposureSupport(com.tmall.wireless.tangram3.support.ExposureSupport) SimpleClickSupport(com.tmall.wireless.tangram3.support.SimpleClickSupport) TimerSupport(com.tmall.wireless.tangram3.support.TimerSupport) BusSupport(com.tmall.wireless.tangram3.eventbus.BusSupport) BannerSupport(com.tmall.wireless.tangram3.support.BannerSupport)

Aggregations

BannerListener (com.tmall.wireless.tangram3.ext.BannerListener)3 BusSupport (com.tmall.wireless.tangram3.eventbus.BusSupport)2 BannerCell (com.tmall.wireless.tangram3.structure.cell.BannerCell)2 BannerSupport (com.tmall.wireless.tangram3.support.BannerSupport)2 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)1 EventContext (com.tmall.wireless.tangram3.eventbus.EventContext)1 ExposureSupport (com.tmall.wireless.tangram3.support.ExposureSupport)1 SimpleClickSupport (com.tmall.wireless.tangram3.support.SimpleClickSupport)1 TimerSupport (com.tmall.wireless.tangram3.support.TimerSupport)1