An Android Studio plugin to help remove use of ButterKnife
Why i do this
ButterKnife is a wellknow open source tool to help you inject your view, but some times, you use plugin to gen butterknife's code, but you don't want to use it again.
It's a very horrible job to delete every line inject code and write findviewbyid code, so, i made this plugin to do it.
How to use it
(You can search it on your AS plugin install page, name is RemoveButterKnife)
1.Clone the code and build it in your idea
2.Then, you can find a jar, install it as a plugin in your AndroidStudio**(You also can find the jar in the project)**
3.Open your Activity/Fragment you want to change.
4.Find the RemoveButterKnife button in your android studio edit menu
The idea of how to design and implement it
You can see this blog
License
See the LICENSE file for license rights and limitations(GNU3.0)
NextStep
On the way
RemoveButterKnife What's the pluginAn Android Studio plugin to help remove use of ButterKnifeWhy i do thisButterKnife is a wellknow open source tool to help you inject your view, but some times, you u...
ButterKnife
是一个专注于
Android
系统的View注入框架,以前总是要写很多findViewById来找到View对象,有了
ButterKnife
可以很轻松的省去这些步骤。
2.配置Butter Knife
(1) 工程根目录外层的build.gradle:
添加:classpath 'com.jakewharton:but...
Reomve
ButterKnife
插
件
这是一个用于
移
除代码中对
ButterKnife
使用
的AS
插
件,接下来我们将从头开始讲讲AS
插
件开发和这个
插
件的开发过程
地址是Remove
ButterKnife
什么是
Android
Studio
插
件
相信能开始阅读这篇文章的朋友都是从事,或者有兴趣从事
Android
开发的,那么,我们现在最常用的开发工具无疑就是
Android
Studio
了。
那么,什么又是...
ButterKnife
这个第三方
库
每次更新之后,绑定view的注解都会改变,从bind,到inject,再到bindview,搞得很多人都不敢升级,一旦升级,就会有巨量的代码需要手动修改,非常痛苦
当我们有一些非常棒的代码需要拿到其他项目
使用
,但是我们发现,那个项目对第三方
库
的
使用
是有限制的,我们不能
使用
butterknife
,这时候,我们又得从注解改回findviewbyid
针对上面的两种
above all can use in Activity/Fragment/Adapter
how to use
(You can search it on your AS plugin install page, name is Remove
ButterKnife
)
1.Clone the code and build it in your idea
2.Then, you can find a jar, install it as a plugin in your
Android
Studio
**(You also can find the jar in the p
经过项目的初步编写和进一步改造,Remove
ButterKnife
插
件终于也有模有样了,但是,功能上仅仅支持Activity/Fragment的BindView注解。
关于编写和优化的过程可以看下面两篇文章
项目构造Remove
ButterKnife
项目改进-重构Remove
ButterKnife
当然,这里也附上这个项目的github地址
为了让
插
件支持更加彻底,我们还要支持组合自定义v...
如上图所示R.class中参数定义
使用
了final关键字, 即R.class里全部是常量; 而R2.class里全部是变量。
PS:Java语言在编译时常量内联, 即
使用
常量值替换参数;
Java 注解的属性和 switch-case 中的 case 表达式,必须
使用
常量或者值,否则会报语法错误。