text:
package com.hyphenate.easeui.ui;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.media.MediaPlayer;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.utils.CoordinateConverter;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.hyphenate.EMChatRoomChangeListener;
import com.hyphenate.EMConnectionListener;
import com.hyphenate.EMContactListener;
import com.hyphenate.EMError;
import com.hyphenate.EMMessageListener;
import com.hyphenate.EMValueCallBack;
import com.hyphenate.chat.EMChatRoom;
import com.hyphenate.chat.EMClient;
import com.hyphenate.chat.EMContactManager;
import com.hyphenate.chat.EMConversation;
import com.hyphenate.chat.EMGroup;
import com.hyphenate.chat.EMImageMessageBody;
import com.hyphenate.chat.EMMessage;
import com.hyphenate.chat.EMMessage.ChatType;
import com.hyphenate.chat.EMTextMessageBody;
import com.hyphenate.easeui.EaseConstant;
import app.config.MyLifecycleHandler;
import app.logic.controller.ChatRoomController;
import app.logic.controller.UserManagerController;
import app.logic.pojo.FriendInfo;
import app.logic.pojo.UserInfo;
import app.logic.pojo.YYChatRoomInfo;
import app.logic.pojo.YYChatSessionInfo;
import app.logic.singleton.YYInterface;
import app.logic.singleton.YYSingleton;
import app.utils.common.Listener;
import app.utils.managers.TYLocationManager;
import app.view.DialogBottom;
import app.yy.geju.R;
import com.hyphenate.easeui.controller.EaseUI;
import com.hyphenate.easeui.domain.EaseEmojicon;
import com.hyphenate.easeui.domain.EaseUser;
import com.hyphenate.easeui.model.EaseAtMessageHelper;
import com.hyphenate.easeui.ui.activity.ChatActivity;
import com.hyphenate.easeui.utils.EaseCommonUtils;
import com.hyphenate.easeui.utils.EaseUserUtils;
import com.hyphenate.easeui.widget.EaseAlertDialog;
import com.hyphenate.easeui.widget.EaseAlertDialog.AlertDialogUser;
import com.hyphenate.easeui.widget.EaseChatExtendMenu;
import com.hyphenate.easeui.widget.EaseChatInputMenu;
import com.hyphenate.easeui.widget.EaseChatInputMenu.ChatInputMenuListener;
import com.hyphenate.easeui.widget.EaseChatMessageList;
import com.hyphenate.easeui.widget.EaseVoiceRecorderView;
import com.hyphenate.easeui.widget.EaseVoiceRecorderView.EaseVoiceRecorderCallback;
import com.hyphenate.easeui.widget.chatrow.EaseCustomChatRowProvider;
import com.hyphenate.exceptions.HyphenateException;
import com.hyphenate.util.EMLog;
import com.hyphenate.util.NetUtils;
import com.hyphenate.util.PathUtil;
import org.ql.activity.customtitle.FragmentActActivity;
import org.ql.utils.QLToastUtils;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static com.hyphenate.easeui.EaseConstant.CHATTYPE_CHATROOM;
import static com.hyphenate.easeui.EaseConstant.CHATTYPE_GROUP;

/**
 * you can new an EaseChatFragment to use or you can inherit it to expand.
 * You need call setArguments to pass chatType and userId
 *

 *

 * you can see ChatActivity in demo for your reference
 */
public class EaseChatFragment extends EaseBaseFragment implements EMMessageListener, EMConnectionListener {
    protected static final String TAG = "EaseChatFragment";
    protected static final int REQUEST_CODE_MAP = 1;
    protected static final int REQUEST_CODE_CAMERA = 2;
    protected static final int REQUEST_CODE_VIDEO = 3;
    protected static final int REQUEST_CODE_LOCAL = 4;
    protected static final int REQUEST_CODE_CAMERA_VIDEO = 5;

    /**
     * params to fragment
     */
    private Context context;
    protected Bundle fragmentArgs;
    protected int chatType;
    protected String toChatUsername;
    protected EaseChatMessageList messageList;
    protected EaseChatInputMenu inputMenu;
    protected EMConversation conversation;
    protected InputMethodManager inputManager; //input_menu
    protected ClipboardManager clipboard;
    protected Handler handler = new Handler();
    protected File cameraFile;
    protected File videoFile;
    protected EaseVoiceRecorderView voiceRecorderView;
    protected SwipeRefreshLayout swipeRefreshLayout;
    protected ListView listView;
    protected boolean isloading;
    protected boolean haveMoreData = true;
    protected int pagesize = 20;
    protected GroupListener groupListener;
    protected EMMessage contextMenuMessage;
    static final int ITEM_TAKE_PICTURE = 1;
    static final int ITEM_PICTURE = 2;
    static final int ITEM_VIDEO = 3;
    static final int ITEM_LOCATION = 4;
    private int nullCount = 0;

    private FriendListener friendListener ;
    public static Handler mHandler ;
    private boolean isFriend  = true ;

    protected int[] itemStrings = {R.string.attach_picture, R.string.attach_take_pic, R.string.attach_video, R.string.attach_location};
    //    protected int[] itemdrawables = {R.drawable.ease_chat_takepic_selector, R.drawable.ease_chat_image_selector,
//            R.drawable.ease_chat_location_selector};
    protected int[] itemdrawables = {R.drawable.icon_ease_chat_picture, R.drawable.icon_ease_chat_carmen, R.drawable.icon_ease_chat_video,
            R.drawable.icon_ease_chat_location};
    protected int[] itemIds = {ITEM_PICTURE, ITEM_TAKE_PICTURE, ITEM_VIDEO, ITEM_LOCATION};
    private EMChatRoomChangeListener chatRoomChangeListener;
    private boolean isMessageListInited;
    protected MyItemClickListener extendMenuItemClickListener;

    //自定义修改
    private String targetAccount ;
    private String targetMemberInfoID;
    private YYChatSessionInfo sessionInfo;
    private String my_head_picture;
    private String target_head_picture;
    private String targetNickName;
    private String roomInfoID;
    private List<UserInfo> singleList;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.ease_fragment_chat, container, false);

    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        context = getActivity();
        fragmentArgs = getArguments();
        // check if single chat or group chat
        chatType = fragmentArgs.getInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_SINGLE);
        // userId you are chat with or group id
        toChatUsername = fragmentArgs.getString(EaseConstant.EXTRA_USER_ID);
        setTitleNew() ;
        super.onActivityCreated(savedInstanceState);
    }

    /**
     * init view
     */
    protected void initView() {
        // hold to record voice
        //noinspection ConstantConditions
        voiceRecorderView = (EaseVoiceRecorderView) getView().findViewById(R.id.voice_recorder);
        // message list layout
        messageList = (EaseChatMessageList) getView().findViewById(R.id.message_list);
        if (chatType != EaseConstant.CHATTYPE_SINGLE)
            messageList.setShowUserNick(true);
        listView = messageList.getListView();
        extendMenuItemClickListener = new MyItemClickListener();
        inputMenu = (EaseChatInputMenu) getView().findViewById(R.id.input_menu);
        registerExtendMenuItem();
        // init input menu
        inputMenu.init(null);
        /**
         * 输入框的
         */
        setMyInputMenu();
        swipeRefreshLayout = messageList.getSwipeRefreshLayout();
        swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light,
                                                   R.color.holo_orange_light, R.color.holo_red_light);
        inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
        getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

