Commit f15e59c0 by 霍志良

feat:im-灵犀2.0-用户显示灵犀的正在输入中

parent 2d620ac1
package com.yidianling.im.session.viewholder; package com.yidianling.im.session.viewholder;
import android.content.ContextWrapper;
import android.os.Build;
import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
...@@ -14,6 +17,7 @@ import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum; ...@@ -14,6 +17,7 @@ import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
import com.netease.nimlib.sdk.msg.model.IMMessage; import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.ydl.ydlcommon.data.http.RxUtils; import com.ydl.ydlcommon.data.http.RxUtils;
import com.yidianling.common.tools.LogUtil; import com.yidianling.common.tools.LogUtil;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R; import com.yidianling.im.R;
import com.yidianling.im.event.MultipleSelectedEvent; import com.yidianling.im.event.MultipleSelectedEvent;
import com.yidianling.im.event.OthersState; import com.yidianling.im.event.OthersState;
...@@ -76,7 +80,6 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -76,7 +80,6 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
switch (customAttachLingxiWhichQuestion.type){ switch (customAttachLingxiWhichQuestion.type){
case "radio"://您想要咨询下列哪类的问题?(单选) case "radio"://您想要咨询下列哪类的问题?(单选)
return R.layout.im_nim_lingxi_which_question; return R.layout.im_nim_lingxi_which_question;
// return R.layout.im_nim_lingxi_multiple_choice;
case "check"://请问是发生了什么事情导致的呢?(多选) case "check"://请问是发生了什么事情导致的呢?(多选)
return R.layout.im_nim_lingxi_multiple_choice; return R.layout.im_nim_lingxi_multiple_choice;
case "3"://您是先生还是女生 case "3"://您是先生还是女生
...@@ -170,6 +173,10 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -170,6 +173,10 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
} }
private void initMultipleChoice() { private void initMultipleChoice() {
confirm_multiple_choice.setOnClickListener(view -> {
//请求接口发送所选题目
answerLingxiQuestion(examId,questionPaperId, ImIn.INSTANCE.getUserInfo().getUid(),questionId,answersItems);
});
multiple_choice_title.setText(customAttachLingxiWhichQuestion.name); multiple_choice_title.setText(customAttachLingxiWhichQuestion.name);
adapterLingxiMultipleChoice = new AdapterLingxiMultipleChoice(); adapterLingxiMultipleChoice = new AdapterLingxiMultipleChoice();
adapterLingxiMultipleChoice.setTagData(questionList); adapterLingxiMultipleChoice.setTagData(questionList);
...@@ -238,15 +245,30 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -238,15 +245,30 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
if (i==position){ if (i==position){
questionList.get(i).setSelected(false); questionList.get(i).setSelected(false);
selectedStr.remove(questionList.get(i).getName()); selectedStr.remove(questionList.get(i).getName());
answersItems.remove(position);
} }
}else{ }else{
if (i==position){ if (i==position){
questionList.get(i).setSelected(true); questionList.get(i).setSelected(true);
selectedStr.add(questionList.get(i).getName()); selectedStr.add(questionList.get(i).getName());
answersItems.add(new AnswersItem(questionList.get(position).getId(),
questionList.get(position).getName(),"其他",questionList.get(position).getRelates()));
} }
} }
} }
confirm_multiple_choice.setText(String.format("确定(%d)", selectedStr.size())); confirm_multiple_choice.setText(String.format("确定(%d)", selectedStr.size()));
if (selectedStr.size()>0){
confirm_multiple_choice.setEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
confirm_multiple_choice.setBackground(context.getResources().getDrawable(R.drawable.im_background_18dp_1da1f2));
}
}else{
confirm_multiple_choice.setEnabled(false);
confirm_multiple_choice.setText("确定");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
confirm_multiple_choice.setBackground(context.getDrawable(R.drawable.im_background_18dp_ebebeb));
}
}
stringBuffer.delete(2,stringBuffer.length()); stringBuffer.delete(2,stringBuffer.length());
for (int i=0;i<selectedStr.size();i++){ for (int i=0;i<selectedStr.size();i++){
stringBuffer.append("#").append(selectedStr.get(i)); stringBuffer.append("#").append(selectedStr.get(i));
...@@ -254,6 +276,9 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -254,6 +276,9 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
isOthers=questionList.get(position).getName().contains("其他"); isOthers=questionList.get(position).getName().contains("其他");
EventBus.getDefault().post(new MultipleSelectedEvent(stringBuffer.toString(),new OthersState(isOthers,questionList.get(position).isSelected()))); EventBus.getDefault().post(new MultipleSelectedEvent(stringBuffer.toString(),new OthersState(isOthers,questionList.get(position).isSelected())));
adapterLingxiMultipleChoice.setTagData(questionList); adapterLingxiMultipleChoice.setTagData(questionList);
} }
private void updateLocalMsg(Integer position) { private void updateLocalMsg(Integer position) {
//更新本地消息 //更新本地消息
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
android:text="婚姻家庭婚姻混" android:text="婚姻家庭婚姻混"
android:textColor="@color/platform_color_1DA1F2" android:textColor="@color/platform_color_1DA1F2"
android:gravity="center" android:gravity="center"
android:minWidth="110dp"
android:background="@drawable/im_background_18dp_e8f5fe" android:background="@drawable/im_background_18dp_e8f5fe"
android:paddingTop="@dimen/platform_dp_8" android:paddingTop="@dimen/platform_dp_8"
android:paddingBottom="@dimen/platform_dp_8" android:paddingBottom="@dimen/platform_dp_8"
......
...@@ -39,11 +39,13 @@ ...@@ -39,11 +39,13 @@
android:text="确定(0)" android:text="确定(0)"
android:layout_marginTop="@dimen/platform_dp_24" android:layout_marginTop="@dimen/platform_dp_24"
android:textSize="@dimen/im_text_size_15" android:textSize="@dimen/im_text_size_15"
android:enabled="false"
app:layout_constraintEnd_toEndOf="@id/multiple_question_rv" app:layout_constraintEnd_toEndOf="@id/multiple_question_rv"
android:layout_marginEnd="@dimen/platform_dp_12" android:layout_marginEnd="@dimen/platform_dp_12"
android:background="@drawable/im_background_18dp_ebebeb" android:background="@drawable/im_background_18dp_ebebeb"
android:paddingTop="@dimen/platform_dp_8" android:paddingTop="@dimen/platform_dp_8"
android:paddingBottom="@dimen/platform_dp_8" android:paddingBottom="@dimen/platform_dp_8"
android:textColor="@color/white"
android:gravity="center" android:gravity="center"
android:layout_marginBottom="@dimen/platform_dp_20" android:layout_marginBottom="@dimen/platform_dp_20"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment