Search in sources :

Example 1 with EventContext

use of com.tmall.wireless.tangram3.eventbus.EventContext 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)

Aggregations

BusSupport (com.tmall.wireless.tangram3.eventbus.BusSupport)1 EventContext (com.tmall.wireless.tangram3.eventbus.EventContext)1 BannerListener (com.tmall.wireless.tangram3.ext.BannerListener)1 BannerCell (com.tmall.wireless.tangram3.structure.cell.BannerCell)1