//        EMClient.getInstance().addConnectionListener(this);
    }

    /**
     * 设置输入框的布局监听
     */
    private void setMyInputMenu() {
        inputMenu.setChatInputMenuListener(new ChatInputMenuListener() {
            @Override
            public void onSendMessage(String content) {
                sendTextMessage(content);
            }
            @Override
            public boolean onPressToSpeakBtnTouch(View v, MotionEvent event) {
                return voiceRecorderView.onPressToSpeakBtnTouch(v, event, new EaseVoiceRecorderCallback() {
                    @Override
                    public void onVoiceRecordComplete(String voiceFilePath, int voiceTimeLength) {
                        sendVoiceMessage(voiceFilePath, voiceTimeLength);
                    }
                });
            }
            @Override
            public void onBigExpressionClicked(EaseEmojicon emojicon) {
                sendBigExpressionMessage(emojicon.getName(), emojicon.getIdentityCode());
            }
        });
    }

    protected void setUpView() {
        if (chatType == EaseConstant.CHATTYPE_SINGLE) {
            // set title
            final String userId = fragmentArgs.getString(EaseConstant.TARGET_ACCOUNT);
            isFriend = fragmentArgs.getBoolean(ChatActivity.ISFRIEND , true );
            friendListener = new FriendListener();
            EMClient.getInstance().contactManager().setContactListener(friendListener);

            UserManagerController.getPhoneMemerInfo(context, userId, new Listener<Integer, List<UserInfo>>() {
                @Override
                public void onCallBack(Integer status, List<UserInfo> reply) {
                    ((FragmentActActivity) context).dismissWaitDialog();
                    if (reply == null || reply.size() < 1) {
                        return;
                    }
                    UserInfo info = reply.get(0);
                    targetMemberInfoID = info.getWp_member_info_id();
                    targetAccount = userId;
                    toChatUsername = userId;
                    targetNickName = fragmentArgs.getString(EaseConstant.TARGET_NICKNAME);
                    singleList = new ArrayList<UserInfo>();

                    my_head_picture = UserManagerController.getCurrUserInfo().getMy_picture_url();
                    target_head_picture = info.getPicture_url();
                    info.setPhone(userId);
                    singleList.add(info);
                    if (targetNickName != null) {
                        ((FragmentActActivity) context).setTitle("" + targetNickName + "");
                    }
                    onConversationInit();
                    onMessageListInit();
                    String forward_msg_id = fragmentArgs.getString("forward_msg_id");
                    if (forward_msg_id != null) {
                        // 显示发送要转发的消息
                        forwardMessage(forward_msg_id);
                    }
                }
            });
        } else {
            toChatUsername = fragmentArgs.getString(EaseConstant.kGroupID);//环信ID
            roomInfoID = fragmentArgs.getString(EaseConstant.kCHAT_ROOM_INFO_ID);//后台参数
            targetAccount = toChatUsername;
            ((FragmentActActivity) context).setTitle("");
            //getChatRoomInfo(roomInfoID);  //获取聊天室成员信息
            if (chatType == EaseConstant.CHATTYPE_GROUP) {
                // listen the event that user moved out group or group is dismissed
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            EMGroup group = EMClient.getInstance().groupManager().getGroupFromServer(toChatUsername);
                            List<String> groupxx = group.getMembers();//获取群成员
                            for(String string : groupxx){
                                System.out.println("=====member==="+string);
                            }
                        } catch (HyphenateException e) {
                            e.printStackTrace();
                        }
                    }
                }).start();
                groupListener = new GroupListener();
                EMClient.getInstance().groupManager().addGroupChangeListener(groupListener);
            } else {
                onChatRoomViewCreation();
            }
            onConversationInit();
            onMessageListInit();
        }
        setRefreshLayoutListener();
        // show forward message if the message is not null
        String forward_msg_id = getArguments().getString("forward_msg_id");
        if (forward_msg_id != null) {
            forwardMessage(forward_msg_id);
        }

        /**
         * 更改好友昵称,回调刷新title
         */
        YYSingleton.getInstance().setIUpdataChatTitle(new YYInterface.IUpdataChatTitle() {
            @Override
            public void onCallBack(String name) {
                if (!TextUtils.isEmpty(name)) {
                    getActivity().setTitle(name);
                }
            }
        });
    }

    private YYChatRoomInfo chatRoomInfo;
    private void getChatRoomInfo(String cr_id) {
        nullCount = 0;   //清一次零,防止多减
        ChatRoomController.getChatRoomInfo(context, cr_id, new Listener<Void, YYChatRoomInfo>() {
            @Override
            public void onCallBack(Void status, YYChatRoomInfo reply) {
                chatRoomInfo = reply;
                if (reply != null) {
                    List<UserInfo> list = reply.getCr_memberList();
                    for ( UserInfo a : list){
                        if (a.getPhone() == null || TextUtils.isEmpty(a.getPhone()) || a.getIs_remove()==1 ) {
                            nullCount++;
                            continue;
                        }
                    }
                    int a = 1 ;
                    if( list != null )a = list.size() - nullCount ;
                    ((FragmentActActivity) context).setTitle(reply.getCr_name()+"("+ a +"人)");
                    initChatMemberInfos(chatRoomInfo);
                }
            }
        });
    }

    private void initChatMemberInfos(YYChatRoomInfo roomInfo) {
        if (messageList == null) {
            return;
        }
        String memberList = fragmentArgs.getString(EaseConstant.kCHAT_MEMBER_LIST);
        if (roomInfo != null && roomInfo.getCr_memberList() != null) {
            messageList.setMassageList(roomInfo.getCr_memberList(), chatType);
        } else if (memberList != null) {
            try {
                // 设置聊天人员列表
                Gson gson = new Gson();
                if (memberList.contains("wp_friends_info_id")) {
                    List<FriendInfo> friendInfos = gson.fromJson(memberList, new TypeToken<List<FriendInfo>>() {
                    }.getType());
                    if (friendInfos != null) {
                        UserInfo _tmpInfo = null;
                        ArrayList<UserInfo> _tmpList = new ArrayList<UserInfo>();
                        for (FriendInfo friendInfo : friendInfos) {
                            _tmpInfo = new UserInfo();
                            _tmpInfo.setPhone(friendInfo.getPhone());
                            _tmpInfo.setPicture_url(friendInfo.getPicture_url());
                            _tmpList.add(_tmpInfo);
                        }
                        messageList.setMassageList(_tmpList, chatType);
                    }
                } else {
                    List<UserInfo> userInfos = gson.fromJson(memberList, new TypeToken<List<UserInfo>>() {
                    }.getType());
                    messageList.setMassageList(userInfos, chatType);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            if (singleList != null) {
                messageList.setMassageList(singleList, chatType);
            }
        }
    }

    /**
     * register extend menu, item id need > 3 if you override this method and keep exist item
     */
    protected void registerExtendMenuItem() {
        for (int i = 0; i < itemStrings.length; i++) {
            inputMenu.registerExtendMenuItem(itemStrings[i], itemdrawables[i], itemIds[i], extendMenuItemClickListener);
        }
    }

    protected void onConversationInit() {
//        conversation = EMClient.getInstance().chatManager().getConversation(toChatUsername, EaseCommonUtils.getConversationType(chatType), true);
        conversation = EMClient.getInstance().chatManager().getConversation(targetAccount, EaseCommonUtils.getConversationType(chatType), true);
        conversation.markAllMessagesAsRead();
        // the number of messages loaded into conversation is getChatOptions().getNumberOfMessagesLoaded
        // you can change this number
        List<EMMessage> msgs = conversation.getAllMessages();
        int msgCount = msgs != null ? msgs.size() : 0;
        if (msgCount < conversation.getAllMsgCount() && msgCount < pagesize) {
            String msgId = null;
            if (msgs != null && msgs.size() > 0) {
                msgId = msgs.get(0).getMsgId();
            }
            conversation.loadMoreMsgFromDB(msgId, pagesize - msgCount);
        }
    }

    protected void onMessageListInit() {
//        messageList.init(toChatUsername, chatType, chatFragmentHelper != null ?
//                chatFragmentHelper.onSetCustomChatRowProvider() : null);
        messageList.init(targetAccount, chatType, chatFragmentHelper != null ?
                chatFragmentHelper.onSetCustomChatRowProvider() : null);
        setListItemClickListener();
        initChatMemberInfos(chatRoomInfo);
        messageList.getListView().setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                hideKeyboard();
                inputMenu.hideExtendMenuContainer();
                return false;
            }
        });
        isMessageListInited = true;
    }

    /**
     * 设置对话列表的监听
     */
    protected void setListItemClickListener() {
        messageList.setItemClickListener(new EaseChatMessageList.MessageListItemClickListener() {
            @Override
            public void onUserAvatarClick(String username) {
                if (chatFragmentHelper != null) {
                    chatFragmentHelper.onAvatarClick(username);
                }
            }
            @Override
            public void onUserAvatarLongClick(String username) {
                if (chatFragmentHelper != null) {
                    chatFragmentHelper.onAvatarLongClick(username);
                }
            }

            @Override
            public void onResendClick(final EMMessage message) {
//                new EaseAlertDialog(getActivity(), R.string.resend, R.string.confirm_resend, null, new AlertDialogUser() {
//                    @Override
//                    public void onResult(boolean confirmed, Bundle bundle) {
//                        if (!confirmed) {
//                            return;
//                        }
//                        resendMessage(message);
//                    }
//                }, true).show();
                resendMessage(message);
            }

            @Override
            public void onBubbleLongClick(EMMessage message) {
                contextMenuMessage = message;
                if (chatFragmentHelper != null) {
                    chatFragmentHelper.onMessageBubbleLongClick(message);
                }
            }

            /**
             * 主要是这里的点击事件
             * @param message
             * @return
             */
            @Override
            public boolean onBubbleClick(EMMessage message) {
                if (chatFragmentHelper == null) {
                    return false;
                }
                return chatFragmentHelper.onMessageBubbleClick(message);
            }

        });
    }

    protected void setRefreshLayoutListener() {
        swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh() {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) {
                            List<EMMessage> messages;
                            try {
                                if (chatType == EaseConstant.CHATTYPE_SINGLE) {
                                    messages = conversation.loadMoreMsgFromDB(messageList.getItem(0).getMsgId(),
                                            pagesize);
                                } else {
                                    messages = conversation.loadMoreMsgFromDB(messageList.getItem(0).getMsgId(),
                                            pagesize);
                                }
                            } catch (Exception e1) {
                                swipeRefreshLayout.setRefreshing(false);
                                return;
                            }
                            if (messages.size() > 0) {
                                messageList.refreshSeekTo(messages.size() - 1);
                                if (messages.size() != pagesize) {
                                    haveMoreData = false;
                                }
                            } else {
                                haveMoreData = false;
                            }
                            isloading = false;
                        } else {
                            Toast.makeText(getActivity(), getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show();
                        }
                        swipeRefreshLayout.setRefreshing(false);
                    }
                }, 600);
            }
        });
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (!inputMenu.onBackPressed()) {
            inputMenu.hideExtendMenuContainer();
        }
        if (resultCode == Activity.RESULT_OK) {
            switch (requestCode) {
                case REQUEST_CODE_CAMERA:
                    if (cameraFile != null && cameraFile.exists())
                        sendImageMessage(cameraFile.getAbsolutePath());
                    break;
                case REQUEST_CODE_LOCAL:
                    if (data != null) {
                        Uri selectedImage = data.getData();
                        if (selectedImage != null) {
                            sendPicByUri(selectedImage);
                        }
                    }
                    break;
                case REQUEST_CODE_MAP:
                    double latitude = data.getDoubleExtra("latitude", 0);
                    double longitude = data.getDoubleExtra("longitude", 0);
                    String locationAddress = data.getStringExtra("address");
                    if (locationAddress != null && !locationAddress.equals("")) {
                        sendLocationMessage(latitude, longitude, locationAddress);
                    } else {
                        Toast.makeText(getActivity(), R.string.unable_to_get_loaction, Toast.LENGTH_SHORT).show();
                    }
                    break;
                case REQUEST_CODE_VIDEO:
                    sendVideoByUri(data.getData());
                    break;
                case REQUEST_CODE_CAMERA_VIDEO:
                    if (videoFile != null && videoFile.exists()) {
                        sendVideoByPath(videoFile);
                    }
                    break;
            }
        }else{
            Toast.makeText(getActivity(), "获取失败" , Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        if (isMessageListInited)
            messageList.refresh();
        EaseUI.getInstance().pushActivity(getActivity());
        // register the event listener when enter the foreground
        EMClient.getInstance().chatManager().addMessageListener(this);

        if (chatType == EaseConstant.CHATTYPE_GROUP) {
            EaseAtMessageHelper.get().removeAtMeGroup(toChatUsername);
        }

        if( chatType != EaseConstant.CHATTYPE_SINGLE ){
            getChatRoomInfo(roomInfoID);    //获取群组的成员列表
        }
    }

    @Override
    public void onStop() {
        super.onStop();
        // unregister this event listener when this activity enters the
        // background
        // remove activity from foreground activity list
        EaseUI.getInstance().popActivity(getActivity());
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (groupListener != null) {
            EMClient.getInstance().groupManager().removeGroupChangeListener(groupListener);
        }
        if(friendListener!=null){
            EMClient.getInstance().contactManager().removeContactListener(friendListener);
        }
        if (chatType == CHATTYPE_CHATROOM) {
            EMClient.getInstance().chatroomManager().leaveChatRoom(toChatUsername);
        }
        if (chatRoomChangeListener != null) {
            EMClient.getInstance().chatroomManager().removeChatRoomChangeListener(chatRoomChangeListener);
        }
        EMClient.getInstance().chatManager().removeMessageListener(this);
    }

    public void onBackPressed() {
        if (inputMenu.onBackPressed()) {
            getActivity().finish();
            if (chatType == EaseConstant.CHATTYPE_GROUP) {
                EaseAtMessageHelper.get().removeAtMeGroup(toChatUsername);
                EaseAtMessageHelper.get().cleanToAtUserList();
            }
            if (chatType == CHATTYPE_CHATROOM) {
                EMClient.getInstance().chatroomManager().leaveChatRoom(toChatUsername);
            }
        }
    }

    protected void onChatRoomViewCreation() {
        final ProgressDialog pd = ProgressDialog.show(getActivity(), "", "Joining......");
        EMClient.getInstance().chatroomManager().joinChatRoom(toChatUsername, new EMValueCallBack<EMChatRoom>() {
            @Override
            public void onSuccess(final EMChatRoom value) {
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (getActivity().isFinishing() || !toChatUsername.equals(value.getId()))
                            return;
                        pd.dismiss();
                        EMChatRoom room = EMClient.getInstance().chatroomManager().getChatRoom(toChatUsername);
//                        if (room != null) {
//                            titleBar.setTitle(room.getName());
//                            EMLog.d(TAG, "join room success : " + room.getName());
//                        } else {
//                            titleBar.setTitle(toChatUsername);
//                        }
                        addChatRoomChangeListenr();
                        onConversationInit();
                        onMessageListInit();
                    }
                });
            }

            @Override
            public void onError(final int error, String errorMsg) {
                // TODO Auto-generated method stub
                EMLog.d(TAG, "join room failure : " + error);
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        pd.dismiss();
                    }
                });
                getActivity().finish();
            }
        });
    }

    protected void addChatRoomChangeListenr() {
        chatRoomChangeListener = new EMChatRoomChangeListener() {
            @Override
            public void onChatRoomDestroyed(String roomId, String roomName) {
                if (roomId.equals(toChatUsername)) {
                    showChatroomToast(" room : " + roomId + " with room name : " + roomName + " was destroyed");
                    getActivity().finish();
                }
            }

            @Override
            public void onMemberJoined(String roomId, String participant) {
                showChatroomToast("member : " + participant + " join the room : " + roomId);
            }

            @Override
            public void onMemberExited(String roomId, String roomName, String participant) {
                showChatroomToast("member : " + participant + " leave the room : " + roomId + " room name : " + roomName);
            }

            @Override
            public void onRemovedFromChatRoom(String roomId, String roomName, String participant) {
                if (roomId.equals(toChatUsername)) {
                    String curUser = EMClient.getInstance().getCurrentUser();
                    if (curUser.equals(participant)) {
                        EMClient.getInstance().chatroomManager().leaveChatRoom(toChatUsername);
                        getActivity().finish();
                    } else {
                        showChatroomToast("member : " + participant + " was kicked from the room : " + roomId + " room name : " + roomName);
                    }
                }
            }
        };
        EMClient.getInstance().chatroomManager().addChatRoomChangeListener(chatRoomChangeListener);
    }

    protected void showChatroomToast(final String toastContent) {
        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                Toast.makeText(getActivity(), toastContent, Toast.LENGTH_SHORT).show();
            }
        });
    }

    // implement methods in EMMessageListener

    /**
     * ---------------------------------------------------------------------------------------------------------------------------
     *

     * 接收消息
     */
    @Override
    public void onMessageReceived(List<EMMessage> messages) {
        for (EMMessage message : messages) {
            String username = null;
            if (message.getChatType() == ChatType.GroupChat || message.getChatType() == ChatType.ChatRoom) {
                username = message.getTo();
            } else {
                username = message.getFrom();
            }
            if( chatType == EaseConstant.CHATTYPE_SINGLE && !isFriend && (((EMTextMessageBody)message.getBody()).getMessage().equals("我们已经是好友了,现在开始对话吧!"))){
                isFriend = true ;  //重新添加为好友
            }
            // if the message is for current conversation
            if (username.equals(toChatUsername) || message.getTo().equals(toChatUsername)) {   //当前会话消息
                messageList.refreshSelectLast();
                if(!MyLifecycleHandler.isApplicationInForeground()) {   //应用程序在后台
                    EaseUI.getInstance().getNotifier().vibrateAndPlayTone(message);
                }
            } else {
                EaseUI.getInstance().getNotifier().onNewMsg(message);
            }
        }
    }

    @Override
    public void onCmdMessageReceived(List<EMMessage> messages) {
        if (isMessageListInited) {
            messageList.refresh();
        }

    }

    @Override
    public void onMessageRead(List<EMMessage> list) {
        if (isMessageListInited) {
            messageList.refresh();
        }
    }

    @Override
    public void onMessageDelivered(List<EMMessage> list) {
        if (isMessageListInited) {
            messageList.refresh();
        }
    }

    @Override
    public void onMessageChanged(EMMessage emMessage, Object change) {
        if (isMessageListInited) {
            messageList.refresh();
        }
    }

    @Override
    public void onConnected() {

    }

    @Override
    public void onDisconnected(final int error) {

        QLToastUtils.showToast(getActivity(), String.valueOf(error));
        getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                if (error == EMError.USER_REMOVED) {

                    // 显示帐号已经被移除
                } else if (error == EMError.USER_LOGIN_ANOTHER_DEVICE) {
                    // 显示帐号在其他设备登录
                } else {
                    if (NetUtils.hasNetwork(getActivity())) {
                    }
                    //连接不到聊天服务器
                    else {

                    }
                    //当前网络不可用,请检查网络设置
                }
            }
        });

    }
    /**
     * ---------------------------------------------------------------------------------------------------------------------------
     */

    /**
     * handle the click event for extend menu
     *

     * 发送其他类型
     */
    class MyItemClickListener implements EaseChatExtendMenu.EaseChatExtendMenuItemClickListener {

        @Override
        public void onClick(int itemId, View view) {
            if (chatFragmentHelper != null) {
                if (chatFragmentHelper.onExtendMenuItemClick(itemId, view)) {
                    return;
                }
            }
            switch (itemId) {
                case ITEM_TAKE_PICTURE:
                    selectPicFromCamera();
                    break;
                case ITEM_PICTURE:
                    selectPicFromLocal();
                    break;
                case ITEM_VIDEO:
                    startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI), REQUEST_CODE_VIDEO);
                    break;
                case ITEM_LOCATION:
//                    startActivityForResult(new Intent(getActivity(), EaseBaiduMapActivity.class), REQUEST_CODE_MAP);
                    requestPermissionByLocal();
                    break;

                default:
                    break;
            }
        }

    }

    /**
     * input @
     *
     * @param username
     */
    protected void inputAtUsername(String username, boolean autoAddAtSymbol) {
        if (EMClient.getInstance().getCurrentUser().equals(username) ||
                chatType != EaseConstant.CHATTYPE_GROUP) {
            return;
        }
        EaseAtMessageHelper.get().addAtUser(username);
        EaseUser user = EaseUserUtils.getUserInfo(username);
        if (user != null) {
            username = user.getNick();
        }
        if (autoAddAtSymbol)
            inputMenu.insertText("@" + username + " ");
        else
            inputMenu.insertText(username + " ");
    }

    /**
     * input @
     *
     * @param username
     */
    protected void inputAtUsername(String username) {
        inputAtUsername(username, true);
    }

    /**
     * 发送文本信息(表情也走这里)
     * @param content
     */
    protected void sendTextMessage(String content) {
        if (EaseAtMessageHelper.get().containsAtUsername(content)) {
            sendAtMessage(content);
        } else {
            //setEmptyUesr();
            EMMessage message = EMMessage.createTxtSendMessage(content, toChatUsername);
            sendMessage(message);
        }
        messageList.refresh();
    }

    /**
     * send @ message, only support group chat message
     *
     * @param content
     */
    @SuppressWarnings("ConstantConditions")
    private void sendAtMessage(String content) {
        if (chatType != EaseConstant.CHATTYPE_GROUP) {
            EMLog.e(TAG, "only support group chat message");
            return;
        }
        //setEmptyUesr();
        EMMessage message = EMMessage.createTxtSendMessage(content, toChatUsername);
        EMGroup group = EMClient.getInstance().groupManager().getGroup(toChatUsername);
        if (EMClient.getInstance().getCurrentUser().equals(group.getOwner()) && EaseAtMessageHelper.get().containsAtAll(content)) {
            message.setAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL);
        } else {
            message.setAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG,
                    EaseAtMessageHelper.get().atListToJsonArray(EaseAtMessageHelper.get().getAtMessageUsernames(content)));
        }
        sendMessage(message);

    }

    protected void sendBigExpressionMessage(String name, String identityCode) {
        //setEmptyUesr();
        EMMessage message = EaseCommonUtils.createExpressionMessage(toChatUsername, name, identityCode);
        sendMessage(message);
    }

    /**
     * 发送语音
     * @param filePath
     * @param length
     */
    protected void sendVoiceMessage(String filePath, int length) {
        //setEmptyUesr();
        EMMessage message = EMMessage.createVoiceSendMessage(filePath, length, toChatUsername);
        sendMessage(message);
    }

    /**
     * 发送图片
     * @param imagePath
     */
    protected void sendImageMessage(String imagePath) {
        //setEmptyUesr();
        EMMessage message = EMMessage.createImageSendMessage(imagePath, false, toChatUsername);
        sendMessage(message);
    }

    /**
     *发送位置
     * @param latitude
     * @param longitude
     * @param locationAddress
     */
    protected void sendLocationMessage(double latitude, double longitude, String locationAddress) {
        //setEmptyUesr();

        EMMessage message = EMMessage.createLocationSendMessage(latitude, longitude, locationAddress, toChatUsername);
        sendMessage(message);
    }

    /**
     *发送视屏
     * @param videoPath
     * @param thumbPath
     * @param videoLength
     */
    protected void sendVideoMessage(String videoPath, String thumbPath, int videoLength) {
        //setEmptyUesr();
        EMMessage message = EMMessage.createVideoSendMessage(videoPath, thumbPath, videoLength, toChatUsername);
        sendMessage(message);
    }

    /**
     * 发送文件
     * @param filePath
     */
    protected void sendFileMessage(String filePath) {
        //setEmptyUesr();
        EMMessage message = EMMessage.createFileSendMessage(filePath, toChatUsername);
        sendMessage(message);
    }

    /**
     * 发送信息
     * @param message
     */
    protected void sendMessage(EMMessage message) {
        if(!isFriend){
            Toast.makeText(getActivity(), "已不是您的好友,不能发信息", Toast.LENGTH_LONG).show();
            return;
        }
        if (message == null) {
            return;
        }
        if (chatFragmentHelper != null) {
            //set extension
            chatFragmentHelper.onSetMessageAttributes(message);
        }
        if (chatType == EaseConstant.CHATTYPE_GROUP) {
            message.setChatType(ChatType.GroupChat);
        } else if (chatType == CHATTYPE_CHATROOM) {
            message.setChatType(ChatType.ChatRoom);
        }
        //send message
        EMClient.getInstance().chatManager().sendMessage(message);
        //refresh ui
        if (isMessageListInited) {
            messageList.refreshSelectLast();
        }
    }

    public void resendMessage(EMMessage message) {
        message.setStatus(EMMessage.Status.CREATE);
        EMClient.getInstance().chatManager().sendMessage(message);
        messageList.refresh();
    }

    //===================================================================================

    private final static int REQUEST_PERMISSION_LOCAL_CODE = 16;

    /**
     * 打开地理位置
     */
    private void requestPermissionByLocal() {
        //TODO
        if (Build.VERSION.SDK_INT >= 23) {
            if (ContextCompat.checkSelfPermission(getActivity(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(getActivity(), new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSION_LOCAL_CODE);
            } else {
                startActivityForResult(new Intent(getActivity(), EaseBaiduMapActivity.class), REQUEST_CODE_MAP);
            }
        } else {
            startActivityForResult(new Intent(getActivity(), EaseBaiduMapActivity.class), REQUEST_CODE_MAP);
        }
    }

    /**
     * send image
     *
     * @param selectedImage
     */
    protected void sendPicByUri(Uri selectedImage) {
        String[] filePathColumn = {MediaStore.Images.Media.DATA};
        Cursor cursor = getActivity().getContentResolver().query(selectedImage, filePathColumn, null, null, null);
        if (cursor != null) {
            cursor.moveToFirst();
            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            String picturePath = cursor.getString(columnIndex);
            cursor.close();
            cursor = null;

            if (picturePath == null || picturePath.equals("null")) {
                Toast toast = Toast.makeText(getActivity(), R.string.cant_find_pictures, Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER, 0, 0);
                toast.show();
                return;
            }
            sendImageMessage(picturePath);
        } else {
            File file = new File(selectedImage.getPath());
            if (!file.exists()) {
                Toast toast = Toast.makeText(getActivity(), R.string.cant_find_pictures, Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER, 0, 0);
                toast.show();
                return;

            }
            sendImageMessage(file.getAbsolutePath());
        }

    }

    /**
     * send file
     *
     * @param uri
     */
    protected void sendFileByUri(Uri uri) {
        String filePath = null;
        if ("content".equalsIgnoreCase(uri.getScheme())) {
            String[] filePathColumn = {MediaStore.Images.Media.DATA};
            Cursor cursor = null;

            try {
                cursor = getActivity().getContentResolver().query(uri, filePathColumn, null, null, null);
                int column_index = cursor.getColumnIndexOrThrow("_data");
                if (cursor.moveToFirst()) {
                    filePath = cursor.getString(column_index);
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (cursor != null) {
                    cursor.close();
                }
            }
        } else if ("file".equalsIgnoreCase(uri.getScheme())) {
            filePath = uri.getPath();
        }
        if (filePath == null) {
            return;
        }
        File file = new File(filePath);
        if (!file.exists()) {
            Toast.makeText(getActivity(), R.string.File_does_not_exist, Toast.LENGTH_SHORT).show();
            return;
        }
        //limit the size < 10M
        if (file.length() > 10 * 1024 * 1024) {
            Toast.makeText(getActivity(), R.string.The_file_is_not_greater_than_10_m, Toast.LENGTH_SHORT).show();
            return;
        }
        sendFileMessage(filePath);
    }

    /**
     * 发送Video(视频)
     *
     * @param uri
     */
    protected void sendVideoByUri(Uri uri) {
        String[] videoPathColumn = {MediaStore.Video.Media.DATA, MediaStore.Video.Media.SIZE, MediaStore.Video.Media._ID, MediaStore.Video.Thumbnails.DATA,MediaStore.Video.Media.DURATION};
        Cursor cursor = getActivity().getContentResolver().query(uri, videoPathColumn, null, null, null);
        String videoPath;
        final String videoThumb;
        int videoSize , videoDuration;
        if (cursor != null) {
            cursor.moveToFirst();
            videoPath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)); //获取路径
            videoSize = (int) cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE)); //文件大小
            videoDuration = (int) cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION)); //视频文件的时长
            cursor.close();
            /**
             * 保存缩略图
             */
            videoThumb = saveThumbImage(videoPath);
            if (videoSize >= 10 * 1024 * 1024) {
                QLToastUtils.showToast(getActivity(), "视频太大,不能超过10M");
                return;
            }
            if(videoThumb==null || TextUtils.isEmpty(videoThumb)){
                QLToastUtils.showToast( getContext() , "无效的视频文件");
                return;
            }
            /**
             * video的路径,缩略图的路径,大小
             */
            sendVideoMessage(videoPath, videoThumb, videoDuration);
        }
    }

    /**
     * 发送录像
     *
     * @param file
     */
    private void sendVideoByPath(File file) {
        if (file.length() >= 10 * 1024 * 1024) {
            QLToastUtils.showToast(getActivity(), "视频太大,不能超过10M,请重新拍摄");
            return;
        }
        String videoPath = file.getAbsolutePath();
        String videoThumb = saveThumbImage(videoPath);
        int videoSize = 0;
        FileInputStream stream = null;
        try {
            stream = new FileInputStream(file);
            videoSize = stream.available();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (stream != null) {
                try {
                    stream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        int getVideoLength = (int) getVideoLength(videoPath);  //获取视频文件的时长
        sendVideoMessage(videoPath, videoThumb, getVideoLength);
    }

    /**
     * 获取视屏文件的时长
     * @param videoPath
     */
    private double getVideoLength( String videoPath ){
        MediaPlayer player = new MediaPlayer();
        try {
            player.setDataSource(videoPath);  //videoPath 为音频文件的路径
            player.prepare();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        double duration= player.getDuration();//获取音频的时间
        player.release();//记得释放资源
        return duration ;
    }

    /**
     * 缩略图
     *
     * @param videoPath
     * @return
     */
    private String saveThumbImage(String videoPath) {
        Bitmap thumbMap = ThumbnailUtils.createVideoThumbnail(videoPath, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
        if(thumbMap==null){  //发现选择发送视频是,选择的是图片或是无效的视频文件时,这个对象是null
            return "";
        }
        String filePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/YYData/images/thumbs";
        File dir = new File(filePath);
        if (!dir.exists()) {
            dir.mkdir();
        }
        File thumbImage = new File(dir, System.currentTimeMillis() + ".jpg");
        BufferedOutputStream bos = null;
        try {
            bos = new BufferedOutputStream(new FileOutputStream(thumbImage));
            thumbMap.compress(Bitmap.CompressFormat.JPEG, 50, bos);
            bos.flush();
            bos.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return thumbImage.getAbsolutePath();
    }

    private static final int REQUEST_PERMISSION_CODE = 15;

    /**
     * capture new image
     */
    protected void selectPicFromCamera() {
        if (!EaseCommonUtils.isSdcardExist()) {
            Toast.makeText(getActivity(), R.string.sd_card_does_not_exist, Toast.LENGTH_SHORT).show();
            return;
        }
        if (Build.VERSION.SDK_INT >= 23) {
            if (ContextCompat.checkSelfPermission(getActivity(), android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(getActivity(), new String[]{android.Manifest.permission.CAMERA}, REQUEST_PERMISSION_CODE);
            } else {
                openCameraSelect();
            }
        } else {
            openCameraSelect();
        }
    }

    /**
     * 打开相机的选择
     */
    private void openCameraSelect() {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_sex_dialogfragment, null);
        final DialogBottom dialog = new DialogBottom(getActivity(), view);
        TextView carmenTv = (TextView) view.findViewById(R.id.man_tv);
        TextView videoTV = (TextView) view.findViewById(R.id.woman_tv);
        TextView cancelTv = (TextView) view.findViewById(R.id.cancel_tv);
        carmenTv.setText("拍照");
        videoTV.setText("录像");
        carmenTv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                cameraFile = new File(PathUtil.getInstance().getImagePath(), EMClient.getInstance().getCurrentUser() + System.currentTimeMillis() + ".jpg");
                //noinspection ResultOfMethodCallIgnored
                cameraFile.getParentFile().mkdirs();
                startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA);
                dialog.dismiss();
            }
        });
        videoTV.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                videoFile = new File(PathUtil.getInstance().getImagePath(), EMClient.getInstance().getCurrentUser() + System.currentTimeMillis() + ".mp4");
                videoFile.getParentFile().mkdirs();
                startActivityForResult(new Intent(MediaStore.ACTION_VIDEO_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(videoFile)), REQUEST_CODE_CAMERA_VIDEO);
                dialog.dismiss();
            }
        });
        cancelTv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
    }
    public static final int REQUEST_PERMISSION_VOICE_ = 17;

    /**
     * 回调权限受理
     *
     * @param requestCode
     * @param permissions
     * @param grantResults
     */
    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        switch (requestCode) {
            case REQUEST_PERMISSION_CODE:
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    openCameraSelect();
                } else {
                    QLToastUtils.showToast(getActivity(), "请先在应用管理设置\"相机\"访问权限");
                }
                break;

            case REQUEST_PERMISSION_LOCAL_CODE:
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    startActivityForResult(new Intent(getActivity(), EaseBaiduMapActivity.class), REQUEST_CODE_MAP);
                } else {
                    QLToastUtils.showToast(getActivity(), "请先在应用管理设置\"相机\"访问权限");
                }
                break;
            case REQUEST_PERMISSION_VOICE_:
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//                    setMy();
                } else {
                    QLToastUtils.showToast(getActivity(), "请先在应用管理设置\"录音\"访问权限");

                }
                break;
        }
    }

    /**
     * select local image
     */
    protected void selectPicFromLocal() {
        Intent intent;
        if (Build.VERSION.SDK_INT < 19) {
            intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("image/*");

        } else {
            intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        }
        startActivityForResult(intent, REQUEST_CODE_LOCAL);
    }

    /**
     * clear the conversation history
     */
    protected void emptyHistory() {
        String msg = getResources().getString(R.string.Whether_to_empty_all_chats);
        new EaseAlertDialog(getActivity(), null, msg, null, new AlertDialogUser() {
            @Override
            public void onResult(boolean confirmed, Bundle bundle) {
                if (confirmed) {
                    EMClient.getInstance().chatManager().deleteConversation(toChatUsername, true);
                    messageList.refresh();
                }
            }
        }, true).show();
    }

    /**
     * open group detail
     */
    protected void toGroupDetails() {
        if (chatType == EaseConstant.CHATTYPE_GROUP) {
            EMGroup group = EMClient.getInstance().groupManager().getGroup(toChatUsername);
            if (group == null) {
                Toast.makeText(getActivity(), R.string.gorup_not_found, Toast.LENGTH_SHORT).show();
                return;
            }
            if (chatFragmentHelper != null) {
                chatFragmentHelper.onEnterToChatDetails();
            }
        } else if (chatType == CHATTYPE_CHATROOM) {
            if (chatFragmentHelper != null) {
                chatFragmentHelper.onEnterToChatDetails();
            }
        }
    }

    /**
     * hide
     */
    protected void hideKeyboard() {
        if (getActivity().getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
            if (getActivity().getCurrentFocus() != null)
                inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }

    /**
     * forward message
     *
     * @param forward_msg_id
     */
    protected void forwardMessage(String forward_msg_id) {
        final EMMessage forward_msg = EMClient.getInstance().chatManager().getMessage(forward_msg_id);
        EMMessage.Type type = forward_msg.getType();
        switch (type) {
            case TXT:
                if (forward_msg.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)) {
                    sendBigExpressionMessage(((EMTextMessageBody) forward_msg.getBody()).getMessage(),
                            forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
                } else {
                    // get the content and send it
                    String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage();
                    sendTextMessage(content);
                }
                break;
            case IMAGE:
                // send image
                String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl();
                if (filePath != null) {
                    File file = new File(filePath);
                    if (!file.exists()) {
                        // send thumb nail if original image does not exist
                        filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath();
                    }
                    sendImageMessage(filePath);
                }
                break;
            default:
                break;
        }

        if (forward_msg.getChatType() == EMMessage.ChatType.ChatRoom) {
            EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo());
        }
    }

    /**
     * listen the group event
     */
    class GroupListener extends EaseGroupRemoveListener {

        @Override
        public void onRequestToJoinReceived(String s, String s1, String s2, String s3) {

        }

        @Override
        public void onRequestToJoinAccepted(String s, String s1, String s2) {

        }

        @Override
        public void onRequestToJoinDeclined(String s, String s1, String s2, String s3) {

        }

        @Override
        public void onUserRemoved(final String groupId, String groupName) {
            final Activity activity = getActivity();
            if( activity != null){
                activity.runOnUiThread(new Runnable() {
                    public void run() {
                        if ( toChatUsername!=null && toChatUsername.equals(groupId)) {
                            //Toast.makeText(getActivity(), R.string.you_are_group, Toast.LENGTH_LONG).show();
                            Toast.makeText(getActivity(), "您已被移除群组", Toast.LENGTH_LONG).show();
                            if (!activity.isFinishing()) {
                                activity.finish();
                            }
                        }
                    }
                });
            }
        }

        @Override
        public void onGroupDestroyed(final String groupId, String groupName) {
            // prompt group is dismissed and finish this activity
            final Activity activity = getActivity();
            if( activity != null ) {
                activity.runOnUiThread(new Runnable() {
                    public void run() {
                        if (toChatUsername != null && toChatUsername.equals(groupId)) {
                            //Toast.makeText(getActivity(), R.string.the_current_group, Toast.LENGTH_LONG).show();
                            Toast.makeText(getActivity(), "群组被解散", Toast.LENGTH_LONG).show();
                            if (!activity.isFinishing()) {
                                activity.finish();
                            }
                        }
                    }
                });
            }
        }
    }

    /**
     * 朋友状态监听器
     */
    public class FriendListener implements EMContactListener {
        @Override  //增加了联系人时回调此方法
        public void onContactAdded(String s) {
            System.out.println("增加了联系人时回调此方法");
        }

        @Override  //被删除时回调此方法
        public void onContactDeleted(final String s) {
            System.out.println("被删除时回调此方法");
            isFriend = false ;
//            final Activity activity = getActivity();
//            if( activity != null){
//                activity.runOnUiThread(new Runnable() {
//                    public void run() {
//                        if ( toChatUsername!=null && toChatUsername.equals(s)) {
//                            //Toast.makeText(getActivity(), R.string.you_are_group, Toast.LENGTH_LONG).show();
//                            Toast.makeText(getActivity(), "您已被好友删除", Toast.LENGTH_LONG).show();
//                            if (!activity.isFinishing()) {
//                                activity.finish();
//                            }
//                        }
//                    }
//                });
//            }
        }

        @Override  //收到好友邀请
        public void onContactInvited(String s, String s1) {
            System.out.println("收到好友邀请");
        }

        @Override  //被接受朋友请求
        public void onFriendRequestAccepted(String s) {
            System.out.println("被接受朋友请求");
        }

        @Override   //被朋友请求拒绝
        public void onFriendRequestDeclined(String s) {
            System.out.println("被朋友请求拒绝");
        }
    }

    protected EaseChatFragmentHelper chatFragmentHelper;

    public void setChatFragmentListener(EaseChatFragmentHelper chatFragmentHelper) {
        this.chatFragmentHelper = chatFragmentHelper;
    }

    public interface EaseChatFragmentHelper {
        /**
         * set message attribute
         */
        void onSetMessageAttributes(EMMessage message);

        /**
         * enter to chat detail
         */
        void onEnterToChatDetails();

        /**
         * on avatar clicked
         *
         * @param username
         */
        void onAvatarClick(String username);

        /**
         * on avatar long pressed
         *
         * @param username
         */
        void onAvatarLongClick(String username);

        /**
         * on message bubble clicked
         */
        boolean onMessageBubbleClick(EMMessage message);

        /**
         * on message bubble long pressed
         */
        void onMessageBubbleLongClick(EMMessage message);

        /**
         * on extend menu item clicked, return true if you want to override
         *
         * @param view
         * @param itemId
         * @return
         */
        boolean onExtendMenuItemClick(int itemId, View view);

        /**
         * on set custom chat row provider
         *
         * @return
         */
        EaseCustomChatRowProvider onSetCustomChatRowProvider();
    }

    /**
     * 设置标题栏
     */
    private void setTitleNew(){
        mHandler = new Handler(){
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                if(msg.what==1){        //更新备注名
                    Bundle bundle = msg.getData();
                    Activity ac1tivity = getActivity();
                    if(ac1tivity!=null) ac1tivity.setTitle(bundle.getString(ChatActivity.REMARKS_NAME));
                }else if(msg.what==2){  //更新接收消息者不是自己的好友标志
                    isFriend = false ;
                    if( getActivity()!=null && !getActivity().isFinishing()){
                        getActivity().finish();
                    }
                }
            }
        };
    }
    /**
     * 设置空用户(10000000000)
     */
