// Path: app/src/main/java/com/demo/amazing/net/action/Action.java
// public class Action {
// 
//     public static final int UNKNOWN_ACTION = -1;
// 
//     public static final int LINK_ACTION = 1;
// 
//     public static final int FAIL_ACTION = 2;
// 
//     public static final int VOTE_ACTION = 3;
// 
//     public static final int DESC_ACTION = 4;
// 
//     public int action;// 动作类型
// 
//     public String desc;
// 
//     public Action(int action) {
//         this.action = action;
//     }
// 
//     public Action(int action, String desc) {
//         this.action = action;
//         this.desc = desc;
//     }
// 
//     public static Action builder() {
//         return new Action(UNKNOWN_ACTION, null);
//     }
// }


import com.demo.amazing.net.action.Action;
import java.util.ArrayList;
package com.demo.amazing.net.observer;



/**
 * Created by hzsunyj on 2017/8/30.
 */

public class Observable implements Observer {

    private final ArrayList<Observer> observers;

    public Observable() {
        observers = new ArrayList<>();
    }

    public synchronized void registerObserver(Observer o) {
        if (o == null)
            return;
        if (!observers.contains(o)) {
            observers.add(o);
        }
    }

    public synchronized void unrigisterObserver(Observer o) {
        observers.remove(o);
    }

    public void onAction() {
        onAction(null);
    }

    @Override
// Path: app/src/main/java/com/demo/amazing/net/action/Action.java
// public class Action {
// 
//     public static final int UNKNOWN_ACTION = -1;
// 
//     public static final int LINK_ACTION = 1;
// 
//     public static final int FAIL_ACTION = 2;
// 
//     public static final int VOTE_ACTION = 3;
// 
//     public static final int DESC_ACTION = 4;
// 
//     public int action;// 动作类型
// 
//     public String desc;
// 
//     public Action(int action) {
//         this.action = action;
//     }
// 
//     public Action(int action, String desc) {
//         this.action = action;
//         this.desc = desc;
//     }
// 
//     public static Action builder() {
//         return new Action(UNKNOWN_ACTION, null);
//     }
// }


// Path: app/src/main/java/com/demo/amazing/net/observer/Observable.java
import com.demo.amazing.net.action.Action;
import java.util.ArrayList;

package com.demo.amazing.net.observer;



/**
 * Created by hzsunyj on 2017/8/30.
 */

public class Observable implements Observer {

    private final ArrayList<Observer> observers;

    public Observable() {
        observers = new ArrayList<>();
    }

    public synchronized void registerObserver(Observer o) {
        if (o == null)
            return;
        if (!observers.contains(o)) {
            observers.add(o);
        }
    }

    public synchronized void unrigisterObserver(Observer o) {
        observers.remove(o);
    }

    public void onAction() {
        onAction(null);
    }

    @Override
    public void onAction(Action action) {