Giter Site home page Giter Site logo

一点疑问 about ddcomponentforandroid HOT 8 CLOSED

luojilab avatar luojilab commented on August 16, 2024
一点疑问

from ddcomponentforandroid.

Comments (8)

mqzhangw avatar mqzhangw commented on August 16, 2024

谢谢~~
1、basiclib的确是放基础工具类的地方。但是设计资源的BaseActivity等类,建议放到basicres这个module中
2、library的module生成的R不是final的,所以不能用butterknife,这与组件化框架无关,android本身就没法这么用。建议改成dataBinding,感觉更方便

from ddcomponentforandroid.

weinierfei avatar weinierfei commented on August 16, 2024

回复的真快!我是不是可以这么理解: basiclib中是与业务无关的基础类, basicres中是与业务有关的公共资源?
第二个问题,咱们可能没说道一起,我的意思是说: butterknife现在本身是支持在library中使用的

from ddcomponentforandroid.

mqzhangw avatar mqzhangw commented on August 16, 2024

1、是这样的,basicres主要放一些theme等资源,以及BaseActivity等。
2、那我理解错了,如果butterknife本身在library中可以使用,那么框架也是支持的。框架做的事情就是在编译的时间增加一个任务分析,其本质上还是使用的compile project

from ddcomponentforandroid.

weinierfei avatar weinierfei commented on August 16, 2024

第二个应该需要框架插件适配支持才行,因为要在R文件与R2文件直接切换;
还有一个问题,我有些基础库需要初始化才能用,正常实在主app的baseApplication中初始化的,组件化后,我将这些库下沉到basiclib;然后我是要在每个组件用到的时候都初始化一下?

from ddcomponentforandroid.

leobert-lan avatar leobert-lan commented on August 16, 2024

以往butterknife不能在library-Module中用的,好像近期的版本进行了支持,可能问题会出现在runalone情况下,因为library-Module中使用R2类,APP-Module中使用R类,但都是写在注解中的,runalone时library-Module的角色变成了APP-Module。可以尝试一下,如果确实有问题的,我看看能不能写一套扩展对Butterknife进行更好的支持。 ps:我还是喜欢使用findviewbyid,尽管使用了遍历。

from ddcomponentforandroid.

mqzhangw avatar mqzhangw commented on August 16, 2024

@weinierfei 这个问题我后面研究一下,你可以暂时改为dataBinding。
初始化需要区分是集成调试还是单独调试,如果是集成,放在app的Application里面就可以了,如果是单独云运行,则需要在组件的runalone文件夹中创建组件自己的Application,并在这里面进行初始化。

from ddcomponentforandroid.

leobert-lan avatar leobert-lan commented on August 16, 2024

抽空尝试了一下,使用最新的butterknife(8.8.1)是可行的。对于app module,作为main Module,使用R或者R2类都不影响,对于其他的library 类型的Component,例如shareComponent,注意:layout资源依旧使用R类,id类、String类资源需要使用R2类(array、integer、anim、drawable等未测试)

layout资源如使用R2类则会抛出NotFound。
其他类型(如id)如使用R类则无法编译,需使用R2。

当shareComponent以runalone形式独立运行时,它本身将作为main module,使用R2也不会有问题。

测试代码我提交到了:feature/butterknife 分支,其中包含了Router的一些代码,可以忽略掉这部分。sample代码是将butterknife的集成测试代码直接移植过来的

如果发现有新问题的话,可以提出来一起研究下。


关于第二个问题,有这样一种情况:shareComponent集成了某sdk,需要初始化,但是在appModule中并没有集成该sdk,这时候可以将初始化的代码安排在ShareApplike#onCreate()中. 获取Application对象 以及 使用SubApplication中封装的业务 可以参考 issue 30issue 33

而该Component的独立运行可以按照mqzhangw所说,在相应的Application类中进行初始化。

from ddcomponentforandroid.

weinierfei avatar weinierfei commented on August 16, 2024

感谢耐心回复,我尝试一下,谢谢二位

from ddcomponentforandroid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.