All Projects → ParfoisMeng → Android-ButterKnife-Injections

ParfoisMeng / Android-ButterKnife-Injections

Licence: Apache-2.0 License
Android-ButterKnife-Injections (Support Kotlin)。支持Kotlin,可选初始化,可选R/R2。

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Android-ButterKnife-Injections

Android-Starter-Kit
This is up-to-date android studio project for native android application, that is using modern tools and libraries.
Stars: ✭ 16 (-75.76%)
Mutual labels:  butterknife
BakingApp
Udacity Android Developer Nanodegree, project 2.
Stars: ✭ 54 (-18.18%)
Mutual labels:  butterknife
Weather-Guru-MVP
Sample Material-design Android weather application build with MVP architectural approach using Dagger2, RxJava2, Retrofit2, Event-Bus, GreenDao, Butterknife, Lottie etc.
Stars: ✭ 15 (-77.27%)
Mutual labels:  butterknife
AndroidStarterAlt
A sample View-based Android app using the MVP architecture. It uses Mosby, Dagger2, RxJava, retrofit, LoganSquare, requery, EventBus, Conductor.
Stars: ✭ 27 (-59.09%)
Mutual labels:  butterknife
OLA Play Music App
Music Streaming App
Stars: ✭ 27 (-59.09%)
Mutual labels:  butterknife
SilverScreener
A feature-rich movie guide app, that lets you discover movies from TMDb.
Stars: ✭ 24 (-63.64%)
Mutual labels:  butterknife
Android Dagger Butterknife Mvp
Simple application using Dagger Android (2.11-2.17), Butterknife (8.7-8.8), and Model-View-Presenter (MVP) with support for Singleton, Activity, Fragment, and child Fragment scopes written in Java and Kotlin
Stars: ✭ 219 (+231.82%)
Mutual labels:  butterknife
GooglePlay2
GooglePlay2.0,基本修复所有bug,应用市场,一款应用下载软件,框架式编程,使用ButterKnife,okHttp网络请求,glide图片加载,联动ToolBar。
Stars: ✭ 20 (-69.7%)
Mutual labels:  butterknife
MVPHulk
Android MVP 快速集成方案 (支持AndroidX)
Stars: ✭ 19 (-71.21%)
Mutual labels:  butterknife
situp android proj
🚀一个基组件化、模块化、MVP + MVVM 计划 App,兼容安卓 10.0 9.0 8.0 等 🔥a app like keep, you can edit your plans here, and you can share your life to others by post, too.🔥
Stars: ✭ 15 (-77.27%)
Mutual labels:  butterknife
ContactsApp
Go-Jek Engineering Task Used MVP and Unit Testing Espresso, Mock Webserver and Activity Instrumentation Tests ,RxJava + RxAndroid + Retrofit 2 + OkHttp 3 + Dagger2 + ButterKnife+ Glide + Active Android ORM
Stars: ✭ 21 (-68.18%)
Mutual labels:  butterknife
Retrofit-with-EventBus
Retrofit With EventBus
Stars: ✭ 21 (-68.18%)
Mutual labels:  butterknife
BaseDevelop
an android project for now fashion open source framework
Stars: ✭ 24 (-63.64%)
Mutual labels:  butterknife
FastWaiMai
仿写美团外卖电商项目
Stars: ✭ 123 (+86.36%)
Mutual labels:  butterknife
chat-app
Simple Android chat app with Node.js backend
Stars: ✭ 19 (-71.21%)
Mutual labels:  butterknife
Marvel
Marvel Characters Android Application Assigned by smava GmbH
Stars: ✭ 227 (+243.94%)
Mutual labels:  butterknife
SimpleDroidRx
An application that helps you learn and better understand ReactiveX
Stars: ✭ 61 (-7.58%)
Mutual labels:  butterknife
KeepSafeNew
Sample app to demonstrate MVP (Model - View - Presenter), Android Architecture Components (Room Persistence, LiveData), RxJava2, ButterKnife in Android.
Stars: ✭ 58 (-12.12%)
Mutual labels:  butterknife
Fineract-CN-mobile
DEPRECATED project - Check the Apache fineract-cn-mobile project instead
Stars: ✭ 17 (-74.24%)
Mutual labels:  butterknife
Moneycim
Spending Tracker Application
Stars: ✭ 48 (-27.27%)
Mutual labels:  butterknife

