package de.beyondsoft.ownchat.page.chat;

import de.beyondsoft.ownchat.model.Group;
import de.beyondsoft.ownchat.model.Message;
import de.beyondsoft.ownchat.page.mvp.MVPView;

import android.net.Uri;
import android.support.annotation.StringRes;

import java.io.File;
import java.util.ArrayList;

import okhttp3.MediaType;

/**
 * Created by Rares Teodorescu on 21/02/2017.
 */
interface ChatView extends MVPView {

    void setCallback(Callback callback);

    void messagesLoaded(ArrayList<Message> messages, boolean isFirstPage);

    void showLoading();

    void hideLoading();

    void showMessagesLoading();

    void hideMessagesLoading();

    void showEmptyMessage();

    void fileDownloadedSuccessfully(String filePath, String fileType);

    void lastMessageUpdated(Message newMessage, String oldMessageId);

    void showError(@StringRes int errorRes);

    void setGroup(Group group);

    void addOneMessage(Message message);

    MediaType getMediaType(Uri fileUri);

    File getFile(Uri fileUri);

    void enableMessageRetry(String messageId);

    void showItemProgress(int itemPosition, int progress);

    void stopItemProgress(int itemPosition);

    void showToastMessage(@StringRes int message);

    interface Callback {

        void loadMessagesFromServerByGroupId(long groupId);

        void loadMessagesFromDBByGroupId(long groupId, boolean fetchWhenFinished);

        void fetchMoreMessagesByGroupId();

        boolean isLoading();

        void saveMessage(Message message);

        void resetMessages();

        void sendFile(Uri fileUri);

        void sendMessage(String message);

        void resendMessage(Message message);

        void downloadFile(Message message, String filePath, int itemPosition);

        void findGroupById();

        long getGroupId();

        void fetchNewMessages(long groupId);
    }

}