//    private void setEmptyUesr(){
//        if( chatType == EaseConstant.CHATTYPE_SINGLE && !isFriend ){
//            toChatUsername = ChatActivity.EMPTYUSER ;
//        }
//    }
}


text:
<!doctype html>
<html ng-app="app">
  <head>
    <title>Links Lab</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.1/angular-material.min.css">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <style>

    .link {
      fill: none;
      stroke: #666;
      stroke-width: 1.5px;
    }

    #licensing {
      fill: green;
    }

    .link.licensing {
      stroke: green;
    }

    .link.resolved {
      stroke-dasharray: 0,2 1;
    }

    circle {
      fill: #ccc;
      stroke: #333;
      stroke-width: 1.5px;
    }

    text {
      font: 10px sans-serif;
      pointer-events: none;
      text-shadow: 0 1px 0 #fff, 1px 0 0 #fff, 0 -1px 0 #fff, -1px 0 0 #fff;
    }

    </style>
  </head>

  <body>
    <div style="width: 650px; margin: auto;">
      <domains></domains>
    </div>
  </body>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.12/d3.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-animate.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-aria.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-messages.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.1/angular-material.min.js"></script>

  <script src="client/app/module.js"></script>
  <script src="client/app/domains/domains.component.js"></script>
  <script src="client/app/domains/domains.service.js"></script>

  <script>

  var render = function(links) {
    var nodes = {};

    // Compute the distinct nodes from the links.
    links.forEach(function(link) {
      link.source = nodes[link.source] || (nodes[link.source] = {name: link.source});
      link.target = nodes[link.target] || (nodes[link.target] = {name: link.target});
    });

    var width = 960,
        height = 500;

    var force = d3.layout.force()
        .nodes(d3.values(nodes))
        .links(links)
        .size([width, height])
        .linkDistance(60)
        .charge(-300)
        .on("tick", tick)
        .start();

    var svg = d3.select("body").append("svg")
        .attr("width", width)
        .attr("height", height);

    // Per-type markers, as they don't inherit styles.
    svg.append("defs").selectAll("marker")
        .data(["suit", "licensing", "resolved"])
      .enter().append("marker")
        .attr("id", function(d) { return d; })
        .attr("viewBox", "0 -5 10 10")
        .attr("refX", 15)
        .attr("refY", -1.5)
        .attr("markerWidth", 6)
        .attr("markerHeight", 6)
        .attr("orient", "auto")
      .append("path")
        .attr("d", "M0,-5L10,0L0,5");

    var path = svg.append("g").selectAll("path")
        .data(force.links())
      .enter().append("path")
        .attr("class", function(d) { return "link " + d.type; })
        .attr("marker-end", function(d) { return "url(#" + d.type + ")"; });

    var circle = svg.append("g").selectAll("circle")
        .data(force.nodes())
      .enter().append("circle")
        .attr("r", 6)
        .call(force.drag);

    var text = svg.append("g").selectAll("text")
        .data(force.nodes())
      .enter().append("text")
        .attr("x", 8)
        .attr("y", ".31em")
        .text(function(d) { return d.name; });

    // Use elliptical arc path segments to doubly-encode directionality.
    function tick() {
      path.attr("d", linkArc);
      circle.attr("transform", transform);
      text.attr("transform", transform);
    }

    function linkArc(d) {
      var dx = d.target.x - d.source.x,
          dy = d.target.y - d.source.y,
          dr = Math.sqrt(dx * dx + dy * dy);
      return "M" + d.source.x + "," + d.source.y + "A" + dr + "," + dr + " 0 0,1 " + d.target.x + "," + d.target.y;
    }

    function transform(d) {
      return "translate(" + d.x + "," + d.y + ")";
    }
  };

  // d3.json('/api/graph', function(links) {
  //   console.log(links);
  //   render(links);
  // })

  </script>
