001/**
002 *
003 * Copyright 2015 Florian Schmaus
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.jivesoftware.smack.roster;
019
020/**
021 * Roster loaded listeners are invoked once the {@link Roster} was successfully loaded.
022 * <p>
023 * A common approach is to call
024 * {@link Roster#getEntriesAndAddListener(RosterListener, RosterEntries)} within
025 * {@link #onRosterLoaded(Roster)}, to initialize or update your UI components with the current
026 * roster state.
027 * </p>
028 */
029public interface RosterLoadedListener {
030
031    /**
032     * Called when the Roster was loaded successfully.
033     *
034     * @param roster the Roster that was loaded successfully.
035     */
036    void onRosterLoaded(Roster roster);
037
038    /**
039     * Called when roster loading has failed.
040     * <p>
041     * Note that the reason for the failure could be as trivial as the connection being not
042     * connected, in which case the exception will be a
043     * {@link org.jivesoftware.smack.SmackException.NotConnectedException}.
044     * </p>
045     *
046     * @param exception the exception which caused the failure.
047     * @since 4.2
048     */
049    void onRosterLoadingFailed(Exception exception);
050
051}