Giter Site home page Giter Site logo

androidnotificationcenter's Introduction

AndroidNotificationCenter

中文介绍

Same as EventBus , Except for

  • Pros

    • Only 150 lines of code.    * register/unregister call 100 times faster than EventBus!(when adding 5000 or more observers)    * post call, about 10 times faster than EventBus.
    • No Annotation! Event is Interface based, using java.lang.reflect.Proxy, so compile time check for typo.
  • Cons

    • no sticky feature
    • event can only be received in main thread

NotificationCenter in 3 steps

1.Define events as java Interface, sub

public interface SomeEvent {

    void someMethodName(Message param1);

}

Sub interface is also Ok, for organising events

public interface SomeEventCategory {

    interface Event1{
        void method1();
        void method2();
    }
    
    interface Event2{
        void method1();
        void method2();
    }

}

2.Prepare observers: Register your observer (in your onCreate or in a constructor):

NotificationCenter.INSTANCE.addObserver(this);

Implement your Event Interface

class SomeActivity implements SomeEvent {

    void someMethodName(Message param1);
    
}

3.Post events:

NotificationCenter.INSTANCE.getObserver(SomeEvent.class).someMethodName(new Message());

Add NotificationCenter to your project

Maven Central

maven

<dependency>
    <groupId>com.yy</groupId>
    <artifactId>notification-center-android</artifactId>
    <version>${version}</version>
</dependency>

gradle

compile 'com.yy:android-push-sdk:${versoion}'

androidnotificationcenter's People

Contributors

xuduo avatar huangzhilong avatar

Watchers

James Cloos avatar  avatar

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.