diff --git a/live/src/main/res/layout/view_sys_msg2.xml b/live/src/main/res/layout/view_sys_msg2.xml
new file mode 100644
index 000000000..ba13c46d0
--- /dev/null
+++ b/live/src/main/res/layout/view_sys_msg2.xml
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/src/main/java/com/yunbao/main/adapter/InteractionMessageAdapter2.java b/main/src/main/java/com/yunbao/main/adapter/InteractionMessageAdapter2.java
new file mode 100644
index 000000000..dbe3a8605
--- /dev/null
+++ b/main/src/main/java/com/yunbao/main/adapter/InteractionMessageAdapter2.java
@@ -0,0 +1,148 @@
+package com.yunbao.main.adapter;
+
+import android.content.Context;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.makeramen.roundedimageview.RoundedImageView;
+import com.yunbao.common.CommonAppConfig;
+import com.yunbao.common.Constants;
+import com.yunbao.common.adapter.RefreshAdapter;
+import com.yunbao.common.glide.ImgLoader;
+import com.yunbao.common.manager.IMLoginManager;
+import com.yunbao.common.utils.RouteUtil;
+import com.yunbao.common.views.weight.ViewClicksAntiShake;
+import com.yunbao.live.R;
+import com.yunbao.live.bean.SystemMessageBean;
+import com.yunbao.main.views.SystemMessageViewHolder2;
+
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import io.rong.imkit.utils.RouteUtils;
+import io.rong.imlib.model.Conversation;
+
+/**
+ * 互動信息
+ */
+public class InteractionMessageAdapter2 extends RefreshAdapter {
+ private SystemMessageViewHolder2 nowSystemMessageViewHolder;
+
+ public InteractionMessageAdapter2(Context context, SystemMessageViewHolder2 systemMessageViewHolder) {
+ super(context);
+ this.nowSystemMessageViewHolder = systemMessageViewHolder;
+ }
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ return new InteractionMessageAdapter2.Vh(mInflater.inflate(R.layout.item_interaction_msg, parent, false));
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
+ ((InteractionMessageAdapter2.Vh) vh).setData(mList.get(position));
+ }
+
+ class Vh extends RecyclerView.ViewHolder {
+ RoundedImageView mIco;
+ TextView mContent;
+ TextView mTime;
+ TextView mText;
+ LinearLayout toView, lt_content2, lt_reply, lt_img;
+ ImageView img_content_pic1, img_content_pic2, img_content_pic3, img_content2_pic1, img_content2_pic2, img_item_interaction;
+ RelativeLayout rt_root;
+ Button mBtnChat;
+
+ public Vh(View itemView) {
+ super(itemView);
+ mIco = itemView.findViewById(R.id.ico);
+ mContent = itemView.findViewById(R.id.content);
+ mTime = itemView.findViewById(R.id.time);
+ mText = itemView.findViewById(R.id.text);
+ toView = itemView.findViewById(R.id.to_view);
+ lt_content2 = itemView.findViewById(R.id.lt_content2);
+ img_content_pic1 = itemView.findViewById(R.id.img_content_pic1);
+ img_content_pic2 = itemView.findViewById(R.id.img_content_pic2);
+ img_content_pic3 = itemView.findViewById(R.id.img_content_pic3);
+ img_content2_pic1 = itemView.findViewById(R.id.img_content2_pic1);
+ img_content2_pic2 = itemView.findViewById(R.id.img_content2_pic2);
+ mBtnChat = itemView.findViewById(R.id.btn_chat);
+ rt_root = itemView.findViewById(R.id.rt_root);
+ lt_reply = itemView.findViewById(R.id.lt_reply);
+ lt_img = itemView.findViewById(R.id.lt_img);
+ img_item_interaction = itemView.findViewById(R.id.img_item_interaction);
+
+ }
+
+ void setData(SystemMessageBean bean) {
+ ImgLoader.displayWithError(mContext, bean.getAvatar_thumb(), mIco, R.mipmap.chat_head_mo);
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ Date currenTimeZone = new Date(Long.parseLong(bean.getAddtime() + "000"));
+ mTime.setText(sdf.format(currenTimeZone));
+ mText.setText(bean.getUser_nicename());
+ mContent.setText(bean.getContent());
+ mIco.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ RouteUtil.forwardUserHome(mContext, bean.getUid(), 2);
+ }
+ });
+ if (IMLoginManager.get(mContext).getAnchorB() == 1) {
+ mBtnChat.setVisibility(View.VISIBLE);
+ } else {
+ mBtnChat.setVisibility(View.GONE);
+ }
+
+ ViewClicksAntiShake.clicksAntiShake(mBtnChat, new ViewClicksAntiShake.ViewClicksCallBack() {
+ @Override
+ public void onViewClicks() {
+ RouteUtils.routeToConversationActivity(
+ mContext,
+ Conversation.ConversationType.PRIVATE,
+ bean.getUid()
+ );
+ }
+ });
+ if (bean.getDynamic_id() != null && !"0".equals(bean.getDynamic_id())) {
+ lt_img.setVisibility(View.VISIBLE);
+ rt_root.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Constants.myIntoIndex = 2;
+ Constants.chatActionUrl = CommonAppConfig.HOST
+ + "/h5/shequ/index.html#/h5/shequ/details?isDetailsChat=1&dynamic_uid="
+ + bean.getUid()
+ + "&id=" + bean.getDynamic_id();
+ RouteUtil.forwardUserHome(mContext, bean.getUid(), 2);
+ }
+ });
+ if (bean.getType() != null && !"0".equals(bean.getType())) {
+ lt_reply.setVisibility(View.VISIBLE);
+ lt_reply.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ nowSystemMessageViewHolder.editPopupWindow(bean.getDynamic_id(), bean.getTo_comment_id());
+ }
+ });
+ } else {
+ lt_reply.setVisibility(View.GONE);
+ }
+ ImgLoader.displayWithError(mContext, bean.getShowImg(), img_item_interaction, R.mipmap.chat_head_mo);
+ } else {
+ lt_img.setVisibility(View.GONE);
+ lt_reply.setVisibility(View.GONE);
+ }
+
+ }
+ }
+}
diff --git a/main/src/main/java/com/yunbao/main/views/MainMessageHeadViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainMessageHeadViewHolder.java
index 54f463871..9c9333e9f 100644
--- a/main/src/main/java/com/yunbao/main/views/MainMessageHeadViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainMessageHeadViewHolder.java
@@ -1,46 +1,26 @@
package com.yunbao.main.views;
-import android.Manifest;
import android.app.Activity;
import android.content.Context;
-import android.content.Intent;
-import android.os.Build;
import android.text.TextUtils;
-import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.TextView;
-import androidx.fragment.app.FragmentActivity;
-
-import com.yunbao.common.event.FloatWarOrderEvent;
-import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.MobclickAgent;
-import com.yunbao.common.utils.ProcessImageUtil;
import com.yunbao.common.utils.ProcessResultUtil;
import com.yunbao.common.utils.RouteUtil;
-import com.yunbao.common.utils.ToastUtil;
import com.yunbao.main.R;
-import com.yunbao.main.activity.CommunitySendActivity;
import com.yunbao.main.activity.MainActivity;
-import org.greenrobot.eventbus.EventBus;
-
/**
* Created by Martin on 2024/3/6.
- * MainActivity 首页-社区m
+ * MainActivity 消息界面新的首页
*/
public class MainMessageHeadViewHolder extends AbsMainHomeParentComViewHolder {
private MainMessageViewHolder2 mainMessageViewHolder2;
- private MainHomeNewViewHolder mainHomeLiveViewHolder;
- private MainHomeRecomComViewHolder mainHomeRecomComViewHolder;
- private MainHomeGameViewHolder mainHomeGameLiveViewHolder;
+ private SystemMessageViewHolder2 systemMessageViewHolder2;
- private final String mPageName = "home_page";
- private TextView tvPlay;
- private ImageView btnSend;
private boolean floatWarOrder;
private String homeZdyPop;
@@ -63,7 +43,7 @@ public class MainMessageHeadViewHolder extends AbsMainHomeParentComViewHolder {
@Override
protected int getLayoutId() {
- return R.layout.view_main_home_com;
+ return R.layout.view_main_message_head;
}
private ProcessResultUtil mProcessResultUtil;
@@ -71,87 +51,31 @@ public class MainMessageHeadViewHolder extends AbsMainHomeParentComViewHolder {
@Override
public void init() {
super.init();
- btnSend = (ImageView) findViewById(R.id.cameraImg);
- btnSend.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- boolean isAnchor = IMLoginManager.get(mContext).getUserInfo().anchorUserType();
- if (isAnchor) {
- String[] permissions;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
- permissions = new String[]{
- Manifest.permission.READ_MEDIA_IMAGES,
- Manifest.permission.CAMERA,
- Manifest.permission.RECORD_AUDIO
- };
- } else {
- permissions = new String[]{
- Manifest.permission.READ_EXTERNAL_STORAGE,
- Manifest.permission.WRITE_EXTERNAL_STORAGE,
- Manifest.permission.CAMERA,
- Manifest.permission.RECORD_AUDIO
- };
- }
- mProcessResultUtil.requestPermissions(permissions, mStartVideoRunnable);
- } else {
- ToastUtil.show(mContext.getResources().getString(R.string.only_open_anchor));
- }
- }
- });
- tvPlay = (TextView) findViewById(R.id.tvPlay);
- tvPlay.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- RouteUtil.forwardCommunityActivity();
- }
+ findViewById(R.id.addressBookImg).setOnClickListener(view -> {
+ //通讯录
+ RouteUtil.forwardActivity(RouteUtil.PATH_ADDRESSBOOK);
});
}
- private Runnable mStartVideoRunnable = new Runnable() {
- @Override
- public void run() {
- Intent intent = new Intent(mContext, CommunitySendActivity.class);
- mContext.startActivity(intent);
- }
- };
public void setCurPosition(int position) {
mViewPager.setCurrentItem(position);
}
- int selected = 1;
+ int selected = 0;
@Override
protected void loadPageData(int position) {
- if (position == 3) {
- RouteUtil.forwardCommunityActivity();
- mIndicator.onPageSelected(selected);
- setCurPosition(selected);
- refreshIndex(selected);
- return;
- }
selected = position;
refreshIndex(position);
switch (position) {
case 0:
floatWarOrder = false;
- MobclickAgent.onEvent(mContext, "home_page_follow", "首页关注列表按钮");
- EventBus.getDefault().post(new FloatWarOrderEvent().setFloatWarOrder(false));
+ MobclickAgent.onEvent(mContext, "home_page_follow", "消息列表");
break;
case 1:
floatWarOrder = false;
- MobclickAgent.onEvent(mContext, "home_page_hot", "首页热门列表按钮");
- EventBus.getDefault().post(new FloatWarOrderEvent().setFloatWarOrder(false));
- break;
- case 2:
- floatWarOrder = false;
- MobclickAgent.onEvent(mContext, "home_page_recommend", "首页推荐列表按钮");
- EventBus.getDefault().post(new FloatWarOrderEvent().setFloatWarOrder(false));
- break;
- case 3:
- floatWarOrder = true;
- MobclickAgent.onEvent(mContext, "home_page_redpk", "首页红包列表按钮");
- EventBus.getDefault().post(new FloatWarOrderEvent().setFloatWarOrder(true));
+ MobclickAgent.onEvent(mContext, "home_page_hot", "互动消息");
break;
}
if (mViewHolders == null) {
@@ -170,8 +94,8 @@ public class MainMessageHeadViewHolder extends AbsMainHomeParentComViewHolder {
vh = mainMessageViewHolder2;
} else if (position == 1) {
- mainHomeLiveViewHolder = new MainHomeNewViewHolder(mContext, parent);
- vh = mainHomeLiveViewHolder;
+ systemMessageViewHolder2 = new SystemMessageViewHolder2(mContext, parent,(MainActivity) mContext);
+ vh = systemMessageViewHolder2;
}
if (vh == null) {
return;
diff --git a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder2.java b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder2.java
index f9f491266..811814425 100644
--- a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder2.java
+++ b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder2.java
@@ -62,6 +62,7 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.JsonBean;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager;
+import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.utils.AppManager;
@@ -73,6 +74,7 @@ import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.SVGAViewUtils;
import com.yunbao.common.utils.StringUtil;
+import com.yunbao.common.utils.SudJsonUtils;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.ViewPageIndicatorUtils;
import com.yunbao.common.utils.WordUtil;
@@ -146,6 +148,12 @@ public class MainMessageViewHolder2 extends AbsMainHomeChildViewHolder {
private int userType = 0; // (0)普通用户 (1)主播A (2)主播B
ChatViewModel chatViewModel;
+ private CommonCallback commonCallback;
+
+ public void setCommonCallback(CommonCallback commonCallback) {
+ this.commonCallback = commonCallback;
+ }
+
public MainMessageViewHolder2 setHomeZdyPop(String homeZdyPop) {
this.homeZdyPop = homeZdyPop;
if (TextUtils.equals(homeZdyPop, "1")) {
@@ -580,6 +588,7 @@ public class MainMessageViewHolder2 extends AbsMainHomeChildViewHolder {
if (TextUtils.isEmpty(userBean.getNum()) || TextUtils.equals("0", userBean.getNum())) {
textNewsNotice.setVisibility(View.GONE);
} else {
+ Log.i("官方通知", "请求消息:" + SudJsonUtils.toJson(userBean));
textNewsNotice.setVisibility(View.VISIBLE);
officialDate.setText(userBean.getLastDate());
officialContent.setText(userBean.getContent());
@@ -603,6 +612,9 @@ public class MainMessageViewHolder2 extends AbsMainHomeChildViewHolder {
break;
//互動消息
case "2":
+ if (commonCallback!=null){
+ commonCallback.callback(userBean);
+ }
// if (TextUtils.isEmpty(userBean.getNum()) || TextUtils.equals("0", userBean.getNum())) {
// textNewsInteraction.setVisibility(View.GONE);
// } else {
@@ -764,16 +776,20 @@ public class MainMessageViewHolder2 extends AbsMainHomeChildViewHolder {
textNewsNotice.setVisibility(View.GONE);
textNewsNotice.setText("");
} else {
- String number = textNewsNotice.getText().toString().trim();
+ // String number = textNewsNotice.getText().toString().trim();
+ Log.i("官方通知", "官方通知:" + model.toString());
textNewsNotice.setVisibility(View.VISIBLE);
- int numberInt = Integer.parseInt(number) + 1;
- if (numberInt > 99) {
- textNewsNotice.setTextSize(TypedValue.COMPLEX_UNIT_SP, 9);
- textNewsNotice.setText("99+");
- } else {
- textNewsNotice.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
- textNewsNotice.setText(String.valueOf(numberInt));
- }
+ officialDate.setText(model.getAddtime());
+ officialContent.setText(model.getContent());
+
+// int numberInt = Integer.parseInt(number) + 1;
+// if (numberInt > 99) {
+// textNewsNotice.setTextSize(TypedValue.COMPLEX_UNIT_SP, 9);
+// textNewsNotice.setText("99+");
+// } else {
+// textNewsNotice.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
+// textNewsNotice.setText(String.valueOf(numberInt));
+// }
}
diff --git a/main/src/main/java/com/yunbao/main/views/SystemMessageViewHolder2.java b/main/src/main/java/com/yunbao/main/views/SystemMessageViewHolder2.java
new file mode 100644
index 000000000..803d02888
--- /dev/null
+++ b/main/src/main/java/com/yunbao/main/views/SystemMessageViewHolder2.java
@@ -0,0 +1,1462 @@
+package com.yunbao.main.views;
+
+import static io.rong.imlib.RongIMClient.BlacklistStatus.NOT_IN_BLACK_LIST;
+
+import android.Manifest;
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.BitmapDrawable;
+import android.media.MediaMetadataRetriever;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Handler;
+import android.os.Parcelable;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.PopupWindow;
+import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.cardview.widget.CardView;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.alibaba.fastjson.JSON;
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.request.RequestOptions;
+import com.makeramen.roundedimageview.RoundedImageView;
+import com.yunbao.common.CommonAppConfig;
+import com.yunbao.common.Constants;
+import com.yunbao.common.activity.PreviewImageActivity;
+import com.yunbao.common.activity.PreviewVideoActivity;
+import com.yunbao.common.activity.SelectImageActivity;
+import com.yunbao.common.adapter.RefreshAdapter;
+import com.yunbao.common.bean.ImageEntity;
+import com.yunbao.common.custom.CommonRefreshView;
+import com.yunbao.common.glide.ImgLoader;
+import com.yunbao.common.http.HttpCallback;
+import com.yunbao.common.interfaces.CommonCallback;
+import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
+import com.yunbao.common.utils.MobclickAgent;
+import com.yunbao.common.utils.RouteUtil;
+import com.yunbao.common.utils.ToastUtil;
+import com.yunbao.common.views.TopGradual;
+import com.yunbao.common.views.weight.ViewClicksAntiShake;
+import com.yunbao.live.R;
+import com.yunbao.live.activity.EditNameRemarksActivity;
+import com.yunbao.live.activity.SystemMessageActivity;
+import com.yunbao.live.bean.ImUserBean;
+import com.yunbao.main.adapter.InteractionMessageAdapter2;
+import com.yunbao.live.bean.SearchUserBean;
+import com.yunbao.live.bean.SystemMessageBean;
+import com.yunbao.live.http.ImHttpConsts;
+import com.yunbao.live.http.ImHttpUtil;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import io.rong.imlib.IRongCallback;
+import io.rong.imlib.RongIMClient;
+import io.rong.imlib.model.Conversation;
+import io.rong.imlib.model.Message;
+import io.rong.message.ImageMessage;
+import io.rong.message.RecallNotificationMessage;
+import io.rong.message.SightMessage;
+import io.rong.message.TextMessage;
+
+/**
+ * Created by Chen Haoxuan on 2022/4/10.修改
+ */
+
+public class SystemMessageViewHolder2 extends AbsMainHomeChildViewHolder implements View.OnClickListener {
+
+ private CommonRefreshView mRefreshView;
+ //系統
+ private RefreshAdapter mAdapter;
+ private RecyclerView rv_chat;
+ private List messagesList;
+ private ImMessageAdapter imMessageAdapter;
+ private Context mContext;
+ private int oldestMessageId = -1;
+ private boolean moretext = true;
+
+ private LinearLayout back_bt_jump;
+ private EditText feedback_edittext;
+ private TextView rttext_fasong;
+ private long dateTime = 0;
+ private boolean isInBlack = false;
+ private Activity nowActivity;
+ private Handler mHandler;
+ private LinearLayout lt_root, lt_photo_button, lt_choospic_button, lt_video_button, lt_controls, lt_chat;
+ private View v_morefeatures;
+ //用户头像
+ private String myAvatar;
+
+
+ public SystemMessageViewHolder2(Context context, ViewGroup parentView, Activity activity) {
+ super(context, parentView);
+ this.mContext = context;
+ this.nowActivity = activity;
+ }
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.view_sys_msg2;
+ }
+
+
+// @Override
+// public void callback(ImUserBean bean) {
+//
+// }
+
+ private String getNowUid(){
+ return "";
+ }
+
+ private String getNowHeadImg(){
+ return "";
+ }
+
+ @Override
+ public void init() {
+
+
+ mRefreshView = (CommonRefreshView) findViewById(R.id.refreshView);
+ rv_chat = (RecyclerView) findViewById(R.id.rv_chat);
+ lt_chat = (LinearLayout) findViewById(R.id.lt_chat);
+
+ back_bt_jump = (LinearLayout) findViewById(R.id.back_bt_jump);
+ feedback_edittext = (EditText) findViewById(R.id.feedback_edittext);
+ rttext_fasong = (TextView) findViewById(R.id.rttext_fasong);
+
+
+ lt_root = (LinearLayout) findViewById(R.id.lt_root);
+
+ lt_photo_button = (LinearLayout) findViewById(R.id.lt_photo_button);
+ lt_choospic_button = (LinearLayout) findViewById(R.id.lt_choospic_button);
+ lt_video_button = (LinearLayout) findViewById(R.id.lt_video_button);
+ v_morefeatures = (View) findViewById(R.id.v_morefeatures);
+ lt_controls = (LinearLayout) findViewById(R.id.lt_controls);
+
+ messagesList = new ArrayList<>();
+
+
+ //判断是否有传入单聊的ID做判断
+ if (!"".equals(getNowUid()) && getNowUid() != null) {
+ lt_chat.setVisibility(View.VISIBLE);
+ mRefreshView.setVisibility(View.GONE);
+ back_bt_jump.setVisibility(View.VISIBLE);
+
+ setInit();
+ setChatApt(0);
+
+ rv_chat.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener() {
+ @Override
+ public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
+ if (e.getAction() == MotionEvent.ACTION_DOWN) {
+ if (lt_controls.getVisibility() == View.VISIBLE) {
+ lt_controls.setVisibility(View.GONE);
+ }
+ InputMethodManager methodManager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (methodManager != null) {
+ methodManager.hideSoftInputFromWindow(feedback_edittext.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
+ }
+ feedback_edittext.clearFocus();
+ }
+ return super.onInterceptTouchEvent(rv, e);
+ }
+ });
+
+ lt_photo_button.setOnClickListener(this);
+ lt_choospic_button.setOnClickListener(this);
+ lt_video_button.setOnClickListener(this);
+ v_morefeatures.setOnClickListener(this);
+ lt_chat.setOnClickListener(this);
+ } else {
+
+ lt_chat.setVisibility(View.GONE);
+ mRefreshView.setVisibility(View.VISIBLE);
+ back_bt_jump.setVisibility(View.GONE);
+ setSysApt();
+ }
+
+ mHandler = new Handler() {
+ @Override
+ public void handleMessage(android.os.Message msg) {
+ switch (msg.what) {
+ case 1:
+ setDataALl(messagesList.size());
+ break;
+ case 2:
+ if (lt_controls.getVisibility() == View.GONE) {
+ lt_controls.setVisibility(View.VISIBLE);
+ setShowBottom();
+ }
+ break;
+ case 3:
+ setDataNew();
+ rttext_fasong.setClickable(true);
+ break;
+ case 4:
+ setDataPosition(0);
+ break;
+ case 5:
+ setShowBottom();
+ break;
+ }
+ }
+ };
+
+ getBlackType();
+ //注册EventBus
+ EventBus.getDefault().register(SystemMessageViewHolder2.this);
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void refreshStatus(SystemMessageBean systemMessageBean) {
+ mRefreshView.initData();
+ }
+
+ //点击加号等各类事件
+ @Override
+ public void onClick(View v) {
+ int i = v.getId();
+ if (i == R.id.lt_photo_button) {
+ choosePic(1);
+ } else if (i == R.id.lt_choospic_button) {
+ choosePic(2);
+ } else if (i == R.id.lt_video_button) {
+ choosePic(3);
+ } else if (i == R.id.v_morefeatures) {
+ feedback_edittext.clearFocus();
+ if (lt_controls.getVisibility() == View.GONE) {
+ InputMethodManager methodManager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (methodManager != null) {
+ methodManager.hideSoftInputFromWindow(feedback_edittext.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
+ }
+
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(250);
+ mHandler.sendEmptyMessageAtTime(2, 0);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ thread.start();
+ }
+ }
+ }
+
+ //获取本地储存消息
+ private void setChatApt(int index) {
+ if (oldestMessageId == 0) {
+ oldestMessageId = -1;
+ }
+ Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
+ RongIMClient.getInstance().getHistoryMessages(conversationType, getNowUid(), oldestMessageId, 20, new RongIMClient.ResultCallback>() {
+ /**
+ * 成功时回调
+ * @param messages 获取的消息列表
+ */
+ @Override
+ public void onSuccess(List messages) {
+ Collections.reverse(messages);
+ EventBus.getDefault().post(messages);
+ if (messages.size() > 0) {
+ if (messages.size() < 20) {
+ moretext = false;
+ } else {
+ moretext = true;
+ }
+ oldestMessageId = messages.get(0).getMessageId();
+ Log.i("chatlist", "oldestMessageId = " + oldestMessageId);
+ if (messagesList.size() == 0) {
+ Message messageNo = new Message();
+ messageNo.setSenderUserId("-1");
+ messagesList.add(messageNo);
+
+ messagesList.addAll(messages);
+ } else {
+ if (moretext) {
+ messagesList.get(0).setSenderUserId("-1");
+ } else {
+ messagesList.get(0).setSenderUserId("-2");
+ }
+ messagesList.addAll(1, messages);
+ }
+ mHandler.sendEmptyMessageAtTime(1, 0);
+ } else {
+ moretext = false;
+ if (messagesList.size() == 0) {
+ Message messageNo = new Message();
+ messageNo.setSenderUserId("-1");
+ messagesList.add(messageNo);
+ messagesList.addAll(messages);
+ }
+ messagesList.get(0).setSenderUserId("-2");
+ mHandler.sendEmptyMessageAtTime(1, 0);
+ }
+ }
+
+ /**
+ * 错误时回调。
+ * @param e 错误码
+ */
+ @Override
+ public void onError(RongIMClient.ErrorCode e) {
+ ToastUtil.show("消息获取失败");
+ }
+ });
+
+ }
+
+ /**
+ * 删除消息
+ *
+ * @param msgId
+ * @param position
+ * @param size
+ */
+ public void delMsg(String msgId, int position, int size) {
+ ImHttpUtil.delMsg(msgId, new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0) {
+ ToastUtil.show(R.string.del_suc);
+ }
+ List systemMessageBeanList = mAdapter.getList();
+ systemMessageBeanList.remove(position);
+ if (position == 0 && size == 1) {
+ mRefreshView.initData();
+ } else if (position == 0) {
+ mAdapter.notifyDataSetChanged();
+ } else {
+ mAdapter.notifyItemRemoved(position);
+ }
+ }
+ });
+ }
+
+ //非单聊列表适配
+ private void setSysApt() {
+ mRefreshView.setEmptyLayoutId(R.layout.view_no_data_mess);
+ mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
+ mRefreshView.setDataHelper(new CommonRefreshView.DataHelper() {
+ @Override
+ public RefreshAdapter getAdapter() {
+ mAdapter = new InteractionMessageAdapter2(mContext, SystemMessageViewHolder2.this);
+ return mAdapter;
+ }
+
+ @Override
+ public void loadData(int p, HttpCallback callback) {
+ ImHttpUtil.getSystemMessageList("2", p, callback);
+ }
+
+ @Override
+ public List processData(String[] info) {
+ return JSON.parseArray(Arrays.toString(info), SystemMessageBean.class);
+ }
+
+ @Override
+ public void onRefreshSuccess(List list, int listCount) {
+
+ }
+
+ @Override
+ public void onRefreshFailure() {
+
+ }
+
+ @Override
+ public void onLoadMoreSuccess(List loadItemList, int loadItemCount) {
+
+ }
+
+ @Override
+ public void onLoadMoreFailure() {
+
+ }
+ });
+ }
+
+ private boolean isSend = true;
+
+
+
+ private void setInit() {
+ //发送键
+ rttext_fasong.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (isSend) {
+ //文本消息
+ if (!"".equals(feedback_edittext.getText().toString().trim())) {
+ isSend = false;
+ Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
+ TextMessage messageContent = TextMessage.obtain(feedback_edittext.getText().toString());
+ Message message = Message.obtain(getNowUid(), conversationType, messageContent);
+ message.setSenderUserId(Constants.myUid);
+ message.setObjectName("RC:TxtMsg");
+ message.setExtra(feedback_edittext.getText().toString());
+ message.setSentTime(new Date().getTime());
+ message.setTargetId(getNowUid());
+ wenZi(message, 0, -1);
+ rttext_fasong.setClickable(false);
+ }
+ } else {
+ ToastUtil.show("消息发送中,请稍等");
+ }
+ }
+ });
+
+ feedback_edittext.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ if (!s.toString().trim().equals("")) {
+ rttext_fasong.setBackground(mContext.getResources().getDrawable(R.mipmap.btn_sand1));
+ } else {
+ rttext_fasong.setBackground(mContext.getResources().getDrawable(R.mipmap.btn_sand));
+ }
+ }
+ });
+
+ feedback_edittext.setOnFocusChangeListener(new View.OnFocusChangeListener() {
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (hasFocus) {//获取焦点
+ if (lt_controls.getVisibility() == View.VISIBLE) {
+ lt_controls.setVisibility(View.GONE);
+ }
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(100);
+ mHandler.sendEmptyMessageAtTime(5, 0);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ thread.start();
+ } else {//失去焦点
+
+ }
+ }
+ });
+
+ }
+
+ //文字信息
+ private void wenZi(Message inMessage, int intoIndex, int position) {
+
+ if (intoIndex != 0) {
+ messagesList.remove(position);
+ setDellPosition(position);
+ }
+ RongcloudIMManager.sendMessage(inMessage, null, null, new IRongCallback.ISendMessageCallback() {
+
+ @Override
+ public void onAttached(Message message) {
+ isSend = true;
+ }
+
+ @Override
+ public void onSuccess(Message message) {
+ message.setReceivedTime(new Date().getTime());
+ messagesList.add(message);
+ feedback_edittext.setText("");
+ mHandler.sendEmptyMessageAtTime(3, 0);
+ if (!"".equals(getNowUid())) {
+ Constants.nowSendUid = getNowUid();
+ }
+ isSend = true;
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+ message.setReceivedTime(0);
+ messagesList.add(message);
+ feedback_edittext.setText("");
+ mHandler.sendEmptyMessageAtTime(3, 0);
+ isSend = true;
+ }
+ });
+ }
+
+ public void getPiclist() {
+ if (mSelectImages.size() > 0) {
+ for (ImageEntity imageEntity : mSelectImages) {
+ media(imageEntity.getPath());
+ }
+ }
+ }
+
+ //媒体消息 图片
+ private void media(String url) {
+ if (!"".equals(url) && url != null) {
+ Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
+ Uri localUri = Uri.parse("file://" + url);
+ ImageMessage imageMessage = ImageMessage.obtain(localUri, localUri);
+ Message message = Message.obtain(getNowUid(), conversationType, imageMessage);
+ message.setSenderUserId(Constants.myUid);
+ message.setObjectName("RC:ImgMsg");
+ message.setExtra("");
+ message.setSentTime(new Date().getTime());
+ message.setTargetId(getNowUid());
+ mediaSend(message, 0, -1, 1);
+ }
+ }
+
+ //媒体消息 视频
+ public void mediaVideo(String url) {
+ if (!"".equals(url) && url != null) {
+ int duration = 0;
+ try {
+ MediaMetadataRetriever mmr = new MediaMetadataRetriever();
+ mmr.setDataSource(url);
+ duration = Integer.parseInt(mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)) / 1000;//除以 1000 返回是秒
+ //时长(毫秒)
+// String duration = mmr.extractMetadata(android.media.MediaMetadataRetriever.METADATA_KEY_DURATION);
+// //宽
+// String width = mmr.extractMetadata(android.media.MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
+// //高
+// String height = mmr.extractMetadata(android.media.MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
+ Uri uri = Uri.parse("file://" + url);
+ SightMessage sightMessage = SightMessage.obtain(uri, duration);
+ Message message = Message.obtain(getNowUid(), conversationType, sightMessage);
+ message.setSenderUserId(Constants.myUid);
+ message.setObjectName("RC:SightMsg");
+ message.setExtra("");
+ message.setSentTime(new Date().getTime());
+ message.setTargetId(getNowUid());
+ mediaSend(message, 0, -1, 2);
+ }
+ }
+
+ //媒体消息发送
+ private void mediaSend(Message inMessage, int intoIndex, int position, int showIndex) {
+ if (intoIndex != 0) {
+ messagesList.remove(position);
+ setDellPosition(position);
+ }
+ RongIMClient.getInstance().sendMediaMessage(inMessage, null, null, new IRongCallback.ISendMediaMessageCallback() {
+ @Override
+ public void onProgress(Message message, int i) {
+ if (i < 100 && i > 0) {
+ if (getComparison(message.getMessageId(), i, 1)) {
+ messagesList.add(message);
+ }
+ mHandler.sendEmptyMessageAtTime(3, 0);
+ if (!"".equals(getNowUid())) {
+ Constants.nowSendUid = getNowUid();
+ }
+ }
+ }
+
+ @Override
+ public void onCanceled(Message message) {
+
+ }
+
+ @Override
+ public void onAttached(Message message) {
+
+ }
+
+ @Override
+ public void onSuccess(Message message) {
+ if (getComparison(message.getMessageId(), 100, 2)) {
+ messagesList.add(message);
+ }
+ mHandler.sendEmptyMessageAtTime(3, 0);
+ if (!"".equals(getNowUid())) {
+ Constants.nowSendUid = getNowUid();
+ }
+ }
+
+ @Override
+ public void onError(final Message message, final RongIMClient.ErrorCode errorCode) {
+ if (getComparison(message.getMessageId(), 100, 0)) {
+ messagesList.add(message);
+ }
+ mHandler.sendEmptyMessageAtTime(3, 0);
+ }
+ });
+ }
+
+ //比对信息
+ private boolean getComparison(int messageId, int i, int intoIndex) {
+ for (int p = 0; p < messagesList.size(); p++) {
+ if (messagesList.get(p).getMessageId() == messageId) {
+ if (intoIndex == 1) {
+ messagesList.get(p).setReceivedTime(i);
+ } else if (intoIndex == 2) {
+ messagesList.get(p).setReceivedTime(new Date().getTime());
+ } else {
+ messagesList.get(p).setReceivedTime(0);
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static final int PERMISSION_REQUEST_CODE = 0;
+ public static final int SELECT_IMAGE_REQUEST = 0x0001;
+ public static final int SELECT_VIDEO_REQUEST = 0x0002;
+ public ArrayList mSelectImages = new ArrayList<>();
+
+ //intoIndex 1=调用相机,2=照片选取,3=视频选取
+ public void choosePic(int intoIndex) {
+ //选择图片
+ String permission1 = Manifest.permission.READ_EXTERNAL_STORAGE;
+ String permission2 = Manifest.permission.WRITE_EXTERNAL_STORAGE;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ permission1 = Manifest.permission.READ_MEDIA_IMAGES;
+ permission2 = Manifest.permission.READ_MEDIA_VIDEO;
+ }
+ int isPermission1 = ContextCompat.checkSelfPermission(mContext, permission1);
+ int isPermission2 = ContextCompat.checkSelfPermission(mContext, permission2);
+ if (isPermission1 == PackageManager.PERMISSION_GRANTED && isPermission2 == PackageManager.PERMISSION_GRANTED) {
+ startActivity(intoIndex);
+ } else {
+ //申请权限
+ ActivityCompat.requestPermissions(nowActivity, new String[]{permission1, permission2}, PERMISSION_REQUEST_CODE);
+ }
+ }
+
+ private void startActivity(int intoIndex) {
+ mSelectImages.clear();
+ Intent intent = new Intent(mContext, SelectImageActivity.class);
+ intent.putParcelableArrayListExtra("selected_images", mSelectImages);
+ intent.putExtra("intoIndex", intoIndex);
+ if (intoIndex == 3) {
+ nowActivity.startActivityForResult(intent, SELECT_VIDEO_REQUEST);
+ } else {
+ nowActivity.startActivityForResult(intent, SELECT_IMAGE_REQUEST);
+ }
+ }
+
+ //右上角点击弹窗
+ public void buttonclick(View view) {
+ View popupView = LayoutInflater.from(mContext).inflate(R.layout.popwindow_chat_more, null);
+ TextView tv_remarks, tv_black, tv_black_move;
+ LinearLayout lt_remarks;
+ lt_remarks = popupView.findViewById(R.id.lt_remarks);
+ tv_black = popupView.findViewById(R.id.tv_black);
+ tv_black_move = popupView.findViewById(R.id.tv_black_move);
+ tv_remarks = popupView.findViewById(R.id.tv_remarks);
+ if (isInBlack) {
+ tv_black.setVisibility(View.GONE);
+ tv_black_move.setVisibility(View.VISIBLE);
+ } else {
+ tv_black.setVisibility(View.VISIBLE);
+ tv_black_move.setVisibility(View.GONE);
+ }
+ if (Constants.isInstructor) {
+ lt_remarks.setVisibility(View.VISIBLE);
+ } else {
+ lt_remarks.setVisibility(View.GONE);
+ }
+ PopupWindow popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
+ popupWindow.showAsDropDown(view);
+ WindowManager.LayoutParams lp = nowActivity.getWindow().getAttributes();
+ lp.alpha = 0.8f;
+ nowActivity.getWindow().setAttributes(lp);
+
+ if (Constants.isInstructor) {
+ tv_black.setVisibility(View.GONE);
+ tv_black_move.setVisibility(View.GONE);
+ }
+ tv_black.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (!Constants.isAdmin.equals("1") && !Constants.isInstructor) {
+ ImHttpUtil.setBlack(getNowUid(), new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0) {
+ RongIMClient.getInstance().addToBlacklist(getNowUid(), new RongIMClient.OperationCallback() {
+ @Override
+ public void onSuccess() {
+ ToastUtil.show(mContext.getResources().getString(R.string.black_succer));
+ isInBlack = true;
+ }
+
+ @Override
+ public void onError(RongIMClient.ErrorCode errorCode) {
+ ToastUtil.show(mContext.getResources().getString(R.string.black_error));
+ }
+ });
+ popupWindow.dismiss();
+ } else {
+ ToastUtil.show(msg);
+ }
+ }
+ });
+ } else {
+ ToastUtil.show("不可拉黑");
+ }
+ }
+ });
+ tv_black_move.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (!Constants.isAdmin.equals("1") && !Constants.isInstructor) {
+ RongIMClient.getInstance().removeFromBlacklist(getNowUid(), new RongIMClient.OperationCallback() {
+
+ @Override
+ public void onSuccess() {
+ ToastUtil.show(mContext.getResources().getString(R.string.black_succer_more));
+ isInBlack = false;
+ }
+
+ @Override
+ public void onError(RongIMClient.ErrorCode errorCode) {
+ ToastUtil.show(mContext.getResources().getString(R.string.black_error_more));
+ }
+ });
+ popupWindow.dismiss();
+ }
+ }
+ });
+ popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
+ @Override
+ public void onDismiss() {
+ lp.alpha = 1f;
+ nowActivity.getWindow().setAttributes(lp);
+ }
+ });
+ //修改备注
+ tv_remarks.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(mContext, EditNameRemarksActivity.class);
+ intent.putExtra(Constants.REMARKS, Constants.remarks);
+ nowActivity.startActivity(intent);
+ popupWindow.dismiss();
+ }
+ });
+ }
+
+ //view当前点击的控件,手指长按任意位置弹窗
+ private void showMoreDialog(Message messageNow, String objectName, View v) {
+ View pop_layout = LayoutInflater.from(mContext).inflate(R.layout.popwindow_chat_withdraw, null);
+ final PopupWindow mPopupWindow = new PopupWindow(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ mPopupWindow.setContentView(pop_layout);
+ mPopupWindow.setFocusable(true);
+ mPopupWindow.setOutsideTouchable(true);
+ mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
+ mPopupWindow.update();
+
+ int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
+ int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
+ pop_layout.measure(w, h);
+ //获取PopWindow宽和高,Constants.xIndex手势X轴Constants.xIndey手势Y轴
+ int mHeight = pop_layout.getMeasuredHeight();
+ int mWidth = pop_layout.getMeasuredWidth();
+ //偏移量
+ nowActivity.getWindowManager();
+ int xoff = Constants.xIndex - 2 * mWidth;
+ int yoff = 0 - (pop_layout.getHeight() - Constants.yindex);
+ mPopupWindow.showAsDropDown(v, xoff, yoff, Gravity.RIGHT);
+
+ TextView tv_withdraw;
+ tv_withdraw = (TextView) pop_layout.findViewById(R.id.tv_withdraw);
+
+ tv_withdraw.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ RongIMClient.getInstance().recallMessage(messageNow, objectName, new RongIMClient.ResultCallback() {
+ @Override
+ public void onSuccess(RecallNotificationMessage recallNotificationMessage) {
+ withdrawMsg(messageNow.getMessageId());
+ }
+
+ @Override
+ public void onError(RongIMClient.ErrorCode e) {
+ ToastUtil.show("" + e);
+ }
+ });
+ feedback_edittext.setFocusable(true);
+ mPopupWindow.dismiss();
+ }
+ });
+ }
+
+ //查看是否在黑名单
+ private void getBlackType() {
+ RongIMClient.getInstance().getBlacklistStatus(getNowUid(), new RongIMClient.ResultCallback() {
+ @Override
+ public void onSuccess(RongIMClient.BlacklistStatus blacklistStatus) {
+ if (blacklistStatus == NOT_IN_BLACK_LIST) {
+ isInBlack = false;
+ } else {
+ isInBlack = true;
+ }
+ }
+
+ @Override
+ public void onError(RongIMClient.ErrorCode e) {
+ isInBlack = true;
+ }
+ });
+ }
+
+ //查看个人信息
+ private void showUserData(String uid) {
+ RouteUtil.forwardUserHome(mContext, uid, 1);
+ }
+
+ //更新新消息
+ public void intoMsg(Message message) {
+ if (lt_chat.getVisibility() == View.VISIBLE) {
+ messagesList.add(message);
+ mHandler.sendEmptyMessageAtTime(3, 0);
+ }
+ }
+
+ //撤回消息
+ public void withdrawMsg(int messageId) {
+ if (lt_chat.getVisibility() == View.VISIBLE) {
+ for (Message msg : messagesList) {
+ if (msg.getMessageId() == messageId) {
+ messagesList.remove(msg);
+ mHandler.sendEmptyMessageAtTime(1, 0);
+ return;
+ }
+ }
+ }
+ }
+
+ //聊天界面更新ui 所有
+ private void setDataALl(int position) {
+ if (imMessageAdapter == null) {
+ imMessageAdapter = new ImMessageAdapter(mContext, messagesList);
+ rv_chat.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
+ rv_chat.addItemDecoration(new TopGradual());
+// imMessageAdapter.setHasStableIds(true);
+ rv_chat.setAdapter(imMessageAdapter);
+ }
+ imMessageAdapter.notifyDataSetChanged();
+ rv_chat.scrollToPosition(position - 1);
+ }
+
+ //聊天界面更新ui 指定位置
+ private void setDataPosition(int position) {
+ if (imMessageAdapter == null) {
+ imMessageAdapter = new ImMessageAdapter(mContext, messagesList);
+ rv_chat.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
+ rv_chat.addItemDecoration(new TopGradual());
+ rv_chat.setAdapter(imMessageAdapter);
+ }
+ imMessageAdapter.notifyItemChanged(position);
+ }
+
+ //聊天界面更新ui 移除某一项
+ private void setDellPosition(int position) {
+ if (imMessageAdapter == null) {
+ imMessageAdapter = new ImMessageAdapter(mContext, messagesList);
+ rv_chat.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
+ rv_chat.addItemDecoration(new TopGradual());
+ rv_chat.setAdapter(imMessageAdapter);
+ }
+ imMessageAdapter.notifyItemRemoved(position);
+ imMessageAdapter.notifyItemRangeChanged(0, messagesList.size());
+ }
+
+ //聊天界面更新ui 添加新消息
+ private void setDataNew() {
+ if (imMessageAdapter == null) {
+ imMessageAdapter = new ImMessageAdapter(mContext, messagesList);
+ rv_chat.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
+ rv_chat.addItemDecoration(new TopGradual());
+ rv_chat.setAdapter(imMessageAdapter);
+ }
+ imMessageAdapter.notifyItemChanged(messagesList.size() - 1);
+ rv_chat.scrollToPosition(messagesList.size() - 1);
+ }
+
+ //聊天界面更新ui 滚动到底部
+ private void setShowBottom() {
+ if (imMessageAdapter == null) {
+ imMessageAdapter = new ImMessageAdapter(mContext, messagesList);
+ rv_chat.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
+ rv_chat.addItemDecoration(new TopGradual());
+ rv_chat.setAdapter(imMessageAdapter);
+ }
+ rv_chat.scrollToPosition(messagesList.size() - 1);
+ }
+
+ public void loadData() {
+ if (mRefreshView != null) {
+ mRefreshView.initData();
+ }
+ }
+
+ public void release() {
+ ImHttpUtil.cancel(ImHttpConsts.GET_SYSTEM_MESSAGE_LIST);
+ //注销EventBus
+ EventBus.getDefault().unregister(this);
+
+ }
+
+
+
+ //适配器
+ public class ImMessageAdapter extends RecyclerView.Adapter {
+ private LayoutInflater mInflater;
+ private List mDatas;
+ private String nowTime = "";
+
+ public ImMessageAdapter(Context context, List datats) {
+ mInflater = LayoutInflater.from(context);
+ mDatas = datats;
+ }
+
+ public class ViewHolder extends RecyclerView.ViewHolder {
+ TextView back_puttime1, back_puttime, chatcontent_text, chatcontent_text1, back_name1;
+ LinearLayout lt_chat_left, lt_chat_right, lt_chat_one;
+ View view_feed_suc;
+ RoundedImageView back_touxiang1, back_touxiang;
+ ImageView chatcontent_img, chatcontent_img1, chatcontent_video_img, chatcontent_video_img1;
+ ImageView chatcontent_video_play, chatcontent_video_play1;
+ LinearLayout lt_text_right, lt_text_left;
+ RelativeLayout rt_video_left, rt_video_right;
+ ProgressBar pb_video_right;
+ CardView cv_chatcontent_img, cv_chatcontent_img1;
+
+ public ViewHolder(View arg0) {
+ super(arg0);
+ //点击更多
+ lt_chat_one = (LinearLayout) arg0.findViewById(R.id.lt_chat_one);
+ //其他消息
+ lt_chat_left = (LinearLayout) arg0.findViewById(R.id.lt_chat_left);//左侧容器
+ back_puttime1 = (TextView) arg0.findViewById(R.id.back_puttime1);//时间
+ chatcontent_text1 = (TextView) arg0.findViewById(R.id.chatcontent_text1);//文本内容
+ back_touxiang1 = (RoundedImageView) arg0.findViewById(R.id.back_touxiang1);//头像
+ back_name1 = (TextView) arg0.findViewById(R.id.back_name1);
+
+ chatcontent_img1 = (ImageView) arg0.findViewById(R.id.chatcontent_img1);//图片
+ lt_text_left = (LinearLayout) arg0.findViewById(R.id.lt_text_left);//文字 容器
+ chatcontent_video_img1 = (ImageView) arg0.findViewById(R.id.chatcontent_video_img1);//视频 图片
+ rt_video_left = (RelativeLayout) arg0.findViewById(R.id.rt_video_left);//视频 容器
+ chatcontent_video_play1 = (ImageView) arg0.findViewById(R.id.chatcontent_video_play1);//视频 按钮
+ cv_chatcontent_img1 = (CardView) arg0.findViewById(R.id.cv_chatcontent_img1);
+
+ //自己消息
+ lt_chat_right = (LinearLayout) arg0.findViewById(R.id.lt_chat_right);//右侧容器
+ back_puttime = (TextView) arg0.findViewById(R.id.back_puttime);//时间
+ view_feed_suc = (View) arg0.findViewById(R.id.view_feed_suc);
+ chatcontent_text = (TextView) arg0.findViewById(R.id.chatcontent_text);//文本内容
+ back_touxiang = (RoundedImageView) arg0.findViewById(R.id.back_touxiang);//头像
+
+ chatcontent_img = (ImageView) arg0.findViewById(R.id.chatcontent_img);//图片
+ lt_text_right = (LinearLayout) arg0.findViewById(R.id.lt_text_right);//文字 容器
+ rt_video_right = (RelativeLayout) arg0.findViewById(R.id.rt_video_right);//视频 容器
+ chatcontent_video_img = (ImageView) arg0.findViewById(R.id.chatcontent_video_img);//视频 图片
+ chatcontent_video_play = (ImageView) arg0.findViewById(R.id.chatcontent_video_play);//视频 按钮
+ pb_video_right = (ProgressBar) arg0.findViewById(R.id.pb_video_right);//视频 进度
+ cv_chatcontent_img = (CardView) arg0.findViewById(R.id.cv_chatcontent_img);
+
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return mDatas.size();
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ /**
+ * 创建ViewHolder
+ */
+ @Override
+ public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
+ View view = mInflater.inflate(R.layout.item_chat_one, viewGroup, false);
+
+ ViewHolder viewHolder = new ViewHolder(view);
+ return viewHolder;
+ }
+
+ /**
+ * 设置值
+ */
+ @Override
+ public void onBindViewHolder(final ViewHolder viewHolder, @SuppressLint("RecyclerView") final int position) {
+ if (position == 0) {
+ if (moretext) {
+ viewHolder.lt_chat_one.setVisibility(View.VISIBLE);
+ viewHolder.lt_chat_one.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ setChatApt(1);
+ }
+ });
+ } else {
+ viewHolder.lt_chat_one.setVisibility(View.GONE);
+ }
+ viewHolder.lt_chat_left.setVisibility(View.GONE);
+ viewHolder.lt_chat_right.setVisibility(View.GONE);
+ } else {
+ String time = "";
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ Date currenTimeZone = new Date(Long.parseLong(mDatas.get(position).getSentTime() + ""));
+ time = sdf.format(currenTimeZone);
+ boolean isShowTime = true;
+ if (position > 1) {
+ isShowTime = timeContrast(mDatas.get(position - 1).getSentTime(), mDatas.get(position).getSentTime());
+ }
+
+ if (!mDatas.get(position).getSenderUserId().equals(CommonAppConfig.getInstance().getUid())) {
+ ImgLoader.displayWithError(mContext, getNowHeadImg(), viewHolder.back_touxiang1, R.mipmap.chat_head_mo);
+// viewHolder.back_name1.setText(SystemMessageActivity.nowTitle);
+// viewHolder.back_name1.setVisibility(View.GONE);
+ //点击头像
+ viewHolder.back_touxiang1.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (Constants.remarks != null && !"".equals(Constants.remarks)) {
+ showUserData(mDatas.get(position).getSenderUserId());
+ }
+ }
+ });
+
+ if (!time.equals("") && isShowTime) {
+ viewHolder.back_puttime1.setVisibility(View.VISIBLE);
+ viewHolder.back_puttime1.setText(time);
+ } else {
+ viewHolder.back_puttime1.setVisibility(View.GONE);
+ }
+ } else {
+ ImgLoader.displayWithError(mContext, myAvatar, viewHolder.back_touxiang, R.mipmap.chat_head_mo);
+ //点击头像
+ viewHolder.back_touxiang.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (Constants.remarks != null && !"".equals(Constants.remarks)) {
+ showUserData(mDatas.get(position).getSenderUserId());
+ }
+ }
+ });
+
+ if (!time.equals("") && isShowTime) {
+ viewHolder.back_puttime.setVisibility(View.VISIBLE);
+ viewHolder.back_puttime.setText(time);
+ } else {
+ viewHolder.back_puttime.setVisibility(View.GONE);
+ }
+ }
+
+ if (mDatas.get(position).getObjectName().equals("RC:TxtMsg")) {
+ TextMessage rongMsg = (TextMessage) mDatas.get(position).getContent();
+ if (rongMsg.getContent() != null) {
+// String firstIndexRM = "";
+// if (rongMsg.getContent().length() > 4) {
+// firstIndexRM = rongMsg.getContent().substring(0, 5);
+// }
+// if ("{\"msg".equals(firstIndexRM)) {
+// viewHolder.lt_chat_one.setVisibility(View.GONE);
+// viewHolder.lt_chat_left.setVisibility(View.GONE);
+// viewHolder.lt_chat_right.setVisibility(View.GONE);
+// } else {
+ if (!mDatas.get(position).getSenderUserId().equals(CommonAppConfig.getInstance().getUid())) {
+ viewHolder.lt_chat_one.setVisibility(View.GONE);
+ viewHolder.lt_chat_left.setVisibility(View.VISIBLE);
+ viewHolder.lt_chat_right.setVisibility(View.GONE);
+ viewHolder.lt_text_left.setVisibility(View.VISIBLE);
+ viewHolder.cv_chatcontent_img.setVisibility(View.GONE);
+
+ if (rongMsg.getContent() != null) {
+ viewHolder.chatcontent_text1.setText(rongMsg.getContent());
+ } else {
+ viewHolder.chatcontent_text1.setText(mDatas.get(position).getExtra());
+ }
+
+ } else {
+ if (mDatas.get(position).getReceivedTime() == 0) {
+ viewHolder.view_feed_suc.setVisibility(View.VISIBLE);
+ viewHolder.view_feed_suc.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //重新发送
+ wenZi(mDatas.get(position), 1, position);
+ }
+ });
+ } else {
+ viewHolder.view_feed_suc.setVisibility(View.GONE);
+ }
+ viewHolder.lt_chat_one.setVisibility(View.GONE);
+ viewHolder.lt_chat_left.setVisibility(View.GONE);
+ viewHolder.lt_chat_right.setVisibility(View.VISIBLE);
+ viewHolder.lt_text_right.setVisibility(View.VISIBLE);
+ viewHolder.cv_chatcontent_img.setVisibility(View.GONE);
+
+ if (!rongMsg.getContent().equals("") && rongMsg.getContent() != null) {
+ viewHolder.chatcontent_text.setText(rongMsg.getContent());
+ } else {
+ viewHolder.chatcontent_text.setText(mDatas.get(position).getExtra());
+ }
+ viewHolder.back_touxiang.setVisibility(View.VISIBLE);
+
+ //长按弹窗 撤回
+ viewHolder.chatcontent_text.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ showMoreDialog(mDatas.get(position), mDatas.get(position).getObjectName(), viewHolder.itemView);
+ return false;
+ }
+ });
+ }
+// }
+ }
+ } else if (mDatas.get(position).getObjectName().equals("RC:RcCmd")) {
+ viewHolder.lt_chat_one.setVisibility(View.GONE);
+ viewHolder.lt_chat_left.setVisibility(View.GONE);
+ viewHolder.lt_chat_right.setVisibility(View.GONE);
+ viewHolder.cv_chatcontent_img.setVisibility(View.GONE);
+ viewHolder.cv_chatcontent_img1.setVisibility(View.GONE);
+ viewHolder.rt_video_left.setVisibility(View.GONE);
+ viewHolder.rt_video_right.setVisibility(View.GONE);
+
+ } else if (mDatas.get(position).getObjectName().equals("RC:ImgMsg")) {
+ ImageMessage imageMessage = (ImageMessage) mDatas.get(position).getContent();
+ viewHolder.lt_chat_one.setVisibility(View.GONE);
+ if (!mDatas.get(position).getSenderUserId().equals(CommonAppConfig.getInstance().getUid())) {
+ viewHolder.lt_chat_left.setVisibility(View.VISIBLE);
+ viewHolder.lt_chat_right.setVisibility(View.GONE);
+ viewHolder.lt_text_left.setVisibility(View.GONE);
+ viewHolder.cv_chatcontent_img1.setVisibility(View.VISIBLE);
+ viewHolder.rt_video_left.setVisibility(View.GONE);
+
+ Glide.with(mContext).load(imageMessage.getThumUri()).into(viewHolder.chatcontent_img1);
+ viewHolder.chatcontent_img1.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (imageMessage.getMediaUrl() != null) {
+ showPic(imageMessage.getMediaUrl());
+ }
+ }
+ });
+ } else {
+ viewHolder.lt_chat_left.setVisibility(View.GONE);
+ viewHolder.lt_chat_right.setVisibility(View.VISIBLE);
+ viewHolder.lt_text_right.setVisibility(View.GONE);
+ viewHolder.cv_chatcontent_img.setVisibility(View.VISIBLE);
+ viewHolder.rt_video_right.setVisibility(View.GONE);
+ if (mDatas.get(position).getReceivedTime() == 0) {
+ Glide.with(mContext).load(imageMessage.getThumUri()).into(viewHolder.chatcontent_img);
+ viewHolder.view_feed_suc.setVisibility(View.VISIBLE);
+ viewHolder.view_feed_suc.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //重新发送
+ mediaSend(mDatas.get(position), 1, position, 1);
+ }
+ });
+ } else if (mDatas.get(position).getReceivedTime() < 100) {
+ viewHolder.view_feed_suc.setVisibility(View.GONE);
+ Glide.with(mContext).load(imageMessage.getThumUri()).into(viewHolder.chatcontent_img);
+ } else {
+ viewHolder.view_feed_suc.setVisibility(View.GONE);
+ Glide.with(mContext).load(imageMessage.getThumUri()).into(viewHolder.chatcontent_img);
+
+ viewHolder.chatcontent_img.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (imageMessage.getLocalUri() != null) {
+ showPic(imageMessage.getLocalUri());
+ }
+ }
+ });
+ }
+
+ //长按弹窗 撤回
+ viewHolder.chatcontent_img.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ showMoreDialog(mDatas.get(position), mDatas.get(position).getObjectName(), viewHolder.itemView);
+ return false;
+ }
+ });
+ }
+
+ } else if (mDatas.get(position).getObjectName().equals("RC:SightMsg")) {
+ SightMessage sightMessage = (SightMessage) mDatas.get(position).getContent();
+ viewHolder.lt_chat_one.setVisibility(View.GONE);
+ if (!mDatas.get(position).getSenderUserId().equals(CommonAppConfig.getInstance().getUid())) {
+ viewHolder.lt_chat_left.setVisibility(View.VISIBLE);
+ viewHolder.lt_chat_right.setVisibility(View.GONE);
+ viewHolder.lt_text_left.setVisibility(View.GONE);
+ viewHolder.cv_chatcontent_img1.setVisibility(View.GONE);
+ viewHolder.rt_video_left.setVisibility(View.VISIBLE);
+
+ viewHolder.chatcontent_video_play1.setVisibility(View.VISIBLE);
+ loadCover(viewHolder.chatcontent_video_img1, sightMessage.getThumbUri(), mContext);
+ viewHolder.chatcontent_video_img1.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (sightMessage.getMediaUrl() != null) {
+ showVideo(sightMessage.getMediaUrl());
+ }
+ }
+ });
+ } else {
+ viewHolder.lt_chat_left.setVisibility(View.GONE);
+ viewHolder.lt_chat_right.setVisibility(View.VISIBLE);
+ viewHolder.lt_text_right.setVisibility(View.GONE);
+ viewHolder.cv_chatcontent_img.setVisibility(View.GONE);
+ viewHolder.rt_video_right.setVisibility(View.VISIBLE);
+
+ if (mDatas.get(position).getReceivedTime() == 0) {
+ viewHolder.view_feed_suc.setVisibility(View.VISIBLE);
+ viewHolder.pb_video_right.setVisibility(View.GONE);
+ viewHolder.chatcontent_video_play.setVisibility(View.GONE);
+ viewHolder.view_feed_suc.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //重新发送
+ mediaSend(mDatas.get(position), 1, position, 2);
+ }
+ });
+ } else if (mDatas.get(position).getReceivedTime() < 100) {
+ viewHolder.view_feed_suc.setVisibility(View.GONE);
+ viewHolder.pb_video_right.setVisibility(View.VISIBLE);
+ viewHolder.chatcontent_video_play.setVisibility(View.GONE);
+
+ } else {
+ viewHolder.view_feed_suc.setVisibility(View.GONE);
+ viewHolder.pb_video_right.setVisibility(View.GONE);
+ viewHolder.chatcontent_video_play.setVisibility(View.VISIBLE);
+ }
+
+ loadCover(viewHolder.chatcontent_video_img, sightMessage.getThumbUri(), mContext);
+ viewHolder.chatcontent_video_img.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (sightMessage.getLocalPath() != null) {
+ showVideo(sightMessage.getLocalPath());
+ }
+ }
+ });
+ //长按弹窗 撤回
+ viewHolder.chatcontent_video_img.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ showMoreDialog(mDatas.get(position), mDatas.get(position).getObjectName(), viewHolder.itemView);
+ return false;
+ }
+ });
+ }
+ } else {
+ viewHolder.lt_chat_one.setVisibility(View.GONE);
+ viewHolder.lt_chat_left.setVisibility(View.GONE);
+ viewHolder.lt_chat_right.setVisibility(View.GONE);
+ }
+ }
+
+ }
+ }
+
+ //time1=前面的时间戳,time2=后面的时间戳
+ private boolean timeContrast(long time1, long time2) {
+ //格式
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ //转换为String类型
+ String Date1 = formatter.format(time1);
+ String Date2 = formatter.format(time2);
+ // 获取服务器返回的时间戳 转换成"yyyy-MM-dd HH:mm:ss"
+ // 计算的时间差
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ try {
+ Date d1 = df.parse(Date1);//前面的时间
+ Date d2 = df.parse(Date2); //后面的时间
+ Long diff = d2.getTime() - d1.getTime(); //两时间差,精确到毫秒
+ Long day = diff / (1000 * 60 * 60 * 24); //以天数为单位取整
+ Long hour = (diff / (60 * 60 * 1000) - day * 24); //以小时为单位取整
+ Long min = ((diff / (60 * 1000)) - day * 24 * 60 - hour * 60); //以分钟为单位取整
+ Long second = (diff / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);//秒
+ Log.e("tag", "day =" + day);
+ Log.e("tag", "hour =" + hour);
+ Log.e("tag", "min =" + min);
+ Log.e("tag", "second =" + second);
+ if (day == 0 && hour == 0 && min <= 3) {
+ if (min == 3 && second == 0) {
+ return false;
+ } else {
+ return false;
+ }
+ }
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+
+ private List mSelectedImages = new ArrayList<>();
+
+ private void showPic(Uri uri) {
+ mSelectedImages.clear();
+
+ ImageEntity imageEntity = new ImageEntity();
+ imageEntity.setPath(uri + "");
+ mSelectedImages.add(imageEntity);
+
+ Intent previewIntent = new Intent(nowActivity, PreviewImageActivity.class);
+ previewIntent.putParcelableArrayListExtra("preview_images", (ArrayList extends Parcelable>) mSelectedImages);
+ nowActivity.startActivity(previewIntent);
+ }
+
+ private void showVideo(Uri uri) {
+ mSelectedImages.clear();
+
+ ImageEntity imageEntity = new ImageEntity();
+ imageEntity.setPath(uri + "");
+ mSelectedImages.add(imageEntity);
+
+ Intent previewIntent = new Intent(nowActivity, PreviewVideoActivity.class);
+ previewIntent.putParcelableArrayListExtra("preview_images", (ArrayList extends Parcelable>) mSelectedImages);
+ nowActivity.startActivity(previewIntent);
+ }
+
+ /**
+ * 版本4+之后才有的功能
+ * 加载第1秒的帧数作为封面
+ * uri就是视频的地址
+ */
+ public static void loadCover(ImageView imageView, Uri uri, Context context) {
+ imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ Glide.with(context).setDefaultRequestOptions(new RequestOptions().frame(1000000).centerCrop().error(R.drawable.anim_loading)//可以忽略
+ .placeholder(R.drawable.anim_loading)//可以忽略
+ ).load(uri).into(imageView);
+ }
+
+ //互动消息回复
+ public void editPopupWindow(String dynamic_id, String to_comment_id) {
+ View popupView = LayoutInflater.from(mContext).inflate(R.layout.dialog_edit, null);
+ PopupWindow popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
+ popupWindow.showAtLocation(lt_root, Gravity.CENTER, 0, 0);
+
+ WindowManager.LayoutParams lp = nowActivity.getWindow().getAttributes();
+ lp.alpha = 0.8f;
+ nowActivity.getWindow().setAttributes(lp);
+
+ final EditText et_back_text;
+ final TextView tv_cancel, tv_assign;
+
+ et_back_text = popupView.findViewById(R.id.et_back_text);
+ tv_cancel = popupView.findViewById(R.id.tv_cancel);
+ tv_assign = popupView.findViewById(R.id.tv_assign);
+
+ tv_cancel.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ popupWindow.dismiss();
+ }
+ });
+
+ tv_assign.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (!et_back_text.getText().toString().equals("")) {
+ ImHttpUtil.sendDynamicComment(dynamic_id, et_back_text.getText().toString(), to_comment_id, new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0) {
+ ToastUtil.show(msg);
+ popupWindow.dismiss();
+ } else {
+ ToastUtil.show(msg);
+ }
+ }
+ });
+
+ }
+ }
+ });
+
+ popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
+ @Override
+ public void onDismiss() {
+ lp.alpha = 1f;
+ nowActivity.getWindow().setAttributes(lp);
+ }
+ });
+ }
+
+
+
+
+ @Override
+ public void onDestroy() {
+ oldestMessageId = -1;
+ super.onDestroy();
+
+ }
+
+ //粘性事件
+ @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
+ public void onAvatar(SearchUserBean userBean) {
+ //判断头像管理员头像不可以被自己本身的头像覆盖
+ if (!TextUtils.isEmpty(userBean.getAvatar()) && TextUtils.equals(userBean.getIs_admin(), "1")) {
+ myAvatar = userBean.getAvatar();
+ } else {
+ myAvatar = Constants.myAvatar;
+ }
+ }
+}
diff --git a/main/src/main/res/layout/view_main_message_head.xml b/main/src/main/res/layout/view_main_message_head.xml
index 4bb0c7659..f59fcdce3 100644
--- a/main/src/main/res/layout/view_main_message_head.xml
+++ b/main/src/main/res/layout/view_main_message_head.xml
@@ -8,5 +8,69 @@
android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file