com.taobao.weex.InitConfig Java Examples

The following examples show how to use com.taobao.weex.InitConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WXApplication.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();
  initDebugEnvironment(false, "DEBUG_SERVER_HOST");
  WXSDKEngine.addCustomOptions("appName", "WXSample");
  WXSDKEngine.addCustomOptions("appGroup", "WXApp");
  WXSDKEngine.initialize(this,
                         new InitConfig.Builder()
                             .setImgAdapter(new ImageAdapter())
                             .setDebugAdapter(new PlayDebugAdapter())
                             .build()
                        );

  try {
    Fresco.initialize(this);
    WXSDKEngine.registerComponent("richtext", RichText.class);
    WXSDKEngine.registerModule("render", RenderModule.class);
    WXSDKEngine.registerModule("event", WXEventModule.class);

    WXSDKEngine.registerModule("myModule", MyModule.class);

  } catch (WXException e) {
    e.printStackTrace();
  }

}
 
Example #2
Source File: WXApplication.java    From WeexOne with MIT License 6 votes vote down vote up
@Override
  public void onCreate() {
    super.onCreate();
//    initDebugEnvironment(false, "DEBUG_SERVER_HOST");
    WXSDKEngine.addCustomOptions("appName", "WXSample");
    WXSDKEngine.addCustomOptions("appGroup", "WXApp");
    WXSDKEngine.initialize(this,
        new InitConfig.Builder()
            .setImgAdapter(new ImageAdapter())
            .build()
    );

    Fresco.initialize(this);
    AppConfig.init(this);
    ExtensionManager.registerComponents(AppConfig.getComponents());
    ExtensionManager.registerModules(AppConfig.getModules());

  }
 
Example #3
Source File: App.java    From CrazyDaily with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化Weex
 */
private void initWeex() {
    InitConfig config = new InitConfig.Builder()
            .setImgAdapter(new WXImageAdapter())
            .setHttpAdapter(new WXHttpAdapter(mAppComponent.provideOkhttpClient()))
            .build();
    WXSDKEngine.initialize(this, config);
    try {
        WXSDKEngine.registerComponent("tabPager", WXTabPagerComponent.class);
        WXSDKEngine.registerComponent(WXBasicComponentType.WEB, WXWebComponent.class);
        WXSDKEngine.registerModule("crazyDaily", CrazyDailyModule.class);
        WXSDKEngine.registerModule("webview", WXWebViewModule.class, true);
        WXSDKEngine.registerModule("log", LogModule.class);
    } catch (WXException e) {
        LoggerUtil.d(e.getMessage());
    }
}
 
Example #4
Source File: UWXInit.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public static void init(Application context) {
        UWXSDKManager.initialize(context);
//        WXSDKEngine.addCustomOptions("scheme", "portal");
//        WXSDKEngine.addCustomOptions(WXConfig.appGroup, "portal");
//        WXSDKEngine.addCustomOptions(WXConfig.appName, "portal");
        WXSDKEngine.initialize(context,
                new InitConfig.Builder()
                        .setImgAdapter(new FrescoImageAdapter())
                        .setJSExceptionAdapter(new JSExceptionAdapter())
                        .setDebugAdapter(new DebugAdapter())
                        .build()
        );
        try {
            WXSDKEngine.registerModule("UNavigator", UWXNavigatorModule.class);
            WXSDKEngine.registerModule("UScheme", UWXSchemeModule.class);
            WXSDKEngine.registerModule("UGlobalEvent", UWXGlobalEventModule.class);
            WXSDKEngine.registerModule("navigator", UWXNavigatorModule2.class);
        } catch (WXException e) {
            e.printStackTrace();
        }
        Fresco.initialize(context);
    }
 
Example #5
Source File: WXApplication.java    From yanxuan-weex-demo with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();
  WXSDKEngine.addCustomOptions("appName", "WXSample");
  WXSDKEngine.addCustomOptions("appGroup", "WXApp");
  WXSDKEngine.initialize(this,
      new InitConfig.Builder().setImgAdapter(new ImageAdapter()).build()
  );
  try {
    WXSDKEngine.registerModule("event", WXEventModule.class);
  } catch (WXException e) {
    e.printStackTrace();
  }
  AppConfig.init(this);
  WeexPluginContainer.loadAll(this);
}
 
