Commit a358fcc2 by 霍志良

feat:im-灵犀2.0-多选逻辑

parent 69d2343d
package com.yidianling.im.event
public class MultipleSelectedEvent (
val strSelected:String
)
\ No newline at end of file
package com.yidianling.im.session.viewholder; package com.yidianling.im.session.viewholder;
import android.widget.TextView;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.yidianling.common.tools.LogUtil;
import com.yidianling.common.tools.ToastUtil; 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.session.extension.CustomAttachLingxiWhichQuestion; import com.yidianling.im.session.extension.CustomAttachLingxiWhichQuestion;
import com.yidianling.im.session.extension.CustomAttachmentOrderStatus; import com.yidianling.im.session.extension.CustomAttachmentOrderStatus;
import com.yidianling.im.session.viewholder.adapter.AdapterLingxiMultipleChoice; import com.yidianling.im.session.viewholder.adapter.AdapterLingxiMultipleChoice;
...@@ -19,15 +23,20 @@ import org.jetbrains.annotations.NotNull; ...@@ -19,15 +23,20 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import de.greenrobot.event.EventBus;
public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implements AdapterLingxiWhichQuestion.OnQuestionlItemClickListener, AdapterLingxiMultipleChoice.OnMultiplelItemClickListener { public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implements AdapterLingxiWhichQuestion.OnQuestionlItemClickListener, AdapterLingxiMultipleChoice.OnMultiplelItemClickListener {
private RecyclerView recycleviewWhichQuestion; private RecyclerView recycleviewWhichQuestion;
private RecyclerView recycleviewMultipleChoice; private RecyclerView recycleviewMultipleChoice;
private TextView confirm_multiple_choice;
private AdapterLingxiWhichQuestion adapterLingxiWhichQuestion; private AdapterLingxiWhichQuestion adapterLingxiWhichQuestion;
private AdapterLingxiMultipleChoice adapterLingxiMultipleChoice; private AdapterLingxiMultipleChoice adapterLingxiMultipleChoice;
ArrayList<QuestionItemBean> questionList = new ArrayList<QuestionItemBean>(); ArrayList<QuestionItemBean> questionList = new ArrayList<QuestionItemBean>();
Boolean isSingleChoice=false; Boolean isSingleChoice=false;
CustomAttachLingxiWhichQuestion customAttachLingxiWhichQuestion; CustomAttachLingxiWhichQuestion customAttachLingxiWhichQuestion;
private StringBuffer stringBuffer=new StringBuffer("已选:");
ArrayList<String> selectedStr=new ArrayList<String>();
public MsgViewHolderLingxiWhichQuestion(BaseMultiItemFetchLoadAdapter adapter) { public MsgViewHolderLingxiWhichQuestion(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter); super(adapter);
} }
...@@ -37,8 +46,8 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -37,8 +46,8 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment()); customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment());
switch (Integer.parseInt(customAttachLingxiWhichQuestion.selectType)){ switch (Integer.parseInt(customAttachLingxiWhichQuestion.selectType)){
case 1://您想要咨询下列哪类的问题?(单选) case 1://您想要咨询下列哪类的问题?(单选)
return R.layout.im_nim_lingxi_which_question; // return R.layout.im_nim_lingxi_which_question;
// return R.layout.im_nim_lingxi_multiple_choice; return R.layout.im_nim_lingxi_multiple_choice;
case 2://请问是发生了什么事情导致的呢?(多选) case 2://请问是发生了什么事情导致的呢?(多选)
return R.layout.im_nim_lingxi_multiple_choice; return R.layout.im_nim_lingxi_multiple_choice;
case 3://您是先生还是女生 case 3://您是先生还是女生
...@@ -52,6 +61,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -52,6 +61,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
protected void inflateContentView() { protected void inflateContentView() {
recycleviewWhichQuestion = findViewById(R.id.which_question_rv); recycleviewWhichQuestion = findViewById(R.id.which_question_rv);
recycleviewMultipleChoice = findViewById(R.id.multiple_question_rv); recycleviewMultipleChoice = findViewById(R.id.multiple_question_rv);
confirm_multiple_choice = findViewById(R.id.confirm_multiple_choice);
} }
...@@ -62,7 +72,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -62,7 +72,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
adapterLingxiWhichQuestion = new AdapterLingxiWhichQuestion(); adapterLingxiWhichQuestion = new AdapterLingxiWhichQuestion();
for (int i=0;i<8;i++){ for (int i=0;i<8;i++){
questionList.add(new QuestionItemBean("1","婚姻情感试",false)); questionList.add(new QuestionItemBean("1","婚姻情感试"+i,false));
} }
for (int i=0;i<questionList.size();i++){ for (int i=0;i<questionList.size();i++){
if (questionList.get(i).getName().length()>5){ if (questionList.get(i).getName().length()>5){
...@@ -70,25 +80,36 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -70,25 +80,36 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
break; break;
} }
} }
adapterLingxiWhichQuestion.setTagData(questionList,isSingleChoice); switch (Integer.parseInt(customAttachLingxiWhichQuestion.selectType)){
adapterLingxiWhichQuestion.setItemListener(this); case 1://您想要咨询下列哪类的问题?(单选)
GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 2); adapterLingxiWhichQuestion.setTagData(questionList,isSingleChoice);
//当list中字段大于6个显示单行,否则显示双行 adapterLingxiWhichQuestion.setItemListener(this);
gridLayoutManager.setSpanCount(isSingleChoice ? 1 : 2); GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 2);
gridLayoutManager.setOrientation(GridLayoutManager.VERTICAL); //当list中字段大于6个显示单行,否则显示双行
recycleviewWhichQuestion.setLayoutManager(gridLayoutManager); gridLayoutManager.setSpanCount(isSingleChoice ? 1 : 2);
recycleviewWhichQuestion.setAdapter(adapterLingxiWhichQuestion); gridLayoutManager.setOrientation(GridLayoutManager.VERTICAL);
recycleviewWhichQuestion.setLayoutManager(gridLayoutManager);
// //请问是发生了什么事情导致的呢?(多选) recycleviewWhichQuestion.setAdapter(adapterLingxiWhichQuestion);
// adapterLingxiMultipleChoice = new AdapterLingxiMultipleChoice(); break;
// adapterLingxiMultipleChoice.setTagData(questionList); case 2://请问是发生了什么事情导致的呢?(多选)
// adapterLingxiMultipleChoice.setItemListener(this); // //请问是发生了什么事情导致的呢?(多选)
// GridLayoutManager multipleChoiceManager = new GridLayoutManager(context, 2); adapterLingxiMultipleChoice = new AdapterLingxiMultipleChoice();
// //当list中字段大于6个显示单行,否则显示双行 adapterLingxiMultipleChoice.setTagData(questionList);
// multipleChoiceManager.setSpanCount(maxItemSize > 6 ? 1 : 2); adapterLingxiMultipleChoice.setItemListener(this);
// multipleChoiceManager.setOrientation(GridLayoutManager.VERTICAL); GridLayoutManager multipleChoiceManager = new GridLayoutManager(context, 2);
// recycleviewMultipleChoice.setLayoutManager(multipleChoiceManager); //当list中字段大于6个显示单行,否则显示双行
// recycleviewMultipleChoice.setAdapter(adapterLingxiMultipleChoice); multipleChoiceManager.setSpanCount( isSingleChoice ? 1 : 2);
multipleChoiceManager.setOrientation(GridLayoutManager.VERTICAL);
recycleviewMultipleChoice.setLayoutManager(multipleChoiceManager);
recycleviewMultipleChoice.setAdapter(adapterLingxiMultipleChoice);
break;
case 3://您是先生还是女生
break;
default:
break;
}
} }
...@@ -107,13 +128,23 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -107,13 +128,23 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
if (questionList.get(i).isSelected()){ if (questionList.get(i).isSelected()){
if (i==position){ if (i==position){
questionList.get(i).setSelected(false); questionList.get(i).setSelected(false);
selectedStr.remove(questionList.get(i).getName());
} }
}else{ }else{
if (i==position){ if (i==position){
questionList.get(i).setSelected(true); questionList.get(i).setSelected(true);
selectedStr.add(questionList.get(i).getName());
} }
} }
} }
confirm_multiple_choice.setText(selectedStr.size());
stringBuffer.delete(2,stringBuffer.length());
for (int i=0;i<selectedStr.size();i++){
stringBuffer.append("#").append(selectedStr.get(i));
}
EventBus.getDefault().post(new MultipleSelectedEvent(stringBuffer.toString()));
adapterLingxiMultipleChoice.setTagData(questionList); adapterLingxiMultipleChoice.setTagData(questionList);
} }
} }
...@@ -22,6 +22,7 @@ import android.widget.LinearLayout; ...@@ -22,6 +22,7 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
...@@ -57,6 +58,7 @@ import com.ydl.ydlcommon.view.CircleImageView; ...@@ -57,6 +58,7 @@ import com.ydl.ydlcommon.view.CircleImageView;
import com.ydl.ydlcommon.view.dialog.CommonDialog; import com.ydl.ydlcommon.view.dialog.CommonDialog;
import com.yidianling.common.tools.ToastUtil; 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.helper.IMChatUtil; import com.yidianling.im.helper.IMChatUtil;
import com.yidianling.im.router.ImIn; import com.yidianling.im.router.ImIn;
import com.yidianling.nimbase.api.UIKitOptions; import com.yidianling.nimbase.api.UIKitOptions;
...@@ -102,6 +104,7 @@ import java.util.Calendar; ...@@ -102,6 +104,7 @@ import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import de.greenrobot.event.EventBus;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
...@@ -167,7 +170,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy { ...@@ -167,7 +170,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
private RelativeLayout rl_common_question_enter; private RelativeLayout rl_common_question_enter;
private FrameLayout fl_question_content; private FrameLayout fl_question_content;
private List<CommonQuestionBean> commonQuestionBeanList; private List<CommonQuestionBean> commonQuestionBeanList;
private TextView question_multiple;
private LinearLayout comment_banner_view_ll; private LinearLayout comment_banner_view_ll;
private TextView tv_all_comment_desc; private TextView tv_all_comment_desc;
private ImageView tv_all_comment_go; private ImageView tv_all_comment_go;
...@@ -260,8 +263,9 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy { ...@@ -260,8 +263,9 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
//和助理私聊时的常用语逻辑 //和助理私聊时的常用语逻辑
rl_common_question_enter = rootView.findViewById(R.id.rl_common_question); rl_common_question_enter = rootView.findViewById(R.id.rl_common_question);
fl_question_content = rootView.findViewById(R.id.fl_question_content); fl_question_content = rootView.findViewById(R.id.fl_question_content);
rl_common_question_enter.setVisibility(ActionHandlerStorage.getL(sessionId) != null && ActionHandlerStorage.getL(sessionId).getUserType() == 3 ? View.VISIBLE : View.GONE); question_multiple = rootView.findViewById(R.id.question_multiple);
//做灵犀2.0 去掉常用语逻辑
//rl_common_question_enter.setVisibility(ActionHandlerStorage.getL(sessionId) != null && ActionHandlerStorage.getL(sessionId).getUserType() == 3 ? View.VISIBLE : View.GONE);
if (ActionHandlerStorage.getL(sessionId).getUserType() != 2) { if (ActionHandlerStorage.getL(sessionId).getUserType() != 2) {
if (null != getActivity() && null != rela_zixun) { if (null != getActivity() && null != rela_zixun) {
rela_zixun.setVisibility(View.GONE); rela_zixun.setVisibility(View.GONE);
...@@ -287,6 +291,12 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy { ...@@ -287,6 +291,12 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
} }
} }
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EventBus.getDefault().register(this);
}
private void initView() { private void initView() {
if (ActionHandlerStorage.getL(sessionId) != null && ActionHandlerStorage.getL(sessionId).getUserType() == 3) { if (ActionHandlerStorage.getL(sessionId) != null && ActionHandlerStorage.getL(sessionId).getUserType() == 3) {
rl_common_question_enter.setOnClickListener(v -> { rl_common_question_enter.setOnClickListener(v -> {
...@@ -1047,7 +1057,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy { ...@@ -1047,7 +1057,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
@Override @Override
public void onDestroy() { public void onDestroy() {
comment_banner_view.onDestory(); comment_banner_view.onDestory();
EventBus.getDefault().unregister(this);
super.onDestroy(); super.onDestroy();
messageListPanel.onDestroy(); messageListPanel.onDestroy();
registerObservers(false); registerObservers(false);
...@@ -1058,7 +1068,9 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy { ...@@ -1058,7 +1068,9 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
aitManager.reset(); aitManager.reset();
} }
} }
public void onEvent(MultipleSelectedEvent event){
question_multiple.setText(event.getStrSelected());
}
public boolean onBackPressed() { public boolean onBackPressed() {
return inputPanel.collapse(true) || messageListPanel.onBackPressed() || openOrCloseCommonQuestionLayout(false); return inputPanel.collapse(true) || messageListPanel.onBackPressed() || openOrCloseCommonQuestionLayout(false);
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
android:layout_width="110dp" android:layout_width="110dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/multiple_question_rv" app:layout_constraintTop_toBottomOf="@id/multiple_question_rv"
android:text="确定(2)" 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"
app:layout_constraintEnd_toEndOf="@id/multiple_question_rv" app:layout_constraintEnd_toEndOf="@id/multiple_question_rv"
......
...@@ -575,6 +575,7 @@ ...@@ -575,6 +575,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="42dp" android:layout_height="42dp"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:visibility="invisible"
android:background="@drawable/im_background_chat_common_question" android:background="@drawable/im_background_chat_common_question"
android:paddingRight="13dp"> android:paddingRight="13dp">
...@@ -589,6 +590,20 @@ ...@@ -589,6 +590,20 @@
android:textStyle="bold" /> android:textStyle="bold" />
</RelativeLayout> </RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/im_sp_14"
android:textColor="@color/im_color_242424"
android:layout_gravity="bottom"
android:id="@+id/question_multiple"
tools:text="已选:#工作压力 #生活压力#其他"
android:layout_marginStart="@dimen/platform_dp_12"
android:layout_marginEnd="@dimen/platform_dp_12"
android:layout_marginBottom="@dimen/platform_dp_8"
>
</TextView>
</FrameLayout> </FrameLayout>
<FrameLayout <FrameLayout
......
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