Search in sources :

Example 1 with IEmotionExtClickListener

use of com.lqr.emoji.IEmotionExtClickListener in project android-chat by wildfirechat.

the class ConversationInputPanel method init.

public void init(Fragment fragment, InputAwareLayout rootInputAwareLayout) {
    LayoutInflater.from(getContext()).inflate(R.layout.conversation_input_panel, this, true);
    ButterKnife.bind(this, this);
    this.activity = fragment.getActivity();
    this.fragment = fragment;
    this.rootLinearLayout = rootInputAwareLayout;
    this.extension = new ConversationExtension(fragment, this, extViewPager);
    sharedPreferences = getContext().getSharedPreferences("sticker", Context.MODE_PRIVATE);
    // emotion
    emotionLayout.setEmotionAddVisiable(true);
    emotionLayout.setEmotionSettingVisiable(true);
    // audio record panel
    audioRecorderPanel = new AudioRecorderPanel(getContext());
    audioRecorderPanel.setRecordListener(new AudioRecorderPanel.OnRecordListener() {

        @Override
        public void onRecordSuccess(String audioFile, int duration) {
            // ๅ‘้€ๆ–‡ไปถ
            File file = new File(audioFile);
            if (file.exists()) {
                messageViewModel.sendAudioFile(conversation, Uri.parse(audioFile), duration);
            }
        }

        @Override
        public void onRecordFail(String reason) {
            Toast.makeText(activity, reason, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onRecordStateChanged(AudioRecorderPanel.RecordState state) {
            if (state == AudioRecorderPanel.RecordState.START) {
                TypingMessageContent content = new TypingMessageContent(TypingMessageContent.TYPING_VOICE);
                messageViewModel.sendMessage(conversation, content);
            }
        }
    });
    SharedPreferences sp = fragment.getContext().getSharedPreferences(Config.SP_CONFIG_FILE_NAME, Context.MODE_PRIVATE);
    boolean pttEnabled = sp.getBoolean("pttEnabled", true);
    if (pttEnabled && PTTClient.checkAddress(ChatManager.Instance().getHost())) {
        pttImageView.setVisibility(View.VISIBLE);
        pttPanel = new PttPanel(getContext());
    }
    // emotion
    emotionLayout.setEmotionSelectedListener(this);
    emotionLayout.setEmotionExtClickListener(new IEmotionExtClickListener() {

        @Override
        public void onEmotionAddClick(View view) {
            Toast.makeText(activity, "add", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onEmotionSettingClick(View view) {
            Toast.makeText(activity, "setting", Toast.LENGTH_SHORT).show();
        }
    });
    messageViewModel = ViewModelProviders.of(fragment).get(MessageViewModel.class);
    conversationViewModel = ViewModelProviders.of(fragment).get(ConversationViewModel.class);
}
Also used : ConversationExtension(cn.wildfire.chat.kit.conversation.ext.core.ConversationExtension) TypingMessageContent(cn.wildfirechat.message.TypingMessageContent) SharedPreferences(android.content.SharedPreferences) PttPanel(cn.wildfire.chat.kit.audio.PttPanel) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) MessageViewModel(cn.wildfire.chat.kit.viewmodel.MessageViewModel) AudioRecorderPanel(cn.wildfire.chat.kit.audio.AudioRecorderPanel) IEmotionExtClickListener(com.lqr.emoji.IEmotionExtClickListener) File(java.io.File)

Aggregations

SharedPreferences (android.content.SharedPreferences)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 AudioRecorderPanel (cn.wildfire.chat.kit.audio.AudioRecorderPanel)1 PttPanel (cn.wildfire.chat.kit.audio.PttPanel)1 ConversationExtension (cn.wildfire.chat.kit.conversation.ext.core.ConversationExtension)1 MessageViewModel (cn.wildfire.chat.kit.viewmodel.MessageViewModel)1 TypingMessageContent (cn.wildfirechat.message.TypingMessageContent)1 IEmotionExtClickListener (com.lqr.emoji.IEmotionExtClickListener)1 File (java.io.File)1