lite your android ! the code is on the way~

Overview

android-lite-auto

lite your android, the code is on the way~ !

LiteAuto是一个代码生成框架,思路参考 JakeWharton 的开源项目 ButterKnife,在它的思路基础添加了一些自己的想法,从0到1设计并实现的。

LiteAuto设计思路的关键是约定大于配置,通过 更简单的注解 帮你自动生成 Android 中琐碎、冗长的功能代码。

目前可以自动生成 View 和 Event 相关的重复代码,还可以生成常用操作代码,而这些都是在编译时期自动生成的代码,几乎不影响性能,而且使得项目非常清晰简单。

和 ButterKnife 的不同点之一是 LiteAuto 只需要在 Activity 上添加一个 @LiteAuto 注解即可,框架自动分析 Activity 或者 Fragment 内部所有的 View 元素,判断是否在 layout 文件中有与之对应的 View 控件,比如一个 TextView 变量名为 “tvLabel”,框架会自动查找 layout 里面id 为 “tvLabel”的控件,并为之生成findViewById代码,如果查找不到那么探测下一个View,Event代码生成并关联的思路也是如此。

关于 @LiteAuto 注解,如果你有 View 变量不需要和 layout 文件关联,只需为变量添加 @UnBind 注解即可。

关于 @SemiAuto 注解,如果你需要向像 ButterKnife 一样,每个 View 或 Event 单独注解, 那么为Activity等添加 @SemiAuto 注解即可。

比如,之前的代码是这样:

public class MainActivity extends Activity {

    TextView tvLabel;
    TextView tvLabel1;
    TextView tvLabel2;
    TextView tvLabel3;
    Button button;
    ImageView imageView;
    ProgressBar progressBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        tvLabel = (TextView) findViewById(R.id.tvLabel);
        tvLabel1 = (TextView) findViewById(R.id.tvLabel1);
        tvLabel2 = (TextView) findViewById(R.id.tvLabel2);
        tvLabel3 = (TextView) findViewById(R.id.tvLabel3);
        button = (Button) findViewById(R.id.button);
        imageView = (ImageView) findViewById(R.id.imageView);
        progressBar = (ProgressBar) findViewById(R.id.progressBar);

        tvLabel1.setOnClickListener(new View.OnClickListener() {

            @Override 
            public void onClick(View v) {
                tvLabel1.setText("TvLabel 1 Clicked!");
            }
        });

        tvLabel2.setOnClickListener(new View.OnClickListener() {

            @Override 
            public void onClick(View v) {
                tvLabel2.setText("TvLabel 2 Clicked!");
                tvLabel3.setText("show me, show me pls!");
            }
        });
    }

}

那么,使用 LiteAuto 的代码是这样:

// 无需findViewById,也不需要为单个变量添加注解,Activity级别添加一个注解即可。
// 框架会分析类和成员变量,自动生成代码
@AutoLite
public class LiteMainActivity extends Activity {

    TextView tvLabel;
    TextView tvLabel1;
    TextView tvLabel2;
    TextView tvLabel3;
    Button button;
    ImageView imageView;
    ProgressBar progressBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        AutoMan.activateThis(this);
    }

    public void clickTvLabel1(View view) {
        tvLabel1.setText("TvLabel Clicked!");
    }

    public void clickTvLabel2(View view) {
        tvLabel2.setText("TvLabel Clicked!");
        tvLabel3.setText("show me, show me pls!");
    }

}
You might also like...
A multi-purpose library containing view injection and threading for Android using annotations
A multi-purpose library containing view injection and threading for Android using annotations

SwissKnife A multi-purpose Groovy library containing view injection and threading for Android using annotations. It's based on both ButterKnife and An

:syringe: Transfuse - A Dependency Injection and Integration framework for Google Android

Transfuse Transfuse is a Java Dependency Injection (DI) and integration library geared specifically for the Google Android API. There are several key

A SharedPreference "injection" library for Android

PreferenceBinder A SharedPreferences binding library for Android. Using annotation processing, this library makes it easy to load SharedPreferences va

This document will walk you through the steps for creating your Android app that runs a deep learning image classification model trained in Pocket AutoML and exported in TensorFlow Lite format
This document will walk you through the steps for creating your Android app that runs a deep learning image classification model trained in Pocket AutoML and exported in TensorFlow Lite format

Pocket AutoML: Tutorial for Creating an Android App for Image Classification with Deep Learning Translations English (this document) Русский Overview

TensorFlow Lite Helper for Android to help getting started with TesnorFlow.

TensorFlow Lite Helper for Android This library helps with getting started with TensorFlow Lite on Android. Inspired by TensorFlow Lite Android image

Age + Gender Estimation on Android - with TensorFlow Lite
Age + Gender Estimation on Android - with TensorFlow Lite

Age + Gender Estimation in Android with TensorFlow Contents Python project Google Colab Notebooks Dataset Model ( Vanilla vs. Lite ) Android project O

TensorFlow Lite Object Detection Android Demo
TensorFlow Lite Object Detection Android Demo

