package com.desfate.chart.ui.old.OTC.listener;

import java.util.ArrayList;

/**
 * 单利模式
 * @author Administrator
 */
public class MessageingManager {
	
	private static MessageingManager instance = null;
	private ArrayList<OnMessageListener> messageListeners = new ArrayList<OnMessageListener>();
	
	public ArrayList<OnMessageListener> getMessageListeners() {
		return messageListeners;
	}

	public static MessageingManager getInstance() {
		if (instance == null) {
			instance = new MessageingManager();
		}
		return instance;
	}
	
	private MessageingManager() {
	}
	
	/**
	 * 注册监听消息
	 * @param messageListener
	 */
	public void regiter(OnMessageListener messageListener) {
		if (messageListeners == null) {
			messageListeners = new ArrayList<OnMessageListener>();
		}
		messageListeners.add(messageListener);
	}
	
	/**
	 * 反注册监听消息
	 * @param messageListener
	 */
	public void unRegiter(OnMessageListener messageListener) {
		if (messageListeners == null) {
			messageListeners = new ArrayList<OnMessageListener>();
		}
		messageListeners.remove(messageListener);
	}
	
}
