Search in sources :

Example 1 with ClickProcessorImpl

use of com.tmall.wireless.virtualviewdemo.custom.ClickProcessorImpl in project Virtualview-Android by alibaba.

the class LocalPreviewActivity method initForPreview.

private void initForPreview() {
    if (mVafContext == null) {
        mVafContext = new VafContext(this);
        mVafContext.setImageLoaderAdapter(new IImageLoaderAdapter() {

            private List<ImageTarget> cache = new ArrayList<ImageTarget>();

            @Override
            public void bindImage(String uri, final ImageBase imageBase, int reqWidth, int reqHeight) {
                RequestCreator requestCreator = Picasso.with(LocalPreviewActivity.this).load(uri);
                Log.d("LocalPreviewActivity", "bindImage request width height " + reqHeight + " " + reqWidth);
                if (reqHeight > 0 || reqWidth > 0) {
                    requestCreator.resize(reqWidth, reqHeight);
                }
                ImageTarget imageTarget = new ImageTarget(imageBase);
                cache.add(imageTarget);
                requestCreator.into(imageTarget);
            }

            @Override
            public void getBitmap(String uri, int reqWidth, int reqHeight, final Listener lis) {
                RequestCreator requestCreator = Picasso.with(LocalPreviewActivity.this).load(uri);
                Log.d("LocalPreviewActivity", "getBitmap request width height " + reqHeight + " " + reqWidth);
                if (reqHeight > 0 || reqWidth > 0) {
                    requestCreator.resize(reqWidth, reqHeight);
                }
                ImageTarget imageTarget = new ImageTarget(lis);
                cache.add(imageTarget);
                requestCreator.into(imageTarget);
            }
        });
        mViewManager = mVafContext.getViewManager();
        mViewManager.init(this.getApplicationContext());
        mVafContext.getEventManager().register(EventManager.TYPE_Click, new ClickProcessorImpl());
        mVafContext.getEventManager().register(EventManager.TYPE_Exposure, new ExposureProcessorImpl());
    }
}
Also used : Listener(com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.Listener) ArrayList(java.util.ArrayList) RequestCreator(com.squareup.picasso.RequestCreator) VafContext(com.tmall.wireless.vaf.framework.VafContext) IImageLoaderAdapter(com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.IImageLoaderAdapter) ClickProcessorImpl(com.tmall.wireless.virtualviewdemo.custom.ClickProcessorImpl) ExposureProcessorImpl(com.tmall.wireless.virtualviewdemo.custom.ExposureProcessorImpl) ImageBase(com.tmall.wireless.vaf.virtualview.view.image.ImageBase)

Example 2 with ClickProcessorImpl

use of com.tmall.wireless.virtualviewdemo.custom.ClickProcessorImpl in project Virtualview-Android by alibaba.