</html>

redpajama_set_name: RedPajamaGithub


text:
001
018
019    package org.apache.hadoop.mapred;
020
021    import org.apache.hadoop.classification.InterfaceAudience;
022    import org.apache.hadoop.classification.InterfaceStability;
023    import org.apache.hadoop.fs.Path;
024    import org.apache.hadoop.fs.PathFilter;
025
026    /**
027     * This class filters log files from directory given
028     * It doesnt accept paths having _logs.
029     * This can be used to list paths of output directory as follows:
030     *   Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir,
031     *                                   new OutputLogFilter()));
032     */
033    @InterfaceAudience.Public
034    @InterfaceStability.Stable
035    public class OutputLogFilter implements PathFilter {
036      private static final PathFilter LOG_FILTER =
037        new Utils.OutputFileUtils.OutputLogFilter();
038      public boolean accept(Path path) {
039        return LOG_FILTER.accept(path);
040      }
041    }


text:
using System;

using GreetingHelloDI.Contracts;

namespace GreetingHelloDI.Models
{
    public class ConsoleWriter : IMessageWriter
    {
        public void Write(string message)
        {
            Console.WriteLine(message);
        }
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>

<behavior name="Example Behavior">

	<executable package_path="flexbe_behaviors.example_behavior_sm" class="ExampleBehaviorSM" />
	<tagstring>demo</tagstring>
	<author>Philipp Schillinger</author>
	<date>Fri Aug 21 2015</date>
	<description>
		This is a simple example for a behavior.
	</description>

