Search in sources :

Example 1 with ImageAdapter

use of com.alibaba.weex.commons.adapter.ImageAdapter in project weex-example by KalicyZhou.

the class WXApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    /**
     * Set up for fresco usage.
     * Set<RequestListener> requestListeners = new HashSet<>();
     * requestListeners.add(new RequestLoggingListener());
     * ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
     *     .setRequestListeners(requestListeners)
     *     .build();
     * Fresco.initialize(this,config);
     **/
    //    initDebugEnvironment(true, false, "DEBUG_SERVER_HOST");
    WXSDKEngine.addCustomOptions("appName", "WXSample");
    WXSDKEngine.addCustomOptions("appGroup", "WXApp");
    WXSDKEngine.initialize(this, new InitConfig.Builder().setImgAdapter(new ImageAdapter()).setDebugAdapter(new PlayDebugAdapter()).setWebSocketAdapterFactory(new DefaultWebSocketAdapterFactory()).setJSExceptionAdapter(new JSExceptionAdapter()).build());
    try {
        Fresco.initialize(this);
        WXSDKEngine.registerComponent("synccomponent", WXComponentSyncTest.class);
        WXSDKEngine.registerComponent("richtext", RichText.class);
        WXSDKEngine.registerModule("render", RenderModule.class);
        WXSDKEngine.registerModule("event", WXEventModule.class);
        WXSDKEngine.registerModule("syncTest", SyncTestModule.class);
        WXSDKEngine.registerModule("myModule", MyModule.class);
        WXSDKEngine.registerModule("geolocation", GeolocationModule.class);
    /**
       * override default image tag
       * WXSDKEngine.registerComponent("image", FrescoImageComponent.class);
       */
    } catch (WXException e) {
        e.printStackTrace();
    }
    registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {

        @Override
        public void onActivityCreated(Activity activity, Bundle bundle) {
        }

        @Override
        public void onActivityStarted(Activity activity) {
        }

        @Override
        public void onActivityResumed(Activity activity) {
        }

        @Override
        public void onActivityPaused(Activity activity) {
        }

        @Override
        public void onActivityStopped(Activity activity) {
        }

        @Override
        public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
        }

        @Override
        public void onActivityDestroyed(Activity activity) {
            // The demo code of calling 'notifyTrimMemory()'
            if (false) {
                // We assume that the application is on an idle time.
                WXSDKManager.getInstance().notifyTrimMemory();
            }
        }
    });
}
Also used : DefaultWebSocketAdapterFactory(com.alibaba.weex.commons.adapter.DefaultWebSocketAdapterFactory) JSExceptionAdapter(com.alibaba.weex.commons.adapter.JSExceptionAdapter) ImageAdapter(com.alibaba.weex.commons.adapter.ImageAdapter) Bundle(android.os.Bundle) WXException(com.taobao.weex.common.WXException) Activity(android.app.Activity) PlayDebugAdapter(com.alibaba.weex.extend.PlayDebugAdapter)

Example 2 with ImageAdapter

use of com.alibaba.weex.commons.adapter.ImageAdapter in project weex-example by KalicyZhou.

the class BenchmarkActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    root = new LinearLayout(this);
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    root.setOrientation(LinearLayout.VERTICAL);
    root.setContentDescription(ROOT);
    setContentView(root);
    root.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            endTime = System.currentTimeMillis();
            Log.v(TAG, "End: " + endTime);
            if (perfStart && (perfEnd || !isWeex)) {
                perfStart = false;
                perfEnd = false;
                duration = (endTime - startTime);
                Log.v(TAG, "OnGlobalLayoutListener: " + getDuration());
            }
        }
    });
    WXEnvironment.isPerf = true;
    WXSDKEngine.addCustomOptions("appName", "WXSample");
    WXSDKEngine.addCustomOptions("appGroup", "WXApp");
    WXSDKEngine.initialize(getApplication(), new InitConfig.Builder().setImgAdapter(new ImageAdapter()).build());
}
Also used : ImageAdapter(com.alibaba.weex.commons.adapter.ImageAdapter) ViewGroup(android.view.ViewGroup) InitConfig(com.taobao.weex.InitConfig) ViewTreeObserver(android.view.ViewTreeObserver) LinearLayout(android.widget.LinearLayout)

Example 3 with ImageAdapter

use of com.alibaba.weex.commons.adapter.ImageAdapter in project weex-example by KalicyZhou.

the class WXApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    //    initDebugEnvironment(true, false, "DEBUG_SERVER_HOST");
    //    WXSDKEngine.addCustomOptions("appName", "WXSample");
    //    WXSDKEngine.addCustomOptions("appGroup", "WXApp");
    WXSDKEngine.initialize(this, new InitConfig.Builder().setImgAdapter(new ImageAdapter()).setURIAdapter(new CustomURIAdapter()).build());
    try {
        WXSDKEngine.registerModule("event", WXEventModule.class);
        WXSDKEngine.registerModule("service", WXServiceModule.class);
    } catch (WXException e) {
        e.printStackTrace();
    }
    Fresco.initialize(this);
    AppConfig.init(this);
    PluginManager.init(this);
}
Also used : CustomURIAdapter(com.alibaba.weex.commons.adapter.CustomURIAdapter) ImageAdapter(com.alibaba.weex.commons.adapter.ImageAdapter) WXException(com.taobao.weex.common.WXException)

Aggregations

ImageAdapter (com.alibaba.weex.commons.adapter.ImageAdapter)3 WXException (com.taobao.weex.common.WXException)2 Activity (android.app.Activity)1 Bundle (android.os.Bundle)1 ViewGroup (android.view.ViewGroup)1 ViewTreeObserver (android.view.ViewTreeObserver)1 LinearLayout (android.widget.LinearLayout)1 CustomURIAdapter (com.alibaba.weex.commons.adapter.CustomURIAdapter)1 DefaultWebSocketAdapterFactory (com.alibaba.weex.commons.adapter.DefaultWebSocketAdapterFactory)1 JSExceptionAdapter (com.alibaba.weex.commons.adapter.JSExceptionAdapter)1 PlayDebugAdapter (com.alibaba.weex.extend.PlayDebugAdapter)1 InitConfig (com.taobao.weex.InitConfig)1