the class VirtualViewApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    if (sVafContext == null) {
        // VVFeatureConfig.setSliderCompat(true);
        Picasso.setSingletonInstance(new Picasso.Builder(this).loggingEnabled(true).build());
        sVafContext = new VafContext(this.getApplicationContext());
        sVafContext.setImageLoaderAdapter(new IImageLoaderAdapter() {

            private List<ImageTarget> cache = new ArrayList<ImageTarget>();

            @Override
            public void bindImage(String uri, final ImageBase imageBase, int reqWidth, int reqHeight) {
                RequestCreator requestCreator = Picasso.with(VirtualViewApplication.this).load(uri);
                Log.d("VirtualViewApplication", "bindImage request width height " + reqHeight + " " + reqWidth);
                if (reqHeight > 0 || reqWidth > 0) {
                    requestCreator.resize(reqWidth, reqHeight);
                }
                ImageTarget imageTarget = new ImageTarget(imageBase);
                cache.add(imageTarget);
                requestCreator.into(imageTarget);
            }

            @Override
            public void getBitmap(String uri, int reqWidth, int reqHeight, final Listener lis) {
                RequestCreator requestCreator = Picasso.with(VirtualViewApplication.this).load(uri);
                Log.d("VirtualViewApplication", "getBitmap request width height " + reqHeight + " " + reqWidth);
                if (reqHeight > 0 || reqWidth > 0) {
                    requestCreator.resize(reqWidth, reqHeight);
                }
                ImageTarget imageTarget = new ImageTarget(lis);
                cache.add(imageTarget);
                requestCreator.into(imageTarget);
            }
        });
        sViewManager = sVafContext.getViewManager();
        sViewManager.init(this.getApplicationContext());
        sViewManager.loadBinBufferSync(NTEXT.BIN);
        sViewManager.loadBinBufferSync(VTEXT.BIN);
        sViewManager.loadBinBufferSync(NIMAGE.BIN);
        sViewManager.loadBinBufferSync(VIMAGE.BIN);
        sViewManager.loadBinBufferSync(VLINE.BIN);
        sViewManager.loadBinBufferSync(NLINE.BIN);
        sViewManager.loadBinBufferSync(PROGRESS.BIN);
        sViewManager.loadBinBufferSync(VGRAPH.BIN);
        sViewManager.loadBinBufferSync(PAGE.BIN);
        sViewManager.loadBinBufferSync(PAGEITEM.BIN);
        sViewManager.loadBinBufferSync(PAGESCROLLSCRIPT.BIN);
        sViewManager.loadBinBufferSync(SLIDER.BIN);
        sViewManager.loadBinBufferSync(SLIDERITEM.BIN);
        sViewManager.loadBinBufferSync(FRAMELAYOUT.BIN);
        sViewManager.loadBinBufferSync(RATIOLAYOUT.BIN);
        sViewManager.loadBinBufferSync(GRIDLAYOUT.BIN);
        sViewManager.loadBinBufferSync(GRID.BIN);
        sViewManager.loadBinBufferSync(GRIDITEM.BIN);
        sViewManager.loadBinBufferSync(VHLAYOUT.BIN);
        sViewManager.loadBinBufferSync(VH2LAYOUT.BIN);
        sViewManager.loadBinBufferSync(VH.BIN);
        sViewManager.loadBinBufferSync(SCROLLERVL.BIN);
        sViewManager.loadBinBufferSync(SCROLLERVS.BIN);
        sViewManager.loadBinBufferSync(SCROLLERH.BIN);
        sViewManager.loadBinBufferSync(TOTALCONTAINER.BIN);
        sViewManager.loadBinBufferSync(NFRAMELAYOUT.BIN);
        sViewManager.loadBinBufferSync(NGRIDLAYOUT.BIN);
        sViewManager.loadBinBufferSync(NRATIOLAYOUT.BIN);
        sViewManager.loadBinBufferSync(NVHLAYOUT.BIN);
        sViewManager.loadBinBufferSync(NVH2LAYOUT.BIN);
        sViewManager.loadBinBufferSync(CLICKSCRIPT.BIN);
        sViewManager.loadBinBufferSync(TMALLCOMPONENT1.BIN);
        sViewManager.loadBinBufferSync(TMALLCOMPONENT2.BIN);
        sViewManager.loadBinBufferSync(TMALLCOMPONENT3.BIN);
        sViewManager.loadBinBufferSync(TMALLCOMPONENT4.BIN);
        sViewManager.loadBinBufferSync(TMALLCOMPONENT5.BIN);
        sViewManager.loadBinBufferSync(TMALLCOMPONENT6.BIN);
        sViewManager.loadBinBufferSync(TMALLCOMPONENT7.BIN);
        sViewManager.loadBinBufferSync(TMALLCOMPONENT8.BIN);
        sViewManager.loadBinBufferSync(PICASSO.BIN);
        sViewManager.getViewFactory().registerBuilder(BizCommon.TM_TOTAL_CONTAINER, new TotalContainer.Builder());
        sViewManager.getViewFactory().registerBuilder(1014, new PicassoImage.Builder());
        sVafContext.getCompactNativeManager().register("TMTags", TMReminderTagsView.class);
        sVafContext.getEventManager().register(EventManager.TYPE_Click, new ClickProcessorImpl());
        sVafContext.getEventManager().register(EventManager.TYPE_Exposure, new ExposureProcessorImpl());
    }
}
Also used : Listener(com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.Listener) ArrayList(java.util.ArrayList) RequestCreator(com.squareup.picasso.RequestCreator) VafContext(com.tmall.wireless.vaf.framework.VafContext) IImageLoaderAdapter(com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.IImageLoaderAdapter) TotalContainer(com.tmall.wireless.virtualviewdemo.custom.TotalContainer) ClickProcessorImpl(com.tmall.wireless.virtualviewdemo.custom.ClickProcessorImpl) Picasso(com.squareup.picasso.Picasso) PicassoImage(com.tmall.wireless.virtualviewdemo.custom.PicassoImage) ExposureProcessorImpl(com.tmall.wireless.virtualviewdemo.custom.ExposureProcessorImpl) ImageBase(com.tmall.wireless.vaf.virtualview.view.image.ImageBase)

Aggregations

RequestCreator (com.squareup.picasso.RequestCreator)2 VafContext (com.tmall.wireless.vaf.framework.VafContext)2 IImageLoaderAdapter (com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.IImageLoaderAdapter)2 Listener (com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.Listener)2 ImageBase (com.tmall.wireless.vaf.virtualview.view.image.ImageBase)2 ClickProcessorImpl (com.tmall.wireless.virtualviewdemo.custom.ClickProcessorImpl)2 ExposureProcessorImpl (com.tmall.wireless.virtualviewdemo.custom.ExposureProcessorImpl)2 ArrayList (java.util.ArrayList)2 Picasso (com.squareup.picasso.Picasso)1 PicassoImage (com.tmall.wireless.virtualviewdemo.custom.PicassoImage)1 TotalContainer (com.tmall.wireless.virtualviewdemo.custom.TotalContainer)1