	<!-- Contained Behaviors -->

	<!-- Available Parameters -->
	<params>

		<param type="numeric" name="waiting_time" default="3" label="Waiting Time" hint="Sets the time to wait after logging.">
			<min value="1" />
			<max value="5" />
		</param>

	</params>

</behavior>


text:
.planningboard .column {
    margin-right: 20px;
}

.new-sprint {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 292px!important;
    height: 132px!important;
    border: 4px dashed #333;
    color: #999;
    cursor: pointer;
}


text:
package apps::protocols::snmp::plugin;

use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);

sub new {
    my ($class, %options) = @_;
    my $self = $class->SUPER::new(package => __PACKAGE__, %options);
    bless $self, $class;

    $self->{modes} = {
        'collection'      => 'apps::protocols::snmp::mode::collection',
        'discovery'       => 'snmp_standard::mode::discovery',
        'dynamic-command' => 'snmp_standard::mode::dynamiccommand',
        'numeric-value'   => 'snmp_standard::mode::numericvalue',
        'response-time'   => 'apps::protocols::snmp::mode::responsetime',
        'string-value'    => 'snmp_standard::mode::stringvalue',
        'uptime'          => 'snmp_standard::mode::uptime'
    };

    return $self;
}

1;

__END__

=head1 PLUGIN DESCRIPTION

Check SNMP values (string, numeric or execute commands).

=cut


text:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using Gallio.Common.Collections;
using Gallio.Runtime.Extensibility;

namespace Gallio.Runtime.FileTypes
{
    /// <summary>
    /// A built-in file type manager that identified file types based on a
    /// set of registered <see cref="IFileTypeRecognizer" /> components.
    /// </summary>
    public class FileTypeManager : IFileTypeManager
    {
        private readonly FileType unknownFileType;
        private readonly List<FileType> fileTypes;
        private readonly Dictionary<string, FileTypeInfo> fileTypeInfos;
        private readonly List<FileTypeInfo> rootFileTypeInfos;