GSoC Project 2021 - TensorFlow Description This repository contains the project where I contributed to the TensorFlow Team during GSoC in the year 202

A lightweight Kotlin friendly wrapper around Couchbase lite for Android.

CouchBaseKtx 🚧 Work In-Progress 🚧 A lightweight Kotlin friendly wrapper around Couchbase-lite for Android Read up a little bit of documentation abou

Android-Java-App - Notepad app with user and password. SQL Lite
Android-Java-App - Notepad app with user and password. SQL Lite

DVNote2 App Android-Java-App Notepad app with user and password Application made in Android Studio with Java language and SQLite database. How does it

This app using Mlkit along with the TensorFlow Lite model for object detection,

I built this app using Mlkit along with the TensorFlow Lite model for object detection, Arcore is used to place anchors to the detected objects. It's a good blend of Machine learning and Augmented reality to visualise ML information in a much better way than regular bounding boxes

The behavior of Couchbase Lite C when attempting to connect to a Sync Gateway

This demo demonstrates the behavior of Couchbase Lite C when attempting to connect to a Sync Gateway, while the process has various numbers of file de

Built the ccp code on compose. Country Code Picker is an android library which provides an easy way to search and select country or international phone code.
Built the ccp code on compose. Country Code Picker is an android library which provides an easy way to search and select country or international phone code.

Built the ccp code on compose. Country Code Picker is an android library which provides an easy way to search and select country or international phone code.

An easy way to customize your log in Android,including output to console, writing log to file in high performance way and so on

EasyLog An easy way to customize your log in Android,including output to console, writing log to file in high performance way and so on. 1. Initializa

Country-code-picker-compose - An android library Jetpack Compose which provides an easy way to search and select country or country phone code
Alligator is a modern Android navigation library that will help to organize your navigation code in clean and testable way.

Alligator Alligator is a modern Android navigation library that will help to organize your navigation code in clean and testable way. Features Any app

Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.
Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.

Bubbles for Android Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your

Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.
Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.

Bubbles for Android Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your

Find your ideal fitness partners according to your preferences and interact with them whenever you want! All this with no hassle, because there's FitMate! Take timed challenges updated daily, read blogs related to health, and be a part of numerous communities too! During covid times, partner with your FitMate to achieve your fitness goals at home. :bouquet: An easy way to persist and run code block only as many times as necessary on Android.
:bouquet: An easy way to persist and run code block only as many times as necessary on Android.

Only 💐 An easy way to persist and run code block only as many times as necessary on Android. Download Gradle Add below codes to your root build.gradl

Owner
马天宇
welcome to http://litesuits.com
马天宇
Gradle plugin to add clock trackings to your dagger components and subcomponents

⏰ Dagger Track A gradle plugin that automatically adds clock tracking for your components and subcomponents. Features DaggerTrack will tell you follow

Amanjeet Singh 60 Aug 16, 2022
A fast dependency injector for Android and Java.

Dagger A fast dependency injector for Java and Android. Dagger is a compile-time framework for dependency injection. It uses no reflection or runtime

Google 16.9k Jan 5, 2023
Fast Android Development. Easy maintainance.

Fast Android Development. Easy maintenance. AndroidAnnotations is an Open Source framework that speeds up Android development. It takes care of the pl

null 11.1k Dec 31, 2022
A scope tree based Dependency Injection (DI) library for Java / Kotlin / Android.

Toothpick (a.k.a T.P. like a teepee) Visit TP wiki ! What is Toothpick ? Toothpick is a scope tree based Dependency Injection (DI) library for Java. I

Stéphane Nicolas 1.1k Jan 1, 2023
Fast Android Development. Easy maintainance.

Fast Android Development. Easy maintenance. AndroidAnnotations is an Open Source framework that speeds up Android development. It takes care of the pl

null 11.1k Dec 31, 2022
Bind Android views and callbacks to fields and methods.

Butter Knife Attention: This tool is now deprecated. Please switch to view binding. Existing versions will continue to work, obviously, but only criti

Jake Wharton 25.7k Jan 3, 2023
A fast dependency injector for Android and Java.

Dagger 1 A fast dependency injector for Android and Java. Deprecated – Please upgrade to Dagger 2 Square's Dagger 1.x is deprecated in favor of Google

Square 7.3k Jan 5, 2023
Google Guice on Android, version 3.0 [RETIRED]

As of August 2016, RoboGuice is no longer supported. For nearly 5 years it was the #1 dependency injection framework on Android due to its ease-of-use

null 3.8k Dec 26, 2022
Bind Android views and callbacks to fields and methods.

Butter Knife Attention: This tool is now deprecated. Please switch to view binding. Existing versions will continue to work, obviously, but only criti

Jake Wharton 25.7k Mar 22, 2021
Lightweight, minimalistic dependency injection library for Kotlin & Android

‼️ This project is in maintenance mode and not actively developed anymore. For more information read this statement. ‼️ Katana Katana is a lightweight

REWE Digital GmbH 179 Nov 27, 2022