package com.ewei.demo.chat;

import android.content.Intent;
import android.view.View;

import com.ewei.demo.otherui.LocationShowActivity;
import com.ewei.demo.ticket.TicketActivity;
import com.ewei.sdk.chat.BaseChatLogActivity;
import com.ewei.sdk.constants.ChatValue;
import com.ewei.sdk.constants.CommonValue;
import com.ewei.sdk.entity.Article;
import com.ewei.sdk.entity.Attachment;
import com.ewei.sdk.entity.ChatLogMessage;
import com.ewei.sdk.entity.Ticket;
import com.ewei.sdk.other.ArticleDetailWebBrowserActivity;
import com.ewei.sdk.other.AttachmentActivity;
import com.ewei.sdk.other.PlayVideoActivity;
import com.ewei.sdk.other.SinglePreviewActivity;

/**
 * Created by Administrator on 2017/1/3.
 */
public class ChatLogActivity extends BaseChatLogActivity {

    @Override
    protected void onClickArticle(Article article) {
        ArticleDetailWebBrowserActivity.startActivity(this, article.title, article.topic.type, article.id);
    }

    @Override
    protected void onClickAttachment(Attachment attachment, String localUrl, String fileType) {
        switch (fileType) {
            case ChatValue.TYPE_CHATLOG_VIDEO:
                PlayVideoActivity.startActivity(this, attachment);
                break;
            case ChatValue.TYPE_CHATLOG_IMAGE:
                SinglePreviewActivity.startActivity(this, attachment);
                break;
            default:
                AttachmentActivity.startAttachment(this, attachment);
                break;
        }
    }

    @Override
    protected void onClickTicket(int ticketId) {
        TicketActivity.startTicketActivity(this, new Ticket(ticketId), TicketActivity.class, 0);
    }

    @Override
    protected void onClickMap(String latitude, String longitude, String addressStr) {
        //        /**
//         * 百度网页版地图展示
//         */
//        String httpUrl = "https://api.map.baidu.com/marker?location=" + latitude + "," + longitude + "&title=我的位置&content=" + addressStr + "&output=html";
//        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(httpUrl));
//        startActivity(intent);
        Intent intent = new Intent(this, LocationShowActivity.class);
        intent.putExtra(CommonValue.LOCATION_ADDRESS, addressStr);
        intent.putExtra(CommonValue.LOCATION_LONGITUDE, longitude);
        intent.putExtra(CommonValue.LOCATION_LATITUDE, latitude);
        startActivity(intent);
    }

    @Override
    protected View addTextView(ChatLogMessage chatLog, boolean isLeft) {
        return getDefaultTextView(chatLog, isLeft);
    }

    @Override
    protected View addFileView(ChatLogMessage chatLog, boolean isLeft) {
        return getDefaultFileView(chatLog, isLeft);
    }

    @Override
    protected View addAudioView(ChatLogMessage chatLog, boolean isLeft) {
        return getDefaultAudioView(chatLog, isLeft);
    }

    @Override
    protected View addVideoView(ChatLogMessage chatLog, boolean isLeft) {
        return getDefaultVideoView(chatLog, isLeft);
    }

    @Override
    protected View addImageView(final ChatLogMessage chatLog, boolean isLeft) {
        return getDefaultImageView(chatLog, isLeft);
    }

    @Override
    protected View addLocationView(ChatLogMessage chatLog, boolean isLeft) {
        return getDefaultLocationView(chatLog, isLeft);
    }

    @Override
    protected View addKnowledgeView(ChatLogMessage chatLog, boolean isLeft) {
        return getDefaultKnowledgeView(chatLog, isLeft);
    }

    @Override
    protected View addUnknownView(ChatLogMessage chatLog, boolean isLeft) {
        return getDefaultUnknownView(chatLog, isLeft);
    }
}