        /// <summary>
        /// Creates a file type manager.
        /// </summary>
        /// <param name="fileTypeRecognizerHandles">The file type recognizer component handles.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="fileTypeRecognizerHandles"/> is null.</exception>
        public FileTypeManager(ComponentHandle<IFileTypeRecognizer, FileTypeRecognizerTraits>[] fileTypeRecognizerHandles)
        {
            if (fileTypeRecognizerHandles == null || Array.IndexOf(fileTypeRecognizerHandles, null) >= 0)
                throw new ArgumentNullException("fileTypeRecognizerHandles");

            unknownFileType = new FileType("Unknown", "File of unknown type.", null);
            fileTypes = new List<FileType>();
            fileTypeInfos = new Dictionary<string, FileTypeInfo>();
            rootFileTypeInfos = new List<FileTypeInfo>();

            Initialize(fileTypeRecognizerHandles);

            // Note: The unknown type is not reachable from the roots so we pay no cost
            //       trying to apply a recognizer to it.  We add it to the other tables for
            //       lookup and enumeration only.
            fileTypes.Add(unknownFileType);
            fileTypeInfos.Add(unknownFileType.Id, new FileTypeInfo()
            {
                FileType = unknownFileType
            });
        }

        /// <inheritdoc />
        public FileType UnknownFileType
        {
            get { return unknownFileType; }
        }

        /// <inheritdoc />
        public FileType GetFileTypeById(string id)
        {
            if (id == null)
                throw new ArgumentNullException("id");

            FileTypeInfo fileTypeInfo;
            if (fileTypeInfos.TryGetValue(id, out fileTypeInfo))
                return fileTypeInfo.FileType;
            return null;
        }

        /// <inheritdoc />
        public IList<FileType> GetFileTypes()
        {
            return new ReadOnlyCollection<FileType>(fileTypes);
        }

        /// <inheritdoc />
        public FileType IdentifyFileType(FileInfo fileInfo)
        {
             if (fileInfo == null)
                throw new ArgumentNullException("fileInfo");

            using (var fileInspector = new LazyFileInspector(fileInfo))
                return IdentifyFileTypeImpl(fileInspector, null);
        }

        /// <inheritdoc />
        public FileType IdentifyFileType(IFileInspector fileInspector)
        {
            if (fileInspector == null)
                throw new ArgumentNullException("fileInspector");

            return IdentifyFileTypeImpl(fileInspector, null);
        }

        /// <inheritdoc />
        public FileType IdentifyFileType(FileInfo fileInfo, IEnumerable<FileType> candidates)
        {
            if (fileInfo == null)
                throw new ArgumentNullException("fileInfo");
            if (candidates == null)
                throw new ArgumentNullException("candidates");

            using (var fileInspector = new LazyFileInspector(fileInfo))
                return IdentifyFileTypeImpl(fileInspector, candidates);
        }

        /// <inheritdoc />
        public FileType IdentifyFileType(IFileInspector fileInspector, IEnumerable<FileType> candidates)
        {
            if (fileInspector == null)
                throw new ArgumentNullException("fileInspector");
            if (candidates == null)
                throw new ArgumentNullException("candidates");

            return IdentifyFileTypeImpl(fileInspector, candidates);
        }

        private FileType IdentifyFileTypeImpl(IFileInspector fileInspector, IEnumerable<FileType> candidates)
        {
            Dictionary<FileType, bool> fileTypeFilter = CreateFileTypeFilter(candidates);

            FileType fileType = IdentifyFileTypeRecursive(fileInspector, fileTypeFilter, rootFileTypeInfos);
            if (fileType == null)
                fileType = unknownFileType;
            return fileType;
        }

        private static Dictionary<FileType, bool> CreateFileTypeFilter(IEnumerable<FileType> candidates)
        {
            if (candidates == null)
                return null;

            Dictionary<FileType, bool> fileTypeFilter = new Dictionary<FileType, bool>();
            foreach (FileType fileType in candidates)
                AddFileTypeToFilter(fileTypeFilter, fileType, true);

            return fileTypeFilter;
        }

        private static void AddFileTypeToFilter(Dictionary<FileType, bool> fileTypeFilter, FileType fileType, bool isExplicitCandidate)
        {
            if (!isExplicitCandidate && fileTypeFilter.ContainsKey(fileType))
                return;

            fileTypeFilter[fileType] = isExplicitCandidate;

            if (fileType.SuperType != null)
                AddFileTypeToFilter(fileTypeFilter, fileType.SuperType, false);
        }

        private static FileType IdentifyFileTypeRecursive(IFileInspector fileInspector, Dictionary<FileType, bool> fileTypeFilter,
            IEnumerable<FileTypeInfo> fileTypeInfos)
        {
            foreach (var fileTypeInfo in fileTypeInfos)
            {
                bool isExplicitCandidate;
                if (fileTypeFilter != null)
                {
                    if (! fileTypeFilter.TryGetValue(fileTypeInfo.FileType, out isExplicitCandidate))
                        continue; // ignore if not in filter
                }
                else
                {
                    isExplicitCandidate = true;
                }

                if (fileTypeInfo.IsRecognizedFile(fileInspector))
                {
                    FileType subtype = IdentifyFileTypeRecursive(fileInspector, fileTypeFilter, fileTypeInfo.Subtypes);
                    if (subtype != null)
                        return subtype;

                    if (isExplicitCandidate)
                        return fileTypeInfo.FileType;
                }
            }

            return null;
        }

