Search in sources :

Example 1 with VafContext

use of com.tmall.wireless.vaf.framework.VafContext in project Tangram-Android by alibaba.

the class MVHelper method mountView.

public void mountView(BaseCell cell, View view) {
    try {
        mvResolver.register(getCellUniqueId(cell), cell, view);
        if (cell.serviceManager != null) {
            CellSupport cellSupport = cell.serviceManager.getService(CellSupport.class);
            if (cellSupport != null) {
                cellSupport.bindView(cell, view);
            }
        }
        if (view instanceof IContainer) {
            ViewBase vb = ((IContainer) view).getVirtualView();
            vb.setVData(cell.extras);
            if (vb.supportExposure()) {
                VafContext context = cell.serviceManager.getService(VafContext.class);
                context.getEventManager().emitEvent(EventManager.TYPE_Exposure, EventData.obtainData(context, vb));
            }
            renderStyle(cell, view);
        } else {
            loadMethod(cell, view);
            initView(cell, view);
            renderView(cell, view);
            renderStyle(cell, view);
        }
        if (resolver().isCompatibleType(cell.stringType)) {
            resolver().getCellClass(cell.stringType).cast(cell).bindView(view);
        }
        postMountView(cell, view);
        if (cell.serviceManager != null) {
            CellSupport cellSupport = cell.serviceManager.getService(CellSupport.class);
            if (cellSupport != null) {
                cellSupport.postBindView(cell, view);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        if (cell.serviceManager != null) {
            CellSupport cellSupport = cell.serviceManager.getService(CellSupport.class);
            if (cellSupport != null) {
                cellSupport.onBindViewException(cell, view, e);
            }
        }
    }
}
Also used : CellSupport(com.tmall.wireless.tangram.support.CellSupport) VafContext(com.tmall.wireless.vaf.framework.VafContext) IContainer(com.tmall.wireless.vaf.virtualview.core.IContainer) ViewBase(com.tmall.wireless.vaf.virtualview.core.ViewBase)

Example 2 with VafContext

use of com.tmall.wireless.vaf.framework.VafContext 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();
    }
    BusSupport busSupport = getService(BusSupport.class);
    if (busSupport != null) {
        busSupport.shutdown();
    }
    VafContext vafContext = getService(VafContext.class);
    if (vafContext != null) {
        vafContext.onDestroy();
    }
}
Also used : VafContext(com.tmall.wireless.vaf.framework.VafContext) TimerSupport(com.tmall.wireless.tangram.support.TimerSupport) BusSupport(com.tmall.wireless.tangram.eventbus.BusSupport)

Aggregations

VafContext (com.tmall.wireless.vaf.framework.VafContext)2 BusSupport (com.tmall.wireless.tangram.eventbus.BusSupport)1 CellSupport (com.tmall.wireless.tangram.support.CellSupport)1 TimerSupport (com.tmall.wireless.tangram.support.TimerSupport)1 IContainer (com.tmall.wireless.vaf.virtualview.core.IContainer)1 ViewBase (com.tmall.wireless.vaf.virtualview.core.ViewBase)1