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;

interface ChatView extends MVPView {

    void setCallback(Callback callback);

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

    void messagesLoaded(ArrayList<Message> messages);

    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);

    MediaType getMediaType(String mimeType);

    File getFile(Uri fileUri);

    void enableMessageRetry(String messageId);

    void showItemProgress(int itemPosition, int progress);

    void stopItemProgress(int itemPosition);

    void showToastMessage(@StringRes int message);

    void showEmptySearchResultMessage(String searchText);

    void scrollToMessage(Message message);

    void scrollToPositionZero();

    interface Callback {
        void loadMessagesInContext(long groupId, long createdAt, Message messageToExclude);

        void loadMessagesFromServerByGroupId(long groupId);

        void loadMessagesFromDBByGroupId(long groupId, boolean fetchWhenFinished);

        void searchMessagesFromDBByGroupIdAndText(long groupId, String text);

        void fetchMoreMessagesByGroupId();

        boolean isLoading();

        void saveMessage(Message message);

        void resetMessages();

        void sendFile(Uri fileUri, String messageText);

        void sendMessage(String message);

        void resendMessage(Message message, String mimeType);

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

        void findGroupById();

        long getGroupId();

        void fetchNewMessages(long groupId);

        void setIsScrollingDown(boolean isScrollingDown);

        boolean getIsScrollingDown();

        boolean hasNewerMessages(long groupId, String messageId);
    }
}
