GreenAnnotations API (Annotations)

GreenAnnotations API (Annotations) to add GreenRobot support to AndroidAnnotations

License

License

GroupId

GroupId

com.tmtron
ArtifactId

ArtifactId

green-annotations-api
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

GreenAnnotations API (Annotations)
GreenAnnotations API (Annotations) to add GreenRobot support to AndroidAnnotations
Project URL

Project URL

https://github.com/tmtron/green-annotations
Project Organization

Project Organization

TMTron
Source Code Management

Source Code Management

https://github.com/tmtron/green-annotations/tree/develop/green-annotations-api

Download green-annotations-api

How to add to project

<!-- https://jarcasting.com/artifacts/com.tmtron/green-annotations-api/ -->
<dependency>
    <groupId>com.tmtron</groupId>
    <artifactId>green-annotations-api</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.tmtron/green-annotations-api/
implementation 'com.tmtron:green-annotations-api:1.0.2'
// https://jarcasting.com/artifacts/com.tmtron/green-annotations-api/
implementation ("com.tmtron:green-annotations-api:1.0.2")
'com.tmtron:green-annotations-api:jar:1.0.2'
<dependency org="com.tmtron" name="green-annotations-api" rev="1.0.2">
  <artifact name="green-annotations-api" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.tmtron', module='green-annotations-api', version='1.0.2')
)
libraryDependencies += "com.tmtron" % "green-annotations-api" % "1.0.2"
[com.tmtron/green-annotations-api "1.0.2"]

Dependencies

provided (1)

Group / Artifact Type Version
com.google.android : android jar 2.3.1

Project Modules

There are no modules declared in this project.

Green Annotations

An Android Annotations plugin to support the Greenrobot Eventbus.
It can inject the default EventBus and automatically handle the registration/unregistration.

Build Status Maven Central Android Arsenal Javadocs license Join the chat at https://gitter.im/green-annotations/Lobby

Usage in your Android Studio project:

In the build.gradle file of the module project:

    dependencies {
        // Android Annotations for Greenrobot
        apt 'com.tmtron:green-annotations:1.0.2'
        compile 'com.tmtron:green-annotations-api:1.0.2'
    }

Note: Green-Annotations version 1.0.2 requires Android-Annotations version 4.4.0

Details

Before

Shows the Activity without using AndroidAnnotations or GreenAnnotations:

    public class ActivityBefore extends Activity {
    
        EventBus eventBus;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            eventBus = EventBus.getDefault();
        }
    
        @Override
        public void onStart() {
            super.onStart();
            eventBus.register(this);
        }
    
        @Override
        public void onStop() {
            eventBus.unregister(this);
            super.onStop();
        }
    
        public void fireEvent(String message) {
            eventBus.post(new MessageEvent(message));
        }
    
        @Subscribe(threadMode = ThreadMode.MAIN)
        public void onMessageEvent(MessageEvent event) {
            Toast.makeText(getApplicationContext(), event.message, Toast.LENGTH_SHORT).show();
        }
    
    }

After

Shows the same Activity with AndroidAnnotations and GreenAnnotations:

    @EActivity
    public class ActivityAfter extends Activity {
    
        @EventBusGreenRobot
        EventBus eventBus;
    
        public void fireEvent(String message) {
            eventBus.post(new MessageEvent(message));
        }
    
        @Subscribe(threadMode = ThreadMode.MAIN)
        public void onMessageEvent(MessageEvent event) {
            Toast.makeText(getApplicationContext(), event.message, Toast.LENGTH_SHORT).show();
        }
    
    }

Note: green-annotations-test is a tiny test-project: a sample android app with only one single activity to show how to use green-annotations (and the gradle-setup).

License

This plugin is under the Apache 2.0 license. Copyright 2016, Martin Trummer

Versions

Version
1.0.2
1.0.1
1.0.0