package com.tencent.liteav.demo.player.util;

import java.util.ArrayList;

public class PlayerTimerUtil {
    public interface Listener {
        void onListen(int type, int value);
    }

    private ArrayList<Listener> listeners = new ArrayList<>();

    private PlayerTimerUtil() {
    }

    private static final PlayerTimerUtil util = new PlayerTimerUtil();


    public static PlayerTimerUtil getInstance() {
        return util;
    }

    public static void addListener(Listener listener) {
        getInstance().listeners.add(listener);
    }

    public static void removeListener(Listener listener) {
        getInstance().listeners.remove(listener);
    }

    public static void setTimer(int type, int num) {
        ArrayList<Listener> listeners = getInstance().listeners;
        for (int i = 0; i < listeners.size(); i++) {
            if (listeners.get(i) != null) {
                listeners.get(i).onListen(type, num);
            }
        }
    }
}
