Code example for Queue

Methods: poll

0
    private void removeMsg(final AppMsg appMsg) {
        ViewGroup parent = ((ViewGroup) appMsg.getView().getParent());
        if (parent != null) {
            appMsg.getView().startAnimation(outAnimation);
            // Remove the AppMsg from the queue. 
            msgQueue.poll();
            // Remove the AppMsg from the view's parent. 
            parent.removeView(appMsg.getView());
            Message msg = obtainMessage(MESSAGE_DISPLAY);
            sendMessage(msg);
        } 
    } 
 
    private void addMsgToView(AppMsg appMsg) {
        if (appMsg.getView().getParent() == null) {
            appMsg.getActivity().addContentView(
                    appMsg.getView(),
                    appMsg.getLayoutParams());
        } 
        appMsg.getView().startAnimation(inAnimation);
        final Message msg = obtainMessage(MESSAGE_REMOVE);