        private void Initialize(IEnumerable<ComponentHandle<IFileTypeRecognizer, FileTypeRecognizerTraits>> fileTypeRecognizerHandles)
        {
            foreach (var handle in fileTypeRecognizerHandles)
            {
                string id = handle.GetTraits().Id;
                if (fileTypeInfos.ContainsKey(id))
                    throw new InvalidOperationException(string.Format("There appear to be multiple file types registered with id '{0}'.", id));

                fileTypeInfos.Add(id, new FileTypeInfo() { RecognizerHandle = handle });
            }

            foreach (var fileTypeInfo in fileTypeInfos.Values)
            {
                FileTypeRecognizerTraits recognizerTraits = fileTypeInfo.RecognizerHandle.GetTraits();

                if (recognizerTraits.FileNameRegex != null)
                    fileTypeInfo.FileNameRegex = new Regex(recognizerTraits.FileNameRegex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);

                if (recognizerTraits.ContentsRegex != null)
                    fileTypeInfo.ContentsRegex = new Regex(recognizerTraits.ContentsRegex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);

                string superTypeId = recognizerTraits.SuperTypeId;
                if (superTypeId != null)
                {
                    FileTypeInfo superTypeInfo;
                    if (!fileTypeInfos.TryGetValue(superTypeId, out superTypeInfo))
                        throw new InvalidOperationException(string.Format("File type '{0}' refers to super type '{1}' but the super type is not registered.", recognizerTraits.Id, superTypeId));

                    if (fileTypeInfo.IsSameOrSubtype(superTypeInfo))
                        throw new InvalidOperationException(string.Format("File type '{0}' contains a circular reference to super type '{1}'.", recognizerTraits.Id, superTypeId));

                    superTypeInfo.AddSubtype(fileTypeInfo);
                }
                else
                {
                    rootFileTypeInfos.Add(fileTypeInfo);
                }
            }

            GenerateFileTypes(rootFileTypeInfos, null);
        }

        private void GenerateFileTypes(IEnumerable<FileTypeInfo> fileTypeInfos, FileType superType)
        {
            foreach (var fileTypeInfo in fileTypeInfos)
            {
                FileTypeRecognizerTraits recognizerTraits = fileTypeInfo.RecognizerHandle.GetTraits();
                FileType fileType = new FileType(recognizerTraits.Id, recognizerTraits.Description, superType);
                fileTypes.Add(fileType);

                fileTypeInfo.FileType = fileType;

                GenerateFileTypes(fileTypeInfo.Subtypes, fileType);
            }
        }

        private sealed class FileTypeInfo
        {
            private List<FileTypeInfo> subtypes;

            public ComponentHandle<IFileTypeRecognizer, FileTypeRecognizerTraits> RecognizerHandle { get; set; }

            public FileType FileType { get; set; }

            public IList<FileTypeInfo> Subtypes
            {
                get { return subtypes ?? (IList<FileTypeInfo>) EmptyArray<FileTypeInfo>.Instance; }
            }

            public Regex FileNameRegex { get; set; }

            public Regex ContentsRegex { get; set; }

            public void AddSubtype(FileTypeInfo subtype)
            {
                if (subtypes == null)
                    subtypes = new List<FileTypeInfo>();
                subtypes.Add(subtype);
            }

            public bool IsRecognizedFile(IFileInspector fileInspector)
            {
                if (FileNameRegex != null)
                {
                    FileInfo fileInfo;
                    if (!fileInspector.TryGetFileInfo(out fileInfo))
                        return false;

                    if (! FileNameRegex.IsMatch(fileInfo.Name))
                        return false;
                }

                if (ContentsRegex != null)
                {
                    string contents;
                    if (!fileInspector.TryGetContents(out contents))
                        return false;

                    if (! ContentsRegex.IsMatch(contents))
                        return false;
                }

                IFileTypeRecognizer fileTypeRecognizer = RecognizerHandle.GetComponent();
                return fileTypeRecognizer.IsRecognizedFile(fileInspector);
            }

            public bool IsSameOrSubtype(FileTypeInfo possibleSubtype)
            {
                if (this == possibleSubtype)
                    return true;

                if (subtypes != null)
                {
                    foreach (FileTypeInfo subtype in Subtypes)
                    {
                        if (subtype.IsSameOrSubtype(possibleSubtype))
                            return true;
                    }
                }

                return false;
            }
        }
    }
}


text:
/**
 */
package fr.inria.atlanmod.json.discoverer.coverage;

import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;

/**
 *
 * The Package for the model.
 * It contains accessors for the meta objects to represent
 *

 *
each class,

 *
each feature of each class,

 *
each enum,

 *
and each data type

 *

 *
 * @see fr.inria.atlanmod.json.discoverer.coverage.CoverageFactory
 * @model kind="package"
 * @generated
 */
public interface CoveragePackage extends EPackage {
	/**
	 * The package name.
	 *
	 *
	 * @generated
	 */
	String eNAME = "coverage";

	/**
	 * The package namespace URI.
	 *
	 *
	 * @generated
	 */
	String eNS_URI = "http://fr.inria.atlanmod/json/coverage";

	/**
	 * The package namespace name.
	 *
	 *
	 * @generated
	 */
	String eNS_PREFIX = "coverage";

	/**
	 * The singleton instance of the package.
	 *
	 *
	 * @generated
	 */
	CoveragePackage eINSTANCE = fr.inria.atlanmod.json.discoverer.coverage.impl.CoveragePackageImpl.init();

	/**
	 * The meta object id for the '{@link fr.inria.atlanmod.json.discoverer.coverage.impl.CoverageImpl Coverage}' class.
	 *
	 *
	 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoverageImpl
	 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoveragePackageImpl#getCoverage()
	 * @generated
	 */
	int COVERAGE = 0;

	/**
	 * The feature id for the 'Mappings' containment reference list.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int COVERAGE__MAPPINGS = 0;

	/**
	 * The feature id for the 'Input' reference.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int COVERAGE__INPUT = 1;

	/**
	 * The feature id for the 'Service' attribute.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int COVERAGE__SERVICE = 2;

	/**
	 * The number of structural features of the 'Coverage' class.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int COVERAGE_FEATURE_COUNT = 3;

	/**
	 * The meta object id for the '{@link fr.inria.atlanmod.json.discoverer.coverage.impl.CoverageMappingImpl Mapping}' class.
	 *
	 *
	 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoverageMappingImpl
	 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoveragePackageImpl#getCoverageMapping()
	 * @generated
	 */
	int COVERAGE_MAPPING = 1;

	/**
	 * The number of structural features of the 'Mapping' class.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int COVERAGE_MAPPING_FEATURE_COUNT = 0;

	/**
	 * The meta object id for the '{@link fr.inria.atlanmod.json.discoverer.coverage.impl.AttMappingImpl Att Mapping}' class.
	 *
	 *
	 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.AttMappingImpl
	 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoveragePackageImpl#getAttMapping()
	 * @generated
	 */
	int ATT_MAPPING = 2;

	/**
	 * The feature id for the 'Source' reference.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int ATT_MAPPING__SOURCE = COVERAGE_MAPPING_FEATURE_COUNT + 0;

	/**
	 * The feature id for the 'Target' reference.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int ATT_MAPPING__TARGET = COVERAGE_MAPPING_FEATURE_COUNT + 1;

	/**
	 * The number of structural features of the 'Att Mapping' class.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int ATT_MAPPING_FEATURE_COUNT = COVERAGE_MAPPING_FEATURE_COUNT + 2;

	/**
	 * The meta object id for the '{@link fr.inria.atlanmod.json.discoverer.coverage.impl.RefMappingImpl Ref Mapping}' class.
	 *
	 *
	 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.RefMappingImpl
	 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoveragePackageImpl#getRefMapping()
	 * @generated
	 */
	int REF_MAPPING = 3;

	/**
	 * The feature id for the 'Source' reference.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int REF_MAPPING__SOURCE = COVERAGE_MAPPING_FEATURE_COUNT + 0;

	/**
	 * The feature id for the 'Target' reference.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int REF_MAPPING__TARGET = COVERAGE_MAPPING_FEATURE_COUNT + 1;

	/**
	 * The number of structural features of the 'Ref Mapping' class.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int REF_MAPPING_FEATURE_COUNT = COVERAGE_MAPPING_FEATURE_COUNT + 2;

	/**
	 * The meta object id for the '{@link fr.inria.atlanmod.json.discoverer.coverage.impl.ConceptMappingImpl Concept Mapping}' class.
	 *
	 *
	 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.ConceptMappingImpl
	 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoveragePackageImpl#getConceptMapping()
	 * @generated
	 */
	int CONCEPT_MAPPING = 4;

	/**
	 * The feature id for the 'Source' reference.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int CONCEPT_MAPPING__SOURCE = COVERAGE_MAPPING_FEATURE_COUNT + 0;

	/**
	 * The feature id for the 'Target' reference.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int CONCEPT_MAPPING__TARGET = COVERAGE_MAPPING_FEATURE_COUNT + 1;

	/**
	 * The number of structural features of the 'Concept Mapping' class.
	 *
	 *
	 * @generated
	 * @ordered
	 */
	int CONCEPT_MAPPING_FEATURE_COUNT = COVERAGE_MAPPING_FEATURE_COUNT + 2;

	/**
	 * Returns the meta object for class '{@link fr.inria.atlanmod.json.discoverer.coverage.Coverage Coverage}'.
	 *
	 *
	 * @return the meta object for class 'Coverage'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.Coverage
	 * @generated
	 */
	EClass getCoverage();

	/**
	 * Returns the meta object for the containment reference list '{@link fr.inria.atlanmod.json.discoverer.coverage.Coverage#getMappings Mappings}'.
	 *
	 *
	 * @return the meta object for the containment reference list 'Mappings'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.Coverage#getMappings()
	 * @see #getCoverage()
	 * @generated
	 */
	EReference getCoverage_Mappings();