Example #6
Source File: WXDomStatementTest.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build());
  ShadowLooper looper = WXBridgeManagerTest.getLooper();
  looper.idle();
  ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
  instance = WXSDKInstanceTest.createInstance();
  rednerManager = new WXRenderManager();
  rednerManager.registerInstance(instance);//
  WXSDKManagerTest.setRenderManager(rednerManager);
  stmt = new DOMActionContextImpl(instance.getInstanceId(),rednerManager );
}
 
Example #7
Source File: WXDomStatementTest.java    From weex-uikit with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build());
  ShadowLooper looper = WXBridgeManagerTest.getLooper();
  looper.idle();
  ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
  instance = WXSDKInstanceTest.createInstance();
  rednerManager = new WXRenderManager();
  rednerManager.registerInstance(instance);//
  stmt = new WXDomStatement(instance.getInstanceId(),rednerManager );
}
 
Example #8
Source File: WXModuleManagerTest.java    From weex-uikit with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build());
  instance = WXSDKInstanceTest.createInstance();
  WXModuleManager.registerModule("test",null,false);
  WXModuleManager.registerModule("test1",new TypeModuleFactory<>(TestModule.class),true);
  WXModuleManager.registerModule("test2",new TypeModuleFactory<>(TestModule.class),false);
  WXBridgeManagerTest.getLooper().idle();
}
 
Example #9
Source File: WXTimerModuleTest.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
  WXSDKEngine.initialize(RuntimeEnvironment.application, new InitConfig.Builder().build());
  WXBridgeManager bridge = Mockito.mock(WXBridgeManager.class);
  when(bridge.getJSLooper()).thenReturn(new WXThread("js").getLooper());
  WXBridgeManagerTest.setBridgeManager(bridge);

  module = Mockito.spy(new WXTimerModule());
  module.mWXSDKInstance = WXSDKInstanceTest.createInstance();
  Handler handler = new Handler(WXBridgeManager.getInstance().getJSLooper(), module);
  mLooper = Shadows.shadowOf(handler.getLooper());
  module.setHandler(handler);
}
 
Example #10
Source File: WXBridgeManagerTest.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build());
  instance = WXSDKInstanceTest.createInstance();
  WXRenderManager rednerManager = new WXRenderManager();
  rednerManager.registerInstance(instance);//
  WXSDKManagerTest.setRenderManager(rednerManager);
}
 
Example #11
Source File: WXModuleManagerTest.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build());
  instance = WXSDKInstanceTest.createInstance();
  WXModuleManager.registerModule("test",null,false);
  WXModuleManager.registerModule("test1",new TypeModuleFactory<>(TestModule.class),true);
  WXModuleManager.registerModule("test2",new TypeModuleFactory<>(TestModule.class),false);
  WXBridgeManagerTest.getLooper().idle();
}
 
Example #12
Source File: BenchmarkActivity.java    From incubator-weex-playground with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #13
Source File: InitWeexTask.java    From android-performance with MIT License 4 votes vote down vote up
@Override
public void run() {

    InitConfig config = new InitConfig.Builder().build();
    WXSDKEngine.initialize((Application) mContext, config);
}
 
Example #14
Source File: WXApplication.java    From weex-uikit with MIT License 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    InitConfig config=new InitConfig.Builder().setImgAdapter(new ImageAdapter()).build();
    WXSDKEngine.initialize(this,config);
}
 
Example #15
Source File: InitHelper.java    From AndroidAll with Apache License 2.0 4 votes vote down vote up
public static void initWeex(Context context) {
    InitConfig config = new InitConfig.Builder().build();
    WXSDKEngine.initialize((Application) context.getApplicationContext(), config);
}
 
Example #16
Source File: WXApplication.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
@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(false, "DEBUG_SERVER_HOST");
    WXSDKEngine.addCustomOptions("appName", "WXSample");
    WXSDKEngine.addCustomOptions("appGroup", "WXApp");
    WXSDKEngine.initialize(this,
                           new InitConfig.Builder()
                               //.setImgAdapter(new FrescoImageAdapter())// use fresco adapter
                               .setImgAdapter(new ImageAdapter())
                               .setDebugAdapter(new PlayDebugAdapter())
                               .build()
                          );

    try {
      Fresco.initialize(this);
      WXSDKEngine.registerComponent("richtext", RichText.class);
      WXSDKEngine.registerModule("render", RenderModule.class);
      WXSDKEngine.registerModule("event", WXEventModule.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();
    }

  }
 
Example #17
Source File: PerformanceApp.java    From android-performance with MIT License 4 votes vote down vote up
private void initWeex() {
    InitConfig config = new InitConfig.Builder().build();
    WXSDKEngine.initialize(this, config);
}