Android ButterKnife Injections (Support Kotlin)

Android ButterKnife Injections (Support Kotlin)。支持Kotlin,可选初始化,可选R/R2。

关于支持Kotlin,插件的说明文档中有写明,是指“适用于父类为kt文件,子类为java文件的情况”。至于Kotlin类,有更好的kotlinx为什么不用呢?

如果本插件对您有帮助,请给个star吧。顺便如果能在JetBrains Plugins Repository评个5星就更好啦(😆)。


AS 4.1 兼容方案

  • MAC:下载jar包,粘贴至 "~/Applications/Android Studio.app/Contents/plugins" 路径下,重启 AS 即可。
  • Windows:下载jar包,粘贴至 "C:\Users\username\AppData\Roaming\Google\AndroidStudio4.1\plugins" 路径下,重启 AS 即可。

清除报错:删除 ~/Library/Application Support/Google/AndroidStudio4.1/plugins 下报错的插件。


使用方法

AS 4.1 兼容有问题,请按上方说明操作。

  • Android Studio -> Setting/Preferences -> Plugins -> Browse repositories,搜索 Android ButterKnife Injections (作者是ParfoisMeng)安装并重启可用。
  • 下载jar包,Android Studio -> Setting/Preferences -> Plugins -> Install plugin from disk -> 选择刚刚下载的jar包安装并重启。

功能点

  1. 包含 Android ButterKnife Zelezny v1.6.0 所有功能,且使用方法与 Android ButterKnife Zelezny 一致。
  2. 可选是否初始化 ButterKnife (避免原版本使用插件即自动在onCreate中添加ButterKnife.bind(this),适用于在基类中初始化)。
  3. 可选是否在 Lib 中使用(使用R2替换R,onClick中使用if-else)。
  4. 2、3可在Android Studio设置页配置默认值。

截图


随便说说

公司要App优化。但原代码里大量14-16年的老代码,质量极差,耦合极重。这种代码怎么可能有性能?

决定更新。原意直接上MVVM,甚至激进的想用androidX,奈何阻力太大,弃之。由于公司App业务功能相对独立,很符合组件化的思路,但组件化的坡度略陡,所幸发现了CC渐进式组件化改造方案(谢谢大佬),开搞。

Kotlin刚被Google认亲的时候就已开始接触学习与使用,能清晰的感受到它相较于Java的优劣。经过考虑,我在抽取基类封装lib_base时使用了Kotlin,本意是先写在基类中,让同事学习一下,慢慢的改变。(虽然目前公司还是用Java,但拥抱改变的心不能放弃,听说我要用Kotlin,同事还是颇有些抗拒的,花了好一番力气才说服之。)

问题来了。

继承Kotlin基类(BaseActivity.kt)的用Java编写的Activity/Fragment无法使用Android-ButterKnife-Zelezny插件!有报错!!

一番研究。。。辛酸泪一大把就不多说了,反正最后结果就是本插件了。(😄哈哈,还是很有成就感的)

我贴上关键处代码方便有兴趣的朋友浏览查阅:

//        if (true) { // 不能直接throw,需要if(true)过编译
//            StringBuilder sb = new StringBuilder();
//            for (int i = 0; i < fields.length; i++) {
//                PsiField field = fields[i];
//                sb.append(i).append("\n")
//                        .append(field.toString()).append("\n")
//                        .append(field.getType()).append("\n")
//                        .append(field.getFirstChild()).append("\n");
//                if (null != field.getFirstChild()) {
//                    sb.append(field.getFirstChild().getText()).append("\n");
//                }
//            }
//            // 不知道怎么log怎么debug,只能用这种方式,build再引入使用看报错
//            throw new RuntimeException(sb.toString());
//        }

        for (PsiField field : fields) {
            // kotlin中field.getFirstChild()可能为null
            PsiElement element = field.getFirstChild();
            if (null == element) {
                continue;
            }

            annotations = element.getText().split(" ");

            for (String annotation : annotations) {
                id = Utils.getInjectionID(butterKnife, annotation.trim());
                if (!Utils.isEmptyString(id)) {
                    ids.add(id);
                }
            }
        }
        

PS:其他的功能代码有点乱就不贴了,有兴趣可以clone源码查阅。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].