	/**
	 * Returns the meta object for the reference '{@link fr.inria.atlanmod.json.discoverer.coverage.Coverage#getInput Input}'.
	 *
	 *
	 * @return the meta object for the reference 'Input'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.Coverage#getInput()
	 * @see #getCoverage()
	 * @generated
	 */
	EReference getCoverage_Input();

	/**
	 * Returns the meta object for the attribute '{@link fr.inria.atlanmod.json.discoverer.coverage.Coverage#getService Service}'.
	 *
	 *
	 * @return the meta object for the attribute 'Service'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.Coverage#getService()
	 * @see #getCoverage()
	 * @generated
	 */
	EAttribute getCoverage_Service();

	/**
	 * Returns the meta object for class '{@link fr.inria.atlanmod.json.discoverer.coverage.CoverageMapping Mapping}'.
	 *
	 *
	 * @return the meta object for class 'Mapping'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.CoverageMapping
	 * @generated
	 */
	EClass getCoverageMapping();

	/**
	 * Returns the meta object for class '{@link fr.inria.atlanmod.json.discoverer.coverage.AttMapping Att Mapping}'.
	 *
	 *
	 * @return the meta object for class 'Att Mapping'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.AttMapping
	 * @generated
	 */
	EClass getAttMapping();

	/**
	 * Returns the meta object for the reference '{@link fr.inria.atlanmod.json.discoverer.coverage.AttMapping#getSource Source}'.
	 *
	 *
	 * @return the meta object for the reference 'Source'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.AttMapping#getSource()
	 * @see #getAttMapping()
	 * @generated
	 */
	EReference getAttMapping_Source();

	/**
	 * Returns the meta object for the reference '{@link fr.inria.atlanmod.json.discoverer.coverage.AttMapping#getTarget Target}'.
	 *
	 *
	 * @return the meta object for the reference 'Target'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.AttMapping#getTarget()
	 * @see #getAttMapping()
	 * @generated
	 */
	EReference getAttMapping_Target();

	/**
	 * Returns the meta object for class '{@link fr.inria.atlanmod.json.discoverer.coverage.RefMapping Ref Mapping}'.
	 *
	 *
	 * @return the meta object for class 'Ref Mapping'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.RefMapping
	 * @generated
	 */
	EClass getRefMapping();

	/**
	 * Returns the meta object for the reference '{@link fr.inria.atlanmod.json.discoverer.coverage.RefMapping#getSource Source}'.
	 *
	 *
	 * @return the meta object for the reference 'Source'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.RefMapping#getSource()
	 * @see #getRefMapping()
	 * @generated
	 */
	EReference getRefMapping_Source();

	/**
	 * Returns the meta object for the reference '{@link fr.inria.atlanmod.json.discoverer.coverage.RefMapping#getTarget Target}'.
	 *
	 *
	 * @return the meta object for the reference 'Target'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.RefMapping#getTarget()
	 * @see #getRefMapping()
	 * @generated
	 */
	EReference getRefMapping_Target();

	/**
	 * Returns the meta object for class '{@link fr.inria.atlanmod.json.discoverer.coverage.ConceptMapping Concept Mapping}'.
	 *
	 *
	 * @return the meta object for class 'Concept Mapping'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.ConceptMapping
	 * @generated
	 */
	EClass getConceptMapping();

	/**
	 * Returns the meta object for the reference '{@link fr.inria.atlanmod.json.discoverer.coverage.ConceptMapping#getSource Source}'.
	 *
	 *
	 * @return the meta object for the reference 'Source'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.ConceptMapping#getSource()
	 * @see #getConceptMapping()
	 * @generated
	 */
	EReference getConceptMapping_Source();

	/**
	 * Returns the meta object for the reference '{@link fr.inria.atlanmod.json.discoverer.coverage.ConceptMapping#getTarget Target}'.
	 *
	 *
	 * @return the meta object for the reference 'Target'.
	 * @see fr.inria.atlanmod.json.discoverer.coverage.ConceptMapping#getTarget()
	 * @see #getConceptMapping()
	 * @generated
	 */
	EReference getConceptMapping_Target();

	/**
	 * Returns the factory that creates the instances of the model.
	 *
	 *
	 * @return the factory that creates the instances of the model.
	 * @generated
	 */
	CoverageFactory getCoverageFactory();

	/**
	 *
	 * Defines literals for the meta objects that represent
	 *

	 *
each class,

	 *
each feature of each class,

	 *
each enum,

	 *
and each data type

	 *

	 *
	 * @generated
	 */
	interface Literals {
		/**
		 * The meta object literal for the '{@link fr.inria.atlanmod.json.discoverer.coverage.impl.CoverageImpl Coverage}' class.
		 *
		 *
		 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoverageImpl
		 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoveragePackageImpl#getCoverage()
		 * @generated
		 */
		EClass COVERAGE = eINSTANCE.getCoverage();

		/**
		 * The meta object literal for the 'Mappings' containment reference list feature.
		 *
		 *
		 * @generated
		 */
		EReference COVERAGE__MAPPINGS = eINSTANCE.getCoverage_Mappings();

		/**
		 * The meta object literal for the 'Input' reference feature.
		 *
		 *
		 * @generated
		 */
		EReference COVERAGE__INPUT = eINSTANCE.getCoverage_Input();

		/**
		 * The meta object literal for the 'Service' attribute feature.
		 *
		 *
		 * @generated
		 */
		EAttribute COVERAGE__SERVICE = eINSTANCE.getCoverage_Service();

		/**
		 * The meta object literal for the '{@link fr.inria.atlanmod.json.discoverer.coverage.impl.CoverageMappingImpl Mapping}' class.
		 *
		 *
		 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoverageMappingImpl
		 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoveragePackageImpl#getCoverageMapping()
		 * @generated
		 */
		EClass COVERAGE_MAPPING = eINSTANCE.getCoverageMapping();

		/**
		 * The meta object literal for the '{@link fr.inria.atlanmod.json.discoverer.coverage.impl.AttMappingImpl Att Mapping}' class.
		 *
		 *
		 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.AttMappingImpl
		 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoveragePackageImpl#getAttMapping()
		 * @generated
		 */
		EClass ATT_MAPPING = eINSTANCE.getAttMapping();

		/**
		 * The meta object literal for the 'Source' reference feature.
		 *
		 *
		 * @generated
		 */
		EReference ATT_MAPPING__SOURCE = eINSTANCE.getAttMapping_Source();

		/**
		 * The meta object literal for the 'Target' reference feature.
		 *
		 *
		 * @generated
		 */
		EReference ATT_MAPPING__TARGET = eINSTANCE.getAttMapping_Target();

		/**
		 * The meta object literal for the '{@link fr.inria.atlanmod.json.discoverer.coverage.impl.RefMappingImpl Ref Mapping}' class.
		 *
		 *
		 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.RefMappingImpl
		 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoveragePackageImpl#getRefMapping()
		 * @generated
		 */
		EClass REF_MAPPING = eINSTANCE.getRefMapping();

		/**
		 * The meta object literal for the 'Source' reference feature.
		 *
		 *
		 * @generated
		 */
		EReference REF_MAPPING__SOURCE = eINSTANCE.getRefMapping_Source();

		/**
		 * The meta object literal for the 'Target' reference feature.
		 *
		 *
		 * @generated
		 */
		EReference REF_MAPPING__TARGET = eINSTANCE.getRefMapping_Target();

		/**
		 * The meta object literal for the '{@link fr.inria.atlanmod.json.discoverer.coverage.impl.ConceptMappingImpl Concept Mapping}' class.
		 *
		 *
		 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.ConceptMappingImpl
		 * @see fr.inria.atlanmod.json.discoverer.coverage.impl.CoveragePackageImpl#getConceptMapping()
		 * @generated
		 */
		EClass CONCEPT_MAPPING = eINSTANCE.getConceptMapping();

		/**
		 * The meta object literal for the 'Source' reference feature.
		 *
		 *
		 * @generated
		 */
		EReference CONCEPT_MAPPING__SOURCE = eINSTANCE.getConceptMapping_Source();

		/**
		 * The meta object literal for the 'Target' reference feature.
		 *
		 *
		 * @generated
		 */
		EReference CONCEPT_MAPPING__TARGET = eINSTANCE.getConceptMapping_Target();

	}

} //CoveragePackage


text:
dojo.provide("dojox.grid._RowSelector");
dojo.require("dojox.grid._View");

dojo.declare('dojox.grid._RowSelector', dojox.grid._View, {
	// summary:
	//	Custom grid view. If used in a grid structure, provides a small selectable region for grid rows.
	defaultWidth: "2em",
	noscroll: true,
	padBorderWidth: 2,
	buildRendering: function(){
		this.inherited('buildRendering', arguments);
		this.scrollboxNode.style.overflow = "hidden";
		this.headerNode.style.visibility = "hidden";
	},
	getWidth: function(){
		return this.viewWidth || this.defaultWidth;
	},
	buildRowContent: function(inRowIndex, inRowNode){
		var w = this.contentWidth || 0;
		inRowNode.innerHTML = '

';
	},
	renderHeader: function(){
	},
	updateRow: function(){
	},
	resize: function(){
		this.adaptHeight();
	},
	adaptWidth: function(){
		// Only calculate this here - rather than every call to buildRowContent
		if(!("contentWidth" in this) && this.contentNode){
			this.contentWidth = this.contentNode.offsetWidth - this.padBorderWidth;
		}
	},
	// styling
	doStyleRowNode: function(inRowIndex, inRowNode){
		var n = [ "dojoxGridRowbar dojoxGridNonNormalizedCell" ];
		if(this.grid.rows.isOver(inRowIndex)){
			n.push("dojoxGridRowbarOver");
		}
		if(this.grid.selection.isSelected(inRowIndex)){
			n.push("dojoxGridRowbarSelected");
		}
		inRowNode.className = n.join(" ");
	},
	// event handlers
	domouseover: function(e){
		this.grid.onMouseOverRow(e);
	},
	domouseout: function(e){
		if(!this.isIntraRowEvent(e)){
			this.grid.onMouseOutRow(e);
		}
	}
});


text:
@interface BABaseTableViewController : QMUICommonTableViewController

- (void)setupUI;

@end