消息的基本完成准备修改细节

This commit is contained in:
ningwenqiang 2024-11-01 13:14:41 +08:00
parent 1bdbb25e94
commit aca96cf800
6 changed files with 1953 additions and 96 deletions

View File

@ -0,0 +1,243 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lt_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.yunbao.common.custom.CommonRefreshView
android:id="@+id/refreshView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:visibility="visible" />
<LinearLayout
android:id="@+id/lt_chat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:visibility="gone">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_chat"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="@+id/back_bt_jump"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginBottom="6dp"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:gravity="center">
<View
android:id="@+id/v_morefeatures"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="@mipmap/btn_morefeatures" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="9dp"
android:layout_weight="1"
android:gravity="center">
<EditText
android:id="@+id/feedback_edittext"
android:layout_width="match_parent"
android:layout_height="42dp"
android:background="@drawable/background_d18_white"
android:paddingLeft="12dp"
android:paddingTop="6dp"
android:paddingRight="12dp"
android:paddingBottom="6dp"
android:text=""
android:textColor="@color/gray1" />
</LinearLayout>
<LinearLayout
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginLeft="6dp"
android:layout_marginRight="9dp"
android:gravity="center">
<TextView
android:id="@+id/rttext_fasong"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@mipmap/btn_sand"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/lt_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:layout_marginLeft="9dp"
android:layout_marginRight="9dp"
android:layout_marginBottom="18dp"
android:gravity="center"
android:orientation="vertical"
android:visibility="visible">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="9dp"
android:visibility="gone"
android:background="@color/gray_ededed" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="1"
android:gravity=""
android:orientation="horizontal">
<LinearLayout
android:id="@+id/lt_photo_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<View
android:layout_width="54dp"
android:layout_height="54dp"
android:background="@mipmap/icon_camera" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="照片"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/lt_choospic_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="21dp"
android:gravity="center"
android:orientation="vertical">
<View
android:layout_width="54dp"
android:layout_height="54dp"
android:background="@mipmap/icon_photo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="相册"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/voice_button"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<View
android:layout_width="36dp"
android:layout_height="32dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="录音"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginLeft="3dp"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<View
android:layout_width="36dp"
android:layout_height="32dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="短语"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/lt_video_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="21dp"
android:gravity="center"
android:orientation="vertical">
<View
android:layout_width="54dp"
android:layout_height="54dp"
android:background="@mipmap/icon_video" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="视频"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginLeft="3dp"
android:gravity="center"
android:onClick="setOnClick"
android:orientation="vertical"
android:visibility="gone">
<View
android:layout_width="36dp"
android:layout_height="32dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="位置"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -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<SystemMessageBean> {
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);
}
}
}
}

View File

@ -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;

View File

@ -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<ImUserBean> commonCallback;
public void setCommonCallback(CommonCallback<ImUserBean> 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));
// }
}

File diff suppressed because it is too large Load Diff

View File

@ -8,5 +8,69 @@
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_marginTop="28dp"
android:background="@android:color/transparent"
android:fadingEdge="none"
app:elevation="0dp"
app:layout_behavior="com.yunbao.common.custom.FixAppBarLayoutBehavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<net.lucode.hackware.magicindicator.MagicIndicator
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/btn_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:padding="6dp"
android:visibility="gone"
android:onClick="mainClick"
android:src="@mipmap/ic_yola_search"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/addressBookImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:padding="6dp"
android:src="@mipmap/ic_yola_address_book"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="6dp"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="@android:color/transparent"
android:overScrollMode="never"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.constraintlayout.widget.ConstraintLayout>