删除公聊大厅相关代码
@@ -107,7 +107,6 @@ android {
|
||||
main {
|
||||
java.srcDirs = [
|
||||
'src/main/java',
|
||||
'src/module_public_chat_hall/java',
|
||||
'src/module_mentoring_relationship/java',
|
||||
'src/module_labour_union/java',
|
||||
'src/module_room_chat/java',
|
||||
@@ -123,7 +122,6 @@ android {
|
||||
res.srcDirs = [
|
||||
'src/main/res',
|
||||
'src/common/res',
|
||||
'src/module_public_chat_hall/res',
|
||||
'src/module_mentoring_relationship/res',
|
||||
'src/module_labour_union/res',
|
||||
'src/module_room_chat/res',
|
||||
|
@@ -13,7 +13,6 @@ import com.chwl.app.R;
|
||||
import com.chwl.app.UIHelper;
|
||||
import com.chwl.app.avroom.widget.ViewItem;
|
||||
import com.chwl.app.common.widget.dialog.DialogManager;
|
||||
import com.chwl.app.public_chat_hall.widget.ShutUpDialog;
|
||||
import com.chwl.app.ui.im.avtivity.NimFriendModel;
|
||||
import com.chwl.app.ui.im.avtivity.NimP2PMessageActivity;
|
||||
import com.chwl.app.ui.widget.ButtonItem;
|
||||
@@ -195,42 +194,6 @@ public class ButtonItemFactory {
|
||||
return buttonItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建相关的buttons 添加到资料卡片
|
||||
*
|
||||
* @param context context
|
||||
* @param uid uid or 云信account
|
||||
* @param listener dialog的监听回调
|
||||
* @return List<ViewItem>
|
||||
*/
|
||||
public static List<ViewItem> createPublicChatHallButtonItems(
|
||||
Context context,
|
||||
long uid,
|
||||
boolean isInRoom,
|
||||
GiftDialog.OnGiftDialogBtnClickListener listener) {
|
||||
if (uid <= 0) return null;
|
||||
String currentUid = String.valueOf(AuthModel.get().getCurrentUid());
|
||||
String account = String.valueOf(uid);
|
||||
//account和chatRoomMember 不会同时为空,如果同时为空,则是前面传参出错
|
||||
boolean isMySelf = Objects.equals(currentUid, account);
|
||||
if (isMySelf) {
|
||||
return null;
|
||||
}
|
||||
List<ViewItem> buttonItems = new ArrayList<>();
|
||||
//不在房间内,也不需要魔法
|
||||
buttonItems.add(createSendGiftItem(context, uid, true, true, listener));
|
||||
// 私聊
|
||||
buttonItems.add(createPrivateChatItem(context, account, isInRoom));
|
||||
//装扮和关注目前是都有的操作
|
||||
//buttonItems.add(createSendDecorationItem(context, uid));
|
||||
buttonItems.add(createAttentItem());
|
||||
buttonItems.add(createFindMeItem());
|
||||
if (PublicChatHallDataManager.get().isRoomAdmin()) {
|
||||
buttonItems.add(createShutupItem(context, uid));
|
||||
}
|
||||
return buttonItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* 踩TA,当该人再房间中的时候,进入他所在的房间
|
||||
*
|
||||
@@ -463,15 +426,6 @@ public class ButtonItemFactory {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 公聊大厅禁言
|
||||
*/
|
||||
public static ViewItem createShutupItem(Context context, long uid) {
|
||||
return new ViewItem(ResUtil.getString(R.string.erban_avroom_buttonitemfactory_028), R.drawable.icon_shut_up, () -> {
|
||||
new ShutUpDialog(context, uid).openDialog();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param isInRoom true 在房间内弹起
|
||||
|
@@ -1,146 +0,0 @@
|
||||
package com.chwl.app.avroom.activity;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.fragment.InviteFriendListFragment;
|
||||
import com.chwl.app.base.BaseBindingActivity;
|
||||
import com.chwl.app.databinding.ActivityCpRoomInviteBinding;
|
||||
import com.chwl.app.public_chat_hall.event.AitFriendEvent;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.room.bean.RoomInfo;
|
||||
import com.chwl.core.room.model.RoomSettingModel;
|
||||
import com.chwl.core.share.bean.SessionType;
|
||||
import com.chwl.core.utils.net.DontWarnObserver;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.functions.Function;
|
||||
|
||||
@ActLayoutRes(R.layout.activity_cp_room_invite)
|
||||
public class CpRoomInviteActivity extends BaseBindingActivity<ActivityCpRoomInviteBinding> {
|
||||
|
||||
private List<String> uids = new ArrayList<>();
|
||||
private List<String> userNames = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
EventBus.getDefault().register(this);
|
||||
initTitleBar(ResUtil.getString(R.string.avroom_activity_cproominviteactivity_01));
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.content, new InviteFriendListFragment(), null).commitAllowingStateLoss();
|
||||
|
||||
mBinding.tvInvite.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo == null) return;
|
||||
if (uids.size() == 0) {
|
||||
toast(ResUtil.getString(R.string.avroom_activity_cproominviteactivity_02));
|
||||
return;
|
||||
}
|
||||
String uid = "";
|
||||
for (int i = 0; i < uids.size(); i++) {
|
||||
String targetUid = uids.get(i);
|
||||
String nick = userNames.get(i);
|
||||
uid += uids.get(i) + ",";
|
||||
int sessionType = SessionType.P2P;
|
||||
IMNetEaseManager.get().sendSharingRoomMessage(sessionType, targetUid);
|
||||
}
|
||||
|
||||
RoomSettingModel model = new RoomSettingModel();
|
||||
|
||||
model.invite(AvRoomDataManager.get().mCurrentRoomInfo.getUid(), uid)
|
||||
.flatMap((Function<String, SingleSource<RoomInfo>>) s -> updateRoomInfo("", RoomInfo.IS_INVITE))
|
||||
.subscribe(new DontWarnObserver<RoomInfo>() {
|
||||
@Override
|
||||
public void accept(RoomInfo roomInfo, String error) {
|
||||
super.accept(roomInfo, error);
|
||||
if (error != null) {
|
||||
toast(error);
|
||||
} else {
|
||||
toast(ResUtil.getString(R.string.avroom_activity_cproominviteactivity_03));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Single<RoomInfo> updateRoomInfo(String encryptPwd, String limitType) {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo == null) {
|
||||
return Single.error(new Throwable(ResUtil.getString(R.string.avroom_activity_cproominviteactivity_04)));
|
||||
}
|
||||
//更新房间接口调用成功后,会发事件RoomEvent.ROOM_INFO_UPDATE
|
||||
RoomSettingModel model = new RoomSettingModel();
|
||||
if (AvRoomDataManager.get().isRoomOwner()) {
|
||||
return model.updateRoomInfo(roomInfo.title,
|
||||
roomInfo.getRoomDesc(),
|
||||
roomInfo.getIntroduction(),
|
||||
encryptPwd,
|
||||
roomInfo.getRoomTag(),
|
||||
roomInfo.tagId,
|
||||
AuthModel.get().getCurrentUid(),
|
||||
AuthModel.get().getTicket(),
|
||||
roomInfo.isHasAnimationEffect(),
|
||||
roomInfo.getAudioQuality(),
|
||||
limitType,
|
||||
roomInfo.isPureMode(),
|
||||
roomInfo.getType(),
|
||||
roomInfo.getMgId());
|
||||
} else {
|
||||
return model.updateByAdmin(roomInfo.getUid(), roomInfo.title,
|
||||
roomInfo.getRoomDesc(),
|
||||
roomInfo.getIntroduction(),
|
||||
encryptPwd,
|
||||
roomInfo.getRoomTag(),
|
||||
roomInfo.tagId,
|
||||
AuthModel.get().getCurrentUid(),
|
||||
AuthModel.get().getTicket(),
|
||||
roomInfo.isHasAnimationEffect(),
|
||||
roomInfo.getAudioQuality(),
|
||||
roomInfo.isPureMode());
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void countingAitFriends(AitFriendEvent event) {
|
||||
switch (event.getType()) {
|
||||
case AitFriendEvent.TYPE_ADD:
|
||||
if (uids.size() == 20) {
|
||||
toast(ResUtil.getString(R.string.avroom_activity_cproominviteactivity_05));
|
||||
return;
|
||||
}
|
||||
if (!uids.contains(event.getUid())) {
|
||||
uids.add(event.getUid());
|
||||
userNames.add(event.getNick());
|
||||
}
|
||||
break;
|
||||
|
||||
case AitFriendEvent.TYTPE_REMOVE:
|
||||
if (uids.contains(event.getUid())) {
|
||||
uids.remove(event.getUid());
|
||||
userNames.remove(event.getNick());
|
||||
}
|
||||
break;
|
||||
}
|
||||
initTitleBar(ResUtil.getString(R.string.avroom_activity_cproominviteactivity_06) + uids.size() + "/20)");
|
||||
}
|
||||
}
|
@@ -1,134 +0,0 @@
|
||||
package com.chwl.app.avroom.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.bean.PublicChatHallFriendInfo;
|
||||
import com.chwl.app.public_chat_hall.event.AitFriendEvent;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.widget.NobleAvatarView;
|
||||
import com.chwl.core.noble.NobleUtil;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
public class InviteFriendListAdapter extends BaseQuickAdapter<PublicChatHallFriendInfo, BaseViewHolder> {
|
||||
|
||||
private Activity context;
|
||||
|
||||
public InviteFriendListAdapter(Activity context) {
|
||||
super(R.layout.item_public_chat_hall_friend_list);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private OnItemClickListener onItemClickListener;
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void sendListener(UserInfo attentionInfo);
|
||||
}
|
||||
|
||||
public void setRylListener(OnItemClickListener onClickListener) {
|
||||
onItemClickListener = onClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, PublicChatHallFriendInfo pchFriendInfo) {
|
||||
if (pchFriendInfo == null) return;
|
||||
final UserInfo item = pchFriendInfo.getUserInfo();
|
||||
|
||||
CheckBox cbFriend = helper.getView(R.id.cb_friend);
|
||||
|
||||
helper.setText(R.id.tv_userName, item.getNick())
|
||||
.setText(R.id.tv_user_desc, item.getUserDesc() != null ?
|
||||
item.getUserDesc()
|
||||
: helper.itemView.getContext().getResources().getString(R.string.msg_no_user_desc))
|
||||
.setVisible(R.id.view_line, helper.getLayoutPosition() != getItemCount() - 1)
|
||||
;
|
||||
|
||||
NobleAvatarView nobleAvatarView = helper.getView(R.id.noble_avatar_view);
|
||||
nobleAvatarView.setSize(47, 70, 13);
|
||||
nobleAvatarView.setData(item.getAvatar(), item.getNobleUsers());
|
||||
|
||||
|
||||
AppCompatImageView ivGender = helper.getView(R.id.iv_gender);
|
||||
if (item.getGender() == 1) {
|
||||
ivGender.setImageResource(R.drawable.ic_gender_male);
|
||||
} else {
|
||||
ivGender.setImageResource(R.drawable.ic_gender_female);
|
||||
}
|
||||
|
||||
AppCompatImageView ivNobleLevel = helper.getView(R.id.iv_noble_level);
|
||||
if (item.getNobleUsers() != null) {
|
||||
ivNobleLevel.setVisibility(View.VISIBLE);
|
||||
String badgeByLevel = NobleUtil.getBadgeByLevel(item.getNobleUsers().getLevel());
|
||||
if (!TextUtils.isEmpty(badgeByLevel)) {
|
||||
NobleUtil.loadResource(badgeByLevel, ivNobleLevel);
|
||||
} else {
|
||||
ivNobleLevel.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
ivNobleLevel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
AppCompatImageView ivUserLevel = helper.getView(R.id.iv_user_level);
|
||||
ivUserLevel.setVisibility(View.GONE);
|
||||
if (item.getUserLevelVo() != null && !TextUtils.isEmpty(item.getUserLevelVo().getExperUrl())) {
|
||||
ivUserLevel.setVisibility(View.VISIBLE);
|
||||
ImageLoadUtils.loadImage(mContext, item.getUserLevelVo().getExperUrl(), ivUserLevel);
|
||||
}
|
||||
|
||||
AppCompatImageView ivCharmLevel = helper.getView(R.id.iv_charm_level);
|
||||
ivCharmLevel.setVisibility(View.GONE);
|
||||
if (item.getUserLevelVo() != null && !TextUtils.isEmpty(item.getUserLevelVo().getCharmUrl())) {
|
||||
ivCharmLevel.setVisibility(View.VISIBLE);
|
||||
ImageLoadUtils.loadImage(mContext, item.getUserLevelVo().getCharmUrl(), ivCharmLevel);
|
||||
}
|
||||
|
||||
cbFriend.setChecked(pchFriendInfo.isSelected());
|
||||
// cbFriend.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// onSelect(cbFriend, pchFriendInfo, item);
|
||||
// }
|
||||
// });
|
||||
// cbFriend.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
//
|
||||
// });
|
||||
helper.getView(R.id.container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onSelect(cbFriend, pchFriendInfo, item);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void onSelect(CheckBox cbFriend, PublicChatHallFriendInfo pchFriendInfo, UserInfo item) {
|
||||
int count = 0;
|
||||
for (PublicChatHallFriendInfo publicChatHallFriendInfo : getData()) {
|
||||
if (publicChatHallFriendInfo.isSelected()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count == 20 && !pchFriendInfo.isSelected()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_adapter_invitefriendlistadapter_01));
|
||||
return;
|
||||
}
|
||||
cbFriend.setChecked(!cbFriend.isChecked());
|
||||
pchFriendInfo.setSelected(!pchFriendInfo.isSelected());
|
||||
EventBus.getDefault().post(new AitFriendEvent()
|
||||
.setType(pchFriendInfo.isSelected() ? AitFriendEvent.TYPE_ADD : AitFriendEvent.TYTPE_REMOVE)
|
||||
.setUid(String.valueOf(item.getUid()))
|
||||
.setNick(item.getNick()));
|
||||
}
|
||||
|
||||
}
|
@@ -1,154 +0,0 @@
|
||||
package com.chwl.app.avroom.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.activity.CpRoomInviteActivity;
|
||||
import com.chwl.app.avroom.widget.EditRoomTitleDialog;
|
||||
import com.chwl.app.databinding.DialogRoomImposeBinding;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.library.common.util.Utils;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.core.room.bean.RoomInfo;
|
||||
import com.chwl.core.room.model.RoomSettingModel;
|
||||
import com.chwl.core.utils.net.DontWarnObserver;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.chwl.library.utils.codec.DESUtils;
|
||||
|
||||
public class RoomImposeDialog extends BottomSheetDialog implements View.OnClickListener {
|
||||
private Context context;
|
||||
private DialogRoomImposeBinding binding;
|
||||
|
||||
public RoomImposeDialog(Context context) {
|
||||
super(context, R.style.ErbanBottomSheetDialogDimFalse);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setCanceledOnTouchOutside(true);
|
||||
setContentView(R.layout.dialog_room_impose);
|
||||
binding = DataBindingUtil.bind(findViewById(R.id.dialog_container));
|
||||
binding.setClick(this);
|
||||
|
||||
FrameLayout bottomSheet = findViewById(R.id.design_bottom_sheet);
|
||||
if (bottomSheet != null) {
|
||||
BottomSheetBehavior.from(bottomSheet).setSkipCollapsed(false);
|
||||
BottomSheetBehavior.from(bottomSheet).setPeekHeight(
|
||||
UIUtil.dip2px(context, 270) +
|
||||
(Utils.hasSoftKeys(context) ? Utils.getNavigationBarHeight(context) : 0));
|
||||
}
|
||||
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display d = windowManager.getDefaultDisplay();
|
||||
DisplayMetrics realDisplayMetrics = new DisplayMetrics();
|
||||
d.getRealMetrics(realDisplayMetrics);
|
||||
WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||
params.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
params.height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
getWindow().setAttributes(params);
|
||||
getWindow().setWindowAnimations(R.style.ErbanCommonWindowAnimationStyle);
|
||||
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo == null) return;
|
||||
if ("lock".equals(roomInfo.getLimitType()) || !TextUtils.isEmpty(roomInfo.roomPwd)) {
|
||||
binding.tvPwd.setTextColor(context.getResources().getColor(R.color.appColor));
|
||||
} else if ("isFriend".equals(roomInfo.getLimitType())) {
|
||||
binding.tvFriend.setTextColor(context.getResources().getColor(R.color.appColor));
|
||||
} else if ("isInvite".equals(roomInfo.getLimitType())) {
|
||||
binding.tvInvite.setTextColor(context.getResources().getColor(R.color.appColor));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo == null) return;
|
||||
switch (v.getId()) {
|
||||
case R.id.tv_invite:
|
||||
context.startActivity(new Intent(context, CpRoomInviteActivity.class));
|
||||
dismiss();
|
||||
break;
|
||||
case R.id.tv_friend:
|
||||
updateRoomInfo("", roomInfo, RoomInfo.IS_FRIEND);
|
||||
break;
|
||||
case R.id.tv_pwd:
|
||||
String oldContent = "";
|
||||
try {
|
||||
oldContent = DESUtils.DESAndBase64Decrypt(roomInfo.roomPwd);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
EditRoomTitleDialog pwdDialog = new EditRoomTitleDialog(context,
|
||||
EditRoomTitleDialog.TYPE_EDIT_PASSWORD, oldContent);
|
||||
pwdDialog.setOnEditTitleListner(new EditRoomTitleDialog.OnEditTitleListner() {
|
||||
@Override
|
||||
public void onEditPwdListner(String newPwd) {
|
||||
String encryptPwd = DESUtils.DESAndBase64(newPwd);
|
||||
|
||||
if (encryptPwd.equals(roomInfo.getRoomPwd())) {
|
||||
return;
|
||||
}
|
||||
updateRoomInfo(encryptPwd, roomInfo, RoomInfo.LOCK);
|
||||
}
|
||||
});
|
||||
pwdDialog.show();
|
||||
break;
|
||||
case R.id.tv_cancel_limit:
|
||||
updateRoomInfo("", roomInfo, "");
|
||||
break;
|
||||
case R.id.btn_cancel:
|
||||
dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRoomInfo(String encryptPwd, RoomInfo roomInfo, String limitType) {
|
||||
//更新房间接口调用成功后,会发事件RoomEvent.ROOM_INFO_UPDATE
|
||||
RoomSettingModel model = new RoomSettingModel();
|
||||
model.updateRoomInfo(roomInfo.title,
|
||||
roomInfo.getRoomDesc(),
|
||||
roomInfo.getIntroduction(),
|
||||
encryptPwd,
|
||||
roomInfo.getRoomTag(),
|
||||
roomInfo.tagId,
|
||||
AuthModel.get().getCurrentUid(),
|
||||
AuthModel.get().getTicket(),
|
||||
roomInfo.isHasAnimationEffect(),
|
||||
roomInfo.getAudioQuality(),
|
||||
limitType,
|
||||
roomInfo.isPureMode(),
|
||||
roomInfo.getType(),
|
||||
roomInfo.getMgId())
|
||||
.subscribe(new DontWarnObserver<RoomInfo>() {
|
||||
@Override
|
||||
public void accept(RoomInfo roomInfo, String error) {
|
||||
super.accept(roomInfo, error);
|
||||
if (error != null) {
|
||||
SingleToastUtil.showToast(error);
|
||||
} else {
|
||||
if (!limitType.equals(RoomInfo.IS_INVITE)) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_dialog_roomimposedialog_04));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
dismiss();
|
||||
}
|
||||
}
|
@@ -127,7 +127,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
addOpenOrClosePublicScreenAction(optAdapter);
|
||||
// addRedPackageSwitch();
|
||||
addCleanScreenAction(optAdapter);
|
||||
addRoomLimit(optAdapter);
|
||||
// addRoomLimit(optAdapter);
|
||||
addGiftValueAction(optAdapter);
|
||||
addSuperAdminAction(optAdapter);
|
||||
addShieldReportAction(optAdapter);
|
||||
@@ -361,12 +361,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
*/
|
||||
private void addRoomLimit(OptAdapter optAdapter) {
|
||||
//添加
|
||||
if (AvRoomDataManager.get().isRoomOwner() && AvRoomDataManager.get().isCpRoom()) {
|
||||
optAdapter.addData(new OptAction(R.drawable.icon_room_limit,
|
||||
ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_023),
|
||||
() -> new RoomImposeDialog(context).show()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,152 +0,0 @@
|
||||
package com.chwl.app.avroom.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.InviteFriendListAdapter;
|
||||
import com.chwl.app.base.BaseFragment;
|
||||
import com.chwl.app.public_chat_hall.bean.PublicChatHallFriendInfo;
|
||||
import com.chwl.core.im.friend.IMFriendModel;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.manager.RelationShipEvent;
|
||||
import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* 公聊大厅选择艾特人的好友页面
|
||||
*/
|
||||
public class InviteFriendListFragment extends BaseFragment {
|
||||
|
||||
private static final String TAG = "InviteFriendListFragment";
|
||||
|
||||
private InviteFriendListAdapter adapter = null;
|
||||
private SwipeRefreshLayout mSwipeRefresh;
|
||||
private RecyclerView mRecyclerView;
|
||||
|
||||
public static InviteFriendListFragment newInstances() {
|
||||
return new InviteFriendListFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindViews() {
|
||||
mSwipeRefresh = mView.findViewById(R.id.swipe_refresh);
|
||||
mRecyclerView = mView.findViewById(R.id.recycler_view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
mSwipeRefresh.setEnabled(false);
|
||||
|
||||
if (adapter == null) {
|
||||
adapter = new InviteFriendListAdapter(getActivity());
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
|
||||
loadFriends();
|
||||
} else {
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
Disposable d = IMNetEaseManager.get().getRelationShipEventObservable().subscribe(this::onGetRelationShipEvent);
|
||||
mCompositeDisposable.add(d);
|
||||
}
|
||||
|
||||
private void onGetRelationShipEvent(RelationShipEvent event) {
|
||||
if (event.event == RelationShipEvent.EVENT_FRIEND_UPDATE) {
|
||||
onFriendListUpdate(event.accounts);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFriends() {
|
||||
onFriendListUpdate(IMFriendModel.get().getMyFriendsAccounts());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRootLayoutId() {
|
||||
return R.layout.fragment_fans_list;
|
||||
}
|
||||
|
||||
private void onFriendListUpdate(List<String> accounts) {
|
||||
if (ListUtils.isListEmpty(accounts)) {
|
||||
showNoData(getString(R.string.no_frenids_text));
|
||||
return;
|
||||
}
|
||||
ArrayList<Long> ids = new ArrayList<>(accounts.size());
|
||||
for (String account : accounts) {
|
||||
ids.add(Long.valueOf(account));
|
||||
}
|
||||
UserModel.get().loadUserInfoByUids(accounts).subscribe(new SingleObserver<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
mCompositeDisposable.add(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<UserInfo> userInfos) {
|
||||
List<PublicChatHallFriendInfo> publicChatHallFriendInfoList = new ArrayList<>();
|
||||
for (UserInfo userInfo : userInfos) {
|
||||
PublicChatHallFriendInfo friendInfo = new PublicChatHallFriendInfo();
|
||||
friendInfo.setUserInfo(userInfo);
|
||||
publicChatHallFriendInfoList.add(friendInfo);
|
||||
}
|
||||
setData(publicChatHallFriendInfoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
toast(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setData(List<PublicChatHallFriendInfo> userInfos) {
|
||||
if (userInfos != null && !userInfos.isEmpty()) {
|
||||
hideStatus();
|
||||
adapter.setNewData(userInfos);
|
||||
//adapter.notifyDataSetChanged();
|
||||
} else {
|
||||
showNoData(getString(R.string.no_frenids_text));
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onCurrentUserInfoUpdate(UserInfo userInfo) {
|
||||
mRecyclerView.postDelayed(() -> onFriendListUpdate(IMFriendModel.get().getMyFriendsAccounts())
|
||||
, 250);
|
||||
}
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package com.chwl.app.headline;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.webview.CommonWebViewFragment;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
|
||||
@ActLayoutRes(R.layout.fragment_common_web_view)
|
||||
public class HeadLineFragment extends CommonWebViewFragment {
|
||||
|
||||
public static HeadLineFragment newInstance() {
|
||||
return new HeadLineFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitArguments(Bundle bundle) {
|
||||
url = UriProvider.getErbanTopMessageUrl();
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package com.chwl.app.headline;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.webview.CommonWebViewFragment;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
|
||||
@ActLayoutRes(R.layout.fragment_common_web_view)
|
||||
public class MyHeadLineFragment extends CommonWebViewFragment {
|
||||
|
||||
public static MyHeadLineFragment newInstance() {
|
||||
return new MyHeadLineFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitArguments(Bundle bundle) {
|
||||
url = UriProvider.getRelatedToMeHeadLineUrl();
|
||||
}
|
||||
}
|
@@ -13,7 +13,6 @@ import com.chwl.app.luckymoney.viewholder.LuckyMoneyMsgViewHolder;
|
||||
import com.chwl.app.luckymoney.viewholder.LuckyMoneyTipsViewHolder;
|
||||
import com.chwl.app.module_hall.HallDataManager;
|
||||
import com.chwl.app.module_hall.im.msgholder.ClanMsgViewHolder;
|
||||
import com.chwl.app.public_chat_hall.msg.viewholder.MsgViewHolderAitMe;
|
||||
import com.chwl.app.share.viewholder.InAppSharingMsgViewHolder;
|
||||
import com.chwl.app.ui.im.actions.GiftAction;
|
||||
import com.chwl.app.ui.im.avtivity.NimP2PMessageActivity;
|
||||
@@ -55,7 +54,6 @@ import com.chwl.core.im.custom.bean.NoticeAttachment;
|
||||
import com.chwl.core.im.custom.bean.OpenRoomNotiAttachment;
|
||||
import com.chwl.core.im.custom.bean.OpenSignInAttachment;
|
||||
import com.chwl.core.im.custom.bean.P2PContactRechargeAttachment;
|
||||
import com.chwl.core.im.custom.bean.RedPackageAttachment;
|
||||
import com.chwl.core.im.custom.bean.RedPacketAttachment;
|
||||
import com.chwl.core.im.custom.bean.SkillMsgAttachment;
|
||||
import com.chwl.core.im.custom.bean.SysMsgAttachment;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
package com.chwl.app.ui.im;
|
||||
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
@@ -22,7 +22,6 @@ import com.chwl.app.home.helper.OpenRoomHelper;
|
||||
import com.chwl.app.module_hall.HallDataManager;
|
||||
import com.chwl.app.module_hall.hall.activity.ModuleClanActivity;
|
||||
import com.chwl.app.module_hall.hall.activity.ModuleHallActivity;
|
||||
import com.chwl.app.public_chat_hall.activity.PublicChatHallHomeActivity;
|
||||
import com.chwl.app.radish.signin.SignInActivity;
|
||||
import com.chwl.app.radish.task.activity.TaskCenterActivity;
|
||||
import com.chwl.app.relation.cp.activity.CpHomeActivity;
|
||||
@@ -129,10 +128,6 @@ public class RouterHandler {
|
||||
case RouterType.TEAM:
|
||||
NimTeamMessageActivity.start(context, routerValue);
|
||||
break;
|
||||
|
||||
case RouterType.PUBLIC_CHAT_HALL:
|
||||
PublicChatHallHomeActivity.openPublicChatHallPage(context);
|
||||
break;
|
||||
case RouterType.BINDING_PHONE:
|
||||
AuthModel.get().isBindPhone()
|
||||
.subscribe(new SingleObserver<String>() {
|
||||
|
@@ -23,7 +23,6 @@ import com.chwl.app.application.IReportConstants;
|
||||
import com.chwl.app.application.ReportManager;
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.family.view.activity.FamilyHomeActivity;
|
||||
import com.chwl.app.public_chat_hall.activity.PublicChatHallHomeActivity;
|
||||
import com.chwl.app.ui.im.RouterHandler;
|
||||
import com.chwl.app.ui.im.avtivity.NimP2PMessageActivity;
|
||||
import com.chwl.app.ui.pay.ChargeActivity;
|
||||
@@ -195,15 +194,7 @@ public class JSInterface {
|
||||
if (!TextUtils.isEmpty(uid)) {
|
||||
try {
|
||||
long uidLong = Long.parseLong(uid);
|
||||
long publicChatHallUid = 0;
|
||||
if (PublicChatHallDataManager.get().getPublicChatHallUid() != null) {
|
||||
publicChatHallUid = Long.parseLong(PublicChatHallDataManager.get().getPublicChatHallUid());
|
||||
}
|
||||
if (uidLong == publicChatHallUid) {
|
||||
PublicChatHallHomeActivity.openPublicChatHallPage(context);
|
||||
} else {
|
||||
AVRoomActivity.start(context, uidLong);
|
||||
}
|
||||
AVRoomActivity.start(context, uidLong);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@ import com.example.lib_utils.ktx.singleClick
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.databinding.AllServiceGiftGoRoomTipsDialogBinding
|
||||
import com.chwl.app.public_chat_hall.activity.PublicChatHallHomeActivity
|
||||
import com.chwl.core.initial.InitialModel
|
||||
import com.chwl.library.common.util.SPUtils
|
||||
import com.chwl.library.utils.JavaUtil
|
||||
@@ -68,11 +67,7 @@ class AllServiceGiftGoRoomTipsDialog(
|
||||
if (isCheck) {
|
||||
ignoreTips()
|
||||
}
|
||||
if (roomId == JavaUtil.str2long(InitialModel.get().publicChatHallUid)) {
|
||||
PublicChatHallHomeActivity.openPublicChatHallPage(context)
|
||||
} else {
|
||||
AVRoomActivity.start(context, roomId)
|
||||
}
|
||||
AVRoomActivity.start(context, roomId)
|
||||
dismiss()
|
||||
}
|
||||
binding?.tvCancel?.singleClick {
|
||||
|
@@ -19,7 +19,6 @@ import com.example.lib_utils.spannable.SpannableTextBuilder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.databinding.DialogGiftAllServiceLevelBinding
|
||||
import com.chwl.app.public_chat_hall.activity.PublicChatHallHomeActivity
|
||||
import com.chwl.core.initial.InitialModel
|
||||
import com.chwl.core.noble.bean.AllServiceGiftProtocol
|
||||
import com.chwl.library.utils.JavaUtil
|
||||
@@ -174,11 +173,7 @@ class AllServiceGiftLevelDialog : BaseDialog {
|
||||
if (AllServiceGiftGoRoomTipsDialog.isNeedTips()) {
|
||||
AllServiceGiftGoRoomTipsDialog(context, data.roomTitle ?: "", data.roomUid).show()
|
||||
} else {
|
||||
if (data.roomUid == JavaUtil.str2long(InitialModel.get().publicChatHallUid)) {
|
||||
PublicChatHallHomeActivity.openPublicChatHallPage(context)
|
||||
} else {
|
||||
AVRoomActivity.start(context, data.roomUid)
|
||||
}
|
||||
AVRoomActivity.start(context, data.roomUid)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
</data>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.chwl.app.base.TitleBar
|
||||
android:id="@+id/title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_below="@id/title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/tv_invite" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_invite"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="38dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/layout_activity_cp_room_invite_01"
|
||||
android:textColor="#ffffffff"
|
||||
android:textSize="15sp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_margin="15dp"
|
||||
android:background="@drawable/shape_appcolor_corner" />
|
||||
</RelativeLayout>
|
||||
</layout>
|
@@ -1,183 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="android.view.View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="270dp"
|
||||
android:background="@color/transparent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="13dp"
|
||||
android:layout_marginRight="13dp"
|
||||
android:background="@drawable/dialog_background"
|
||||
android:orientation="vertical"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_more"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/dialog_background"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_invite"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/dialog_background"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:minHeight="@dimen/dialog_msg_min_height"
|
||||
android:onClick="@{click}"
|
||||
android:singleLine="true"
|
||||
android:text="@string/layout_dialog_room_impose_01"
|
||||
android:textColor="#ff3f3f3f"
|
||||
android:textSize="16dp"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="#ffd9d9d9" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_friend"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:minHeight="@dimen/dialog_msg_min_height"
|
||||
android:onClick="@{click}"
|
||||
android:singleLine="true"
|
||||
android:text="@string/layout_dialog_room_impose_02"
|
||||
android:textColor="#ff3f3f3f"
|
||||
android:textSize="16dp"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="#ffd9d9d9" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/dialog_background"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_pwd"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/dialog_background"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:minHeight="@dimen/dialog_msg_min_height"
|
||||
android:onClick="@{click}"
|
||||
android:singleLine="true"
|
||||
android:text="@string/layout_dialog_room_impose_03"
|
||||
android:textColor="#ff3f3f3f"
|
||||
android:textSize="16dp"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="#ffd9d9d9" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/dialog_background"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cancel_limit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/dialog_background"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:minHeight="@dimen/dialog_msg_min_height"
|
||||
android:onClick="@{click}"
|
||||
android:singleLine="true"
|
||||
android:text="@string/layout_dialog_room_impose_04"
|
||||
android:textColor="#ff3f3f3f"
|
||||
android:textSize="16dp"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="13dp"
|
||||
android:layout_marginRight="13dp"
|
||||
android:background="@color/white"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
app:cardCornerRadius="5dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btn_cancel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:gravity="center"
|
||||
android:minHeight="@dimen/dialog_msg_min_height"
|
||||
android:onClick="@{click}"
|
||||
android:text="@string/layout_dialog_room_impose_05"
|
||||
android:textSize="16dp"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp" />
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
@@ -16,7 +16,6 @@ import com.flyco.tablayout.SlidingTabLayout;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseMvpActivity;
|
||||
import com.chwl.app.public_chat_hall.adapter.PagerDataAdapter;
|
||||
import com.chwl.app.music.fragment.LocalMusicListFragment;
|
||||
import com.chwl.app.music.fragment.ShareMusicListFragment;
|
||||
import com.chwl.app.music.presenter.MusicListPresenter;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package com.chwl.app.public_chat_hall.adapter;
|
||||
package com.chwl.app.music.activity;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
@@ -1,191 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.activity;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseBindingActivity;
|
||||
import com.chwl.app.databinding.ActivityPublicChatHallSearchFriendsBinding;
|
||||
import com.chwl.app.public_chat_hall.adapter.AitFriendsSearchAdapter;
|
||||
import com.chwl.app.public_chat_hall.bean.PublicChatHallSearchRoomInfo;
|
||||
import com.chwl.app.public_chat_hall.event.PublicChatHallAitFriendSearchCompleteEvent;
|
||||
import com.chwl.app.public_chat_hall.event.PublicChatHallAitFriendSearchFinishEvent;
|
||||
import com.chwl.core.contacts.ContactModel;
|
||||
import com.chwl.core.room.bean.SearchRoomInfo;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.utils.ImeUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ActLayoutRes(R.layout.activity_public_chat_hall_search_friends)
|
||||
public class AitFriendsSearchActivity extends BaseBindingActivity<ActivityPublicChatHallSearchFriendsBinding> {
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private AitFriendsSearchAdapter searchAdapter;
|
||||
private EditText searchEdit;
|
||||
private ImageView ivBack;
|
||||
private TextView tvSearch;
|
||||
private ImageView ivClearText;
|
||||
|
||||
public static void start(Context context) {
|
||||
Intent intent = new Intent(context, AitFriendsSearchActivity.class);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
|
||||
searchEdit = (EditText) findViewById(R.id.search_edit);
|
||||
searchEdit.addTextChangedListener(textWatcher);
|
||||
searchEdit.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
|
||||
searchEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
||||
String str = v.getText().toString();
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
// Toast.makeText(v.getContext(), ResUtil.getString(R.string.public_chat_hall_activity_aitfriendssearchactivity_01), Toast.LENGTH_SHORT).show();
|
||||
SingleToastUtil.showToastShort(ResUtil.getString(R.string.public_chat_hall_activity_aitfriendssearchactivity_02));
|
||||
return true;
|
||||
}
|
||||
ImeUtil.hideIME(AitFriendsSearchActivity.this, tvSearch);
|
||||
searchRooms(str);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
});
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
searchAdapter = new AitFriendsSearchAdapter(this);
|
||||
View headerView = LayoutInflater.from(this).inflate(R.layout.layout_search_header, null, false);
|
||||
searchAdapter.addHeaderView(headerView);
|
||||
recyclerView.setAdapter(searchAdapter);
|
||||
|
||||
ivBack = (ImageView) findViewById(R.id.iv_back);
|
||||
ivBack.setOnClickListener(this);
|
||||
|
||||
tvSearch = (TextView) findViewById(R.id.tv_search);
|
||||
tvSearch.setOnClickListener(this);
|
||||
|
||||
ivClearText = (ImageView) findViewById(R.id.iv_clear_text);
|
||||
ivClearText.setOnClickListener(this);
|
||||
ivClearText.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private TextWatcher textWatcher = 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 (TextUtils.isEmpty(s.toString())) {
|
||||
ivClearText.setVisibility(View.GONE);
|
||||
} else {
|
||||
ivClearText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void update(List<SearchRoomInfo> homeRooms) {
|
||||
if (homeRooms != null && homeRooms.size() > 0) {
|
||||
List<PublicChatHallSearchRoomInfo> searchRoomInfos = new ArrayList<>();
|
||||
for (SearchRoomInfo homeRoom : homeRooms) {
|
||||
PublicChatHallSearchRoomInfo searchRoomInfo = new PublicChatHallSearchRoomInfo();
|
||||
searchRoomInfo.setSearchRoomInfo(homeRoom);
|
||||
searchRoomInfo.setSelected(false);
|
||||
searchRoomInfos.add(searchRoomInfo);
|
||||
}
|
||||
hideStatus();
|
||||
searchAdapter.setNewData(searchRoomInfos);
|
||||
searchAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
searchAdapter.setNewData(null);
|
||||
showNoData();
|
||||
}
|
||||
}
|
||||
|
||||
public void showToast(String msg) {
|
||||
toast(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == ivBack.getId()) {
|
||||
finish();
|
||||
} else if (id == tvSearch.getId()) {
|
||||
String str = searchEdit.getText().toString();
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
// Toast.makeText(this, ResUtil.getString(R.string.public_chat_hall_activity_aitfriendssearchactivity_03), Toast.LENGTH_SHORT).show();
|
||||
SingleToastUtil.showToastShort(ResUtil.getString(R.string.public_chat_hall_activity_aitfriendssearchactivity_04));
|
||||
return;
|
||||
}
|
||||
ImeUtil.hideIME(this, tvSearch);
|
||||
searchRooms(str);
|
||||
|
||||
} else if (id == ivClearText.getId()) {
|
||||
searchEdit.setText("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void searchRooms(String str) {
|
||||
ContactModel.get()
|
||||
.searchContacts(str)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe((homeTabResult, throwable) -> {
|
||||
if (throwable == null) {
|
||||
update(homeTabResult.getData());
|
||||
} else {
|
||||
toast(throwable.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void handleSelected(PublicChatHallAitFriendSearchFinishEvent event) {
|
||||
EventBus.getDefault().post(new PublicChatHallAitFriendSearchCompleteEvent());
|
||||
finish();
|
||||
}
|
||||
}
|
@@ -1,138 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.activity;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.View;
|
||||
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseBindingActivity;
|
||||
import com.chwl.app.databinding.ActivityPublicChatHallAitFriendsBinding;
|
||||
import com.chwl.app.public_chat_hall.adapter.PagerDataAdapter;
|
||||
import com.chwl.app.public_chat_hall.event.AitFriendEvent;
|
||||
import com.chwl.app.public_chat_hall.event.PublicChatHallAitFriendSearchCompleteEvent;
|
||||
import com.chwl.app.public_chat_hall.event.PublicChatHallSelectFriendEvent;
|
||||
import com.chwl.app.public_chat_hall.fragment.PublicChatHallAttentionFragment;
|
||||
import com.chwl.app.public_chat_hall.fragment.PublicChatHallFansListFragment;
|
||||
import com.chwl.app.public_chat_hall.fragment.PublicChatHallFriendListFragment;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ActLayoutRes(R.layout.activity_public_chat_hall_ait_friends)
|
||||
public class PublicChatHallAitFriendsActivity extends BaseBindingActivity<ActivityPublicChatHallAitFriendsBinding> {
|
||||
|
||||
private final String[] titles = {ResUtil.getString(R.string.public_chat_hall_activity_publicchathallaitfriendsactivity_01), ResUtil.getString(R.string.public_chat_hall_activity_publicchathallaitfriendsactivity_02), ResUtil.getString(R.string.public_chat_hall_activity_publicchathallaitfriendsactivity_03)};
|
||||
private List<Fragment> fragments = new ArrayList<>();
|
||||
private PagerDataAdapter adapter = new PagerDataAdapter(getSupportFragmentManager());
|
||||
private List<String> uids = new ArrayList<>();
|
||||
private List<String> userNames = new ArrayList<>();
|
||||
|
||||
public static void start(Context context) {
|
||||
context.startActivity(new Intent(context, PublicChatHallAitFriendsActivity.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
fragments.add(PublicChatHallFriendListFragment.newInstances());
|
||||
fragments.add(PublicChatHallAttentionFragment.newInstance());
|
||||
fragments.add(PublicChatHallFansListFragment.newInstance());
|
||||
adapter.setData(fragments);
|
||||
mBinding.vpAitFriend.setAdapter(adapter);
|
||||
mBinding.stlPublicChatHall.setViewPager(mBinding.vpAitFriend, titles);
|
||||
mBinding.vpAitFriend.setOffscreenPageLimit(2);
|
||||
mBinding.setClick(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needSteepStateBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setStatusBar() {
|
||||
super.setStatusBar();
|
||||
StatusBarUtil.transparencyBar(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentView(int layoutResID) {
|
||||
super.setContentView(layoutResID);
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
public void updateTitle() {
|
||||
if (uids.size() == 0) {
|
||||
initTitleBar(getString(R.string.title_ait_friends));
|
||||
} else {
|
||||
initTitleBar(getString(R.string.title_ait_friends_number, String.valueOf(uids.size())));
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void countingAitFriends(AitFriendEvent event) {
|
||||
switch (event.getType()) {
|
||||
case AitFriendEvent.TYPE_ADD:
|
||||
if (!uids.contains(event.getUid())) {
|
||||
uids.add(event.getUid());
|
||||
userNames.add(event.getNick());
|
||||
}
|
||||
break;
|
||||
|
||||
case AitFriendEvent.TYTPE_REMOVE:
|
||||
if (uids.contains(event.getUid())) {
|
||||
uids.remove(event.getUid());
|
||||
userNames.remove(event.getNick());
|
||||
}
|
||||
break;
|
||||
}
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void handleSearchComplete(PublicChatHallAitFriendSearchCompleteEvent event) {
|
||||
aitFinish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
super.onClick(v);
|
||||
switch (v.getId()) {
|
||||
case R.id.btn_confirm:
|
||||
aitFinish();
|
||||
break;
|
||||
|
||||
case R.id.tv_search_hints:
|
||||
AitFriendsSearchActivity.start(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void aitFinish() {
|
||||
EventBus.getDefault().post(new PublicChatHallSelectFriendEvent()
|
||||
.setUids(uids).setUserNames(userNames));
|
||||
finish();
|
||||
}
|
||||
}
|
@@ -1,150 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.activity;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.View;
|
||||
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseBindingActivity;
|
||||
import com.chwl.app.databinding.ActivityPublicChatHallBinding;
|
||||
import com.chwl.app.headline.HeadLineFragment;
|
||||
import com.chwl.app.public_chat_hall.adapter.PagerDataAdapter;
|
||||
import com.chwl.app.public_chat_hall.fragment.PublicChatHallMessageFragment;
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.zyyoona7.lib.EasyPopup;
|
||||
import com.zyyoona7.lib.HorizontalGravity;
|
||||
import com.zyyoona7.lib.VerticalGravity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ActLayoutRes(R.layout.activity_public_chat_hall)
|
||||
public class PublicChatHallHomeActivity extends BaseBindingActivity<ActivityPublicChatHallBinding> {
|
||||
|
||||
private static final String TAG = "PublicChatHallHomeActiv";
|
||||
|
||||
public static final String KEY_PAGE = "key_page";
|
||||
|
||||
private final String[] titles = {ResUtil.getString(R.string.public_chat_hall_activity_publicchathallhomeactivity_01), ResUtil.getString(R.string.public_chat_hall_activity_publicchathallhomeactivity_02)};
|
||||
private int page = 0;
|
||||
private List<Fragment> fragments = new ArrayList<>();
|
||||
private PagerDataAdapter adapter = new PagerDataAdapter(getSupportFragmentManager());
|
||||
private EasyPopup easyPopup;
|
||||
private PublicChatHallMessageFragment messageFragment;
|
||||
|
||||
public static void openPublicChatHallPage(Context context) {
|
||||
start(context, 0);
|
||||
}
|
||||
|
||||
public static void openHeadlinePage(Context context) {
|
||||
start(context, 1);
|
||||
}
|
||||
|
||||
public static void start(Context context, int page) {
|
||||
Intent intent = new Intent(context, PublicChatHallHomeActivity.class);
|
||||
intent.putExtra(KEY_PAGE, page);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needSteepStateBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setStatusBar() {
|
||||
super.setStatusBar();
|
||||
StatusBarUtil.transparencyBar(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
messageFragment = PublicChatHallMessageFragment.newInstance();
|
||||
fragments.add(messageFragment);
|
||||
fragments.add(HeadLineFragment.newInstance());
|
||||
adapter.setData(fragments);
|
||||
mBinding.vpPublicChatHall.setAdapter(adapter);
|
||||
mBinding.stlPublicChatHall.setViewPager(mBinding.vpPublicChatHall, titles);
|
||||
mBinding.ivBack.setOnClickListener(this);
|
||||
mBinding.ivMore.setOnClickListener(this);
|
||||
initEasyPop();
|
||||
if (getIntent() != null) {
|
||||
page = getIntent().getIntExtra(KEY_PAGE, page);
|
||||
}
|
||||
mBinding.vpPublicChatHall.setCurrentItem(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
if (intent != null) {
|
||||
page = intent.getIntExtra(KEY_PAGE, page);
|
||||
}
|
||||
mBinding.vpPublicChatHall.setCurrentItem(page);
|
||||
}
|
||||
|
||||
private void initEasyPop() {
|
||||
|
||||
easyPopup = new EasyPopup(this)
|
||||
.setContentView(R.layout.menu_public_chat_hall_home)
|
||||
.setFocusAndOutsideEnable(true)
|
||||
.setBackgroundDimEnable(true)
|
||||
.setDimView(mBinding.rlMessageLayout)
|
||||
.setWidth(UIUtil.dip2px(this, 130))
|
||||
.setHeight(UIUtil.dip2px(this, 148))
|
||||
.createPopup();
|
||||
|
||||
easyPopup.getView(R.id.tv_related_to_me).setOnClickListener(this);
|
||||
easyPopup.getView(R.id.tv_face_wall).setOnClickListener(this);
|
||||
easyPopup.getView(R.id.tv_help).setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!messageFragment.onBackPressed()) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
super.onClick(v);
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_back:
|
||||
finish();
|
||||
break;
|
||||
|
||||
case R.id.iv_more:
|
||||
easyPopup.showAtAnchorView(mBinding.ivMore,
|
||||
VerticalGravity.BELOW,
|
||||
HorizontalGravity.ALIGN_RIGHT,
|
||||
UIUtil.dip2px(this, -15),
|
||||
UIUtil.dip2px(this, 15));
|
||||
break;
|
||||
|
||||
case R.id.tv_related_to_me:
|
||||
PublicChatHallRelatedToMeActivity.openPublicChatHallMyMessagePage(this);
|
||||
easyPopup.dismiss();
|
||||
break;
|
||||
|
||||
case R.id.tv_face_wall:
|
||||
CommonWebViewActivity.start(this, UriProvider.getReportWallUrl());
|
||||
easyPopup.dismiss();
|
||||
break;
|
||||
|
||||
case R.id.tv_help:
|
||||
CommonWebViewActivity.start(this, UriProvider.getPublicChatHallHelpUrl());
|
||||
easyPopup.dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,82 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.activity;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.View;
|
||||
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseBindingActivity;
|
||||
import com.chwl.app.databinding.ActivityPublicChatHallRelatedToMeBinding;
|
||||
import com.chwl.app.headline.MyHeadLineFragment;
|
||||
import com.chwl.app.public_chat_hall.adapter.PagerDataAdapter;
|
||||
import com.chwl.app.public_chat_hall.fragment.PublicChatHallMessageFragment;
|
||||
import com.chwl.app.public_chat_hall.fragment.PublicChatHallMyMessageFragment;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ActLayoutRes(R.layout.activity_public_chat_hall_related_to_me)
|
||||
public class PublicChatHallRelatedToMeActivity extends BaseBindingActivity<ActivityPublicChatHallRelatedToMeBinding> {
|
||||
|
||||
private static final String TAG = "PCHRelatedToMeAct";
|
||||
|
||||
public static final String KEY_PAGE = "key_page";
|
||||
|
||||
private final String[] titles = {ResUtil.getString(R.string.public_chat_hall_activity_publicchathallrelatedtomeactivity_01), ResUtil.getString(R.string.public_chat_hall_activity_publicchathallrelatedtomeactivity_02)};
|
||||
private int page = 0;
|
||||
private List<Fragment> fragments = new ArrayList<>();
|
||||
private PagerDataAdapter adapter = new PagerDataAdapter(getSupportFragmentManager());
|
||||
private PublicChatHallMessageFragment messageFragment;
|
||||
|
||||
public static void openPublicChatHallMyMessagePage(Context context) {
|
||||
start(context, 0);
|
||||
}
|
||||
|
||||
public static void openMyHeadlinePage(Context context) {
|
||||
start(context, 1);
|
||||
}
|
||||
|
||||
public static void start(Context context, int page) {
|
||||
Intent intent = new Intent(context, PublicChatHallRelatedToMeActivity.class);
|
||||
intent.putExtra(KEY_PAGE, page);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needSteepStateBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setStatusBar() {
|
||||
super.setStatusBar();
|
||||
StatusBarUtil.transparencyBar(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
fragments.add(PublicChatHallMyMessageFragment.newInstance());
|
||||
fragments.add(MyHeadLineFragment.newInstance());
|
||||
adapter.setData(fragments);
|
||||
mBinding.vpPublicChatHall.setAdapter(adapter);
|
||||
mBinding.stlPublicChatHall.setViewPager(mBinding.vpPublicChatHall, titles);
|
||||
mBinding.ivBack.setOnClickListener(this);
|
||||
mBinding.vpPublicChatHall.setCurrentItem(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
super.onClick(v);
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_back:
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,100 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.bean.PublicChatHallSearchRoomInfo;
|
||||
import com.chwl.app.public_chat_hall.event.AitFriendEvent;
|
||||
import com.chwl.app.public_chat_hall.event.PublicChatHallAitFriendSearchFinishEvent;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.widget.NobleAvatarView;
|
||||
import com.chwl.core.noble.NobleUtil;
|
||||
import com.chwl.core.room.bean.SearchRoomInfo;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
|
||||
public class AitFriendsSearchAdapter extends BaseQuickAdapter<PublicChatHallSearchRoomInfo, BaseViewHolder> {
|
||||
|
||||
private Context context;
|
||||
private int type;
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public AitFriendsSearchAdapter(Context context) {
|
||||
super(R.layout.item_public_chat_hall_friend_list);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, PublicChatHallSearchRoomInfo pchSearchRoomInfo) {
|
||||
if (pchSearchRoomInfo == null) return;
|
||||
final SearchRoomInfo item = pchSearchRoomInfo.getSearchRoomInfo();
|
||||
if (item == null) return;
|
||||
|
||||
CheckBox cbFriend = helper.getView(R.id.cb_friend);
|
||||
|
||||
helper.setText(R.id.tv_userName, item.getNick())
|
||||
.setVisible(R.id.view_line, helper.getLayoutPosition() != getItemCount() - 1);
|
||||
|
||||
NobleAvatarView nobleAvatarView = helper.getView(R.id.noble_avatar_view);
|
||||
nobleAvatarView.setSize(47, 70, 13);
|
||||
nobleAvatarView.setData(item.getAvatar(), item.getNobleUsers());
|
||||
|
||||
|
||||
AppCompatImageView ivGender = helper.getView(R.id.iv_gender);
|
||||
ivGender.setVisibility(View.GONE);
|
||||
|
||||
AppCompatImageView ivNobleLevel = helper.getView(R.id.iv_noble_level);
|
||||
if (item.getNobleUsers() != null) {
|
||||
ivNobleLevel.setVisibility(View.VISIBLE);
|
||||
String badgeByLevel = NobleUtil.getBadgeByLevel(item.getNobleUsers().getLevel());
|
||||
if (!TextUtils.isEmpty(badgeByLevel)) {
|
||||
NobleUtil.loadResource(badgeByLevel, ivNobleLevel);
|
||||
} else {
|
||||
ivNobleLevel.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
ivNobleLevel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
AppCompatImageView ivUserLevel = helper.getView(R.id.iv_user_level);
|
||||
ivUserLevel.setVisibility(View.GONE);
|
||||
if (item.getUserLevelVo() != null && !TextUtils.isEmpty(item.getUserLevelVo().getExperUrl())) {
|
||||
ivUserLevel.setVisibility(View.VISIBLE);
|
||||
ImageLoadUtils.loadImage(mContext, item.getUserLevelVo().getExperUrl(), ivUserLevel);
|
||||
}
|
||||
|
||||
AppCompatImageView ivCharmLevel = helper.getView(R.id.iv_charm_level);
|
||||
ivCharmLevel.setVisibility(View.GONE);
|
||||
if (item.getUserLevelVo() != null && !TextUtils.isEmpty(item.getUserLevelVo().getCharmUrl())) {
|
||||
ivCharmLevel.setVisibility(View.VISIBLE);
|
||||
ImageLoadUtils.loadImage(mContext, item.getUserLevelVo().getCharmUrl(), ivCharmLevel);
|
||||
}
|
||||
|
||||
cbFriend.setChecked(pchSearchRoomInfo.isSelected());
|
||||
cbFriend.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
pchSearchRoomInfo.setSelected(isChecked);
|
||||
EventBus.getDefault().post(new AitFriendEvent()
|
||||
.setType(isChecked ? AitFriendEvent.TYPE_ADD : AitFriendEvent.TYTPE_REMOVE)
|
||||
.setUid(String.valueOf(item.getUid()))
|
||||
.setNick(item.getNick()));
|
||||
EventBus.getDefault().post(new PublicChatHallAitFriendSearchFinishEvent());
|
||||
});
|
||||
helper.getView(R.id.container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
cbFriend.setChecked(!cbFriend.isChecked());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -1,86 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.adapter;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.bean.PublicChatHallAttentionInfo;
|
||||
import com.chwl.app.public_chat_hall.event.AitFriendEvent;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.widget.NobleAvatarView;
|
||||
import com.chwl.core.noble.NobleUtil;
|
||||
import com.chwl.core.user.bean.AttentionInfo;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PublicChatHallAttentionListAdapter extends BaseQuickAdapter<PublicChatHallAttentionInfo, BaseViewHolder> {
|
||||
|
||||
public PublicChatHallAttentionListAdapter(List<PublicChatHallAttentionInfo> attentionInfoList) {
|
||||
super(R.layout.item_public_chat_hall_attention_list, attentionInfoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder baseViewHolder, final PublicChatHallAttentionInfo pchAttentionInfo) {
|
||||
if (pchAttentionInfo == null) return;
|
||||
AttentionInfo attentionInfo = pchAttentionInfo.getAttentionInfo();
|
||||
if (attentionInfo == null) return;
|
||||
baseViewHolder.setText(R.id.tv_userName, attentionInfo.getNick())
|
||||
.setText(R.id.tv_user_desc, attentionInfo.getUserDesc() != null ?
|
||||
attentionInfo.getUserDesc()
|
||||
: baseViewHolder.itemView.getContext().getResources().getString(R.string.msg_no_user_desc))
|
||||
.setVisible(R.id.view_line, baseViewHolder.getLayoutPosition() != getItemCount() - 1)
|
||||
.setChecked(R.id.cb_attention, pchAttentionInfo.isSelected())
|
||||
.addOnClickListener(R.id.container)
|
||||
.setOnCheckedChangeListener(R.id.cb_attention, (buttonView, isChecked) -> {
|
||||
pchAttentionInfo.setSelected(isChecked);
|
||||
EventBus.getDefault().post(new AitFriendEvent()
|
||||
.setType(isChecked ? AitFriendEvent.TYPE_ADD : AitFriendEvent.TYTPE_REMOVE)
|
||||
.setUid(String.valueOf(attentionInfo.getUid()))
|
||||
.setNick(attentionInfo.getNick()));
|
||||
});
|
||||
|
||||
AppCompatImageView ivGender = baseViewHolder.getView(R.id.iv_gender);
|
||||
if (attentionInfo.getGender() == 1) {
|
||||
ivGender.setImageResource(R.drawable.ic_gender_male);
|
||||
} else {
|
||||
ivGender.setImageResource(R.drawable.ic_gender_female);
|
||||
}
|
||||
|
||||
AppCompatImageView ivNobleLevel = baseViewHolder.getView(R.id.iv_noble_level);
|
||||
if (attentionInfo.nobleUsers != null) {
|
||||
ivNobleLevel.setVisibility(View.VISIBLE);
|
||||
String badgeByLevel = NobleUtil.getBadgeByLevel(attentionInfo.nobleUsers.getLevel());
|
||||
if (!TextUtils.isEmpty(badgeByLevel)) {
|
||||
NobleUtil.loadResource(badgeByLevel, ivNobleLevel);
|
||||
} else {
|
||||
ivNobleLevel.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
ivNobleLevel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
NobleAvatarView nobleAvatarView = baseViewHolder.getView(R.id.noble_avatar_view);
|
||||
nobleAvatarView.setSize(50, 75, 15);
|
||||
nobleAvatarView.setData(attentionInfo.avatar, attentionInfo.nobleUsers);
|
||||
|
||||
AppCompatImageView ivUserLevel = baseViewHolder.getView(R.id.iv_user_level);
|
||||
ivUserLevel.setVisibility(View.GONE);
|
||||
if (attentionInfo.userLevelVo != null && !TextUtils.isEmpty(attentionInfo.userLevelVo.getExperUrl())) {
|
||||
ivUserLevel.setVisibility(View.VISIBLE);
|
||||
ImageLoadUtils.loadImage(mContext, attentionInfo.userLevelVo.getExperUrl(), ivUserLevel);
|
||||
}
|
||||
|
||||
AppCompatImageView ivCharmLevel = baseViewHolder.getView(R.id.iv_charm_level);
|
||||
ivCharmLevel.setVisibility(View.GONE);
|
||||
if (attentionInfo.userLevelVo != null && !TextUtils.isEmpty(attentionInfo.userLevelVo.getCharmUrl())) {
|
||||
ivCharmLevel.setVisibility(View.VISIBLE);
|
||||
ImageLoadUtils.loadImage(mContext, attentionInfo.userLevelVo.getCharmUrl(), ivCharmLevel);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,77 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.adapter;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.bean.PublicChatHallFansInfo;
|
||||
import com.chwl.app.public_chat_hall.event.AitFriendEvent;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.widget.NobleAvatarView;
|
||||
import com.chwl.core.noble.NobleUtil;
|
||||
import com.chwl.core.user.bean.FansInfo;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PublicChatHallFansViewAdapter extends BaseQuickAdapter<PublicChatHallFansInfo, BaseViewHolder> {
|
||||
|
||||
public PublicChatHallFansViewAdapter(List<PublicChatHallFansInfo> fansInfoList) {
|
||||
super(R.layout.item_public_chat_hall_fans_list, fansInfoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder baseViewHolder, final PublicChatHallFansInfo pchFansInfo) {
|
||||
if (pchFansInfo == null) return;
|
||||
FansInfo fansInfo = pchFansInfo.getFansInfo();
|
||||
if (fansInfo == null) return;
|
||||
baseViewHolder.setText(R.id.tv_userName, fansInfo.getNick())
|
||||
.setText(R.id.tv_user_desc, fansInfo.getUserDesc() != null ?
|
||||
fansInfo.getUserDesc()
|
||||
: baseViewHolder.itemView.getContext().getResources().getString(R.string.msg_no_user_desc))
|
||||
.setVisible(R.id.view_line, baseViewHolder.getLayoutPosition() != getItemCount() - 1)
|
||||
.setChecked(R.id.cb_fans, pchFansInfo.isSelected())
|
||||
.addOnClickListener(R.id.container)
|
||||
.setOnCheckedChangeListener(R.id.cb_fans, (buttonView, isChecked) -> {
|
||||
Log.e(TAG, "convert: check in fans adapter");
|
||||
pchFansInfo.setSelected(isChecked);
|
||||
EventBus.getDefault().post(new AitFriendEvent()
|
||||
.setType(isChecked ? AitFriendEvent.TYPE_ADD : AitFriendEvent.TYTPE_REMOVE)
|
||||
.setUid(String.valueOf(fansInfo.getUid()))
|
||||
.setNick(fansInfo.getNick()));
|
||||
});
|
||||
|
||||
NobleAvatarView nobleAvatarView = baseViewHolder.getView(R.id.noble_avatar_view);
|
||||
nobleAvatarView.setSize(50, 75, 15);
|
||||
nobleAvatarView.setData(fansInfo.getAvatar(), fansInfo.getNobleUsers());
|
||||
|
||||
AppCompatImageView ivBadge = baseViewHolder.getView(R.id.iv_noble_level);
|
||||
ivBadge.setVisibility(View.GONE);
|
||||
if (fansInfo.getNobleUsers() != null) {
|
||||
String badgeByLevel = NobleUtil.getBadgeByLevel(fansInfo.getNobleUsers().getLevel());
|
||||
if (!TextUtils.isEmpty(badgeByLevel)) {
|
||||
ivBadge.setVisibility(View.VISIBLE);
|
||||
NobleUtil.loadResource(badgeByLevel, ivBadge);
|
||||
}
|
||||
}
|
||||
|
||||
AppCompatImageView ivUserLevel = baseViewHolder.getView(R.id.iv_user_level);
|
||||
ivUserLevel.setVisibility(View.GONE);
|
||||
if (fansInfo.getUserLevelVo() != null && !TextUtils.isEmpty(fansInfo.getUserLevelVo().getExperUrl())) {
|
||||
ivUserLevel.setVisibility(View.VISIBLE);
|
||||
ImageLoadUtils.loadImage(mContext, fansInfo.getUserLevelVo().getExperUrl(), ivUserLevel);
|
||||
}
|
||||
|
||||
AppCompatImageView ivCharmLevel = baseViewHolder.getView(R.id.iv_charm_level);
|
||||
ivCharmLevel.setVisibility(View.GONE);
|
||||
if (fansInfo.getUserLevelVo() != null && !TextUtils.isEmpty(fansInfo.getUserLevelVo().getCharmUrl())) {
|
||||
ivCharmLevel.setVisibility(View.VISIBLE);
|
||||
ImageLoadUtils.loadImage(mContext, fansInfo.getUserLevelVo().getCharmUrl(), ivCharmLevel);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.bean.PublicChatHallFriendInfo;
|
||||
import com.chwl.app.public_chat_hall.event.AitFriendEvent;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.widget.NobleAvatarView;
|
||||
import com.chwl.core.noble.NobleUtil;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
public class PublicChatHallFriendListAdapter extends BaseQuickAdapter<PublicChatHallFriendInfo, BaseViewHolder> {
|
||||
|
||||
private Activity context;
|
||||
|
||||
public PublicChatHallFriendListAdapter(Activity context) {
|
||||
super(R.layout.item_public_chat_hall_friend_list);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private OnItemClickListener onItemClickListener;
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void sendListener(UserInfo attentionInfo);
|
||||
}
|
||||
|
||||
public void setRylListener(OnItemClickListener onClickListener) {
|
||||
onItemClickListener = onClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, PublicChatHallFriendInfo pchFriendInfo) {
|
||||
if (pchFriendInfo == null) return;
|
||||
final UserInfo item = pchFriendInfo.getUserInfo();
|
||||
|
||||
CheckBox cbFriend = helper.getView(R.id.cb_friend);
|
||||
|
||||
helper.setText(R.id.tv_userName, item.getNick())
|
||||
.setText(R.id.tv_user_desc, item.getUserDesc() != null ?
|
||||
item.getUserDesc()
|
||||
: helper.itemView.getContext().getResources().getString(R.string.msg_no_user_desc))
|
||||
.setVisible(R.id.view_line, helper.getLayoutPosition() != getItemCount() - 1)
|
||||
;
|
||||
|
||||
NobleAvatarView nobleAvatarView = helper.getView(R.id.noble_avatar_view);
|
||||
nobleAvatarView.setSize(47, 70, 13);
|
||||
nobleAvatarView.setData(item.getAvatar(), item.getNobleUsers());
|
||||
|
||||
|
||||
AppCompatImageView ivGender = helper.getView(R.id.iv_gender);
|
||||
if (item.getGender() == 1) {
|
||||
ivGender.setImageResource(R.drawable.ic_gender_male);
|
||||
} else {
|
||||
ivGender.setImageResource(R.drawable.ic_gender_female);
|
||||
}
|
||||
|
||||
AppCompatImageView ivNobleLevel = helper.getView(R.id.iv_noble_level);
|
||||
if (item.getNobleUsers() != null) {
|
||||
ivNobleLevel.setVisibility(View.VISIBLE);
|
||||
String badgeByLevel = NobleUtil.getBadgeByLevel(item.getNobleUsers().getLevel());
|
||||
if (!TextUtils.isEmpty(badgeByLevel)) {
|
||||
NobleUtil.loadResource(badgeByLevel, ivNobleLevel);
|
||||
} else {
|
||||
ivNobleLevel.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
ivNobleLevel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
AppCompatImageView ivUserLevel = helper.getView(R.id.iv_user_level);
|
||||
ivUserLevel.setVisibility(View.GONE);
|
||||
if (item.getUserLevelVo() != null && !TextUtils.isEmpty(item.getUserLevelVo().getExperUrl())) {
|
||||
ivUserLevel.setVisibility(View.VISIBLE);
|
||||
ImageLoadUtils.loadImage(mContext, item.getUserLevelVo().getExperUrl(), ivUserLevel);
|
||||
}
|
||||
|
||||
AppCompatImageView ivCharmLevel = helper.getView(R.id.iv_charm_level);
|
||||
ivCharmLevel.setVisibility(View.GONE);
|
||||
if (item.getUserLevelVo() != null && !TextUtils.isEmpty(item.getUserLevelVo().getCharmUrl())) {
|
||||
ivCharmLevel.setVisibility(View.VISIBLE);
|
||||
ImageLoadUtils.loadImage(mContext, item.getUserLevelVo().getCharmUrl(), ivCharmLevel);
|
||||
}
|
||||
|
||||
cbFriend.setChecked(pchFriendInfo.isSelected());
|
||||
cbFriend.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
pchFriendInfo.setSelected(isChecked);
|
||||
EventBus.getDefault().post(new AitFriendEvent()
|
||||
.setType(isChecked ? AitFriendEvent.TYPE_ADD : AitFriendEvent.TYTPE_REMOVE)
|
||||
.setUid(String.valueOf(item.getUid()))
|
||||
.setNick(item.getNick()));
|
||||
});
|
||||
helper.getView(R.id.container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
cbFriend.setChecked(!cbFriend.isChecked());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,339 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.adapter;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
import com.netease.nim.uikit.business.session.module.Container;
|
||||
import com.netease.nim.uikit.common.util.sys.TimeUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMultiItemFetchLoadAdapter;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMsgViewHolder;
|
||||
import com.chwl.app.public_chat_hall.msg.viewholder.ChatRoomMsgViewHolderBase;
|
||||
import com.chwl.app.public_chat_hall.msg.viewholder.ChatRoomMsgViewHolderFactory;
|
||||
import com.chwl.core.public_chat_hall.bean.PublicChatHallMessage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by huangjun on 2016/12/21.
|
||||
*/
|
||||
public class PublicChatHallMsgAdapter extends BaseMultiItemFetchLoadAdapter<ChatRoomMessage, BaseMsgViewHolder> {
|
||||
|
||||
private Map<Class<? extends ChatRoomMsgViewHolderBase>, Integer> holder2ViewType;
|
||||
|
||||
private PublicChatHallMsgAdapter.ViewHolderEventListener eventListener;
|
||||
private Map<String, Float> progresses; // 有文件传输,需要显示进度条的消息ID map
|
||||
private String messageId;
|
||||
private Container container;
|
||||
private Map<String, PublicChatHallMessage> publicChatHallMessageList = new HashMap<>();
|
||||
|
||||
public PublicChatHallMsgAdapter(RecyclerView recyclerView, List<ChatRoomMessage> data, Container container) {
|
||||
super(recyclerView, data);
|
||||
|
||||
timedItems = new HashSet<>();
|
||||
progresses = new HashMap<>();
|
||||
|
||||
// view type, view holder
|
||||
holder2ViewType = new HashMap<>();
|
||||
List<Class<? extends ChatRoomMsgViewHolderBase>> holders = ChatRoomMsgViewHolderFactory.getAllViewHolders();
|
||||
int viewType = 0;
|
||||
for (Class<? extends ChatRoomMsgViewHolderBase> holder : holders) {
|
||||
viewType++;
|
||||
addItemType(viewType, R.layout.item_message_public_chat_hall, holder);
|
||||
holder2ViewType.put(holder, viewType);
|
||||
}
|
||||
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getViewType(ChatRoomMessage message) {
|
||||
return holder2ViewType.get(ChatRoomMsgViewHolderFactory.getViewHolderByType(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getItemKey(ChatRoomMessage item) {
|
||||
return item.getUuid();
|
||||
}
|
||||
|
||||
public void setEventListener(PublicChatHallMsgAdapter.ViewHolderEventListener eventListener) {
|
||||
this.eventListener = eventListener;
|
||||
}
|
||||
|
||||
public PublicChatHallMsgAdapter.ViewHolderEventListener getEventListener() {
|
||||
return eventListener;
|
||||
}
|
||||
|
||||
public void deleteItem(IMMessage message, boolean isRelocateTime) {
|
||||
if (message == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (IMMessage item : getData()) {
|
||||
if (item.isTheSame(message)) {
|
||||
break;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
|
||||
if (index < getDataSize()) {
|
||||
remove(index);
|
||||
if (isRelocateTime) {
|
||||
relocateShowTimeItemAfterDelete(message, index);
|
||||
}
|
||||
notifyDataSetChanged(); // 可以不要!!!
|
||||
}
|
||||
}
|
||||
|
||||
public float getProgress(IMMessage message) {
|
||||
Float progress = progresses.get(message.getUuid());
|
||||
return progress == null ? 0 : progress;
|
||||
}
|
||||
|
||||
public void putProgress(IMMessage message, float progress) {
|
||||
progresses.put(message.getUuid(), progress);
|
||||
}
|
||||
|
||||
/**
|
||||
* *********************** 时间显示处理 ***********************
|
||||
*/
|
||||
|
||||
private Set<String> timedItems; // 需要显示消息时间的消息ID
|
||||
private IMMessage lastShowTimeItem; // 用于消息时间显示,判断和上条消息间的时间间隔
|
||||
|
||||
public boolean needShowTime(IMMessage message) {
|
||||
// publicChatHallMessageList 没有内容认为是聊天界面的消息需要判断是不是需要显示时间
|
||||
if (publicChatHallMessageList.size() <= 0) {
|
||||
return timedItems.contains(message.getUuid());
|
||||
} else {
|
||||
PublicChatHallMessage publicChatHallMessage = publicChatHallMessageList.get(message.getUuid());
|
||||
if (publicChatHallMessage != null) {
|
||||
return timedItems.contains(publicChatHallMessage.getMsgidClient());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getMessageTime(IMMessage message) {
|
||||
// publicChatHallMessageList 没有内容认为是聊天界面的消息
|
||||
// 从 IMMessage 里取时间
|
||||
String defaultResult = TimeUtil.getTimeShowString(message.getTime(), false);
|
||||
if (publicChatHallMessageList.size() <= 0) {
|
||||
return defaultResult;
|
||||
} else {
|
||||
PublicChatHallMessage publicChatHallMessage = publicChatHallMessageList.get(message.getUuid());
|
||||
if (publicChatHallMessage != null) {
|
||||
return TimeUtil.getTimeShowString(publicChatHallMessage.getMsgTimestamp(), false);
|
||||
} else {
|
||||
return defaultResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表加入新消息时,更新时间显示
|
||||
*/
|
||||
public void updateShowTimeItem(List<ChatRoomMessage> items, boolean fromStart, boolean update) {
|
||||
IMMessage anchor = fromStart ? null : lastShowTimeItem;
|
||||
for (IMMessage message : items) {
|
||||
if (setShowTimeFlag(message, anchor)) {
|
||||
anchor = message;
|
||||
}
|
||||
}
|
||||
|
||||
if (update) {
|
||||
lastShowTimeItem = anchor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否显示时间item
|
||||
*/
|
||||
private boolean setShowTimeFlag(IMMessage message, IMMessage anchor) {
|
||||
boolean update = false;
|
||||
|
||||
if (hideTimeAlways(message)) {
|
||||
setShowTime(message, false);
|
||||
} else {
|
||||
if (anchor == null) {
|
||||
setShowTime(message, true);
|
||||
update = true;
|
||||
} else {
|
||||
long time = anchor.getTime();
|
||||
long now = message.getTime();
|
||||
|
||||
if (now - time == 0) {
|
||||
// 消息撤回时使用
|
||||
setShowTime(message, true);
|
||||
lastShowTimeItem = message;
|
||||
update = true;
|
||||
} else if (now - time < (long) (5 * 60 * 1000)) {
|
||||
setShowTime(message, false);
|
||||
} else {
|
||||
setShowTime(message, true);
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return update;
|
||||
}
|
||||
|
||||
private void setShowTime(IMMessage message, boolean show) {
|
||||
if (show) {
|
||||
timedItems.add(message.getUuid());
|
||||
} else {
|
||||
timedItems.remove(message.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
/////////////// for PublicChatHallMessage ////////////////
|
||||
private PublicChatHallMessage lastShowTimeMsg;
|
||||
|
||||
/**
|
||||
* 列表加入新消息时,更新时间显示
|
||||
*/
|
||||
public void updateShowTimeMsg(List<PublicChatHallMessage> items, boolean fromStart, boolean update) {
|
||||
PublicChatHallMessage anchor = fromStart ? null : lastShowTimeMsg;
|
||||
for (PublicChatHallMessage message : items) {
|
||||
if (setShowTimeFlag(message, anchor)) {
|
||||
anchor = message;
|
||||
}
|
||||
}
|
||||
|
||||
if (update) {
|
||||
lastShowTimeMsg = anchor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否显示时间item
|
||||
*/
|
||||
private boolean setShowTimeFlag(PublicChatHallMessage message, PublicChatHallMessage anchor) {
|
||||
boolean update = false;
|
||||
|
||||
if (hideTimeAlways(message)) {
|
||||
setShowTime(message, false);
|
||||
} else {
|
||||
if (anchor == null) {
|
||||
setShowTime(message, true);
|
||||
update = true;
|
||||
} else {
|
||||
long time = anchor.getMsgTimestamp();
|
||||
long now = message.getMsgTimestamp();
|
||||
|
||||
if (now - time == 0) {
|
||||
// 消息撤回时使用
|
||||
setShowTime(message, true);
|
||||
lastShowTimeMsg = message;
|
||||
update = true;
|
||||
} else if (now - time < (long) (5 * 60 * 1000)) {
|
||||
setShowTime(message, false);
|
||||
} else {
|
||||
setShowTime(message, true);
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return update;
|
||||
}
|
||||
|
||||
private void setShowTime(PublicChatHallMessage message, boolean show) {
|
||||
if (show) {
|
||||
timedItems.add(message.getMsgidClient());
|
||||
} else {
|
||||
timedItems.remove(message.getMsgidClient());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hideTimeAlways(PublicChatHallMessage message) {
|
||||
return false;
|
||||
}
|
||||
/////////////// for PublicChatHallMessage ////////////////
|
||||
|
||||
private void relocateShowTimeItemAfterDelete(IMMessage messageItem, int index) {
|
||||
// 如果被删的项显示了时间,需要继承
|
||||
if (needShowTime(messageItem)) {
|
||||
setShowTime(messageItem, false);
|
||||
if (getDataSize() > 0) {
|
||||
IMMessage nextItem;
|
||||
if (index == getDataSize()) {
|
||||
//删除的是最后一项
|
||||
nextItem = getItem(index - 1);
|
||||
} else {
|
||||
//删除的不是最后一项
|
||||
nextItem = getItem(index);
|
||||
}
|
||||
|
||||
// 增加其他不需要显示时间的消息类型判断
|
||||
if (hideTimeAlways(nextItem)) {
|
||||
setShowTime(nextItem, false);
|
||||
if (lastShowTimeItem != null && lastShowTimeItem != null
|
||||
&& lastShowTimeItem.isTheSame(messageItem)) {
|
||||
lastShowTimeItem = null;
|
||||
for (int i = getDataSize() - 1; i >= 0; i--) {
|
||||
IMMessage item = getItem(i);
|
||||
if (needShowTime(item)) {
|
||||
lastShowTimeItem = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setShowTime(nextItem, true);
|
||||
if (lastShowTimeItem == null
|
||||
|| (lastShowTimeItem != null && lastShowTimeItem.isTheSame(messageItem))) {
|
||||
lastShowTimeItem = nextItem;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lastShowTimeItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hideTimeAlways(IMMessage message) {
|
||||
switch (message.getMsgType()) {
|
||||
case notification:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, PublicChatHallMessage> getPublicChatHallMessageList() {
|
||||
return publicChatHallMessageList;
|
||||
}
|
||||
|
||||
public interface ViewHolderEventListener {
|
||||
// 长按事件响应处理
|
||||
boolean onViewHolderLongClick(View clickView, View viewHolderView, IMMessage item);
|
||||
|
||||
// 发送失败或者多媒体文件下载失败指示按钮点击响应处理
|
||||
void onFailedBtnClick(IMMessage resendMessage);
|
||||
|
||||
// viewholder footer按钮点击,如机器人继续会话
|
||||
void onFooterClick(ChatRoomMsgViewHolderBase holderBase, IMMessage message);
|
||||
}
|
||||
|
||||
public void setUuid(String messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public Container getContainer() {
|
||||
return container;
|
||||
}
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.bean;
|
||||
|
||||
import com.chwl.core.user.bean.AttentionInfo;
|
||||
|
||||
public class PublicChatHallAttentionInfo {
|
||||
|
||||
private AttentionInfo attentionInfo;
|
||||
private boolean isSelected;
|
||||
|
||||
public AttentionInfo getAttentionInfo() {
|
||||
return attentionInfo;
|
||||
}
|
||||
|
||||
public void setAttentionInfo(AttentionInfo attentionInfo) {
|
||||
this.attentionInfo = attentionInfo;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return isSelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
isSelected = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PublicChatHallAttentionInfo{" +
|
||||
"attentionInfo=" + attentionInfo +
|
||||
", isSelected=" + isSelected +
|
||||
'}';
|
||||
}
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.bean;
|
||||
|
||||
import com.chwl.core.user.bean.FansInfo;
|
||||
|
||||
public class PublicChatHallFansInfo {
|
||||
|
||||
private FansInfo fansInfo;
|
||||
private boolean isSelected;
|
||||
|
||||
public FansInfo getFansInfo() {
|
||||
return fansInfo;
|
||||
}
|
||||
|
||||
public void setFansInfo(FansInfo fansInfo) {
|
||||
this.fansInfo = fansInfo;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return isSelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
isSelected = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PublicChatHallFansInfo{" +
|
||||
"fansInfo=" + fansInfo +
|
||||
", isSelected=" + isSelected +
|
||||
'}';
|
||||
}
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.bean;
|
||||
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
|
||||
public class PublicChatHallFriendInfo {
|
||||
|
||||
private UserInfo userInfo;
|
||||
private boolean isSelected;
|
||||
|
||||
public boolean isSelected() {
|
||||
return isSelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
isSelected = selected;
|
||||
}
|
||||
|
||||
public UserInfo getUserInfo() {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setUserInfo(UserInfo userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PublicChatHallFriendInfo{" +
|
||||
"userInfo=" + userInfo +
|
||||
", isSelected=" + isSelected +
|
||||
'}';
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.chwl.core.room.bean.SearchRoomInfo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PublicChatHallSearchRoomInfo implements Parcelable {
|
||||
|
||||
private SearchRoomInfo searchRoomInfo;
|
||||
|
||||
private boolean isSelected;
|
||||
|
||||
public PublicChatHallSearchRoomInfo() {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeParcelable(this.searchRoomInfo, flags);
|
||||
dest.writeByte(this.isSelected ? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
protected PublicChatHallSearchRoomInfo(Parcel in) {
|
||||
this.searchRoomInfo = in.readParcelable(SearchRoomInfo.class.getClassLoader());
|
||||
this.isSelected = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<PublicChatHallSearchRoomInfo> CREATOR = new Parcelable.Creator<PublicChatHallSearchRoomInfo>() {
|
||||
@Override
|
||||
public PublicChatHallSearchRoomInfo createFromParcel(Parcel source) {
|
||||
return new PublicChatHallSearchRoomInfo(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicChatHallSearchRoomInfo[] newArray(int size) {
|
||||
return new PublicChatHallSearchRoomInfo[size];
|
||||
}
|
||||
};
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.event;
|
||||
|
||||
public class AitFriendEvent {
|
||||
|
||||
public static final String TYPE_ADD = "0";
|
||||
public static final String TYTPE_REMOVE = "1";
|
||||
|
||||
private String type;
|
||||
private String uid;
|
||||
private String nick;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public AitFriendEvent setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public AitFriendEvent setUid(String uid) {
|
||||
this.uid = uid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNick() {
|
||||
return nick;
|
||||
}
|
||||
|
||||
public AitFriendEvent setNick(String nick) {
|
||||
this.nick = nick;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AitFriendEvent{" +
|
||||
"type='" + type + '\'' +
|
||||
", uid='" + uid + '\'' +
|
||||
", nick='" + nick + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@@ -1,4 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.event;
|
||||
|
||||
public class PublicChatHallAitFriendSearchCompleteEvent {
|
||||
}
|
@@ -1,4 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.event;
|
||||
|
||||
public class PublicChatHallAitFriendSearchFinishEvent {
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.event;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PublicChatHallAvatarClickEvent {
|
||||
|
||||
private Context context;
|
||||
private IMMessage message;
|
||||
|
||||
public PublicChatHallAvatarClickEvent setContext(Context context) {
|
||||
this.context = context;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PublicChatHallAvatarClickEvent setMessage(IMMessage message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PublicChatHallSelectFriendEvent {
|
||||
|
||||
private List<String> uids;
|
||||
private List<String> userNames;
|
||||
|
||||
public List<String> getUids() {
|
||||
return uids;
|
||||
}
|
||||
|
||||
public PublicChatHallSelectFriendEvent setUids(List<String> uids) {
|
||||
this.uids = uids;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getUserNames() {
|
||||
return userNames;
|
||||
}
|
||||
|
||||
public PublicChatHallSelectFriendEvent setUserNames(List<String> userNames) {
|
||||
this.userNames = userNames;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PublicChatHallSelectFriendEvent{" +
|
||||
"uids=" + uids +
|
||||
", userNames=" + userNames +
|
||||
'}';
|
||||
}
|
||||
}
|
@@ -1,167 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseFragment;
|
||||
import com.chwl.app.public_chat_hall.adapter.PublicChatHallAttentionListAdapter;
|
||||
import com.chwl.app.public_chat_hall.bean.PublicChatHallAttentionInfo;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.user.AttentionModel;
|
||||
import com.chwl.core.user.bean.AttentionInfo;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* 公聊大厅选择艾特人的关注页面
|
||||
*/
|
||||
public class PublicChatHallAttentionFragment extends BaseFragment {
|
||||
public static final String TAG = "PCHAttentionFragment";
|
||||
|
||||
private RecyclerView mRecylcerView;
|
||||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
private PublicChatHallAttentionListAdapter adapter;
|
||||
private List<PublicChatHallAttentionInfo> mAttentionInfoList = new ArrayList<>();
|
||||
private int mPage = Constants.PAGE_START;
|
||||
|
||||
public static PublicChatHallAttentionFragment newInstance() {
|
||||
return new PublicChatHallAttentionFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindViews() {
|
||||
mRecylcerView = (RecyclerView) mView.findViewById(R.id.recycler_view);
|
||||
swipeRefreshLayout = (SwipeRefreshLayout) mView.findViewById(R.id.swipe_refresh);
|
||||
mRecylcerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
swipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
if (adapter == null) {
|
||||
adapter = new PublicChatHallAttentionListAdapter(mAttentionInfoList);
|
||||
showLoading();
|
||||
onRefreshing();
|
||||
}
|
||||
adapter.setOnItemChildClickListener((adapter1, view, position) -> {
|
||||
Log.e(TAG, "onSetListener: on item click in attention fragment---container");
|
||||
CheckBox checkBox = view.findViewById(R.id.cb_attention);
|
||||
checkBox.setChecked(!checkBox.isChecked());
|
||||
});
|
||||
adapter.setOnLoadMoreListener(() -> {
|
||||
mPage++;
|
||||
onRefreshing();
|
||||
}, mRecylcerView);
|
||||
|
||||
mRecylcerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRootLayoutId() {
|
||||
return R.layout.fragment_public_chat_hall_attention;
|
||||
}
|
||||
|
||||
|
||||
public void firstLoadData() {
|
||||
mPage = Constants.PAGE_START;
|
||||
onRefreshing();
|
||||
}
|
||||
|
||||
private void onRefreshing() {
|
||||
AttentionModel.get().getAttentionList(
|
||||
AuthModel.get().getCurrentUid(),
|
||||
mPage,
|
||||
Constants.PAGE_SIZE
|
||||
)
|
||||
.subscribe(new SingleObserver<List<AttentionInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
mCompositeDisposable.add(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<AttentionInfo> attentionInfos) {
|
||||
onGetAttentionList(attentionInfos, mPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
onGetAttentionListFail(e.getMessage(), mPage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onGetAttentionList(List<AttentionInfo> attentionInfoList, int page) {
|
||||
mPage = page;
|
||||
if (!ListUtils.isListEmpty(attentionInfoList)) {
|
||||
List<PublicChatHallAttentionInfo> publicChatHallAttentionInfos = new ArrayList<>();
|
||||
for (AttentionInfo attentionInfo : attentionInfoList) {
|
||||
PublicChatHallAttentionInfo pchAttentionInfo = new PublicChatHallAttentionInfo();
|
||||
pchAttentionInfo.setAttentionInfo(attentionInfo);
|
||||
publicChatHallAttentionInfos.add(pchAttentionInfo);
|
||||
}
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
hideStatus();
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
mAttentionInfoList.clear();
|
||||
adapter.setNewData(publicChatHallAttentionInfos);
|
||||
if (attentionInfoList.size() < Constants.PAGE_SIZE) {
|
||||
adapter.setEnableLoadMore(false);
|
||||
}
|
||||
} else {
|
||||
adapter.loadMoreComplete();
|
||||
adapter.addData(publicChatHallAttentionInfos);
|
||||
}
|
||||
} else {
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
showNoData(getString(R.string.no_attention_text));
|
||||
} else {
|
||||
adapter.loadMoreEnd(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void onGetAttentionListFail(String error, int page) {
|
||||
mPage = page;
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
showNetworkErr();
|
||||
} else {
|
||||
adapter.loadMoreFail();
|
||||
toast(error);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadData() {
|
||||
super.onReloadData();
|
||||
mPage = Constants.PAGE_START;
|
||||
showLoading();
|
||||
onRefreshing();
|
||||
}
|
||||
}
|
@@ -1,166 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseFragment;
|
||||
import com.chwl.app.public_chat_hall.adapter.PublicChatHallFansViewAdapter;
|
||||
import com.chwl.app.public_chat_hall.bean.PublicChatHallFansInfo;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.user.AttentionModel;
|
||||
import com.chwl.core.user.bean.FansInfo;
|
||||
import com.chwl.core.user.bean.FansListInfo;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* 公聊大厅选择艾特人的粉丝页面
|
||||
*/
|
||||
public class PublicChatHallFansListFragment extends BaseFragment {
|
||||
|
||||
private static final String TAG = "PCHFansListFragment";
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
private PublicChatHallFansViewAdapter adapter;
|
||||
private int mCurrentCounter = Constants.PAGE_START;
|
||||
private List<PublicChatHallFansInfo> mFansInfoList = new ArrayList<>();
|
||||
private Context mContext;
|
||||
|
||||
public static PublicChatHallFansListFragment newInstance() {
|
||||
return new PublicChatHallFansListFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mContext = getContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindViews() {
|
||||
mRecyclerView = (RecyclerView) mView.findViewById(R.id.recycler_view);
|
||||
mSwipeRefreshLayout = (SwipeRefreshLayout) mView.findViewById(R.id.swipe_refresh);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
mSwipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
|
||||
private void onRefreshing() {
|
||||
AttentionModel.get().getFansList(
|
||||
AuthModel.get().getCurrentUid(),
|
||||
mCurrentCounter,
|
||||
Constants.PAGE_SIZE
|
||||
).subscribe(new SingleObserver<FansListInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
mCompositeDisposable.add(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(FansListInfo fansListInfo) {
|
||||
onGetMyFansList(fansListInfo, mCurrentCounter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
onGetMyFansListFail(e.getMessage(), mCurrentCounter);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
if (adapter == null) {
|
||||
adapter = new PublicChatHallFansViewAdapter(mFansInfoList);
|
||||
showLoading();
|
||||
onRefreshing();
|
||||
}
|
||||
adapter.setOnItemChildClickListener((adapter1, view, position) -> {
|
||||
Log.e(TAG, "onSetListener: on item click in fans fragment---container");
|
||||
CheckBox checkBox = view.findViewById(R.id.cb_fans);
|
||||
checkBox.setChecked(!checkBox.isChecked());
|
||||
});
|
||||
adapter.setOnLoadMoreListener(() -> {
|
||||
mCurrentCounter ++;
|
||||
onRefreshing();
|
||||
}, mRecyclerView);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRootLayoutId() {
|
||||
return R.layout.fragment_fans_list;
|
||||
}
|
||||
|
||||
public void onGetMyFansList(FansListInfo fansListInfo, int page) {
|
||||
mCurrentCounter = page;
|
||||
List<FansInfo> fansList = fansListInfo.getFansList();
|
||||
if (!ListUtils.isListEmpty(fansList)) {
|
||||
List<PublicChatHallFansInfo> publicChatHallFansInfos = new ArrayList<>();
|
||||
for (FansInfo fansInfo : fansListInfo.getFansList()) {
|
||||
PublicChatHallFansInfo publicChatHallFansInfo = new PublicChatHallFansInfo();
|
||||
publicChatHallFansInfo.setFansInfo(fansInfo);
|
||||
publicChatHallFansInfos.add(publicChatHallFansInfo);
|
||||
}
|
||||
if (mCurrentCounter == Constants.PAGE_START) {
|
||||
hideStatus();
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
mFansInfoList.clear();
|
||||
// mFansInfoList.addAll(publicChatHallFansInfos);
|
||||
adapter.setNewData(publicChatHallFansInfos);
|
||||
if (publicChatHallFansInfos.size() < Constants.PAGE_SIZE) {
|
||||
adapter.setEnableLoadMore(false);
|
||||
}
|
||||
adapter.loadMoreComplete();
|
||||
} else {
|
||||
adapter.loadMoreComplete();
|
||||
adapter.addData(publicChatHallFansInfos);
|
||||
}
|
||||
} else {
|
||||
if (mCurrentCounter == Constants.PAGE_START) {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
showNoData(getString(R.string.no_fan_text));
|
||||
} else {
|
||||
adapter.loadMoreEnd(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onGetMyFansListFail(String error, int page) {
|
||||
mCurrentCounter = page;
|
||||
if (mCurrentCounter == Constants.PAGE_START) {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
showNetworkErr();
|
||||
} else {
|
||||
adapter.loadMoreFail();
|
||||
toast(error);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadData() {
|
||||
super.onReloadData();
|
||||
mCurrentCounter = Constants.PAGE_START;
|
||||
showLoading();
|
||||
onRefreshing();
|
||||
}
|
||||
}
|
@@ -1,153 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseFragment;
|
||||
import com.chwl.app.public_chat_hall.adapter.PublicChatHallFriendListAdapter;
|
||||
import com.chwl.app.public_chat_hall.bean.PublicChatHallFriendInfo;
|
||||
import com.chwl.core.im.friend.IMFriendModel;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.manager.RelationShipEvent;
|
||||
import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.user.event.LoginUserInfoUpdateEvent;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* 公聊大厅选择艾特人的好友页面
|
||||
*/
|
||||
public class
|
||||
PublicChatHallFriendListFragment extends BaseFragment {
|
||||
|
||||
private static final String TAG = "PCHFriendListFragment";
|
||||
|
||||
private PublicChatHallFriendListAdapter adapter = null;
|
||||
private SwipeRefreshLayout mSwipeRefresh;
|
||||
private RecyclerView mRecyclerView;
|
||||
|
||||
public static PublicChatHallFriendListFragment newInstances() {
|
||||
return new PublicChatHallFriendListFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindViews() {
|
||||
mSwipeRefresh = mView.findViewById(R.id.swipe_refresh);
|
||||
mRecyclerView = mView.findViewById(R.id.recycler_view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
mSwipeRefresh.setEnabled(false);
|
||||
|
||||
if (adapter == null) {
|
||||
adapter = new PublicChatHallFriendListAdapter(getActivity());
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
|
||||
loadFriends();
|
||||
} else {
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
Disposable d = IMNetEaseManager.get().getRelationShipEventObservable().subscribe(this::onGetRelationShipEvent);
|
||||
mCompositeDisposable.add(d);
|
||||
}
|
||||
|
||||
private void onGetRelationShipEvent(RelationShipEvent event) {
|
||||
if (event.event == RelationShipEvent.EVENT_FRIEND_UPDATE) {
|
||||
onFriendListUpdate(event.accounts);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFriends() {
|
||||
onFriendListUpdate(IMFriendModel.get().getMyFriendsAccounts());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRootLayoutId() {
|
||||
return R.layout.fragment_fans_list;
|
||||
}
|
||||
|
||||
private void onFriendListUpdate(List<String> accounts) {
|
||||
if (ListUtils.isListEmpty(accounts)) {
|
||||
showNoData(getString(R.string.no_frenids_text));
|
||||
return;
|
||||
}
|
||||
ArrayList<Long> ids = new ArrayList<>(accounts.size());
|
||||
for (String account : accounts){
|
||||
ids.add(Long.valueOf(account));
|
||||
}
|
||||
UserModel.get().loadUserInfoByUids(accounts).subscribe(new SingleObserver<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
mCompositeDisposable.add(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<UserInfo> userInfos) {
|
||||
List<PublicChatHallFriendInfo> publicChatHallFriendInfoList = new ArrayList<>();
|
||||
for (UserInfo userInfo : userInfos) {
|
||||
PublicChatHallFriendInfo friendInfo = new PublicChatHallFriendInfo();
|
||||
friendInfo.setUserInfo(userInfo);
|
||||
publicChatHallFriendInfoList.add(friendInfo);
|
||||
}
|
||||
setData(publicChatHallFriendInfoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
toast(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setData(List<PublicChatHallFriendInfo> userInfos) {
|
||||
if (userInfos != null && !userInfos.isEmpty()) {
|
||||
hideStatus();
|
||||
adapter.setNewData(userInfos);
|
||||
adapter.notifyDataSetChanged();
|
||||
} else {
|
||||
showNoData(getString(R.string.no_frenids_text));
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLoginUserInfoUpdateEvent(LoginUserInfoUpdateEvent event) {
|
||||
mRecyclerView.postDelayed(()->onFriendListUpdate(IMFriendModel.get().getMyFriendsAccounts())
|
||||
, 250);
|
||||
}
|
||||
|
||||
}
|
@@ -1,556 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.api.model.chatroom.ChatRoomSessionCustomization;
|
||||
import com.netease.nim.uikit.business.ait.AitManager;
|
||||
import com.netease.nim.uikit.business.ait.event.AitContactAddEvent;
|
||||
import com.netease.nim.uikit.business.ait.event.AitContactDeleteEvent;
|
||||
import com.netease.nim.uikit.business.chatroom.helper.ChatRoomHelper;
|
||||
import com.netease.nim.uikit.business.session.actions.BaseAction;
|
||||
import com.netease.nim.uikit.business.session.helper.MessageListPanelHelper;
|
||||
import com.netease.nim.uikit.business.session.module.Container;
|
||||
import com.netease.nim.uikit.business.session.module.ModuleProxy;
|
||||
import com.netease.nim.uikit.common.antispam.AntiSpamEvent;
|
||||
import com.netease.nim.uikit.common.fragment.TFragment;
|
||||
import com.netease.nim.uikit.impl.NimUIKitImpl;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.NIMSDK;
|
||||
import com.netease.nimlib.sdk.RequestCallbackWrapper;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.msg.MessageBuilder;
|
||||
import com.netease.nimlib.sdk.msg.MsgService;
|
||||
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.CustomMessageConfig;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.netease.nimlib.sdk.robot.model.NimRobotInfo;
|
||||
import com.netease.nimlib.sdk.robot.model.RobotAttachment;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.ButtonItemFactory;
|
||||
import com.chwl.app.avroom.widget.ViewItem;
|
||||
import com.chwl.app.public_chat_hall.event.PublicChatHallAvatarClickEvent;
|
||||
import com.chwl.app.public_chat_hall.event.PublicChatHallSelectFriendEvent;
|
||||
import com.chwl.app.public_chat_hall.module.PublicChatHallInputPanel;
|
||||
import com.chwl.app.public_chat_hall.module.PublicChatHallMessageListPanel;
|
||||
import com.chwl.app.public_chat_hall.utils.RemainCountManager;
|
||||
import com.chwl.app.public_chat_hall.widget.PublicChatHallGiftAnimationDialog;
|
||||
import com.chwl.app.ui.gift.callback.OnGiftDialogBtnClickListenerWrapper;
|
||||
import com.chwl.app.ui.widget.GiftDialog;
|
||||
import com.chwl.app.ui.widget.UserInfoDialog;
|
||||
import com.chwl.app.ui.widget.dialog.OpenNobleDialog;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.gift.GiftModel;
|
||||
import com.chwl.core.gift.bean.GiftInfo;
|
||||
import com.chwl.core.gift.bean.GiftReceiveInfo;
|
||||
import com.chwl.core.gift.toolbox.GiftToolbox;
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.chwl.core.im.custom.bean.ImTipAttachment;
|
||||
import com.chwl.core.im.custom.bean.RouterType;
|
||||
import com.chwl.core.initial.InitialModel;
|
||||
import com.chwl.core.public_chat_hall.attachment.AitFriendsAttachment;
|
||||
import com.chwl.core.public_chat_hall.attachment.AitMeAttachment;
|
||||
import com.chwl.core.public_chat_hall.bean.AitFriendsInfo;
|
||||
import com.chwl.core.public_chat_hall.bean.AitMeInfo;
|
||||
import com.chwl.core.public_chat_hall.event.PublicChatHallMsgCountingDownEvent;
|
||||
import com.chwl.core.public_chat_hall.event.PublicChatHallMsgIncomingEvent;
|
||||
import com.chwl.core.public_chat_hall.event.PublicChatHallPlayGiftAnimationEvent;
|
||||
import com.chwl.core.public_chat_hall.manager.PublicChatHallDataManager;
|
||||
import com.chwl.core.public_chat_hall.model.PublicChatHallModel;
|
||||
import com.chwl.core.room.queue.bean.MicMemberInfo;
|
||||
import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.user.event.LoginUserInfoUpdateEvent;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
|
||||
/**
|
||||
* 聊天室直播互动fragment
|
||||
*/
|
||||
public class PublicChatHallMessageFragment extends TFragment implements ModuleProxy {
|
||||
|
||||
private String roomId;
|
||||
protected View rootView;
|
||||
private static ChatRoomSessionCustomization customization;
|
||||
|
||||
// modules
|
||||
protected PublicChatHallInputPanel inputPanel;
|
||||
protected PublicChatHallMessageListPanel messageListPanel;
|
||||
protected AitManager aitManager;
|
||||
|
||||
private CompositeDisposable compositeDisposable;
|
||||
private List<String> uids = new ArrayList();
|
||||
private List<String> names = new ArrayList<>();
|
||||
private Map<String, String> aitContractsMap = new Hashtable<>();
|
||||
|
||||
private volatile LinkedList<PublicChatHallPlayGiftAnimationEvent> giftList = new LinkedList<>();
|
||||
private PublicChatHallGiftAnimationDialog giftAnimationDialog;
|
||||
private Disposable disposable;
|
||||
|
||||
public static PublicChatHallMessageFragment newInstance() {
|
||||
PublicChatHallMessageFragment messageFragment = new PublicChatHallMessageFragment();
|
||||
return messageFragment;
|
||||
}
|
||||
|
||||
public static void setChatRoomSessionCustomization(ChatRoomSessionCustomization roomSessionCustomization) {
|
||||
customization = roomSessionCustomization;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHiddenChanged(boolean hidden) {
|
||||
super.onHiddenChanged(hidden);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
rootView = inflater.inflate(R.layout.fragment_public_chat_hall_message, container, false);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
compositeDisposable = new CompositeDisposable();
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
// 刷新礼物列表,获取房间专属礼物列表
|
||||
GiftModel.get().refreshGiftList(InitialModel.get().getPublicChatHallUid()).subscribe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
init(String.valueOf(PublicChatHallDataManager.get().getPublicChatHallId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (inputPanel != null) {
|
||||
inputPanel.onPause();
|
||||
}
|
||||
if (messageListPanel != null) {
|
||||
messageListPanel.onPause();
|
||||
}
|
||||
NIMSDK.getMsgService()
|
||||
.setChattingAccount(MsgService.MSG_CHATTING_ACCOUNT_NONE, SessionTypeEnum.None);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (messageListPanel != null) {
|
||||
messageListPanel.onResume();
|
||||
}
|
||||
NIMSDK.getMsgService()
|
||||
.setChattingAccount(
|
||||
String.valueOf(PublicChatHallDataManager.get().getPublicChatHallId()),
|
||||
SessionTypeEnum.ChatRoom);
|
||||
}
|
||||
|
||||
public boolean onBackPressed() {
|
||||
if (inputPanel != null && inputPanel.collapse(true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (messageListPanel != null && messageListPanel.onBackPressed()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
|
||||
if (messageListPanel != null) {
|
||||
messageListPanel.onDestroy();
|
||||
}
|
||||
if (aitManager != null) {
|
||||
aitManager.reset();
|
||||
}
|
||||
|
||||
if (compositeDisposable != null && !compositeDisposable.isDisposed()) {
|
||||
compositeDisposable.dispose();
|
||||
}
|
||||
// 清除礼物动画队列
|
||||
giftList.clear();
|
||||
|
||||
if (giftAnimationDialog != null && giftAnimationDialog.isShowing()) {
|
||||
giftAnimationDialog.dismiss();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
if (inputPanel != null)
|
||||
inputPanel.hideInputMethod();
|
||||
super.onDestroyView();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (aitManager != null) {
|
||||
aitManager.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
inputPanel.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onAntiSpamEvent(AntiSpamEvent event) {
|
||||
// Toast.makeText(getContext(), ResUtil.getString(R.string.public_chat_hall_fragment_publicchathallmessagefragment_02), Toast.LENGTH_SHORT).show();
|
||||
SingleToastUtil.showToastShort(ResUtil.getString(R.string.public_chat_hall_fragment_publicchathallmessagefragment_03));
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLoginUserInfoUpdateEvent(LoginUserInfoUpdateEvent event) {
|
||||
inputPanel.updateInputPanel();
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void handleAitFriends(PublicChatHallSelectFriendEvent event) {
|
||||
for (int i = 0; i < event.getUids().size(); i++) {
|
||||
String uid = event.getUids().get(i);
|
||||
String nick = event.getUserNames().get(i);
|
||||
if (!inputPanel.isTextLimited(nick) && !uids.contains(uid)) {
|
||||
uids.add(uid);
|
||||
names.add(nick);
|
||||
aitManager.insertAitMember(uid, nick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void handleAitAddCotact(AitContactAddEvent event) {
|
||||
String account = event.getAccount();
|
||||
if (account != null) {
|
||||
int pos = uids.indexOf(account);
|
||||
if (pos != -1) {
|
||||
aitContractsMap.put(account, names.get(pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void handleAitDeleteCotact(AitContactDeleteEvent event) {
|
||||
String account = event.getAccount();
|
||||
aitContractsMap.remove(account);
|
||||
if (account != null) {
|
||||
int pos = uids.indexOf(account);
|
||||
if (pos != -1) {
|
||||
uids.remove(pos);
|
||||
names.remove(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void handleSendMessageButton(PublicChatHallMsgCountingDownEvent event) {
|
||||
inputPanel.updateSendMessageButton();
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void handleAvatarClick(PublicChatHallAvatarClickEvent event) {
|
||||
PublicChatHallModel.get().getOwnerInfo()
|
||||
.subscribe((s, throwable) -> {
|
||||
List<ViewItem> list = ButtonItemFactory.createPublicChatHallButtonItems(
|
||||
event.getContext(), Long.valueOf(event.getMessage().getFromAccount()), false,
|
||||
new OnGiftDialogBtnClickListenerWrapper() {
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
public void onSendGiftBtnClick(GiftInfo giftInfo, ArrayList<MicMemberInfo> micMemberInfos, int number, String msg, boolean isKnap, boolean isWholeMic, List<List<Integer>> drawFixedArray, GiftDialog.SenGiftCallback callback) {
|
||||
if (giftInfo == null) return;
|
||||
boolean canUseNobleGiftOrNot = GiftModel.get().canUseNobleGiftOrNot(giftInfo);
|
||||
if (canUseNobleGiftOrNot) {
|
||||
GiftModel.get().sendPersonalGiftInPublicChatHall(giftInfo.getGiftId(),
|
||||
micMemberInfos.get(0).getAccount(), number, msg, isKnap)
|
||||
.doOnError(throwable -> {
|
||||
if (callback != null) {
|
||||
callback.onFail();
|
||||
}
|
||||
})
|
||||
.flatMap(giftReceiveInfoServiceResult -> {
|
||||
if (callback != null) {
|
||||
callback.onSuccess();
|
||||
}
|
||||
return GiftToolbox.sendGiftPublicChatHallMessage(giftReceiveInfoServiceResult.getData());
|
||||
})
|
||||
.subscribe((chatRoomMessage, throwable) -> {
|
||||
if (throwable == null) {
|
||||
// 手动更新送礼物的消息
|
||||
MessageListPanelHelper.getInstance().notifyAddMessage(chatRoomMessage);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
|
||||
int currentLevel = userInfo == null ? 0 : userInfo.getNobleInfo() == null ? 0 : userInfo.getNobleInfo().getLevel();
|
||||
new OpenNobleDialog(getActivity(), currentLevel, giftInfo.getLevel(), ResUtil.getString(R.string.public_chat_hall_fragment_publicchathallmessagefragment_04)).show();
|
||||
callback.onFail();
|
||||
}
|
||||
}
|
||||
});
|
||||
GiftDialog.GIFT_DIALOG_FROM = ResUtil.getString(R.string.public_chat_hall_fragment_publicchathallmessagefragment_05);
|
||||
UserInfoDialog.showNewUserInfoDialog(event.getContext(), Long.valueOf(event.getMessage().getFromAccount()));
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void handleGiftAnimation(PublicChatHallPlayGiftAnimationEvent event) {
|
||||
giftList.add(event);
|
||||
if (giftAnimationDialog != null && giftAnimationDialog.isShowing()) {
|
||||
// 如果正在展示,先不理
|
||||
GiftReceiveInfo giftReceiveInfo = giftList.peekFirst().getGiftReceiveInfo();
|
||||
if (giftReceiveInfo != null) {
|
||||
return;
|
||||
} else {
|
||||
if (getActivity() != null && !getActivity().isFinishing() && !isDestroyed()) {
|
||||
giftAnimationDialog.dismiss();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 如果当前没有在展示,则取出队列里的第一条进行展示
|
||||
showGiftDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void showGiftDialog() {
|
||||
if (giftList.size() == 0) return;
|
||||
giftAnimationDialog = new PublicChatHallGiftAnimationDialog(getContext(), giftList.peekFirst().getGiftReceiveInfo());
|
||||
giftAnimationDialog.setOnDismissListener(dialog -> {
|
||||
giftList.pollFirst();
|
||||
PublicChatHallPlayGiftAnimationEvent event = giftList.peekFirst();
|
||||
if (event != null) {
|
||||
GiftReceiveInfo giftReceiveInfo = event.getGiftReceiveInfo();
|
||||
if (giftReceiveInfo != null) {
|
||||
if (getActivity() != null && !getActivity().isFinishing() && !isDestroyed()) {
|
||||
showGiftDialog();
|
||||
} else {
|
||||
giftList.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
giftAnimationDialog.show();
|
||||
}
|
||||
|
||||
public void onLeave() {
|
||||
if (inputPanel != null) {
|
||||
inputPanel.collapse(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void init(String roomId) {
|
||||
this.roomId = roomId;
|
||||
findViews();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送提示信息
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void sendTipMessage(String msg) {
|
||||
ImTipAttachment attachment = new ImTipAttachment(CustomAttachment.CUSTOM_MSG_IM_TIP, CustomAttachment.CUSTOM_MSG_IM_TIP_RESULT);
|
||||
attachment.setMsg(msg);
|
||||
ChatRoomMessage imMessage = ChatRoomMessageBuilder.createChatRoomCustomMessage(
|
||||
PublicChatHallDataManager.get().getPublicChatHallId() + "", attachment);
|
||||
PublicChatHallModel.get().sendChatRoomMessage(imMessage, true)
|
||||
.subscribe((chatRoomMessage, throwable) -> {
|
||||
if (throwable != null) {
|
||||
throwable.printStackTrace();
|
||||
} else {
|
||||
messageListPanel.onMsgSend(imMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void findViews() {
|
||||
Container container = new Container(getActivity(), roomId, SessionTypeEnum.ChatRoom, this);
|
||||
if (messageListPanel == null) {
|
||||
messageListPanel = new PublicChatHallMessageListPanel(container, rootView);
|
||||
} else {
|
||||
messageListPanel.reload(container);
|
||||
}
|
||||
|
||||
if (inputPanel == null) {
|
||||
inputPanel = new PublicChatHallInputPanel(container, rootView, getActionList(), false);
|
||||
} else {
|
||||
inputPanel.reload(container, null);
|
||||
}
|
||||
|
||||
if (NimUIKitImpl.getOptions().aitEnable && NimUIKitImpl.getOptions().aitChatRoomRobot) {
|
||||
if (aitManager == null) {
|
||||
aitManager = new AitManager(getContext(), null, true);
|
||||
}
|
||||
inputPanel.addAitTextWatcher(aitManager);
|
||||
aitManager.setTextChangeListener(inputPanel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onIncomingMsg(PublicChatHallMsgIncomingEvent event) {
|
||||
List<ChatRoomMessage> messages = new ArrayList<>();
|
||||
ChatRoomMessage chatRoomMessage = event.getChatRoomMessage();
|
||||
messages.add(chatRoomMessage);
|
||||
messageListPanel.onIncomingMessage(messages);
|
||||
}
|
||||
|
||||
/************************** Module proxy ***************************/
|
||||
|
||||
@Override
|
||||
public boolean sendMessage(IMMessage msg) {
|
||||
// UserInfo currentUserInfo = UserModel.get().getCacheLoginUserInfo();
|
||||
// if (currentUserInfo != null && !currentUserInfo.isBindPhone()) {
|
||||
// DialogManager dialogManager = new DialogManager(getActivity());
|
||||
// String tips = getString(R.string.tips_need_to_bind_phone);
|
||||
// SpannableStringBuilder builder = new SpannableStringBuilder(tips);
|
||||
// builder.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.appColor)),
|
||||
// tips.length() - 5, tips.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
// dialogManager.showTipsDialog(builder, getString(R.string.label_go_to_bind_phone), new DialogManager.AbsOkDialogListener() {
|
||||
// @Override
|
||||
// public void onOk() {
|
||||
// BindPhoneActivity.start(getContext());
|
||||
// }
|
||||
// });
|
||||
// return false;
|
||||
// }
|
||||
ChatRoomMessage message = (ChatRoomMessage) msg;
|
||||
|
||||
if (aitContractsMap.size() > 0) {
|
||||
AitFriendsAttachment attachment = new AitFriendsAttachment();
|
||||
attachment.setFirst(CustomAttachment.CUSTOM_MSG_PUBLIC_CHAT_HALL);
|
||||
attachment.setSecond(CustomAttachment.CUSTOM_MSG_SUB_PUBLIC_CHAT_HALL_AIT);
|
||||
message = ChatRoomMessageBuilder.createChatRoomCustomMessage(roomId, attachment);
|
||||
AitFriendsInfo aitFriendsInfo = new AitFriendsInfo();
|
||||
aitFriendsInfo.setRoomId(roomId);
|
||||
aitFriendsInfo.setAtUids(uids);
|
||||
aitFriendsInfo.setAtNames(names);
|
||||
aitFriendsInfo.setContent(msg.getContent());
|
||||
aitFriendsInfo.setMessageId(message.getUuid());
|
||||
attachment.setAitFriendsInfo(aitFriendsInfo);
|
||||
}
|
||||
|
||||
ChatRoomHelper.buildMemberTypeInRemoteExt(message, roomId);
|
||||
|
||||
compositeDisposable.add(
|
||||
PublicChatHallModel.get()
|
||||
.sendChatRoomMessage(message, false)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe((chatRoomMessage, throwable) -> {
|
||||
if (throwable != null) {
|
||||
String throwableMessage = throwable.getMessage();
|
||||
if (throwable.getMessage().contains("13004")) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.public_chat_hall_fragment_publicchathallmessagefragment_07) + PublicChatHallDataManager.get().mOwnerMember.getTempMuteDuration() / 60 + ResUtil.getString(R.string.public_chat_hall_fragment_publicchathallmessagefragment_08));
|
||||
} else {
|
||||
// Toast.makeText(NimUIKit.getContext(), throwableMessage, Toast.LENGTH_SHORT).show();
|
||||
SingleToastUtil.showToastShort(throwableMessage);
|
||||
}
|
||||
} else {
|
||||
if (aitContractsMap.size() > 0) {
|
||||
//统计用户@了1次
|
||||
RemainCountManager.plusHasRemainCount();
|
||||
for (String uid : uids) {
|
||||
AitMeAttachment aitMeAttachment = new AitMeAttachment();
|
||||
AitMeInfo aitMeInfo = new AitMeInfo();
|
||||
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
|
||||
aitMeInfo.setAtUid(String.valueOf(AuthModel.get().getCurrentUid()));
|
||||
aitMeInfo.setAtName(userInfo != null ? userInfo.getNick() : "");
|
||||
aitMeInfo.setRoomId(String.valueOf(PublicChatHallDataManager.get().getPublicChatHallId()));
|
||||
aitMeInfo.setContent(ResUtil.getString(R.string.public_chat_hall_fragment_publicchathallmessagefragment_09));
|
||||
aitMeInfo.setRouterType(RouterType.PUBLIC_CHAT_HALL);
|
||||
aitMeAttachment.setAitMeInfo(aitMeInfo);
|
||||
CustomMessageConfig config = new CustomMessageConfig();
|
||||
IMMessage imMessage = MessageBuilder.createCustomMessage(uid,
|
||||
SessionTypeEnum.P2P, "", aitMeAttachment, config);
|
||||
aitMeInfo.setMessageId(imMessage.getUuid());
|
||||
NIMClient.getService(MsgService.class)
|
||||
.sendMessage(imMessage, false)
|
||||
.setCallback(new RequestCallbackWrapper<Void>() {
|
||||
@Override
|
||||
public void onResult(int code, Void result, Throwable exception) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
uids.clear();
|
||||
names.clear();
|
||||
aitContractsMap.clear();
|
||||
}
|
||||
})
|
||||
);
|
||||
messageListPanel.onMsgSend(message);
|
||||
if (aitManager != null) {
|
||||
aitManager.reset();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputPanelExpand() {
|
||||
messageListPanel.scrollToBottom();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shouldCollapseInputPanel() {
|
||||
inputPanel.collapse(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemFooterClick(IMMessage message) {
|
||||
if (aitManager != null) {
|
||||
RobotAttachment attachment = (RobotAttachment) message.getAttachment();
|
||||
NimRobotInfo robot = NimUIKit.getRobotInfoProvider().getRobotByAccount(attachment.getFromRobotAccount());
|
||||
aitManager.insertAitRobot(robot.getAccount(), robot.getName(), inputPanel.getEditSelectionStart());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLongClickEnabled() {
|
||||
return !inputPanel.isRecording();
|
||||
}
|
||||
|
||||
// 操作面板集合
|
||||
protected List<BaseAction> getActionList() {
|
||||
List<BaseAction> actions = new ArrayList<>();
|
||||
if (customization != null) {
|
||||
actions.addAll(customization.actions);
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,250 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.netease.nim.uikit.business.session.module.Container;
|
||||
import com.netease.nim.uikit.common.util.sys.NetworkUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseMvpFragment;
|
||||
import com.chwl.app.public_chat_hall.adapter.PublicChatHallMsgAdapter;
|
||||
import com.chwl.app.public_chat_hall.presenter.PublicChatHallMyMessagePresenter;
|
||||
import com.chwl.app.public_chat_hall.view.IPublicChatHallMyMessageView;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.chwl.core.im.custom.bean.GiftAttachment;
|
||||
import com.chwl.core.im.custom.bean.ImTipAttachment;
|
||||
import com.chwl.core.public_chat_hall.attachment.AitFriendsAttachment;
|
||||
import com.chwl.core.public_chat_hall.bean.PublicChatHallMessage;
|
||||
import com.chwl.core.public_chat_hall.manager.PublicChatHallDataManager;
|
||||
import com.chwl.library.base.factory.CreatePresenter;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@CreatePresenter(PublicChatHallMyMessagePresenter.class)
|
||||
public class PublicChatHallMyHistoryMessageFragment extends
|
||||
BaseMvpFragment<IPublicChatHallMyMessageView, PublicChatHallMyMessagePresenter>
|
||||
implements IPublicChatHallMyMessageView {
|
||||
|
||||
public static final String KEY_MY_MESSAGE_TYPE = "key_my_message_type";
|
||||
public static final int KEY_AIT_ME = 0;
|
||||
public static final int KEY_SENT = 1;
|
||||
|
||||
private int type = 0;
|
||||
private volatile int page = Constants.PAGE_START;
|
||||
|
||||
// message list view
|
||||
private RecyclerView messageListView;
|
||||
private LinkedList<ChatRoomMessage> items;
|
||||
private PublicChatHallMsgAdapter adapter;
|
||||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
|
||||
public static PublicChatHallMyHistoryMessageFragment getAitMeInstance() {
|
||||
return newInstance(KEY_AIT_ME);
|
||||
}
|
||||
|
||||
public static PublicChatHallMyHistoryMessageFragment getSentMessageInstance() {
|
||||
return newInstance(KEY_SENT);
|
||||
}
|
||||
|
||||
public static PublicChatHallMyHistoryMessageFragment newInstance(int type) {
|
||||
PublicChatHallMyHistoryMessageFragment fragment = new PublicChatHallMyHistoryMessageFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(KEY_MY_MESSAGE_TYPE, type);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view != null) {
|
||||
messageListView = view.findViewById(R.id.recycler_view);
|
||||
swipeRefreshLayout = view.findViewById(R.id.swipe_refresh);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitArguments(Bundle bundle) {
|
||||
super.onInitArguments(bundle);
|
||||
if (bundle != null) {
|
||||
type = bundle.getInt(KEY_MY_MESSAGE_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRootLayoutId() {
|
||||
return R.layout.fragment_public_chat_hall_message_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindViews() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
Container container = new Container(getActivity(),
|
||||
String.valueOf(PublicChatHallDataManager.get().getPublicChatHallId()),
|
||||
SessionTypeEnum.ChatRoom, null);
|
||||
|
||||
messageListView.setLayoutManager(new LinearLayoutManager(container.activity));
|
||||
|
||||
// adapter
|
||||
items = new LinkedList<>();
|
||||
adapter = new PublicChatHallMsgAdapter(messageListView, items, container);
|
||||
messageListView.setAdapter(adapter);
|
||||
adapter.setEnableLoadMore(false);
|
||||
swipeRefreshLayout.setOnRefreshListener(() -> {
|
||||
if (NetworkUtil.getNetworkConnectionStatus(getContext())) {
|
||||
page++;
|
||||
getMvpPresenter().loadMessageList(type, page);
|
||||
} else {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
swipeRefreshLayout.setRefreshing(true);
|
||||
if (NetworkUtil.getNetworkConnectionStatus(getContext())) {
|
||||
getMvpPresenter().loadMessageList(type, page);
|
||||
} else {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
showNetworkErr();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetMessageListSuccess(List<PublicChatHallMessage> messageList, int page) {
|
||||
if (!ListUtils.isListEmpty(messageList)) {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
Collections.reverse(messageList);
|
||||
List<ChatRoomMessage> list = new ArrayList<>();
|
||||
for (PublicChatHallMessage publicChatHallMessage : messageList) {
|
||||
ChatRoomMessage chatRoomMessage = getChatRoomMessage(publicChatHallMessage);
|
||||
list.add(chatRoomMessage);
|
||||
adapter.getPublicChatHallMessageList().put(chatRoomMessage.getUuid(), publicChatHallMessage);
|
||||
}
|
||||
|
||||
adapter.updateShowTimeMsg(messageList, true, true);
|
||||
if (page == Constants.PAGE_START) {
|
||||
hideStatus();
|
||||
adapter.setNewData(list);
|
||||
messageListView.scrollToPosition(adapter.getBottomDataPosition());
|
||||
} else {
|
||||
adapter.addFrontData(list);
|
||||
messageListView.scrollToPosition(0);
|
||||
}
|
||||
} else {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
if (page == Constants.PAGE_START) {
|
||||
showNoData(getString(R.string.tips_no_recent_contact));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private ChatRoomMessage getChatRoomMessage(PublicChatHallMessage publicChatHallMessage) {
|
||||
ChatRoomMessage chatRoomMessage;
|
||||
switch (publicChatHallMessage.getMsgType()) {
|
||||
case PublicChatHallMessage.TYPE_MSG_CUSTOM:
|
||||
String attach = publicChatHallMessage.getAttach();
|
||||
CustomAttachment customAttachment = JSON.parseObject(attach, CustomAttachment.class);
|
||||
if (customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_PUBLIC_CHAT_HALL) {
|
||||
switch (customAttachment.getSecond()) {
|
||||
case CustomAttachment.CUSTOM_MSG_SUB_PUBLIC_CHAT_HALL_AIT:
|
||||
AitFriendsAttachment aitFriendsAttachment = new AitFriendsAttachment();
|
||||
aitFriendsAttachment.fromJson(customAttachment.getData());
|
||||
chatRoomMessage = ChatRoomMessageBuilder
|
||||
.createChatRoomCustomMessage(
|
||||
String.valueOf(publicChatHallMessage.getRoomId()),
|
||||
aitFriendsAttachment);
|
||||
break;
|
||||
|
||||
case CustomAttachment.CUSTOM_MSG_SUB_PUBLIC_CHAT_HALL_GIFT:
|
||||
GiftAttachment giftAttachment = new GiftAttachment(
|
||||
CustomAttachment.CUSTOM_MSG_PUBLIC_CHAT_HALL,
|
||||
CustomAttachment.CUSTOM_MSG_SUB_PUBLIC_CHAT_HALL_GIFT);
|
||||
giftAttachment.fromJson(customAttachment.getData());
|
||||
chatRoomMessage = ChatRoomMessageBuilder
|
||||
.createChatRoomCustomMessage(
|
||||
String.valueOf(publicChatHallMessage.getRoomId()),
|
||||
giftAttachment);
|
||||
break;
|
||||
default:
|
||||
chatRoomMessage = ChatRoomMessageBuilder
|
||||
.createChatRoomCustomMessage(
|
||||
String.valueOf(publicChatHallMessage.getRoomId()),
|
||||
customAttachment);
|
||||
}
|
||||
} else if (customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_IM_TIP) {
|
||||
ImTipAttachment imTipAttachment = new ImTipAttachment(
|
||||
CustomAttachment.CUSTOM_MSG_IM_TIP,
|
||||
CustomAttachment.CUSTOM_MSG_IM_TIP_RESULT);
|
||||
imTipAttachment.fromJson(customAttachment.getData());
|
||||
chatRoomMessage = ChatRoomMessageBuilder
|
||||
.createChatRoomCustomMessage(
|
||||
String.valueOf(publicChatHallMessage.getRoomId()),
|
||||
imTipAttachment);
|
||||
} else {
|
||||
chatRoomMessage = ChatRoomMessageBuilder
|
||||
.createChatRoomCustomMessage(
|
||||
String.valueOf(publicChatHallMessage.getRoomId()),
|
||||
customAttachment);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case PublicChatHallMessage.TYPE_MSG_TEXT:
|
||||
chatRoomMessage = ChatRoomMessageBuilder
|
||||
.createChatRoomTextMessage(String.valueOf(publicChatHallMessage.getRoomId()),
|
||||
publicChatHallMessage.getAttach());
|
||||
break;
|
||||
}
|
||||
chatRoomMessage.setFromAccount(String.valueOf(publicChatHallMessage.getFromAccount()));
|
||||
Map<String, Object> remoteExt = JSON.parseObject(publicChatHallMessage.getFromExt());
|
||||
chatRoomMessage.setRemoteExtension(remoteExt);
|
||||
chatRoomMessage.setStatus(MsgStatusEnum.success);
|
||||
chatRoomMessage.setDirect(Objects.equals(
|
||||
publicChatHallMessage.getFromAccount(), AuthModel.get().getCurrentUid()) ?
|
||||
MsgDirectionEnum.Out : MsgDirectionEnum.In);
|
||||
return chatRoomMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestFail(String error) {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.fragment;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.flyco.tablayout.listener.OnTabSelectListener;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseBindingFragment;
|
||||
import com.chwl.app.databinding.FragmentPublicChatHallMyMesageBinding;
|
||||
import com.chwl.app.public_chat_hall.adapter.PagerDataAdapter;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ActLayoutRes(R.layout.fragment_public_chat_hall_my_mesage)
|
||||
public class PublicChatHallMyMessageFragment extends BaseBindingFragment<FragmentPublicChatHallMyMesageBinding> {
|
||||
public static final String KEY_PAGE = "key_page";
|
||||
|
||||
private final String[] titles = {ResUtil.getString(R.string.public_chat_hall_fragment_publicchathallmymessagefragment_01), ResUtil.getString(R.string.public_chat_hall_fragment_publicchathallmymessagefragment_02)};
|
||||
private int page = 0;
|
||||
private List<Fragment> fragments = new ArrayList<>();
|
||||
private PagerDataAdapter adapter;
|
||||
|
||||
public static PublicChatHallMyMessageFragment newInstance() {
|
||||
return new PublicChatHallMyMessageFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
fragments.add(PublicChatHallMyHistoryMessageFragment.getAitMeInstance());
|
||||
fragments.add(PublicChatHallMyHistoryMessageFragment.getSentMessageInstance());
|
||||
adapter = new PagerDataAdapter(getActivity().getSupportFragmentManager());
|
||||
adapter.setData(fragments);
|
||||
mBinding.vpPublicChatHallMyMessage.setAdapter(adapter);
|
||||
mBinding.stlPublicChatHallMyMessage.setTabData(titles);
|
||||
mBinding.vpPublicChatHallMyMessage.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
mBinding.stlPublicChatHallMyMessage.setCurrentTab(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
});
|
||||
mBinding.stlPublicChatHallMyMessage.setOnTabSelectListener(new OnTabSelectListener() {
|
||||
@Override
|
||||
public void onTabSelect(int position) {
|
||||
mBinding.vpPublicChatHallMyMessage.setCurrentItem(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselect(int position) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,886 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.module;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.Chronometer;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.api.UIKitOptions;
|
||||
import com.netease.nim.uikit.api.model.session.SessionCustomization;
|
||||
import com.netease.nim.uikit.business.ait.AitTextChangeListener;
|
||||
import com.netease.nim.uikit.business.session.actions.BaseAction;
|
||||
import com.netease.nim.uikit.business.session.emoji.EmoticonPickerView;
|
||||
import com.netease.nim.uikit.business.session.emoji.IEmoticonSelectedListener;
|
||||
import com.netease.nim.uikit.business.session.emoji.MoonUtil;
|
||||
import com.netease.nim.uikit.business.session.module.Container;
|
||||
import com.netease.nim.uikit.common.antispam.AntiSpamEvent;
|
||||
import com.netease.nim.uikit.common.ui.dialog.EasyAlertDialogHelper;
|
||||
import com.netease.nim.uikit.common.util.AntiSpamUtil;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
import com.netease.nim.uikit.impl.NimUIKitImpl;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
|
||||
import com.netease.nimlib.sdk.media.record.AudioRecorder;
|
||||
import com.netease.nimlib.sdk.media.record.IAudioRecordCallback;
|
||||
import com.netease.nimlib.sdk.media.record.RecordType;
|
||||
import com.netease.nimlib.sdk.msg.MessageBuilder;
|
||||
import com.netease.nimlib.sdk.msg.MsgService;
|
||||
import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;
|
||||
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.CustomNotification;
|
||||
import com.netease.nimlib.sdk.msg.model.CustomNotificationConfig;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.activity.PublicChatHallAitFriendsActivity;
|
||||
import com.chwl.app.public_chat_hall.utils.RemainCountManager;
|
||||
import com.chwl.app.utils.KeyBoardUtils;
|
||||
import com.chwl.core.initial.InitialModel;
|
||||
import com.chwl.core.public_chat_hall.manager.PublicChatHallDataManager;
|
||||
import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.utils.StringFormatUtils;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 底部文本编辑,语音等模块
|
||||
* Created by hzxuwen on 2015/6/16.
|
||||
*/
|
||||
public class PublicChatHallInputPanel implements IEmoticonSelectedListener, IAudioRecordCallback, AitTextChangeListener {
|
||||
|
||||
private static final String TAG = "MsgSendLayout";
|
||||
|
||||
private static final int SHOW_LAYOUT_DELAY = 200;
|
||||
|
||||
protected Container container;
|
||||
protected View view;
|
||||
protected Handler uiHandler;
|
||||
|
||||
// protected View actionPanelBottomLayout; // 更多布局
|
||||
protected LinearLayout messageActivityBottomLayout;
|
||||
protected EditText messageEditText;// 文本消息编辑框
|
||||
protected Button audioRecordBtn; // 录音按钮
|
||||
protected View audioAnimLayout; // 录音动画布局
|
||||
protected FrameLayout textAudioSwitchLayout; // 切换文本,语音按钮布局
|
||||
protected View switchToTextButtonInInputBar;// 文本消息选择按钮
|
||||
protected View switchToAudioButtonInInputBar;// 语音消息选择按钮
|
||||
// protected View moreFuntionButtonInInputBar;// 更多消息选择按钮
|
||||
protected View sendMessageButtonInInputBar;// 发送消息按钮
|
||||
protected View emojiButtonInInputBar;// 发送消息按钮
|
||||
protected View aitFriendsInputBar; // @ 人按钮
|
||||
protected View messageInputBar;
|
||||
|
||||
private SessionCustomization customization;
|
||||
|
||||
// 表情
|
||||
protected EmoticonPickerView emoticonPickerView; // 贴图表情控件
|
||||
|
||||
// 语音
|
||||
protected AudioRecorder audioMessageHelper;
|
||||
private Chronometer time;
|
||||
private TextView timerTip;
|
||||
private LinearLayout timerTipContainer;
|
||||
private boolean started = false;
|
||||
private boolean cancelled = false;
|
||||
private boolean touched = false; // 是否按着
|
||||
private boolean isKeyboardShowed = true; // 是否显示键盘
|
||||
|
||||
// state
|
||||
private boolean actionPanelBottomLayoutHasSetup = false;
|
||||
private boolean isTextAudioSwitchShow = true;
|
||||
|
||||
// adapter
|
||||
private List<BaseAction> actions;
|
||||
|
||||
// data
|
||||
private long typingTime = 0;
|
||||
|
||||
private boolean isRobotSession;
|
||||
|
||||
private TextWatcher aitTextWatcher;
|
||||
|
||||
private volatile boolean disable;
|
||||
|
||||
public PublicChatHallInputPanel(Container container, View view, List<BaseAction> actions, boolean isTextAudioSwitchShow) {
|
||||
this.container = container;
|
||||
this.view = view;
|
||||
this.actions = actions;
|
||||
this.uiHandler = new Handler();
|
||||
this.isTextAudioSwitchShow = isTextAudioSwitchShow;
|
||||
init();
|
||||
}
|
||||
|
||||
public PublicChatHallInputPanel(Container container, View view, List<BaseAction> actions) {
|
||||
this(container, view, actions, true);
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
// 停止录音
|
||||
if (audioMessageHelper != null) {
|
||||
onEndAudioRecord(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
// release
|
||||
if (audioMessageHelper != null) {
|
||||
audioMessageHelper.destroyAudioRecorder();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean collapse(boolean immediately) {
|
||||
boolean respond = (emoticonPickerView != null && emoticonPickerView.getVisibility() == View.VISIBLE);
|
||||
|
||||
hideAllInputLayout(immediately);
|
||||
|
||||
return respond;
|
||||
}
|
||||
|
||||
public void addAitTextWatcher(TextWatcher watcher) {
|
||||
aitTextWatcher = watcher;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
initViews();
|
||||
initInputBarListener();
|
||||
initTextEdit();
|
||||
initAudioRecordButton();
|
||||
restoreText(false);
|
||||
|
||||
for (int i = 0; i < actions.size(); ++i) {
|
||||
actions.get(i).setIndex(i);
|
||||
actions.get(i).setContainer(container);
|
||||
}
|
||||
|
||||
if (disable) {
|
||||
disableButtons();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCustomization(SessionCustomization customization) {
|
||||
this.customization = customization;
|
||||
if (customization != null) {
|
||||
emoticonPickerView.setWithSticker(customization.withSticker);
|
||||
}
|
||||
}
|
||||
|
||||
public void reload(Container container, SessionCustomization customization) {
|
||||
this.container = container;
|
||||
setCustomization(customization);
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
// input bar
|
||||
messageActivityBottomLayout = (LinearLayout) view.findViewById(R.id.messageActivityBottomLayout);
|
||||
messageInputBar = view.findViewById(R.id.textMessageLayout);
|
||||
switchToTextButtonInInputBar = view.findViewById(R.id.buttonTextMessage);
|
||||
switchToAudioButtonInInputBar = view.findViewById(R.id.buttonAudioMessage);
|
||||
// moreFuntionButtonInInputBar = view.findViewById(R.id.buttonMoreFuntionInText);
|
||||
emojiButtonInInputBar = view.findViewById(R.id.emoji_button);
|
||||
sendMessageButtonInInputBar = view.findViewById(R.id.buttonSendMessage);
|
||||
messageEditText = (EditText) view.findViewById(R.id.editTextMessage);
|
||||
|
||||
// 语音
|
||||
audioRecordBtn = (Button) view.findViewById(R.id.audioRecord);
|
||||
audioAnimLayout = view.findViewById(R.id.layoutPlayAudio);
|
||||
time = (Chronometer) view.findViewById(R.id.timer);
|
||||
timerTip = (TextView) view.findViewById(R.id.timer_tip);
|
||||
timerTipContainer = (LinearLayout) view.findViewById(R.id.timer_tip_container);
|
||||
|
||||
// 表情
|
||||
emoticonPickerView = (EmoticonPickerView) view.findViewById(R.id.emoticon_picker_view);
|
||||
|
||||
// 录音按钮
|
||||
switchToTextButtonInInputBar.setVisibility(View.GONE);
|
||||
switchToAudioButtonInInputBar.setVisibility(View.GONE);
|
||||
|
||||
// 文本录音按钮切换布局
|
||||
textAudioSwitchLayout = (FrameLayout) view.findViewById(R.id.switchLayout);
|
||||
if (isTextAudioSwitchShow) {
|
||||
textAudioSwitchLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
textAudioSwitchLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// @ 人
|
||||
aitFriendsInputBar = view.findViewById(R.id.ait_button);
|
||||
}
|
||||
|
||||
public void disableButtons() {
|
||||
if (messageEditText != null && audioRecordBtn != null &&
|
||||
switchToTextButtonInInputBar != null && switchToAudioButtonInInputBar != null &&
|
||||
emojiButtonInInputBar != null) {
|
||||
messageEditText.setEnabled(false);
|
||||
messageEditText.setHint(ResUtil.getString(R.string.public_chat_hall_module_publicchathallinputpanel_01));
|
||||
messageEditText.setHintTextColor(Color.parseColor("#999999"));
|
||||
audioRecordBtn.setEnabled(false);
|
||||
switchToTextButtonInInputBar.setEnabled(false);
|
||||
switchToAudioButtonInInputBar.setEnabled(false);
|
||||
// moreFuntionButtonInInputBar.setEnabled(false);
|
||||
emojiButtonInInputBar.setEnabled(false);
|
||||
} else {
|
||||
setDisable(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDisable(boolean disable) {
|
||||
this.disable = disable;
|
||||
}
|
||||
|
||||
private void initInputBarListener() {
|
||||
switchToTextButtonInInputBar.setOnClickListener(clickListener);
|
||||
switchToAudioButtonInInputBar.setOnClickListener(clickListener);
|
||||
emojiButtonInInputBar.setOnClickListener(clickListener);
|
||||
sendMessageButtonInInputBar.setOnClickListener(clickListener);
|
||||
// moreFuntionButtonInInputBar.setOnClickListener(clickListener);
|
||||
aitFriendsInputBar.setOnClickListener(clickListener);
|
||||
}
|
||||
|
||||
private void initTextEdit() {
|
||||
messageEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||
messageEditText.setOnTouchListener(new View.OnTouchListener() {
|
||||
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
switchToTextLayout(true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
messageEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
checkSendButtonEnable(messageEditText);
|
||||
}
|
||||
});
|
||||
|
||||
messageEditText.addTextChangedListener(new TextWatcher() {
|
||||
private int start;
|
||||
private int count;
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
this.start = start;
|
||||
this.count = count;
|
||||
if (aitTextWatcher != null) {
|
||||
aitTextWatcher.onTextChanged(s, start, before, count);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (aitTextWatcher != null) {
|
||||
aitTextWatcher.beforeTextChanged(s, start, count, after);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
// checkSendButtonEnable(messageEditText);
|
||||
MoonUtil.replaceEmoticons(container.activity, s, start, count);
|
||||
|
||||
int editEnd = messageEditText.getSelectionEnd();
|
||||
messageEditText.removeTextChangedListener(this);
|
||||
while (StringUtil.counterChars(s.toString()) > NimUIKitImpl.getOptions().maxInputTextLength && editEnd > 0) {
|
||||
s.delete(editEnd - 1, editEnd);
|
||||
editEnd--;
|
||||
}
|
||||
messageEditText.setSelection(editEnd);
|
||||
messageEditText.addTextChangedListener(this);
|
||||
|
||||
if (aitTextWatcher != null) {
|
||||
aitTextWatcher.afterTextChanged(s);
|
||||
}
|
||||
|
||||
sendTypingCommand();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送“正在输入”通知
|
||||
*/
|
||||
private void sendTypingCommand() {
|
||||
if (container.account.equals(NimUIKit.getAccount())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (container.sessionType == SessionTypeEnum.Team || container.sessionType == SessionTypeEnum.ChatRoom) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() - typingTime > 5000L) {
|
||||
typingTime = System.currentTimeMillis();
|
||||
CustomNotification command = new CustomNotification();
|
||||
command.setSessionId(container.account);
|
||||
command.setSessionType(container.sessionType);
|
||||
CustomNotificationConfig config = new CustomNotificationConfig();
|
||||
config.enablePush = false;
|
||||
config.enableUnreadCount = false;
|
||||
command.setConfig(config);
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", "1");
|
||||
command.setContent(json.toString());
|
||||
|
||||
NIMClient.getService(MsgService.class).sendCustomNotification(command);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ************************* 键盘布局切换 *******************************
|
||||
*/
|
||||
|
||||
private View.OnClickListener clickListener = new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == switchToTextButtonInInputBar) {
|
||||
switchToTextLayout(true);// 显示文本发送的布局
|
||||
} else if (v == sendMessageButtonInInputBar) {
|
||||
onTextMessageSendButtonPressed();
|
||||
} else if (v == switchToAudioButtonInInputBar) {
|
||||
switchToAudioLayout();
|
||||
} else if (v == emojiButtonInInputBar) {
|
||||
toggleEmojiLayout();
|
||||
} else if (v == aitFriendsInputBar) {
|
||||
onAitFriendsButtonPressed();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void onAitFriendsButtonPressed() {
|
||||
if (!RemainCountManager.isCanRemain()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.public_chat_hall_module_publicchathallinputpanel_02) + RemainCountManager.MAX_CAN_REMAIN_COUNT + ResUtil.getString(R.string.public_chat_hall_module_publicchathallinputpanel_03));
|
||||
return;
|
||||
}
|
||||
hideAllInputLayout(false);
|
||||
KeyBoardUtils.hideKeyBoard(messageEditText.getContext(), messageEditText);
|
||||
PublicChatHallAitFriendsActivity.start(view.getContext());
|
||||
}
|
||||
|
||||
// 点击edittext,切换键盘和更多布局
|
||||
private void switchToTextLayout(boolean needShowInput) {
|
||||
hideEmojiLayout();
|
||||
|
||||
audioRecordBtn.setVisibility(View.GONE);
|
||||
messageEditText.setVisibility(View.VISIBLE);
|
||||
switchToTextButtonInInputBar.setVisibility(View.GONE);
|
||||
switchToAudioButtonInInputBar.setVisibility(View.GONE);
|
||||
|
||||
if(messageInputBar != null) {
|
||||
messageInputBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (needShowInput) {
|
||||
uiHandler.postDelayed(showTextRunnable, SHOW_LAYOUT_DELAY);
|
||||
} else {
|
||||
hideInputMethod();
|
||||
}
|
||||
}
|
||||
|
||||
// 发送文本消息
|
||||
private void onTextMessageSendButtonPressed() {
|
||||
String text = messageEditText.getText().toString();
|
||||
if (StringFormatUtils.isEmpty(text)) return;
|
||||
IMMessage textMessage = createTextMessage(text);
|
||||
if (AntiSpamUtil.checkLocalAntiSpam(textMessage)) {
|
||||
EventBus.getDefault().post(new AntiSpamEvent());
|
||||
} else {
|
||||
if (container.proxy.sendMessage(textMessage)) {
|
||||
restoreText(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected IMMessage createTextMessage(String text) {
|
||||
return ChatRoomMessageBuilder.createChatRoomTextMessage(container.account, text);
|
||||
}
|
||||
|
||||
// 切换成音频,收起键盘,按钮切换成键盘
|
||||
private void switchToAudioLayout() {
|
||||
messageEditText.setVisibility(View.GONE);
|
||||
audioRecordBtn.setVisibility(View.VISIBLE);
|
||||
hideInputMethod();
|
||||
hideEmojiLayout();
|
||||
|
||||
switchToAudioButtonInInputBar.setVisibility(View.GONE);
|
||||
switchToTextButtonInInputBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
// 点击表情,切换到表情布局
|
||||
private void toggleEmojiLayout() {
|
||||
if (emoticonPickerView == null || emoticonPickerView.getVisibility() == View.GONE) {
|
||||
showEmojiLayout();
|
||||
} else {
|
||||
hideEmojiLayout();
|
||||
}
|
||||
}
|
||||
|
||||
// 隐藏表情布局
|
||||
private void hideEmojiLayout() {
|
||||
uiHandler.removeCallbacks(showEmojiRunnable);
|
||||
emojiButtonInInputBar.setPressed(false);
|
||||
if (emoticonPickerView != null) {
|
||||
emoticonPickerView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
// 隐藏键盘布局
|
||||
public void hideInputMethod() {
|
||||
isKeyboardShowed = false;
|
||||
uiHandler.removeCallbacks(showTextRunnable);
|
||||
InputMethodManager imm = (InputMethodManager) container.activity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(messageEditText.getWindowToken(), 0);
|
||||
messageEditText.clearFocus();
|
||||
}
|
||||
|
||||
// 隐藏语音布局
|
||||
private void hideAudioLayout() {
|
||||
audioRecordBtn.setVisibility(View.GONE);
|
||||
messageEditText.setVisibility(View.VISIBLE);
|
||||
switchToTextButtonInInputBar.setVisibility(View.GONE);
|
||||
switchToAudioButtonInInputBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 显示表情布局
|
||||
private void showEmojiLayout() {
|
||||
hideInputMethod();
|
||||
hideAudioLayout();
|
||||
|
||||
messageEditText.requestFocus();
|
||||
uiHandler.postDelayed(showEmojiRunnable, 200);
|
||||
emojiButtonInInputBar.setPressed(true);
|
||||
emoticonPickerView.setVisibility(View.VISIBLE);
|
||||
emoticonPickerView.show(this);
|
||||
container.proxy.onInputPanelExpand();
|
||||
}
|
||||
|
||||
// 显示键盘布局
|
||||
private void showInputMethod(EditText editTextMessage) {
|
||||
editTextMessage.requestFocus();
|
||||
//如果已经显示,则继续操作时不需要把光标定位到最后
|
||||
if (!isKeyboardShowed) {
|
||||
editTextMessage.setSelection(editTextMessage.getText().length());
|
||||
isKeyboardShowed = true;
|
||||
}
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) container.activity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(editTextMessage, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
container.proxy.onInputPanelExpand();
|
||||
}
|
||||
|
||||
private Runnable showEmojiRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
emoticonPickerView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
};
|
||||
|
||||
private Runnable showTextRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showInputMethod(messageEditText);
|
||||
}
|
||||
};
|
||||
|
||||
private void restoreText(boolean clearText) {
|
||||
if (clearText) {
|
||||
messageEditText.setText("");
|
||||
PublicChatHallDataManager.get().startCountingDown();
|
||||
}
|
||||
|
||||
checkSendButtonEnable(messageEditText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新输入面板
|
||||
*/
|
||||
public void updateInputPanel() {
|
||||
checkSendButtonEnable(messageEditText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示发送或更多
|
||||
*
|
||||
* @param editText
|
||||
*/
|
||||
private void checkSendButtonEnable(EditText editText) {
|
||||
if (isRobotSession) {
|
||||
return;
|
||||
}
|
||||
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
|
||||
// 默认4级以下不能发言
|
||||
int limitLevel = 1;
|
||||
if (InitialModel.get().getCacheInitInfo() != null) {
|
||||
limitLevel = InitialModel.get().getCacheInitInfo().getPublicChatRoomLevelNo();
|
||||
}
|
||||
if (userInfo != null &&
|
||||
userInfo.getUserLevelVo() != null &&
|
||||
userInfo.getUserLevelVo().experLevelSeq < limitLevel) {
|
||||
// editText.setHint(R.string.hint_not_enough_level_to_send_message);
|
||||
editText.setHint(ResUtil.getString(R.string.public_chat_hall_module_publicchathallinputpanel_04) + limitLevel + ResUtil.getString(R.string.public_chat_hall_module_publicchathallinputpanel_05));
|
||||
editText.setFocusable(false);
|
||||
editText.setFocusableInTouchMode(false);
|
||||
sendMessageButtonInInputBar.setEnabled(false);
|
||||
} else if (userInfo != null &&
|
||||
userInfo.getUserLevelVo() != null &&
|
||||
userInfo.getUserLevelVo().experLevelSeq >= limitLevel) {
|
||||
editText.setHint(R.string.hint_input_message);
|
||||
editText.setFocusable(true);
|
||||
editText.setFocusableInTouchMode(true);
|
||||
editText.requestFocus();
|
||||
sendMessageButtonInInputBar.setEnabled(true);
|
||||
|
||||
if (PublicChatHallDataManager.get().millisUntilFinished != -1) {
|
||||
updateSendMessageButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSendMessageButton() {
|
||||
long millisUntilFinished = PublicChatHallDataManager.get().millisUntilFinished;
|
||||
if (millisUntilFinished > -1) {
|
||||
sendMessageButtonInInputBar.setEnabled(false);
|
||||
((TextView) sendMessageButtonInInputBar).setText(((int) millisUntilFinished / 1000) + "s");
|
||||
} else {
|
||||
sendMessageButtonInInputBar.setEnabled(true);
|
||||
((TextView) sendMessageButtonInInputBar).setText(R.string.send);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算已有输入字符跟即将插入的字符是否会超过最大长度
|
||||
*
|
||||
* @param input 即将插入的字符
|
||||
* @return true 如果已经超过长度了,否则为 false
|
||||
*/
|
||||
public boolean isTextLimited(String input) {
|
||||
return messageEditText.getText().length() + input.length() >
|
||||
messageEditText.getContext().getResources()
|
||||
.getInteger(R.integer.limit_input_text_length);
|
||||
}
|
||||
|
||||
/**
|
||||
* *************** IEmojiSelectedListener ***************
|
||||
*/
|
||||
@Override
|
||||
public void onEmojiSelected(String key) {
|
||||
Editable mEditable = messageEditText.getText();
|
||||
if (key.equals("/DEL")) {
|
||||
messageEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
|
||||
} else {
|
||||
int start = messageEditText.getSelectionStart();
|
||||
int end = messageEditText.getSelectionEnd();
|
||||
start = (start < 0 ? 0 : start);
|
||||
end = (start < 0 ? 0 : end);
|
||||
mEditable.replace(start, end, key);
|
||||
}
|
||||
}
|
||||
|
||||
private Runnable hideAllInputLayoutRunnable;
|
||||
|
||||
@Override
|
||||
public void onStickerSelected(String category, String item) {
|
||||
Log.i("PCHInputPanel", "onStickerSelected, category =" + category + ", sticker =" + item);
|
||||
|
||||
if (customization != null) {
|
||||
MsgAttachment attachment = customization.createStickerAttachment(category, item);
|
||||
IMMessage stickerMessage = MessageBuilder.createCustomMessage(container.account, container.sessionType, ResUtil.getString(R.string.public_chat_hall_module_publicchathallinputpanel_06), attachment);
|
||||
container.proxy.sendMessage(stickerMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextAdd(String content, int start, int length) {
|
||||
if (messageEditText.getVisibility() != View.VISIBLE ||
|
||||
(emoticonPickerView != null && emoticonPickerView.getVisibility() == View.VISIBLE)) {
|
||||
switchToTextLayout(true);
|
||||
} else {
|
||||
uiHandler.postDelayed(showTextRunnable, SHOW_LAYOUT_DELAY);
|
||||
}
|
||||
messageEditText.getEditableText().insert(start, content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextDelete(int start, int length) {
|
||||
if (messageEditText.getVisibility() != View.VISIBLE) {
|
||||
switchToTextLayout(true);
|
||||
} else {
|
||||
uiHandler.postDelayed(showTextRunnable, SHOW_LAYOUT_DELAY);
|
||||
}
|
||||
int end = start + length - 1;
|
||||
messageEditText.getEditableText().replace(start, end, "");
|
||||
}
|
||||
|
||||
public int getEditSelectionStart() {
|
||||
return messageEditText.getSelectionStart();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 隐藏所有输入布局
|
||||
*/
|
||||
private void hideAllInputLayout(boolean immediately) {
|
||||
if (hideAllInputLayoutRunnable == null) {
|
||||
hideAllInputLayoutRunnable = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
hideInputMethod();
|
||||
hideEmojiLayout();
|
||||
}
|
||||
};
|
||||
}
|
||||
long delay = immediately ? 0 : ViewConfiguration.getDoubleTapTimeout();
|
||||
uiHandler.postDelayed(hideAllInputLayoutRunnable, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* ****************************** 语音 ***********************************
|
||||
*/
|
||||
private void initAudioRecordButton() {
|
||||
audioRecordBtn.setOnTouchListener(new View.OnTouchListener() {
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
touched = true;
|
||||
initAudioRecord();
|
||||
onStartAudioRecord();
|
||||
} else if (event.getAction() == MotionEvent.ACTION_CANCEL
|
||||
|| event.getAction() == MotionEvent.ACTION_UP) {
|
||||
touched = false;
|
||||
onEndAudioRecord(isCancelled(v, event));
|
||||
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
touched = true;
|
||||
cancelAudioRecord(isCancelled(v, event));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 上滑取消录音判断
|
||||
private static boolean isCancelled(View view, MotionEvent event) {
|
||||
int[] location = new int[2];
|
||||
view.getLocationOnScreen(location);
|
||||
|
||||
if (event.getRawX() < location[0] || event.getRawX() > location[0] + view.getWidth()
|
||||
|| event.getRawY() < location[1] - 40) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化AudioRecord
|
||||
*/
|
||||
private void initAudioRecord() {
|
||||
if (audioMessageHelper == null) {
|
||||
UIKitOptions options = NimUIKitImpl.getOptions();
|
||||
audioMessageHelper = new AudioRecorder(container.activity, options.audioRecordType, options.audioRecordMaxTime, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始语音录制
|
||||
*/
|
||||
private void onStartAudioRecord() {
|
||||
container.activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
audioMessageHelper.startRecord();
|
||||
cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束语音录制
|
||||
*
|
||||
* @param cancel
|
||||
*/
|
||||
private void onEndAudioRecord(boolean cancel) {
|
||||
started = false;
|
||||
container.activity.getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
audioMessageHelper.completeRecord(cancel);
|
||||
audioRecordBtn.setText(R.string.record_audio);
|
||||
audioRecordBtn.setBackgroundResource(R.drawable.nim_message_input_edittext_box);
|
||||
stopAudioRecordAnim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消语音录制
|
||||
*
|
||||
* @param cancel
|
||||
*/
|
||||
private void cancelAudioRecord(boolean cancel) {
|
||||
// reject
|
||||
if (!started) {
|
||||
return;
|
||||
}
|
||||
// no change
|
||||
if (cancelled == cancel) {
|
||||
return;
|
||||
}
|
||||
|
||||
cancelled = cancel;
|
||||
updateTimerTip(cancel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 正在进行语音录制和取消语音录制,界面展示
|
||||
*
|
||||
* @param cancel
|
||||
*/
|
||||
private void updateTimerTip(boolean cancel) {
|
||||
if (cancel) {
|
||||
timerTip.setText(R.string.recording_cancel_tip);
|
||||
timerTipContainer.setBackgroundResource(R.drawable.nim_cancel_record_red_bg);
|
||||
} else {
|
||||
timerTip.setText(R.string.recording_cancel);
|
||||
timerTipContainer.setBackgroundResource(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始语音录制动画
|
||||
*/
|
||||
private void playAudioRecordAnim() {
|
||||
audioAnimLayout.setVisibility(View.VISIBLE);
|
||||
time.setBase(SystemClock.elapsedRealtime());
|
||||
time.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束语音录制动画
|
||||
*/
|
||||
private void stopAudioRecordAnim() {
|
||||
audioAnimLayout.setVisibility(View.GONE);
|
||||
time.stop();
|
||||
time.setBase(SystemClock.elapsedRealtime());
|
||||
}
|
||||
|
||||
// 录音状态回调
|
||||
@Override
|
||||
public void onRecordReady() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecordStart(File audioFile, RecordType recordType) {
|
||||
started = true;
|
||||
if (!touched) {
|
||||
return;
|
||||
}
|
||||
|
||||
audioRecordBtn.setText(R.string.record_audio_end);
|
||||
audioRecordBtn.setBackgroundResource(R.drawable.nim_message_input_edittext_box_pressed);
|
||||
|
||||
updateTimerTip(false); // 初始化语音动画状态
|
||||
playAudioRecordAnim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecordSuccess(File audioFile, long audioLength, RecordType recordType) {
|
||||
IMMessage audioMessage = MessageBuilder.createAudioMessage(container.account, container.sessionType, audioFile, audioLength);
|
||||
container.proxy.sendMessage(audioMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecordFail() {
|
||||
if (started) {
|
||||
// Toast.makeText(container.activity, R.string.recording_error, Toast.LENGTH_SHORT).show();
|
||||
SingleToastUtil.showToastShort(R.string.recording_error);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecordCancel() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecordReachedMaxTime(final int maxTime) {
|
||||
stopAudioRecordAnim();
|
||||
EasyAlertDialogHelper.createOkCancelDiolag(container.activity, "", container.activity.getString(R.string.recording_max_time), false, new EasyAlertDialogHelper.OnDialogActionListener() {
|
||||
@Override
|
||||
public void doCancelAction() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doOkAction() {
|
||||
audioMessageHelper.handleEndRecord(true, maxTime);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
public boolean isRecording() {
|
||||
return audioMessageHelper != null && audioMessageHelper.isRecording();
|
||||
}
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode != Activity.RESULT_OK) {
|
||||
return;
|
||||
}
|
||||
int index = (requestCode << 16) >> 24;
|
||||
if (index != 0) {
|
||||
index--;
|
||||
if (index < 0 | index >= actions.size()) {
|
||||
LogUtil.d(TAG, "request code out of actions' range");
|
||||
return;
|
||||
}
|
||||
BaseAction action = actions.get(index);
|
||||
if (action != null) {
|
||||
action.onActivityResult(requestCode & 0xff, resultCode, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void switchRobotMode(boolean isRobot) {
|
||||
isRobotSession = isRobot;
|
||||
if (isRobot) {
|
||||
textAudioSwitchLayout.setVisibility(View.GONE);
|
||||
emojiButtonInInputBar.setVisibility(View.GONE);
|
||||
sendMessageButtonInInputBar.setVisibility(View.VISIBLE);
|
||||
// moreFuntionButtonInInputBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
textAudioSwitchLayout.setVisibility(View.VISIBLE);
|
||||
emojiButtonInInputBar.setVisibility(View.VISIBLE);
|
||||
sendMessageButtonInInputBar.setVisibility(View.VISIBLE);
|
||||
// moreFuntionButtonInInputBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,553 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.module;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.business.preference.UserPreferences;
|
||||
import com.netease.nim.uikit.business.robot.parser.elements.group.LinkElement;
|
||||
import com.netease.nim.uikit.business.session.audio.MessageAudioControl;
|
||||
import com.netease.nim.uikit.business.session.module.Container;
|
||||
import com.netease.nim.uikit.business.session.viewholder.robot.RobotLinkView;
|
||||
import com.netease.nim.uikit.common.ui.dialog.EasyAlertDialog;
|
||||
import com.netease.nim.uikit.common.ui.dialog.EasyAlertDialogHelper;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.IRecyclerView;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.Observer;
|
||||
import com.netease.nimlib.sdk.RequestCallbackWrapper;
|
||||
import com.netease.nimlib.sdk.ResponseCode;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomService;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomServiceObserver;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.msg.attachment.FileAttachment;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.AttachmentProgress;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.netease.nimlib.sdk.robot.model.RobotAttachment;
|
||||
import com.netease.nimlib.sdk.robot.model.RobotMsgType;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.adapter.PublicChatHallMsgAdapter;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseFetchLoadAdapter;
|
||||
import com.chwl.app.public_chat_hall.msg.MsgListFetchLoadMoreView;
|
||||
import com.chwl.app.public_chat_hall.msg.OnMsgItemClickListener;
|
||||
import com.chwl.app.public_chat_hall.msg.viewholder.ChatRoomMsgViewHolderBase;
|
||||
import com.chwl.core.public_chat_hall.manager.PublicChatHallDataManager;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 聊天室消息收发模块
|
||||
* Created by huangjun on 2016/1/27.
|
||||
* copy from uikit
|
||||
*/
|
||||
public class PublicChatHallMessageListPanel {
|
||||
private static final int MESSAGE_CAPACITY = 500;
|
||||
|
||||
// container
|
||||
private Container container;
|
||||
private View rootView;
|
||||
private Handler uiHandler;
|
||||
|
||||
// message list view
|
||||
private RecyclerView messageListView;
|
||||
private List<ChatRoomMessage> items;
|
||||
private PublicChatHallMsgAdapter adapter;
|
||||
|
||||
private ImageView newMessageTipsView;
|
||||
private CountDownTimer countDownTimer;
|
||||
|
||||
public PublicChatHallMessageListPanel(Container container, View rootView) {
|
||||
this.container = container;
|
||||
this.rootView = rootView;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
setEarPhoneMode(UserPreferences.isEarPhoneModeEnable(), false);
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
MessageAudioControl.getInstance(container.activity).stopAudio();
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
registerObservers(false);
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBackPressed() {
|
||||
uiHandler.removeCallbacks(null);
|
||||
MessageAudioControl.getInstance(container.activity).stopAudio(); // 界面返回,停止语音播放
|
||||
return false;
|
||||
}
|
||||
|
||||
public void reload(Container container) {
|
||||
this.container = container;
|
||||
if (adapter != null) {
|
||||
adapter.clearData();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
initListView();
|
||||
this.uiHandler = new Handler(NimUIKit.getContext().getMainLooper());
|
||||
registerObservers(true);
|
||||
}
|
||||
|
||||
private void initListView() {
|
||||
// RecyclerView
|
||||
messageListView = (RecyclerView) rootView.findViewById(R.id.messageListView);
|
||||
messageListView.setLayoutManager(new LinearLayoutManager(container.activity));
|
||||
messageListView.requestDisallowInterceptTouchEvent(true);
|
||||
messageListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState != RecyclerView.SCROLL_STATE_IDLE) {
|
||||
container.proxy.shouldCollapseInputPanel();
|
||||
}
|
||||
}
|
||||
});
|
||||
messageListView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
|
||||
// adapter
|
||||
items = Collections.synchronizedList(new LinkedList<>());
|
||||
adapter = new PublicChatHallMsgAdapter(messageListView, items, container);
|
||||
adapter.closeLoadAnimation();
|
||||
adapter.setFetchMoreView(new MsgListFetchLoadMoreView());
|
||||
adapter.setLoadMoreView(new MsgListFetchLoadMoreView());
|
||||
adapter.setEventListener(new MsgItemEventListener());
|
||||
adapter.setOnFetchMoreListener(new MessageLoader()); // load from start
|
||||
messageListView.setAdapter(adapter);
|
||||
|
||||
messageListView.addOnItemTouchListener(listener);
|
||||
|
||||
newMessageTipsView = rootView.findViewById(R.id.iv_bottom_new_message);
|
||||
newMessageTipsView.setOnClickListener(v -> {
|
||||
doScrollToBottom();
|
||||
newMessageTipsView.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
public void onIncomingMessage(List<ChatRoomMessage> messages) {
|
||||
boolean needScrollToBottom = isLastMessageVisible();
|
||||
boolean needRefresh = false;
|
||||
List<ChatRoomMessage> addedListItems = new ArrayList<>(messages.size());
|
||||
for (ChatRoomMessage message : messages) {
|
||||
// 保证显示到界面上的消息,来自同一个聊天室
|
||||
if (isMyMessage(message)) {
|
||||
saveMessage(message);
|
||||
addedListItems.add(message);
|
||||
needRefresh = true;
|
||||
}
|
||||
}
|
||||
if (needRefresh) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
adapter.updateShowTimeItem(addedListItems, false, true);
|
||||
|
||||
// incoming messages tip
|
||||
ChatRoomMessage lastMsg = messages.get(messages.size() - 1);
|
||||
if (isMyMessage(lastMsg) && needScrollToBottom) {
|
||||
doScrollToBottom();
|
||||
newMessageTipsView.setVisibility(View.GONE);
|
||||
} else {
|
||||
// 出现「底部有新消息」的图片作为提示
|
||||
newMessageTipsView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLastMessageVisible() {
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) messageListView.getLayoutManager();
|
||||
int lastVisiblePosition = layoutManager.findLastCompletelyVisibleItemPosition();
|
||||
return lastVisiblePosition >= adapter.getBottomDataPosition();
|
||||
}
|
||||
|
||||
|
||||
// 发送消息后,更新本地消息列表
|
||||
public void onMsgSend(ChatRoomMessage message) {
|
||||
List<ChatRoomMessage> addedListItems = new ArrayList<>(1);
|
||||
addedListItems.add(message);
|
||||
adapter.updateShowTimeItem(addedListItems, false, true);
|
||||
saveMessage(message);
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
doScrollToBottom();
|
||||
|
||||
uiHandler.postDelayed(() -> newMessageTipsView.setVisibility(View.GONE), 200);
|
||||
|
||||
}
|
||||
|
||||
public void saveMessage(final ChatRoomMessage message) {
|
||||
if (message == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (items.size() >= MESSAGE_CAPACITY) {
|
||||
items.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* *************** MessageLoader ***************
|
||||
*/
|
||||
private class MessageLoader implements BaseFetchLoadAdapter.RequestLoadMoreListener, BaseFetchLoadAdapter.RequestFetchMoreListener {
|
||||
|
||||
private static final int LOAD_MESSAGE_COUNT = 10;
|
||||
|
||||
private IMMessage anchor;
|
||||
|
||||
private volatile boolean firstLoad = true;
|
||||
|
||||
private volatile boolean fetching = false;
|
||||
|
||||
public MessageLoader() {
|
||||
anchor = null;
|
||||
loadFromRemote();
|
||||
}
|
||||
|
||||
private RequestCallbackWrapper<List<ChatRoomMessage>> callback = new RequestCallbackWrapper<List<ChatRoomMessage>>() {
|
||||
@Override
|
||||
public void onResult(int code, List<ChatRoomMessage> messages, Throwable exception) {
|
||||
if (fetching) {
|
||||
if (code == ResponseCode.RES_SUCCESS && messages != null) {
|
||||
onMessageLoaded(messages);
|
||||
} else {
|
||||
if (exception != null) {
|
||||
exception.printStackTrace();
|
||||
} else {
|
||||
if (code == 416) {
|
||||
// Toast.makeText(container.activity, ResUtil.getString(R.string.public_chat_hall_module_publicchathallmessagelistpanel_01), Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.public_chat_hall_module_publicchathallmessagelistpanel_02));
|
||||
} else {
|
||||
// Toast.makeText(container.activity, ResUtil.getString(R.string.public_chat_hall_module_publicchathallmessagelistpanel_03) + code, Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.public_chat_hall_module_publicchathallmessagelistpanel_04) + code);
|
||||
}
|
||||
}
|
||||
adapter.fetchMoreFailed();
|
||||
}
|
||||
fetching = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private synchronized void loadFromRemote() {
|
||||
if (!fetching) {
|
||||
fetching = true;
|
||||
PublicChatHallDataManager.get()
|
||||
.fetchHistory(container, anchor(), callback);
|
||||
}
|
||||
}
|
||||
|
||||
private IMMessage anchor() {
|
||||
if (items.size() == 0) {
|
||||
return (anchor == null ? ChatRoomMessageBuilder.createEmptyChatRoomMessage(container.account, 0) : anchor);
|
||||
} else {
|
||||
return items.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史消息加载处理
|
||||
*/
|
||||
private synchronized void onMessageLoaded(List<ChatRoomMessage> messages) {
|
||||
int msgCount = messages.size();
|
||||
List<ChatRoomMessage> loadedMessages = new ArrayList<>(messages);
|
||||
|
||||
// 逆序
|
||||
Collections.reverse(loadedMessages);
|
||||
// 加入到列表中
|
||||
if (items.size() >= MESSAGE_CAPACITY) {
|
||||
// 超过设定的上限后,不再予以拉取更多历史消息的操作
|
||||
adapter.fetchMoreEnd(loadedMessages, true);
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.public_chat_hall_module_publicchathallmessagelistpanel_05));
|
||||
} else {
|
||||
if (msgCount <= 0) {
|
||||
adapter.fetchMoreEnd(loadedMessages, true);
|
||||
} else {
|
||||
adapter.fetchMoreComplete(loadedMessages);
|
||||
}
|
||||
}
|
||||
|
||||
adapter.updateShowTimeItem(loadedMessages, true, firstLoad); // 更新要显示时间的消息
|
||||
|
||||
// 如果是第一次加载,updateShowTimeItem返回的就是lastShowTimeItem
|
||||
if (firstLoad) {
|
||||
doScrollToBottom();
|
||||
}
|
||||
|
||||
firstLoad = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchMoreRequested() {
|
||||
loadFromRemote();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreRequested() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ************************* 观察者 ********************************
|
||||
*/
|
||||
|
||||
private void registerObservers(boolean register) {
|
||||
ChatRoomServiceObserver service = NIMClient.getService(ChatRoomServiceObserver.class);
|
||||
service.observeMsgStatus(messageStatusObserver, register);
|
||||
service.observeAttachmentProgress(attachmentProgressObserver, register);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息状态变化观察者
|
||||
*/
|
||||
private Observer<ChatRoomMessage> messageStatusObserver = new Observer<ChatRoomMessage>() {
|
||||
@Override
|
||||
public void onEvent(ChatRoomMessage message) {
|
||||
if (isMyMessage(message)) {
|
||||
onMessageStatusChange(message);
|
||||
PublicChatHallDataManager.get().pushMyMessage(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 消息附件上传/下载进度观察者
|
||||
*/
|
||||
private Observer<AttachmentProgress> attachmentProgressObserver = new Observer<AttachmentProgress>() {
|
||||
@Override
|
||||
public void onEvent(AttachmentProgress progress) {
|
||||
onAttachmentProgressChange(progress);
|
||||
}
|
||||
};
|
||||
|
||||
private void onMessageStatusChange(ChatRoomMessage message) {
|
||||
int index = getItemIndex(message.getUuid());
|
||||
if (index >= 0 && index < items.size()) {
|
||||
IMMessage item = items.get(index);
|
||||
item.setStatus(message.getStatus());
|
||||
item.setAttachStatus(message.getAttachStatus());
|
||||
// 处理语音、音视频通话
|
||||
if (item.getMsgType() == MsgTypeEnum.audio || item.getMsgType() == MsgTypeEnum.avchat) {
|
||||
item.setAttachment(message.getAttachment()); // 附件可能更新了
|
||||
}
|
||||
|
||||
// resend的的情况,可能时间已经变化了,这里要重新检查是否要显示时间
|
||||
List<ChatRoomMessage> msgList = new ArrayList<>(1);
|
||||
msgList.add(message);
|
||||
adapter.updateShowTimeItem(msgList, false, true);
|
||||
|
||||
refreshViewHolderByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
private void onAttachmentProgressChange(AttachmentProgress progress) {
|
||||
int index = getItemIndex(progress.getUuid());
|
||||
if (index >= 0 && index < items.size()) {
|
||||
IMMessage item = items.get(index);
|
||||
float value = (float) progress.getTransferred() / (float) progress.getTotal();
|
||||
adapter.putProgress(item, value);
|
||||
refreshViewHolderByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isMyMessage(ChatRoomMessage message) {
|
||||
return message.getSessionType() == container.sessionType
|
||||
&& message.getSessionId() != null
|
||||
&& message.getSessionId().equals(container.account);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新单条消息
|
||||
*/
|
||||
private void refreshViewHolderByIndex(final int index) {
|
||||
container.activity.runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
adapter.notifyDataItemChanged(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private int getItemIndex(String uuid) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
IMMessage message = items.get(i);
|
||||
if (TextUtils.equals(message.getUuid(), uuid)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private OnMsgItemClickListener listener = new OnMsgItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(IRecyclerView adapter, View view, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemLongClick(IRecyclerView adapter, View view, int position) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemChildClick(IRecyclerView adapter2, View view, int position) {
|
||||
if (view != null && view instanceof RobotLinkView) {
|
||||
RobotLinkView robotLinkView = (RobotLinkView) view;
|
||||
LinkElement element = robotLinkView.getElement();
|
||||
if (element != null) {
|
||||
element.getTarget();
|
||||
if (LinkElement.TYPE_URL.equals(element.getType())) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("android.intent.action.VIEW");
|
||||
Uri content_url = Uri.parse(element.getTarget());
|
||||
intent.setData(content_url);
|
||||
try {
|
||||
container.activity.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
// Toast.makeText(container.activity, ResUtil.getString(R.string.public_chat_hall_module_publicchathallmessagelistpanel_06), Toast.LENGTH_SHORT).show();
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.public_chat_hall_module_publicchathallmessagelistpanel_07));
|
||||
}
|
||||
|
||||
} else if (LinkElement.TYPE_BLOCK.equals(element.getType())) {
|
||||
// 发送点击的block
|
||||
ChatRoomMessage message = adapter.getItem(position);
|
||||
if (message != null) {
|
||||
String robotAccount = ((RobotAttachment) message.getAttachment()).getFromRobotAccount();
|
||||
ChatRoomMessage robotMsg = ChatRoomMessageBuilder.createRobotMessage(container.account, robotAccount,
|
||||
robotLinkView.getShowContent(), RobotMsgType.LINK, "", element.getTarget(), element.getParams());
|
||||
container.proxy.sendMessage(robotMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private class MsgItemEventListener implements PublicChatHallMsgAdapter.ViewHolderEventListener {
|
||||
|
||||
@Override
|
||||
public void onFailedBtnClick(IMMessage message) {
|
||||
if (message.getDirect() == MsgDirectionEnum.Out) {
|
||||
// 发出的消息,如果是发送失败,直接重发,否则有可能是漫游到的多媒体消息,但文件下载
|
||||
if (message.getStatus() == MsgStatusEnum.fail) {
|
||||
resendMessage(message); // 重发
|
||||
} else {
|
||||
if (message.getAttachment() instanceof FileAttachment) {
|
||||
FileAttachment attachment = (FileAttachment) message.getAttachment();
|
||||
if (TextUtils.isEmpty(attachment.getPath())
|
||||
&& TextUtils.isEmpty(attachment.getThumbPath())) {
|
||||
showReDownloadConfirmDlg(message);
|
||||
}
|
||||
} else {
|
||||
resendMessage(message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
showReDownloadConfirmDlg(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onViewHolderLongClick(View clickView, View viewHolderView, IMMessage item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFooterClick(ChatRoomMsgViewHolderBase viewHolderBase, IMMessage message) {
|
||||
// 与 robot 对话
|
||||
container.proxy.onItemFooterClick(message);
|
||||
}
|
||||
|
||||
// 重新下载(对话框提示)
|
||||
private void showReDownloadConfirmDlg(final IMMessage message) {
|
||||
EasyAlertDialogHelper.OnDialogActionListener listener = new EasyAlertDialogHelper.OnDialogActionListener() {
|
||||
|
||||
@Override
|
||||
public void doCancelAction() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doOkAction() {
|
||||
// 正常情况收到消息后附件会自动下载。如果下载失败,可调用该接口重新下载
|
||||
if (message.getAttachment() != null && message.getAttachment() instanceof FileAttachment)
|
||||
NIMClient.getService(ChatRoomService.class).downloadAttachment((ChatRoomMessage) message, true);
|
||||
}
|
||||
};
|
||||
|
||||
final EasyAlertDialog dialog = EasyAlertDialogHelper.createOkCancelDiolag(container.activity, null,
|
||||
container.activity.getString(com.netease.nim.uikit.R.string.repeat_download_message), true, listener);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
// 重发消息到服务器
|
||||
private void resendMessage(IMMessage message) {
|
||||
// 重置状态为unsent
|
||||
int index = getItemIndex(message.getUuid());
|
||||
if (index >= 0 && index < items.size()) {
|
||||
IMMessage item = items.get(index);
|
||||
item.setStatus(MsgStatusEnum.sending);
|
||||
refreshViewHolderByIndex(index);
|
||||
}
|
||||
|
||||
NIMClient.getService(ChatRoomService.class)
|
||||
.sendMessage((ChatRoomMessage) message, true)
|
||||
.setCallback(new RequestCallbackWrapper<Void>() {
|
||||
@Override
|
||||
public void onResult(int code, Void result, Throwable exception) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void setEarPhoneMode(boolean earPhoneMode, boolean update) {
|
||||
if (update) {
|
||||
UserPreferences.setEarPhoneModeEnable(earPhoneMode);
|
||||
}
|
||||
MessageAudioControl.getInstance(container.activity).setEarPhoneModeEnable(earPhoneMode);
|
||||
}
|
||||
|
||||
public void scrollToBottom() {
|
||||
uiHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doScrollToBottom();
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
|
||||
private void doScrollToBottom() {
|
||||
messageListView.scrollToPosition(adapter.getBottomDataPosition());
|
||||
}
|
||||
|
||||
}
|
@@ -1,989 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.IRecyclerView;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.animation.AlphaInAnimation;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.animation.BaseAnimation;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.animation.ScaleInAnimation;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.animation.SlideInBottomAnimation;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.animation.SlideInLeftAnimation;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.animation.SlideInRightAnimation;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.util.RecyclerViewUtil;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
|
||||
public abstract class BaseFetchLoadAdapter<T, K extends BaseMsgViewHolder> extends RecyclerView.Adapter<K> implements IRecyclerView {
|
||||
|
||||
private static final String TAG = BaseFetchLoadAdapter.class.getSimpleName();
|
||||
|
||||
// fetch more
|
||||
public interface RequestFetchMoreListener {
|
||||
void onFetchMoreRequested();
|
||||
}
|
||||
|
||||
protected RecyclerView mRecyclerView;
|
||||
|
||||
private boolean mFetching = false;
|
||||
private boolean mFetchMoreEnable = false;
|
||||
private boolean mNextFetchEnable = false;
|
||||
private boolean mFirstFetchSuccess = true;
|
||||
private int mAutoFetchMoreSize = 1; // 距离顶部多少条就开始拉取数据了
|
||||
private RequestFetchMoreListener mRequestFetchMoreListener;
|
||||
private LoadMoreView mFetchMoreView = new SimpleLoadMoreView();
|
||||
|
||||
//load more
|
||||
public interface RequestLoadMoreListener {
|
||||
void onLoadMoreRequested();
|
||||
}
|
||||
|
||||
private boolean mLoading = false;
|
||||
private boolean mNextLoadEnable = false;
|
||||
private boolean mLoadMoreEnable = false;
|
||||
private boolean mFirstLoadSuccess = true;
|
||||
private int mAutoLoadMoreSize = 1; // 距离底部多少条就开始加载数据了
|
||||
private RequestLoadMoreListener mRequestLoadMoreListener;
|
||||
private LoadMoreView mLoadMoreView = new SimpleLoadMoreView();
|
||||
|
||||
// animation
|
||||
private boolean mAnimationShowFirstOnly = true;
|
||||
private boolean mOpenAnimationEnable = false;
|
||||
private Interpolator mInterpolator = new LinearInterpolator();
|
||||
private int mAnimationDuration = 200;
|
||||
private int mLastPosition = -1;
|
||||
|
||||
// @AnimationType
|
||||
private BaseAnimation mCustomAnimation;
|
||||
private BaseAnimation mSelectAnimation = new AlphaInAnimation();
|
||||
|
||||
// empty
|
||||
private FrameLayout mEmptyView;
|
||||
private boolean mIsUseEmpty = true;
|
||||
|
||||
// basic
|
||||
protected Context mContext;
|
||||
protected int mLayoutResId;
|
||||
protected LayoutInflater mLayoutInflater;
|
||||
protected List<T> mData;
|
||||
private boolean isScrolling = false;
|
||||
|
||||
/**
|
||||
* Implement this method and use the helper to adapt the view to the given item.
|
||||
*
|
||||
* @param helper A fully initialized helper.
|
||||
* @param item the item that needs to be displayed.
|
||||
* @param position the item position
|
||||
* @param isScrolling RecyclerView is scrolling
|
||||
*/
|
||||
protected abstract void convert(K helper, T item, int position, boolean isScrolling);
|
||||
|
||||
|
||||
@IntDef({ALPHAIN, SCALEIN, SLIDEIN_BOTTOM, SLIDEIN_LEFT, SLIDEIN_RIGHT})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface AnimationType {
|
||||
}
|
||||
|
||||
/**
|
||||
* Use with {@link #openLoadAnimation}
|
||||
*/
|
||||
public static final int ALPHAIN = 0x00000001;
|
||||
/**
|
||||
* Use with {@link #openLoadAnimation}
|
||||
*/
|
||||
public static final int SCALEIN = 0x00000002;
|
||||
/**
|
||||
* Use with {@link #openLoadAnimation}
|
||||
*/
|
||||
public static final int SLIDEIN_BOTTOM = 0x00000003;
|
||||
/**
|
||||
* Use with {@link #openLoadAnimation}
|
||||
*/
|
||||
public static final int SLIDEIN_LEFT = 0x00000004;
|
||||
/**
|
||||
* Use with {@link #openLoadAnimation}
|
||||
*/
|
||||
public static final int SLIDEIN_RIGHT = 0x00000005;
|
||||
|
||||
|
||||
/**
|
||||
* Same as QuickAdapter#QuickAdapter(Context,int) but with
|
||||
* some initialization data.
|
||||
*
|
||||
* @param layoutResId The layout resource id of each item.
|
||||
* @param data A new list is created out of this one to avoid mutable list
|
||||
*/
|
||||
public BaseFetchLoadAdapter(RecyclerView recyclerView, int layoutResId, List<T> data) {
|
||||
this.mRecyclerView = recyclerView;
|
||||
this.mData = data == null ? new ArrayList<T>() : data;
|
||||
if (layoutResId != 0) {
|
||||
this.mLayoutResId = layoutResId;
|
||||
}
|
||||
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
isScrolling = newState != RecyclerView.SCROLL_STATE_IDLE;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 关闭默认viewholder item动画
|
||||
*/
|
||||
RecyclerViewUtil.changeItemAnimation(recyclerView, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeaderLayoutCount() {
|
||||
return getFetchMoreViewCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* *********************************** fetch more 顶部下拉加载 ***********************************
|
||||
*/
|
||||
|
||||
public void setOnFetchMoreListener(RequestFetchMoreListener requestFetchMoreListener) {
|
||||
this.mRequestFetchMoreListener = requestFetchMoreListener;
|
||||
mNextFetchEnable = true;
|
||||
mFetchMoreEnable = true;
|
||||
mFetching = false;
|
||||
}
|
||||
|
||||
public void setAutoFetchMoreSize(int autoFetchMoreSize) {
|
||||
if (autoFetchMoreSize > 1) {
|
||||
mAutoFetchMoreSize = autoFetchMoreSize;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFetchMoreView(LoadMoreView fetchMoreView) {
|
||||
this.mFetchMoreView = fetchMoreView; // 自定义View
|
||||
}
|
||||
|
||||
private int getFetchMoreViewCount() {
|
||||
if (mRequestFetchMoreListener == null || !mFetchMoreEnable) {
|
||||
return 0;
|
||||
}
|
||||
if (!mNextFetchEnable && mFetchMoreView.isLoadEndMoreGone()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表滑动时自动拉取数据
|
||||
*
|
||||
* @param position
|
||||
*/
|
||||
private void autoRequestFetchMoreData(int position) {
|
||||
if (getFetchMoreViewCount() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (position > mAutoFetchMoreSize - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mFetchMoreView.getLoadMoreStatus() != LoadMoreView.STATUS_DEFAULT) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mData.size() == 0 && mFirstFetchSuccess) {
|
||||
return; // 都还没有数据,不自动触发加载,等外部塞入数据后再加载
|
||||
}
|
||||
|
||||
Log.d(TAG, "auto fetch, pos=" + position);
|
||||
|
||||
mFetchMoreView.setLoadMoreStatus(LoadMoreView.STATUS_LOADING);
|
||||
if (!mFetching) {
|
||||
mFetching = true;
|
||||
mRequestFetchMoreListener.onFetchMoreRequested();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fetch complete
|
||||
*/
|
||||
public void fetchMoreComplete(final List<T> newData) {
|
||||
addFrontData(newData); // notifyItemRangeInserted从顶部向下加入View,顶部View并没有改变
|
||||
|
||||
if (getFetchMoreViewCount() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetchMoreComplete(newData.size());
|
||||
}
|
||||
|
||||
public void fetchMoreComplete(int newDataSize) {
|
||||
if (getFetchMoreViewCount() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
mFetching = false;
|
||||
mFetchMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
|
||||
notifyItemChanged(0);
|
||||
|
||||
// 定位到insert新消息前的top消息位置。必须移动,否则还在顶部,会继续fetch!!!
|
||||
if (mRecyclerView != null) {
|
||||
RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager();
|
||||
// 只有LinearLayoutManager才有查找第一个和最后一个可见view位置的方法
|
||||
if (layoutManager instanceof LinearLayoutManager) {
|
||||
LinearLayoutManager linearManager = (LinearLayoutManager) layoutManager;
|
||||
//获取第一个可见view的位置
|
||||
int firstItemPosition = linearManager.findFirstVisibleItemPosition();
|
||||
if (firstItemPosition == 0) {
|
||||
// 最顶部可见的View已经是FetchMoreView了,那么add数据&局部刷新后,要进行定位到上次的最顶部消息。
|
||||
mRecyclerView.scrollToPosition(newDataSize + getFetchMoreViewCount());
|
||||
}
|
||||
} else {
|
||||
mRecyclerView.scrollToPosition(newDataSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fetch end, no more data
|
||||
*
|
||||
* @param data last load data to add
|
||||
* @param gone if true gone the fetch more view
|
||||
*/
|
||||
public void fetchMoreEnd(List<T> data, boolean gone) {
|
||||
addFrontData(data);
|
||||
|
||||
if (getFetchMoreViewCount() == 0) {
|
||||
return;
|
||||
}
|
||||
mFetching = false;
|
||||
mNextFetchEnable = false;
|
||||
mFetchMoreView.setLoadMoreEndGone(gone);
|
||||
if (gone) {
|
||||
notifyItemRemoved(0);
|
||||
} else {
|
||||
mFetchMoreView.setLoadMoreStatus(LoadMoreView.STATUS_END);
|
||||
notifyItemChanged(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fetch failed
|
||||
*/
|
||||
public void fetchMoreFailed() {
|
||||
if (getFetchMoreViewCount() == 0) {
|
||||
return;
|
||||
}
|
||||
mFetching = false;
|
||||
if (mData.size() == 0) {
|
||||
mFirstFetchSuccess = false; // 首次加载失败
|
||||
}
|
||||
mFetchMoreView.setLoadMoreStatus(LoadMoreView.STATUS_FAIL);
|
||||
|
||||
notifyItemChanged(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* *********************************** load more 底部上拉加载 ***********************************
|
||||
*/
|
||||
|
||||
public void setLoadMoreView(LoadMoreView loadingView) {
|
||||
this.mLoadMoreView = loadingView; // 自定义View
|
||||
}
|
||||
|
||||
public void setOnLoadMoreListener(RequestLoadMoreListener requestLoadMoreListener) {
|
||||
this.mRequestLoadMoreListener = requestLoadMoreListener;
|
||||
mNextLoadEnable = true;
|
||||
mLoadMoreEnable = true;
|
||||
mLoading = false;
|
||||
}
|
||||
|
||||
public void setAutoLoadMoreSize(int autoLoadMoreSize) {
|
||||
if (autoLoadMoreSize > 1) {
|
||||
mAutoLoadMoreSize = autoLoadMoreSize;
|
||||
}
|
||||
}
|
||||
|
||||
private int getLoadMoreViewCount() {
|
||||
if (mRequestLoadMoreListener == null || !mLoadMoreEnable) {
|
||||
return 0;
|
||||
}
|
||||
if (!mNextLoadEnable && mLoadMoreView.isLoadEndMoreGone()) {
|
||||
return 0;
|
||||
}
|
||||
if (mData.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表滑动时自动加载数据
|
||||
*
|
||||
* @param position
|
||||
*/
|
||||
private void autoRequestLoadMoreData(int position) {
|
||||
if (getLoadMoreViewCount() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (position < getItemCount() - mAutoLoadMoreSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mLoadMoreView.getLoadMoreStatus() != LoadMoreView.STATUS_DEFAULT) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mData.size() == 0 && mFirstLoadSuccess) {
|
||||
return; // 都还没有数据,不自动触发加载,等外部塞入数据后再加载
|
||||
}
|
||||
|
||||
Log.d(TAG, "auto load, pos=" + position);
|
||||
mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_LOADING);
|
||||
if (!mLoading) {
|
||||
mLoading = true;
|
||||
mRequestLoadMoreListener.onLoadMoreRequested();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load complete
|
||||
*/
|
||||
public void loadMoreComplete(final List<T> newData) {
|
||||
appendData(newData);
|
||||
|
||||
loadMoreComplete();
|
||||
}
|
||||
|
||||
public void loadMoreComplete() {
|
||||
if (getLoadMoreViewCount() == 0) {
|
||||
return;
|
||||
}
|
||||
mLoading = false;
|
||||
mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
|
||||
notifyItemChanged(getFetchMoreViewCount() + mData.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* load end, no more data
|
||||
*
|
||||
* @param data last data to append
|
||||
* @param gone if true gone the load more view
|
||||
*/
|
||||
public void loadMoreEnd(List<T> data, boolean gone) {
|
||||
appendData(data);
|
||||
|
||||
if (getLoadMoreViewCount() == 0) {
|
||||
return;
|
||||
}
|
||||
mLoading = false;
|
||||
mNextLoadEnable = false;
|
||||
mLoadMoreView.setLoadMoreEndGone(gone);
|
||||
if (gone) {
|
||||
notifyItemRemoved(getFetchMoreViewCount() + mData.size());
|
||||
} else {
|
||||
mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_END);
|
||||
notifyItemChanged(getFetchMoreViewCount() + mData.size());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load failed
|
||||
*/
|
||||
public void loadMoreFail() {
|
||||
if (getLoadMoreViewCount() == 0) {
|
||||
return;
|
||||
}
|
||||
mLoading = false;
|
||||
if (mData.size() == 0) {
|
||||
mFirstLoadSuccess = false; // 首次加载失败
|
||||
}
|
||||
mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_FAIL);
|
||||
notifyItemChanged(getFetchMoreViewCount() + mData.size());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the enabled state of load more.
|
||||
*
|
||||
* @param enable True if load more is enabled, false otherwise.
|
||||
*/
|
||||
public void setEnableLoadMore(boolean enable) {
|
||||
int oldLoadMoreCount = getLoadMoreViewCount();
|
||||
mLoadMoreEnable = enable;
|
||||
int newLoadMoreCount = getLoadMoreViewCount();
|
||||
|
||||
if (oldLoadMoreCount == 1) {
|
||||
if (newLoadMoreCount == 0) {
|
||||
notifyItemRemoved(getFetchMoreViewCount() + mData.size());
|
||||
}
|
||||
} else {
|
||||
if (newLoadMoreCount == 1) {
|
||||
mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
|
||||
notifyItemInserted(getFetchMoreViewCount() + mData.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enabled status for load more.
|
||||
*
|
||||
* @return True if load more is enabled, false otherwise.
|
||||
*/
|
||||
public boolean isLoadMoreEnable() {
|
||||
return mLoadMoreEnable;
|
||||
}
|
||||
|
||||
/**
|
||||
* *********************************** 数据源管理 ***********************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* setting up a new instance to data;
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void setNewData(List<T> data) {
|
||||
this.mData = data == null ? new ArrayList<T>() : data;
|
||||
if (mRequestLoadMoreListener != null) {
|
||||
mNextLoadEnable = true;
|
||||
mLoadMoreEnable = true;
|
||||
mLoading = false;
|
||||
mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
|
||||
}
|
||||
if (mRequestFetchMoreListener != null) {
|
||||
mNextFetchEnable = true;
|
||||
mFetchMoreEnable = true;
|
||||
mFetching = false;
|
||||
mFetchMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
|
||||
}
|
||||
|
||||
mLastPosition = -1;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* clear data before reload
|
||||
*/
|
||||
public void clearData() {
|
||||
this.mData.clear();
|
||||
if (mRequestLoadMoreListener != null) {
|
||||
mNextLoadEnable = true;
|
||||
mLoading = false;
|
||||
mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
|
||||
}
|
||||
if (mRequestFetchMoreListener != null) {
|
||||
mNextFetchEnable = true;
|
||||
mFetching = false;
|
||||
mFetchMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
|
||||
}
|
||||
|
||||
mLastPosition = -1;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* insert a item associated with the specified position of adapter
|
||||
*
|
||||
* @param position
|
||||
* @param item
|
||||
*/
|
||||
public void add(int position, T item) {
|
||||
mData.add(position, item);
|
||||
notifyItemInserted(position + getFetchMoreViewCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* add new data in to certain location
|
||||
*
|
||||
* @param position
|
||||
*/
|
||||
public void addData(int position, List<T> data) {
|
||||
if (0 <= position && position < mData.size()) {
|
||||
mData.addAll(position, data);
|
||||
notifyItemRangeInserted(getFetchMoreViewCount() + position, data.size());
|
||||
} else {
|
||||
throw new ArrayIndexOutOfBoundsException("inserted position most greater than 0 and less than data size");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove the item associated with the specified position of adapter
|
||||
*
|
||||
* @param position
|
||||
*/
|
||||
public void remove(int position) {
|
||||
final T item = mData.get(position);
|
||||
mData.remove(position);
|
||||
notifyItemRemoved(position + getHeaderLayoutCount());
|
||||
onRemove(item);
|
||||
}
|
||||
|
||||
protected void onRemove(T item) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* add new data to head location
|
||||
*/
|
||||
public void addFrontData(List<T> data) {
|
||||
if (data == null || data.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mData.addAll(0, data);
|
||||
notifyItemRangeInserted(getFetchMoreViewCount(), data.size()); // add到FetchMoreView之下,保持FetchMoreView在顶部
|
||||
}
|
||||
|
||||
/**
|
||||
* additional data;
|
||||
*
|
||||
* @param newData
|
||||
*/
|
||||
public void appendData(List<T> newData) {
|
||||
if (newData == null || newData.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.mData.addAll(newData);
|
||||
notifyItemRangeInserted(mData.size() - newData.size() + getFetchMoreViewCount(), newData.size());
|
||||
}
|
||||
|
||||
public void appendData(T newData) {
|
||||
List<T> data = new ArrayList<>(1);
|
||||
data.add(newData);
|
||||
appendData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data of list
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<T> getData() {
|
||||
return mData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data item associated with the specified position in the data set.
|
||||
*
|
||||
* @param position Position of the item whose data we want within the adapter's
|
||||
* data set.
|
||||
* @return The data at the specified position.
|
||||
*/
|
||||
public T getItem(int position) {
|
||||
return mData.get(position);
|
||||
}
|
||||
|
||||
public int getDataSize() {
|
||||
return mData == null ? 0 : mData.size();
|
||||
}
|
||||
|
||||
public int getBottomDataPosition() {
|
||||
return getHeaderLayoutCount() + mData.size() - 1;
|
||||
}
|
||||
|
||||
public void notifyDataItemChanged(int dataIndex) {
|
||||
notifyItemChanged(getHeaderLayoutCount() + dataIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* *********************************** ViewHolder/ViewType ***********************************
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
int count;
|
||||
if (getEmptyViewCount() == 1) {
|
||||
count = 1;
|
||||
} else {
|
||||
count = getFetchMoreViewCount() + mData.size() + getLoadMoreViewCount();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (getEmptyViewCount() == 1) {
|
||||
return EMPTY_VIEW;
|
||||
}
|
||||
|
||||
// fetch
|
||||
autoRequestFetchMoreData(position);
|
||||
// load
|
||||
autoRequestLoadMoreData(position);
|
||||
int fetchMoreCount = getFetchMoreViewCount();
|
||||
if (position < fetchMoreCount) {
|
||||
Log.d(TAG, "FETCH pos=" + position);
|
||||
return FETCHING_VIEW;
|
||||
} else {
|
||||
int adjPosition = position - fetchMoreCount;
|
||||
int adapterCount = mData.size();
|
||||
if (adjPosition < adapterCount) {
|
||||
Log.d(TAG, "DATA pos=" + position);
|
||||
return getDefItemViewType(adjPosition);
|
||||
} else {
|
||||
Log.d(TAG, "LOAD pos=" + position);
|
||||
return LOADING_VIEW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To bind different types of holder and solve different the bind events
|
||||
*
|
||||
* @param holder
|
||||
* @param positions
|
||||
* @see #getDefItemViewType(int)
|
||||
*/
|
||||
@Override
|
||||
public void onBindViewHolder(K holder, int positions) {
|
||||
int viewType = holder.getItemViewType();
|
||||
|
||||
switch (viewType) {
|
||||
case LOADING_VIEW:
|
||||
mLoadMoreView.convert(holder);
|
||||
break;
|
||||
case FETCHING_VIEW:
|
||||
mFetchMoreView.convert(holder);
|
||||
break;
|
||||
case EMPTY_VIEW:
|
||||
break;
|
||||
default:
|
||||
convert(holder, mData.get(holder.getLayoutPosition() - getFetchMoreViewCount()), positions, isScrolling);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected K onCreateDefViewHolder(ViewGroup parent, int viewType) {
|
||||
return createBaseViewHolder(parent, mLayoutResId);
|
||||
}
|
||||
|
||||
protected K createBaseViewHolder(ViewGroup parent, int layoutResId) {
|
||||
return createBaseViewHolder(getItemView(layoutResId, parent));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layoutResId ID for an XML layout resource to load
|
||||
* @param parent Optional view to be the parent of the generated hierarchy or else simply an object that
|
||||
* provides a set of LayoutParams values for root of the returned
|
||||
* hierarchy
|
||||
* @return view will be return
|
||||
*/
|
||||
protected View getItemView(int layoutResId, ViewGroup parent) {
|
||||
return mLayoutInflater.inflate(layoutResId, parent, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* if you want to use subclass of BaseViewHolder in the adapter,
|
||||
* you must override the method to create new ViewHolder.
|
||||
*
|
||||
* @param view view
|
||||
* @return new ViewHolder
|
||||
*/
|
||||
protected K createBaseViewHolder(View view) {
|
||||
return (K) new BaseMsgViewHolder(view);
|
||||
}
|
||||
|
||||
protected int getDefItemViewType(int position) {
|
||||
return super.getItemViewType(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public K onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
K baseViewHolder;
|
||||
this.mContext = parent.getContext();
|
||||
this.mLayoutInflater = LayoutInflater.from(mContext);
|
||||
switch (viewType) {
|
||||
case FETCHING_VIEW:
|
||||
baseViewHolder = getFetchingView(parent);
|
||||
break;
|
||||
case LOADING_VIEW:
|
||||
baseViewHolder = getLoadingView(parent);
|
||||
break;
|
||||
case EMPTY_VIEW:
|
||||
baseViewHolder = createBaseViewHolder(mEmptyView);
|
||||
break;
|
||||
default:
|
||||
baseViewHolder = onCreateDefViewHolder(parent, viewType);
|
||||
}
|
||||
return baseViewHolder;
|
||||
|
||||
}
|
||||
|
||||
private K getLoadingView(ViewGroup parent) {
|
||||
View view = getItemView(mLoadMoreView.getLayoutId(), parent);
|
||||
K holder = createBaseViewHolder(view);
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mLoadMoreView.getLoadMoreStatus() == LoadMoreView.STATUS_FAIL) {
|
||||
mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
|
||||
notifyItemChanged(getFetchMoreViewCount() + mData.size());
|
||||
}
|
||||
}
|
||||
});
|
||||
return holder;
|
||||
}
|
||||
|
||||
private K getFetchingView(ViewGroup parent) {
|
||||
View view = getItemView(mFetchMoreView.getLayoutId(), parent);
|
||||
K holder = createBaseViewHolder(view);
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mFetchMoreView.getLoadMoreStatus() == LoadMoreView.STATUS_FAIL) {
|
||||
mFetchMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
|
||||
notifyItemChanged(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return holder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a view created by this adapter has been attached to a window.
|
||||
* simple to solve item will layout using all
|
||||
* {@link #setFullSpan(RecyclerView.ViewHolder)}
|
||||
*
|
||||
* @param holder
|
||||
*/
|
||||
@Override
|
||||
public void onViewAttachedToWindow(K holder) {
|
||||
super.onViewAttachedToWindow(holder);
|
||||
int type = holder.getItemViewType();
|
||||
if (type == EMPTY_VIEW || type == LOADING_VIEW || type == FETCHING_VIEW) {
|
||||
setFullSpan(holder);
|
||||
} else {
|
||||
addAnimation(holder);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When set to true, the item will layout using all span area. That means, if orientation
|
||||
* is vertical, the view will have full width; if orientation is horizontal, the view will
|
||||
* have full height.
|
||||
* if the hold view use StaggeredGridLayoutManager they should using all span area
|
||||
*
|
||||
* @param holder True if this item should traverse all spans.
|
||||
*/
|
||||
protected void setFullSpan(RecyclerView.ViewHolder holder) {
|
||||
if (holder.itemView.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
|
||||
StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
|
||||
params.setFullSpan(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(final RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
|
||||
if (manager instanceof GridLayoutManager) {
|
||||
final GridLayoutManager gridManager = ((GridLayoutManager) manager);
|
||||
gridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
int type = getItemViewType(position);
|
||||
if (mSpanSizeLookup == null) {
|
||||
return (type == EMPTY_VIEW || type == LOADING_VIEW || type == FETCHING_VIEW) ? gridManager.getSpanCount() : 1;
|
||||
} else {
|
||||
return (type == EMPTY_VIEW || type == LOADING_VIEW || type == FETCHING_VIEW) ? gridManager
|
||||
.getSpanCount() : mSpanSizeLookup.getSpanSize(gridManager, position - getFetchMoreViewCount());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private SpanSizeLookup mSpanSizeLookup;
|
||||
|
||||
public interface SpanSizeLookup {
|
||||
int getSpanSize(GridLayoutManager gridLayoutManager, int position);
|
||||
}
|
||||
|
||||
/**
|
||||
* *********************************** EmptyView ***********************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* if mEmptyView will be return 1 or not will be return 0
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getEmptyViewCount() {
|
||||
if (mEmptyView == null || mEmptyView.getChildCount() == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (!mIsUseEmpty) {
|
||||
return 0;
|
||||
}
|
||||
if (mData.size() != 0) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void setEmptyView(View emptyView) {
|
||||
boolean insert = false;
|
||||
if (mEmptyView == null) {
|
||||
mEmptyView = new FrameLayout(emptyView.getContext());
|
||||
mEmptyView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
|
||||
insert = true;
|
||||
}
|
||||
mEmptyView.removeAllViews();
|
||||
mEmptyView.addView(emptyView);
|
||||
mIsUseEmpty = true;
|
||||
if (insert) {
|
||||
if (getEmptyViewCount() == 1) {
|
||||
notifyItemInserted(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to use empty view
|
||||
*
|
||||
* @param isUseEmpty
|
||||
*/
|
||||
public void isUseEmpty(boolean isUseEmpty) {
|
||||
mIsUseEmpty = isUseEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
* When the current adapter is empty, the BaseQuickAdapter can display a special view
|
||||
* called the empty view. The empty view is used to provide feedback to the user
|
||||
* that no data is available in this AdapterView.
|
||||
*
|
||||
* @return The view to show if the adapter is empty.
|
||||
*/
|
||||
public View getEmptyView() {
|
||||
return mEmptyView;
|
||||
}
|
||||
|
||||
/**
|
||||
* *********************************** 动画 ***********************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set the view animation type.
|
||||
*
|
||||
* @param animationType One of {@link #ALPHAIN}, {@link #SCALEIN}, {@link #SLIDEIN_BOTTOM}, {@link #SLIDEIN_LEFT}, {@link #SLIDEIN_RIGHT}.
|
||||
*/
|
||||
public void openLoadAnimation(@AnimationType int animationType) {
|
||||
this.mOpenAnimationEnable = true;
|
||||
mCustomAnimation = null;
|
||||
switch (animationType) {
|
||||
case ALPHAIN:
|
||||
mSelectAnimation = new AlphaInAnimation();
|
||||
break;
|
||||
case SCALEIN:
|
||||
mSelectAnimation = new ScaleInAnimation();
|
||||
break;
|
||||
case SLIDEIN_BOTTOM:
|
||||
mSelectAnimation = new SlideInBottomAnimation();
|
||||
break;
|
||||
case SLIDEIN_LEFT:
|
||||
mSelectAnimation = new SlideInLeftAnimation();
|
||||
break;
|
||||
case SLIDEIN_RIGHT:
|
||||
mSelectAnimation = new SlideInRightAnimation();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Custom ObjectAnimator
|
||||
*
|
||||
* @param animation ObjectAnimator
|
||||
*/
|
||||
public void openLoadAnimation(BaseAnimation animation) {
|
||||
this.mOpenAnimationEnable = true;
|
||||
this.mCustomAnimation = animation;
|
||||
}
|
||||
|
||||
/**
|
||||
* To open the animation when loading
|
||||
*/
|
||||
public void openLoadAnimation() {
|
||||
this.mOpenAnimationEnable = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* To close the animation when loading
|
||||
*/
|
||||
public void closeLoadAnimation() {
|
||||
this.mOpenAnimationEnable = false;
|
||||
this.mSelectAnimation = null;
|
||||
this.mCustomAnimation = null;
|
||||
this.mAnimationDuration = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link #addAnimation(RecyclerView.ViewHolder)}
|
||||
*
|
||||
* @param firstOnly true just show anim when first loading false show anim when load the data every time
|
||||
*/
|
||||
public void setAnimationShowFirstOnly(boolean firstOnly) {
|
||||
this.mAnimationShowFirstOnly = firstOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the duration of the animation.
|
||||
*
|
||||
* @param duration The length of the animation, in milliseconds.
|
||||
*/
|
||||
public void setAnimationDuration(int duration) {
|
||||
mAnimationDuration = duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* add animation when you want to show time
|
||||
*
|
||||
* @param holder
|
||||
*/
|
||||
private void addAnimation(RecyclerView.ViewHolder holder) {
|
||||
if (mOpenAnimationEnable) {
|
||||
if (!mAnimationShowFirstOnly || holder.getLayoutPosition() > mLastPosition) {
|
||||
BaseAnimation animation;
|
||||
if (mCustomAnimation != null) {
|
||||
animation = mCustomAnimation;
|
||||
} else {
|
||||
animation = mSelectAnimation;
|
||||
}
|
||||
for (Animator anim : animation.getAnimators(holder.itemView)) {
|
||||
startAnim(anim, holder.getLayoutPosition());
|
||||
}
|
||||
mLastPosition = holder.getLayoutPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set anim to start when loading
|
||||
*
|
||||
* @param anim
|
||||
* @param index
|
||||
*/
|
||||
protected void startAnim(Animator anim, int index) {
|
||||
anim.setDuration(mAnimationDuration).start();
|
||||
anim.setInterpolator(mInterpolator);
|
||||
}
|
||||
}
|
@@ -1,500 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.widget.Adapter;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.CheckedTextView;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RatingBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
public class BaseMsgViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
/**
|
||||
* Views indexed with their IDs
|
||||
*/
|
||||
private final SparseArray<View> views;
|
||||
|
||||
private final LinkedHashSet<Integer> childClickViewIds;
|
||||
private final LinkedHashSet<Integer> itemChildLongClickViewIds;
|
||||
|
||||
|
||||
public View convertView;
|
||||
|
||||
/**
|
||||
* Package private field to retain the associated user object and detect a change
|
||||
*/
|
||||
Object associatedObject;
|
||||
|
||||
|
||||
public BaseMsgViewHolder(View view) {
|
||||
super(view);
|
||||
this.views = new SparseArray<View>();
|
||||
this.childClickViewIds = new LinkedHashSet<>();
|
||||
this.itemChildLongClickViewIds = new LinkedHashSet<>();
|
||||
convertView = view;
|
||||
|
||||
}
|
||||
|
||||
public HashSet<Integer> getItemChildLongClickViewIds() {
|
||||
return itemChildLongClickViewIds;
|
||||
}
|
||||
|
||||
public HashSet<Integer> getChildClickViewIds() {
|
||||
return childClickViewIds;
|
||||
}
|
||||
|
||||
public View getConvertView() {
|
||||
return convertView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will set the text of a TextView.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param value The text to put in the text view.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setText(int viewId, CharSequence value) {
|
||||
TextView view = getView(viewId);
|
||||
view.setText(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BaseMsgViewHolder setText(int viewId, @StringRes int strId) {
|
||||
TextView view = getView(viewId);
|
||||
view.setText(strId);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will set the image of an ImageView from a resource id.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param imageResId The image resource id.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setImageResource(int viewId, @DrawableRes int imageResId) {
|
||||
ImageView view = getView(viewId);
|
||||
view.setImageResource(imageResId);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will set background color of a view.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param color A color, not a resource id.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setBackgroundColor(int viewId, int color) {
|
||||
View view = getView(viewId);
|
||||
view.setBackgroundColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will set background of a view.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param backgroundRes A resource to use as a background.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setBackgroundRes(int viewId, @DrawableRes int backgroundRes) {
|
||||
View view = getView(viewId);
|
||||
view.setBackgroundResource(backgroundRes);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will set text color of a TextView.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param textColor The text color (not a resource id).
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setTextColor(int viewId, int textColor) {
|
||||
TextView view = getView(viewId);
|
||||
view.setTextColor(textColor);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Will set the image of an ImageView from a drawable.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param drawable The image drawable.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setImageDrawable(int viewId, Drawable drawable) {
|
||||
ImageView view = getView(viewId);
|
||||
view.setImageDrawable(drawable);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an action to set the image of an image view. Can be called multiple times.
|
||||
*/
|
||||
public BaseMsgViewHolder setImageBitmap(int viewId, Bitmap bitmap) {
|
||||
ImageView view = getView(viewId);
|
||||
view.setImageBitmap(bitmap);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an action to set the alpha of a view. Can be called multiple times.
|
||||
* Alpha between 0-1.
|
||||
*/
|
||||
public BaseMsgViewHolder setAlpha(int viewId, float value) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
getView(viewId).setAlpha(value);
|
||||
} else {
|
||||
// Pre-honeycomb hack to set Alpha value
|
||||
AlphaAnimation alpha = new AlphaAnimation(value, value);
|
||||
alpha.setDuration(0);
|
||||
alpha.setFillAfter(true);
|
||||
getView(viewId).startAnimation(alpha);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a view visibility to VISIBLE (true) or GONE (false).
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param visible True for VISIBLE, false for GONE.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setVisible(int viewId, boolean visible) {
|
||||
View view = getView(viewId);
|
||||
view.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add links into a TextView.
|
||||
*
|
||||
* @param viewId The id of the TextView to linkify.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder linkify(int viewId) {
|
||||
TextView view = getView(viewId);
|
||||
Linkify.addLinks(view, Linkify.ALL);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the typeface to the given viewId, and enable subpixel rendering.
|
||||
*/
|
||||
public BaseMsgViewHolder setTypeface(int viewId, Typeface typeface) {
|
||||
TextView view = getView(viewId);
|
||||
view.setTypeface(typeface);
|
||||
view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the typeface to all the given viewIds, and enable subpixel rendering.
|
||||
*/
|
||||
public BaseMsgViewHolder setTypeface(Typeface typeface, int... viewIds) {
|
||||
for (int viewId : viewIds) {
|
||||
TextView view = getView(viewId);
|
||||
view.setTypeface(typeface);
|
||||
view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress of a ProgressBar.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param progress The progress.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setProgress(int viewId, int progress) {
|
||||
ProgressBar view = getView(viewId);
|
||||
view.setProgress(progress);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress and max of a ProgressBar.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param progress The progress.
|
||||
* @param max The max value of a ProgressBar.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setProgress(int viewId, int progress, int max) {
|
||||
ProgressBar view = getView(viewId);
|
||||
view.setMax(max);
|
||||
view.setProgress(progress);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the range of a ProgressBar to 0...max.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param max The max value of a ProgressBar.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setMax(int viewId, int max) {
|
||||
ProgressBar view = getView(viewId);
|
||||
view.setMax(max);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rating (the number of stars filled) of a RatingBar.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param rating The rating.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setRating(int viewId, float rating) {
|
||||
RatingBar view = getView(viewId);
|
||||
view.setRating(rating);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rating (the number of stars filled) and max of a RatingBar.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param rating The rating.
|
||||
* @param max The range of the RatingBar to 0...max.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setRating(int viewId, float rating, int max) {
|
||||
RatingBar view = getView(viewId);
|
||||
view.setMax(max);
|
||||
view.setRating(rating);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the on click listener of the view.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param listener The on click listener;
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseMsgViewHolder setOnClickListener(int viewId, View.OnClickListener listener) {
|
||||
View view = getView(viewId);
|
||||
view.setOnClickListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* add childView id
|
||||
*
|
||||
* @param viewId add the child view id can support childview click
|
||||
* @return
|
||||
*/
|
||||
public BaseMsgViewHolder addOnClickListener(int viewId) {
|
||||
childClickViewIds.add(viewId);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* add long click view id
|
||||
*
|
||||
* @param viewId
|
||||
* @return
|
||||
*/
|
||||
public BaseMsgViewHolder addOnLongClickListener(int viewId) {
|
||||
itemChildLongClickViewIds.add(viewId);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the on touch listener of the view.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param listener The on touch listener;
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setOnTouchListener(int viewId, View.OnTouchListener listener) {
|
||||
View view = getView(viewId);
|
||||
view.setOnTouchListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the on long click listener of the view.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param listener The on long click listener;
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setOnLongClickListener(int viewId, View.OnLongClickListener listener) {
|
||||
View view = getView(viewId);
|
||||
view.setOnLongClickListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the listview or gridview's item click listener of the view
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param listener The item on click listener;
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
|
||||
AdapterView view = getView(viewId);
|
||||
view.setOnItemClickListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the listview or gridview's item long click listener of the view
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param listener The item long click listener;
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setOnItemLongClickListener(int viewId, AdapterView.OnItemLongClickListener listener) {
|
||||
AdapterView view = getView(viewId);
|
||||
view.setOnItemLongClickListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the listview or gridview's item selected click listener of the view
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param listener The item selected click listener;
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setOnItemSelectedClickListener(int viewId, AdapterView.OnItemSelectedListener listener) {
|
||||
AdapterView view = getView(viewId);
|
||||
view.setOnItemSelectedListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the on checked change listener of the view.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param listener The checked change listener of compound button.
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setOnCheckedChangeListener(int viewId, CompoundButton.OnCheckedChangeListener listener) {
|
||||
CompoundButton view = getView(viewId);
|
||||
view.setOnCheckedChangeListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tag of the view.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param tag The tag;
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setTag(int viewId, Object tag) {
|
||||
View view = getView(viewId);
|
||||
view.setTag(tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tag of the view.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param key The key of tag;
|
||||
* @param tag The tag;
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setTag(int viewId, int key, Object tag) {
|
||||
View view = getView(viewId);
|
||||
view.setTag(key, tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the checked status of a checkable.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param checked The checked status;
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setChecked(int viewId, boolean checked) {
|
||||
View view = getView(viewId);
|
||||
// View unable cast to Checkable
|
||||
if (view instanceof CompoundButton) {
|
||||
((CompoundButton) view).setChecked(checked);
|
||||
} else if (view instanceof CheckedTextView) {
|
||||
((CheckedTextView) view).setChecked(checked);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the adapter of a adapter view.
|
||||
*
|
||||
* @param viewId The view id.
|
||||
* @param adapter The adapter;
|
||||
* @return The BaseViewHolder for chaining.
|
||||
*/
|
||||
public BaseMsgViewHolder setAdapter(int viewId, Adapter adapter) {
|
||||
AdapterView view = getView(viewId);
|
||||
view.setAdapter(adapter);
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends View> T getView(int viewId) {
|
||||
View view = views.get(viewId);
|
||||
if (view == null) {
|
||||
view = convertView.findViewById(viewId);
|
||||
views.put(viewId, view);
|
||||
}
|
||||
return (T) view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the last converted object on this view.
|
||||
*/
|
||||
public Object getAssociatedObject() {
|
||||
return associatedObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called during convert
|
||||
*/
|
||||
public void setAssociatedObject(Object associatedObject) {
|
||||
this.associatedObject = associatedObject;
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
if (convertView == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return convertView.getContext();
|
||||
}
|
||||
}
|
@@ -1,131 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.util.SparseArray;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class BaseMultiItemFetchLoadAdapter<T, K extends BaseMsgViewHolder> extends BaseFetchLoadAdapter<T, K> {
|
||||
|
||||
/**
|
||||
* viewType->layoutResId
|
||||
*/
|
||||
private SparseArray<Integer> layouts;
|
||||
|
||||
/**
|
||||
* viewType->view holder class
|
||||
*/
|
||||
private SparseArray<Class<? extends RecyclerViewHolder>> holderClasses;
|
||||
|
||||
/**
|
||||
* viewType->view holder instance
|
||||
*/
|
||||
private Map<Integer, Map<String, RecyclerViewHolder>> multiTypeViewHolders;
|
||||
|
||||
/**
|
||||
* get view type from data item
|
||||
*
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
protected abstract int getViewType(T item);
|
||||
|
||||
/**
|
||||
* get view holder unique key from data item
|
||||
*
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
protected abstract String getItemKey(T item);
|
||||
|
||||
public BaseMultiItemFetchLoadAdapter(RecyclerView recyclerView, List<T> data) {
|
||||
super(recyclerView, 0, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* add viewType->layoutResId, viewType->ViewHolder.class
|
||||
*
|
||||
* @param type view type
|
||||
* @param layoutResId
|
||||
* @param viewHolderClass
|
||||
*/
|
||||
protected void addItemType(int type, @LayoutRes int layoutResId, Class<? extends RecyclerViewHolder> viewHolderClass) {
|
||||
// layouts
|
||||
if (layouts == null) {
|
||||
layouts = new SparseArray<>();
|
||||
}
|
||||
layouts.put(type, layoutResId);
|
||||
|
||||
// view holder class
|
||||
if (holderClasses == null) {
|
||||
holderClasses = new SparseArray<>();
|
||||
}
|
||||
holderClasses.put(type, viewHolderClass);
|
||||
|
||||
// view holder
|
||||
if (multiTypeViewHolders == null) {
|
||||
multiTypeViewHolders = new HashMap<>();
|
||||
}
|
||||
multiTypeViewHolders.put(type, new HashMap<String, RecyclerViewHolder>());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDefItemViewType(int position) {
|
||||
return getViewType(mData.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected K onCreateDefViewHolder(ViewGroup parent, int viewType) {
|
||||
return createBaseViewHolder(parent, getLayoutId(viewType));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(final K baseHolder, final T item, final int position, boolean isScrolling) {
|
||||
final String key = getItemKey(item);
|
||||
final int viewType = baseHolder.getItemViewType();
|
||||
|
||||
RecyclerViewHolder h = multiTypeViewHolders.get(viewType).get(key);
|
||||
if (h == null) {
|
||||
// build
|
||||
try {
|
||||
Class<? extends RecyclerViewHolder> cls = holderClasses.get(viewType);
|
||||
Constructor c = cls.getDeclaredConstructors()[0]; // 第一个显式的构造函数
|
||||
c.setAccessible(true);
|
||||
h = (RecyclerViewHolder) c.newInstance(new Object[]{this});
|
||||
multiTypeViewHolders.get(viewType).put(key, h);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// convert
|
||||
if (h != null) {
|
||||
h.convert(baseHolder, item, position, isScrolling);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRemove(final T item) {
|
||||
super.onRemove(item);
|
||||
|
||||
// 移除holder
|
||||
multiTypeViewHolders.get(getViewType(item)).remove(getItemKey(item));
|
||||
}
|
||||
|
||||
private int getLayoutId(int viewType) {
|
||||
return layouts.get(viewType);
|
||||
}
|
||||
|
||||
protected RecyclerViewHolder getViewHolder(int viewType, String viewHolderKey) {
|
||||
if (multiTypeViewHolders.containsKey(viewType)) {
|
||||
return multiTypeViewHolders.get(viewType).get(viewHolderKey);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -1,116 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.LayoutRes;
|
||||
|
||||
public abstract class LoadMoreView {
|
||||
|
||||
public static final int STATUS_DEFAULT = 1;
|
||||
public static final int STATUS_LOADING = 2;
|
||||
public static final int STATUS_FAIL = 3;
|
||||
public static final int STATUS_END = 4;
|
||||
|
||||
private int mLoadMoreStatus = STATUS_DEFAULT;
|
||||
private boolean mLoadMoreEndGone = false;
|
||||
|
||||
public void setLoadMoreStatus(int loadMoreStatus) {
|
||||
this.mLoadMoreStatus = loadMoreStatus;
|
||||
}
|
||||
|
||||
public int getLoadMoreStatus() {
|
||||
return mLoadMoreStatus;
|
||||
}
|
||||
|
||||
public void convert(BaseMsgViewHolder holder) {
|
||||
switch (mLoadMoreStatus) {
|
||||
case STATUS_LOADING:
|
||||
visibleLoading(holder, true);
|
||||
visibleLoadFail(holder, false);
|
||||
visibleLoadEnd(holder, false);
|
||||
break;
|
||||
case STATUS_FAIL:
|
||||
visibleLoading(holder, false);
|
||||
visibleLoadFail(holder, true);
|
||||
visibleLoadEnd(holder, false);
|
||||
break;
|
||||
case STATUS_END:
|
||||
visibleLoading(holder, false);
|
||||
visibleLoadFail(holder, false);
|
||||
visibleLoadEnd(holder, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void visibleLoading(BaseMsgViewHolder holder, boolean visible) {
|
||||
holder.setVisible(getLoadingViewId(), visible);
|
||||
}
|
||||
|
||||
private void visibleLoadFail(BaseMsgViewHolder holder, boolean visible) {
|
||||
holder.setVisible(getLoadFailViewId(), visible);
|
||||
}
|
||||
|
||||
private void visibleLoadEnd(BaseMsgViewHolder holder, boolean visible) {
|
||||
final int loadEndViewId = getLoadEndViewId();
|
||||
if (loadEndViewId != 0) {
|
||||
holder.setVisible(loadEndViewId, visible);
|
||||
}
|
||||
}
|
||||
|
||||
public final void setLoadMoreEndGone(boolean loadMoreEndGone) {
|
||||
this.mLoadMoreEndGone = loadMoreEndGone;
|
||||
}
|
||||
|
||||
public final boolean isLoadEndMoreGone() {
|
||||
if (getLoadEndViewId() == 0) {
|
||||
return true;
|
||||
}
|
||||
return mLoadMoreEndGone;
|
||||
}
|
||||
|
||||
/**
|
||||
* No more data is hidden
|
||||
*
|
||||
* @return true for no more data hidden load more
|
||||
* @deprecated Use {@link BaseQuickAdapter#loadMoreEnd(boolean)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isLoadEndGone() {
|
||||
return mLoadMoreEndGone;
|
||||
}
|
||||
|
||||
/**
|
||||
* load more layout
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract
|
||||
@LayoutRes
|
||||
int getLayoutId();
|
||||
|
||||
/**
|
||||
* loading view
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract
|
||||
@IdRes
|
||||
int getLoadingViewId();
|
||||
|
||||
/**
|
||||
* load fail view
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract
|
||||
@IdRes
|
||||
int getLoadFailViewId();
|
||||
|
||||
/**
|
||||
* load end view, you can return 0
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract
|
||||
@IdRes
|
||||
int getLoadEndViewId();
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg;
|
||||
|
||||
import com.chwl.app.R;
|
||||
|
||||
public final class MsgListFetchLoadMoreView extends LoadMoreView {
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.nim_msg_list_fetch_load_more;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLoadingViewId() {
|
||||
return R.id.load_more_loading_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLoadFailViewId() {
|
||||
return R.id.load_more_load_fail_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLoadEndViewId() {
|
||||
return R.id.load_more_load_end_view;
|
||||
}
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.IRecyclerView;
|
||||
|
||||
/**
|
||||
* A convenience class to extend when you only want to OnItemClickListener for a subset
|
||||
* of all the SimpleClickListener. This implements all methods in the
|
||||
* {@link SimpleClickListener}
|
||||
*/
|
||||
public abstract class OnMsgItemClickListener<T extends IRecyclerView> extends SimpleClickListener<T> {
|
||||
|
||||
@Override
|
||||
public void onItemLongClick(T adapter, View view, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemChildClick(T adapter, View view, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemChildLongClick(T adapter, View view, int position) {
|
||||
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* Created by huangjun on 2016/12/11.
|
||||
*/
|
||||
|
||||
public abstract class RecyclerViewHolder<T extends RecyclerView.Adapter, V extends BaseMsgViewHolder, K> {
|
||||
final private T adapter;
|
||||
|
||||
public RecyclerViewHolder(T adapter) {
|
||||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
public T getAdapter() {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
public abstract void convert(V holder, K data, int position, boolean isScrolling);
|
||||
}
|
@@ -1,297 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg;
|
||||
|
||||
import android.os.Build;
|
||||
import androidx.core.view.GestureDetectorCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.IRecyclerView;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class SimpleClickListener<T extends IRecyclerView> implements RecyclerView.OnItemTouchListener {
|
||||
private GestureDetectorCompat mGestureDetector;
|
||||
private RecyclerView recyclerView;
|
||||
private Set<Integer> childClickViewIds;
|
||||
private Set<Integer> longClickViewIds;
|
||||
protected T baseAdapter;
|
||||
public static String TAG = "SimpleClickListener";
|
||||
private boolean mIsPrepressed = false;
|
||||
private boolean mIsShowPress = false;
|
||||
private View mPressedView = null;
|
||||
private boolean shouldDetectGesture = true;
|
||||
private int longClickDelta = 200;
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
|
||||
if (!shouldDetectGesture()) {
|
||||
return false; // 拦截手势检测
|
||||
}
|
||||
|
||||
// 手势检测
|
||||
if (recyclerView == null) {
|
||||
this.recyclerView = rv;
|
||||
this.baseAdapter = (T) recyclerView.getAdapter();
|
||||
mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener(recyclerView));
|
||||
}
|
||||
if (!mGestureDetector.onTouchEvent(e) && e.getActionMasked() == MotionEvent.ACTION_UP && mIsShowPress) {
|
||||
if (mPressedView != null) {
|
||||
BaseMsgViewHolder vh = (BaseMsgViewHolder) recyclerView.getChildViewHolder(mPressedView);
|
||||
if (vh == null || vh.getItemViewType() != IRecyclerView.LOADING_VIEW || vh.getItemViewType() != IRecyclerView.FETCHING_VIEW) {
|
||||
mPressedView.setPressed(false);
|
||||
}
|
||||
mPressedView = null;
|
||||
}
|
||||
mIsShowPress = false;
|
||||
mIsPrepressed = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
|
||||
if (!shouldDetectGesture()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mGestureDetector.onTouchEvent(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||
}
|
||||
|
||||
private class ItemTouchHelperGestureListener extends GestureDetector.SimpleOnGestureListener {
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
public ItemTouchHelperGestureListener(RecyclerView recyclerView) {
|
||||
this.recyclerView = recyclerView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDown(MotionEvent e) {
|
||||
if (!shouldDetectGesture()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mIsPrepressed = true;
|
||||
mPressedView = recyclerView.findChildViewUnder(e.getX(), e.getY());
|
||||
|
||||
super.onDown(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowPress(MotionEvent e) {
|
||||
if (!shouldDetectGesture()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsPrepressed && mPressedView != null) {
|
||||
// mPressedView.setPressed(true);
|
||||
mIsShowPress = true;
|
||||
}
|
||||
super.onShowPress(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
if (!shouldDetectGesture()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mIsPrepressed && mPressedView != null) {
|
||||
final View pressedView = mPressedView;
|
||||
BaseMsgViewHolder vh = (BaseMsgViewHolder) recyclerView.getChildViewHolder(pressedView);
|
||||
|
||||
if (isHeaderOrFooterPosition(vh.getLayoutPosition())) {
|
||||
return false;
|
||||
}
|
||||
childClickViewIds = vh.getChildClickViewIds();
|
||||
|
||||
if (childClickViewIds != null && childClickViewIds.size() > 0) {
|
||||
for (Iterator it = childClickViewIds.iterator(); it.hasNext(); ) {
|
||||
View childView = pressedView.findViewById((Integer) it.next());
|
||||
if (inRangeOfView(childView, e) && childView.isEnabled()) {
|
||||
setPressViewHotSpot(e, childView);
|
||||
childView.setPressed(true);
|
||||
onItemChildClick(baseAdapter, childView, vh.getLayoutPosition() - baseAdapter.getHeaderLayoutCount());
|
||||
resetPressedView(childView);
|
||||
return true;
|
||||
} else {
|
||||
childView.setPressed(false);
|
||||
}
|
||||
}
|
||||
setPressViewHotSpot(e, pressedView);
|
||||
mPressedView.setPressed(true);
|
||||
for (Iterator it = childClickViewIds.iterator(); it.hasNext(); ) {
|
||||
View childView = pressedView.findViewById((Integer) it.next());
|
||||
childView.setPressed(false);
|
||||
}
|
||||
onItemClick(baseAdapter, pressedView, vh.getLayoutPosition() - baseAdapter.getHeaderLayoutCount());
|
||||
} else {
|
||||
setPressViewHotSpot(e, pressedView);
|
||||
mPressedView.setPressed(true);
|
||||
for (Iterator it = childClickViewIds.iterator(); it.hasNext(); ) {
|
||||
View childView = pressedView.findViewById((Integer) it.next());
|
||||
childView.setPressed(false);
|
||||
}
|
||||
onItemClick(baseAdapter, pressedView, vh.getLayoutPosition() - baseAdapter.getHeaderLayoutCount());
|
||||
}
|
||||
resetPressedView(pressedView);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent e) {
|
||||
if (!shouldDetectGesture()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isChildLongClick = false;
|
||||
if (mIsPrepressed && mPressedView != null) {
|
||||
mPressedView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||
BaseMsgViewHolder vh = (BaseMsgViewHolder) recyclerView.getChildViewHolder(mPressedView);
|
||||
if (!isHeaderOrFooterPosition(vh.getLayoutPosition())) {
|
||||
longClickViewIds = vh.getItemChildLongClickViewIds();
|
||||
if (longClickViewIds != null && longClickViewIds.size() > 0) {
|
||||
for (Iterator it = longClickViewIds.iterator(); it.hasNext(); ) {
|
||||
View childView = mPressedView.findViewById((Integer) it.next());
|
||||
if (inRangeOfView(childView, e) && childView.isEnabled()) {
|
||||
setPressViewHotSpot(e, childView);
|
||||
onItemChildLongClick(baseAdapter, childView, vh.getLayoutPosition() - baseAdapter.getHeaderLayoutCount());
|
||||
childView.setPressed(true);
|
||||
mIsShowPress = true;
|
||||
isChildLongClick = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isChildLongClick) {
|
||||
onItemLongClick(baseAdapter, mPressedView, vh.getLayoutPosition() - baseAdapter.getHeaderLayoutCount());
|
||||
setPressViewHotSpot(e, mPressedView);
|
||||
mPressedView.setPressed(true);
|
||||
for (Iterator it = longClickViewIds.iterator(); it.hasNext(); ) {
|
||||
View childView = mPressedView.findViewById((Integer) it.next());
|
||||
childView.setPressed(false);
|
||||
}
|
||||
mIsShowPress = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final void resetPressedView(final View pressedView) {
|
||||
if (pressedView != null) {
|
||||
pressedView.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (pressedView != null) {
|
||||
pressedView.setPressed(false);
|
||||
}
|
||||
}
|
||||
}, longClickDelta);
|
||||
}
|
||||
|
||||
mIsPrepressed = false;
|
||||
mPressedView = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void setPressViewHotSpot(final MotionEvent e, final View mPressedView) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
/**
|
||||
* when click Outside the region ,mPressedView is null
|
||||
*/
|
||||
if (mPressedView != null && mPressedView.getBackground() != null) {
|
||||
mPressedView.getBackground().setHotspot(e.getRawX(), e.getY() - mPressedView.getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback method to be invoked when an item in this AdapterView has
|
||||
* been clicked.
|
||||
*
|
||||
* @param view The view within the AdapterView that was clicked (this
|
||||
* will be a view provided by the adapter)
|
||||
* @param position The position of the view in the adapter.
|
||||
*/
|
||||
public abstract void onItemClick(T adapter, View view, int position);
|
||||
|
||||
/**
|
||||
* callback method to be invoked when an item in this view has been
|
||||
* click and held
|
||||
*
|
||||
* @param view The view whihin the AbsListView that was clicked
|
||||
* @param position The position of the view int the adapter
|
||||
* @return true if the callback consumed the long click ,false otherwise
|
||||
*/
|
||||
public abstract void onItemLongClick(T adapter, View view, int position);
|
||||
|
||||
public abstract void onItemChildClick(T adapter, View view, int position);
|
||||
|
||||
public abstract void onItemChildLongClick(T adapter, View view, int position);
|
||||
|
||||
public boolean inRangeOfView(View view, MotionEvent ev) {
|
||||
int[] location = new int[2];
|
||||
if (view.getVisibility() != View.VISIBLE) {
|
||||
return false;
|
||||
}
|
||||
view.getLocationOnScreen(location);
|
||||
int x = location[0];
|
||||
int y = location[1];
|
||||
if (ev.getRawX() < x
|
||||
|| ev.getRawX() > (x + view.getWidth())
|
||||
|| ev.getRawY() < y
|
||||
|| ev.getRawY() > (y + view.getHeight())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isHeaderOrFooterPosition(int position) {
|
||||
/**
|
||||
* have a headview and EMPTY_VIEW FOOTER_VIEW LOADING_VIEW
|
||||
*/
|
||||
if (baseAdapter == null) {
|
||||
if (recyclerView != null) {
|
||||
baseAdapter = (T) recyclerView.getAdapter();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int type = baseAdapter.getItemViewType(position);
|
||||
return (type == IRecyclerView.EMPTY_VIEW || type == IRecyclerView.HEADER_VIEW || type == IRecyclerView.FOOTER_VIEW
|
||||
|| type == IRecyclerView.LOADING_VIEW || type == IRecyclerView.FETCHING_VIEW);
|
||||
}
|
||||
|
||||
public void setShouldDetectGesture(boolean shouldDetectGesture) {
|
||||
this.shouldDetectGesture = shouldDetectGesture;
|
||||
}
|
||||
|
||||
private boolean shouldDetectGesture() {
|
||||
if (!shouldDetectGesture) {
|
||||
mIsPrepressed = false;
|
||||
mPressedView = null;
|
||||
}
|
||||
|
||||
return shouldDetectGesture;
|
||||
}
|
||||
|
||||
public void setLongClickDelta(int longClickDelta) {
|
||||
if (longClickDelta <= 0 || longClickDelta > 2000) {
|
||||
longClickDelta = 200;
|
||||
}
|
||||
|
||||
this.longClickDelta = longClickDelta;
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg;
|
||||
|
||||
import com.chwl.app.R;
|
||||
|
||||
public final class SimpleLoadMoreView extends LoadMoreView {
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.nim_simple_load_more;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLoadingViewId() {
|
||||
return R.id.load_more_loading_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLoadFailViewId() {
|
||||
return R.id.load_more_load_fail_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLoadEndViewId() {
|
||||
return R.id.load_more_load_end_view;
|
||||
}
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.business.session.emoji.MoonUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMultiItemFetchLoadAdapter;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.public_chat_hall.attachment.AitFriendsAttachment;
|
||||
import com.chwl.core.public_chat_hall.bean.AitFriendsInfo;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ChatRoomMsgViewHolderAitFriends extends ChatRoomMsgViewHolderBase {
|
||||
|
||||
private static final String TAG = "ChatRoomMsgViewHolderAi";
|
||||
|
||||
private TextView aitMessageView;
|
||||
|
||||
public ChatRoomMsgViewHolderAitFriends(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.view_holder_public_chat_hall_ait_friends;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
aitMessageView = findViewById(R.id.nim_message_item_text_body);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
aitMessageView.setTextColor(isReceivedMessage() ?
|
||||
ContextCompat.getColor(context, R.color.color_1A1A1A) :
|
||||
ContextCompat.getColor(context, R.color.color_white));
|
||||
AitFriendsAttachment attachment = (AitFriendsAttachment) message.getAttachment();
|
||||
AitFriendsInfo aitFriendsInfo = attachment.getAitFriendsInfo();
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder(aitFriendsInfo.getContent());
|
||||
if (aitFriendsInfo.getAtUids() != null && aitFriendsInfo.getAtNames() != null) {
|
||||
for (int i = 0; i < aitFriendsInfo.getAtUids().size(); i++) {
|
||||
String name = aitFriendsInfo.getAtNames().get(i);
|
||||
String uid = aitFriendsInfo.getAtUids().get(i);
|
||||
// 只有当被 @ 人的数组中包含自己的时候才会去变色
|
||||
if (Objects.equals(uid, String.valueOf(AuthModel.get().getCurrentUid()))) {
|
||||
Pattern pattern = Pattern.compile(Pattern.quote("@" + name));
|
||||
Matcher matcher = pattern.matcher(aitFriendsInfo.getContent());
|
||||
while (matcher.find()) {
|
||||
int start = matcher.start();
|
||||
int end = matcher.end();
|
||||
builder.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_FF3D56)),
|
||||
start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 解析表情
|
||||
MoonUtil.replaceEmoticons(NimUIKit.getContext(), aitFriendsInfo.getContent(), builder);
|
||||
aitMessageView.setText(builder);
|
||||
aitMessageView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
aitMessageView.setOnLongClickListener(longClickListener);
|
||||
}
|
||||
}
|
@@ -1,482 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.common.ui.imageview.HeadImageView;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.netease.nim.uikit.impl.NimUIKitImpl;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.msg.MsgService;
|
||||
import com.netease.nimlib.sdk.msg.attachment.FileAttachment;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.adapter.PublicChatHallMsgAdapter;
|
||||
import com.chwl.app.public_chat_hall.event.PublicChatHallAvatarClickEvent;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMultiItemFetchLoadAdapter;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMsgViewHolder;
|
||||
import com.chwl.app.public_chat_hall.msg.RecyclerViewHolder;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.core.level.UserLevelResourceType;
|
||||
import com.chwl.core.noble.NobleResourceType;
|
||||
import com.chwl.core.noble.NobleUtil;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.utils.StringFormatUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 会话窗口消息列表项的ViewHolder基类,负责每个消息项的外层框架,包括头像,昵称,发送/接收进度条,重发按钮等。<br>
|
||||
* 具体的消息展示项可继承该基类,然后完成具体消息内容展示即可。
|
||||
*/
|
||||
public abstract class ChatRoomMsgViewHolderBase extends RecyclerViewHolder<BaseMultiItemFetchLoadAdapter,
|
||||
BaseMsgViewHolder, ChatRoomMessage> {
|
||||
|
||||
public ChatRoomMsgViewHolderBase(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
// basic
|
||||
protected View view;
|
||||
protected Context context;
|
||||
protected BaseMultiItemFetchLoadAdapter adapter;
|
||||
|
||||
// data
|
||||
protected ChatRoomMessage message;
|
||||
|
||||
// view
|
||||
protected View alertButton;
|
||||
protected TextView timeTextView;
|
||||
protected ProgressBar progressBar;
|
||||
protected TextView nameTextView;
|
||||
protected FrameLayout contentContainer;
|
||||
protected LinearLayout nameContainer;
|
||||
protected TextView readReceiptTextView;
|
||||
|
||||
private HeadImageView avatarLeft;
|
||||
private HeadImageView avatarRight;
|
||||
|
||||
public ImageView nameIconView;
|
||||
public ImageView nobleIconView;
|
||||
public ImageView expIconView;
|
||||
public ImageView charmIconView;
|
||||
public ImageView officialIconView;
|
||||
public ImageView newUserIconView;
|
||||
public ImageView prettyIconView;
|
||||
|
||||
public View inOfficialMask;
|
||||
public TextView tvOfficialMask;
|
||||
public ImageView ivOfficialMask;
|
||||
|
||||
// contentContainerView的默认长按事件。如果子类需要不同的处理,可覆盖onItemLongClick方法
|
||||
// 但如果某些子控件会拦截触摸消息,导致contentContainer收不到长按事件,子控件也可在inflate时重新设置
|
||||
protected View.OnLongClickListener longClickListener;
|
||||
|
||||
/// -- 以下接口可由子类覆盖或实现
|
||||
// 返回具体消息类型内容展示区域的layout res id
|
||||
abstract protected int getContentResId();
|
||||
|
||||
// 在该接口中根据layout对各控件成员变量赋值
|
||||
abstract protected void inflateContentView();
|
||||
|
||||
// 将消息数据项与内容的view进行绑定
|
||||
abstract protected void bindContentView();
|
||||
|
||||
// 在该接口操作BaseViewHolder中的数据,进行事件绑定,可选
|
||||
protected void bindHolder(BaseMsgViewHolder holder) {
|
||||
|
||||
}
|
||||
|
||||
// 内容区域点击事件响应处理。
|
||||
protected void onItemClick() {
|
||||
}
|
||||
|
||||
// 内容区域长按事件响应处理。该接口的优先级比adapter中有长按事件的处理监听高,当该接口返回为true时,adapter的长按事件监听不会被调用到。
|
||||
protected boolean onItemLongClick() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 当是接收到的消息时,内容区域背景的drawable id
|
||||
protected int leftBackground() {
|
||||
// return R.drawable.shape_round_white_5dp_padding_13dp;
|
||||
return R.drawable.bg_nim_water_drop_other;
|
||||
}
|
||||
|
||||
// 当是发送出去的消息时,内容区域背景的drawable id
|
||||
protected int rightBackground() {
|
||||
// return R.drawable.shape_round_color_ff9976_radius_5dp_padding_13dp;
|
||||
return R.drawable.bg_ap_water_drop_self;
|
||||
}
|
||||
|
||||
// 返回该消息是不是居中显示
|
||||
protected boolean isMiddleItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 是否显示头像,默认为显示
|
||||
protected boolean isShowHeadImage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 是否显示气泡背景,默认为显示
|
||||
protected boolean isShowBubble() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 是否显示昵称
|
||||
protected boolean shouldDisplayNick() {
|
||||
return !isMiddleItem();
|
||||
}
|
||||
|
||||
/// -- 以下接口可由子类调用
|
||||
protected final PublicChatHallMsgAdapter getMsgAdapter() {
|
||||
return (PublicChatHallMsgAdapter) adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载附件/缩略图
|
||||
*/
|
||||
protected void downloadAttachment() {
|
||||
if (message.getAttachment() != null && message.getAttachment() instanceof FileAttachment)
|
||||
NIMClient.getService(MsgService.class).downloadAttachment(message, true);
|
||||
}
|
||||
|
||||
// 设置FrameLayout子控件的gravity参数
|
||||
protected final void setGravity(View view, int gravity) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) view.getLayoutParams();
|
||||
params.gravity = gravity;
|
||||
}
|
||||
|
||||
// 设置控件的长宽
|
||||
protected void setLayoutParams(int width, int height, View... views) {
|
||||
for (View view : views) {
|
||||
ViewGroup.LayoutParams maskParams = view.getLayoutParams();
|
||||
maskParams.width = width;
|
||||
maskParams.height = height;
|
||||
view.setLayoutParams(maskParams);
|
||||
}
|
||||
}
|
||||
|
||||
// 根据layout id查找对应的控件
|
||||
protected <T extends View> T findViewById(int id) {
|
||||
return (T) view.findViewById(id);
|
||||
}
|
||||
|
||||
// 判断消息方向,是否是接收到的消息
|
||||
protected boolean isReceivedMessage() {
|
||||
return message.getDirect() == MsgDirectionEnum.In;
|
||||
}
|
||||
|
||||
/// -- 以下是基类实现代码
|
||||
@Override
|
||||
public void convert(BaseMsgViewHolder holder, ChatRoomMessage data, int position, boolean isScrolling) {
|
||||
view = holder.getConvertView();
|
||||
context = holder.getContext();
|
||||
message = data;
|
||||
|
||||
inflate();
|
||||
refresh();
|
||||
bindHolder(holder);
|
||||
}
|
||||
|
||||
protected final void inflate() {
|
||||
timeTextView = findViewById(R.id.message_item_time);
|
||||
avatarLeft = findViewById(R.id.message_item_portrait_left);
|
||||
avatarRight = findViewById(R.id.message_item_portrait_right);
|
||||
alertButton = findViewById(R.id.message_item_alert);
|
||||
progressBar = findViewById(R.id.message_item_progress);
|
||||
nameTextView = findViewById(R.id.message_item_nickname);
|
||||
contentContainer = findViewById(R.id.message_item_content);
|
||||
nameIconView = findViewById(R.id.message_item_name_icon);
|
||||
nameContainer = findViewById(R.id.message_item_name_layout);
|
||||
readReceiptTextView = findViewById(R.id.textViewAlreadyRead);
|
||||
nobleIconView = findViewById(R.id.message_item_name_icon_noble);
|
||||
expIconView = findViewById(R.id.message_item_name_icon_exp);
|
||||
charmIconView = findViewById(R.id.message_item_name_icon_charm);
|
||||
officialIconView = findViewById(R.id.message_item_name_icon_official);
|
||||
newUserIconView = findViewById(R.id.message_item_name_icon_new);
|
||||
prettyIconView = findViewById(R.id.message_item_name_icon_pretty);
|
||||
|
||||
inOfficialMask = findViewById(R.id.in_official_mask);
|
||||
if (inOfficialMask != null) {
|
||||
tvOfficialMask = inOfficialMask.findViewById(R.id.tv_official_mask);
|
||||
ivOfficialMask = inOfficialMask.findViewById(R.id.iv_official_mask);
|
||||
}
|
||||
|
||||
// 这里只要inflate出来后加入一次即可
|
||||
if (contentContainer.getChildCount() == 0) {
|
||||
View.inflate(view.getContext(), getContentResId(), contentContainer);
|
||||
}
|
||||
inflateContentView();
|
||||
}
|
||||
|
||||
protected final void refresh() {
|
||||
setHeadImageView();
|
||||
setNameTextView();
|
||||
setTimeTextView();
|
||||
setStatus();
|
||||
setOnClickListener();
|
||||
setLongClickListener();
|
||||
setContent();
|
||||
|
||||
bindContentView();
|
||||
}
|
||||
|
||||
public void refreshCurrentItem() {
|
||||
if (message != null) {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置时间显示
|
||||
*/
|
||||
private void setTimeTextView() {
|
||||
if (getMsgAdapter().needShowTime(message)) {
|
||||
timeTextView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
timeTextView.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
String text = getMsgAdapter().getMessageTime(message);
|
||||
timeTextView.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置消息发送状态
|
||||
*/
|
||||
private void setStatus() {
|
||||
MsgStatusEnum status = message.getStatus();
|
||||
switch (status) {
|
||||
case fail:
|
||||
progressBar.setVisibility(View.GONE);
|
||||
alertButton.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case sending:
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
alertButton.setVisibility(View.GONE);
|
||||
break;
|
||||
default:
|
||||
progressBar.setVisibility(View.GONE);
|
||||
alertButton.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void setHeadImageView() {
|
||||
HeadImageView show = isReceivedMessage() ? avatarLeft : avatarRight;
|
||||
HeadImageView hide = isReceivedMessage() ? avatarRight : avatarLeft;
|
||||
hide.setVisibility(View.GONE);
|
||||
if (!isShowHeadImage()) {
|
||||
show.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (isMiddleItem()) {
|
||||
show.setVisibility(View.GONE);
|
||||
} else {
|
||||
show.setVisibility(View.VISIBLE);
|
||||
show.loadBuddyAvatar(message.getFromAccount());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setOnClickListener() {
|
||||
// 重发/重收按钮响应事件
|
||||
if (getMsgAdapter().getEventListener() != null) {
|
||||
alertButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getMsgAdapter().getEventListener().onFailedBtnClick(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 内容区域点击事件响应, 相当于点击了整项
|
||||
contentContainer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onItemClick();
|
||||
}
|
||||
});
|
||||
|
||||
// 头像点击事件响应
|
||||
if (NimUIKitImpl.getSessionListener() != null) {
|
||||
View.OnClickListener portraitListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
EventBus.getDefault().post(new PublicChatHallAvatarClickEvent()
|
||||
.setContext(context)
|
||||
.setMessage(message));
|
||||
}
|
||||
};
|
||||
avatarLeft.setOnClickListener(portraitListener);
|
||||
avatarRight.setOnClickListener(portraitListener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* item长按事件监听
|
||||
*/
|
||||
private void setLongClickListener() {
|
||||
longClickListener = new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
// 优先派发给自己处理,
|
||||
if (!onItemLongClick()) {
|
||||
if (getMsgAdapter().getEventListener() != null) {
|
||||
getMsgAdapter().getEventListener().onViewHolderLongClick(contentContainer, view, message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
// 消息长按事件响应处理
|
||||
contentContainer.setOnLongClickListener(longClickListener);
|
||||
|
||||
// 头像长按事件响应处理
|
||||
if (NimUIKitImpl.getSessionListener() != null) {
|
||||
View.OnLongClickListener longClickListener = new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
NimUIKitImpl.getSessionListener().onAvatarLongClicked(context, message);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
avatarLeft.setOnLongClickListener(longClickListener);
|
||||
avatarRight.setOnLongClickListener(longClickListener);
|
||||
}
|
||||
}
|
||||
|
||||
private void setNameTextView() {
|
||||
if (!shouldDisplayNick()) {
|
||||
nameTextView.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
nameContainer.setPadding(ScreenUtil.dip2px(6), 0, 0, 0);
|
||||
expIconView.setVisibility(View.GONE);
|
||||
charmIconView.setVisibility(View.GONE);
|
||||
nobleIconView.setVisibility(View.GONE);
|
||||
newUserIconView.setVisibility(View.GONE);
|
||||
officialIconView.setVisibility(View.GONE);
|
||||
prettyIconView.setVisibility(View.GONE);
|
||||
nameTextView.setVisibility(View.VISIBLE);
|
||||
nameTextView.setText(getNameText());
|
||||
inOfficialMask.setVisibility(View.GONE);
|
||||
setStyleOfNameTextView(nameTextView, nameIconView);
|
||||
Map<String, Object> remoteExtension = message.getRemoteExtension();
|
||||
if (remoteExtension != null && remoteExtension.get(message.getFromAccount()) != null) {
|
||||
Map<String, Object> map = (Map<String, Object>) remoteExtension.get(message.getFromAccount());
|
||||
if (map.get(UserLevelResourceType.EXPER_URL) != null) {
|
||||
String expUrl = String.valueOf(map.get(UserLevelResourceType.EXPER_URL));
|
||||
ImageLoadUtils.loadImage(context, expUrl, expIconView);
|
||||
expIconView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (map.get(UserLevelResourceType.CHARM_URL) != null) {
|
||||
String charmUrl = String.valueOf(map.get(UserLevelResourceType.CHARM_URL));
|
||||
ImageLoadUtils.loadImage(context, charmUrl, charmIconView);
|
||||
charmIconView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (map.get(NobleResourceType.KEY_LEVEL) != null) {
|
||||
String badgeUrl = "";
|
||||
if (map.get(NobleResourceType.KEY_LEVEL) instanceof Integer) {
|
||||
badgeUrl = NobleUtil.getBadgeByLevel((Integer) map.get(NobleResourceType.KEY_LEVEL));
|
||||
} else if (map.get(NobleResourceType.KEY_LEVEL) instanceof String) {
|
||||
badgeUrl = NobleUtil.getBadgeByLevel(Integer.parseInt((String) map.get(NobleResourceType.KEY_LEVEL)));
|
||||
}
|
||||
NobleUtil.loadResource(badgeUrl, nobleIconView);
|
||||
nobleIconView.setVisibility(StringFormatUtils.isEmpty(badgeUrl) ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
if (map.get(UserInfo.IS_OFFICIAL) != null) {
|
||||
boolean isOfficial = (boolean) map.get(UserInfo.IS_OFFICIAL);
|
||||
officialIconView.setVisibility(isOfficial ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
if (map.get(UserInfo.IS_NEW_USER) != null) {
|
||||
boolean isOfficial = (boolean) map.get(UserInfo.IS_NEW_USER);
|
||||
newUserIconView.setVisibility(isOfficial ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
if (map.get(UserInfo.DEF_USER) != null) {
|
||||
int isOfficial = (int) map.get(UserInfo.DEF_USER);
|
||||
officialIconView.setVisibility(isOfficial == UserInfo.USER_TYPE_OFFICIAL ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
if (map.get(UserInfo.HAS_PRETTY) != null) {
|
||||
boolean isOfficial = (boolean) map.get(UserInfo.HAS_PRETTY);
|
||||
prettyIconView.setVisibility(isOfficial ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
String oacName = (String) map.get(UserInfo.OAC_NAME);
|
||||
String oacIcon = (String) map.get(UserInfo.OAC_ICON);
|
||||
if (!TextUtils.isEmpty(oacName) && !TextUtils.isEmpty(oacIcon)) {
|
||||
inOfficialMask.setVisibility(View.VISIBLE);
|
||||
if (tvOfficialMask != null) {
|
||||
tvOfficialMask.setText(oacName);
|
||||
}
|
||||
|
||||
if (ivOfficialMask != null) {
|
||||
NobleUtil.loadResource(oacIcon, ivOfficialMask);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String getNameText() {
|
||||
return ChatRoomViewHolderHelper.getNameText(message);
|
||||
}
|
||||
|
||||
protected void setStyleOfNameTextView(TextView nameTextView, ImageView nameIconView) {
|
||||
ChatRoomViewHolderHelper.setStyleOfNameTextView(message, nameTextView, nameIconView);
|
||||
}
|
||||
|
||||
private void setContent() {
|
||||
if (!isShowBubble() && !isMiddleItem()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LinearLayout bodyContainer = (LinearLayout) view.findViewById(R.id.message_item_body);
|
||||
|
||||
// 调整container的位置
|
||||
int index = isReceivedMessage() ? 0 : 3;
|
||||
if (bodyContainer.getChildAt(index) != contentContainer) {
|
||||
bodyContainer.removeView(contentContainer);
|
||||
bodyContainer.addView(contentContainer, index);
|
||||
}
|
||||
|
||||
if (isMiddleItem()) {
|
||||
setGravity(bodyContainer, Gravity.CENTER);
|
||||
} else {
|
||||
if (isReceivedMessage()) {
|
||||
setGravity(bodyContainer, Gravity.LEFT);
|
||||
contentContainer.setBackgroundResource(leftBackground());
|
||||
} else {
|
||||
setGravity(bodyContainer, Gravity.RIGHT);
|
||||
contentContainer.setBackgroundResource(rightBackground());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setReadReceipt() {
|
||||
if (!TextUtils.isEmpty(getMsgAdapter().getUuid()) && message.getUuid().equals(getMsgAdapter().getUuid())) {
|
||||
readReceiptTextView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
readReceiptTextView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,81 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
|
||||
import com.netease.nimlib.sdk.msg.attachment.ImageAttachment;
|
||||
import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.robot.model.RobotAttachment;
|
||||
import com.chwl.core.im.custom.bean.GiftAttachment;
|
||||
import com.chwl.core.im.custom.bean.ImTipAttachment;
|
||||
import com.chwl.core.public_chat_hall.attachment.AitFriendsAttachment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 聊天室消息项展示ViewHolder工厂类。
|
||||
*/
|
||||
public class ChatRoomMsgViewHolderFactory {
|
||||
|
||||
private static HashMap<Class<? extends MsgAttachment>, Class<? extends ChatRoomMsgViewHolderBase>> viewHolders =
|
||||
new HashMap<>();
|
||||
|
||||
static {
|
||||
// built in
|
||||
register(ChatRoomNotificationAttachment.class, ChatRoomMsgViewHolderNotification.class);
|
||||
register(RobotAttachment.class, ChatRoomMsgViewHolderRobot.class);
|
||||
register(ImageAttachment.class, ChatRoomMsgViewHolderPicture.class);
|
||||
// custom
|
||||
register(AitFriendsAttachment.class, ChatRoomMsgViewHolderAitFriends.class);
|
||||
register(GiftAttachment.class, ChatRoomMsgViewHolderGiftText.class);
|
||||
register(ImTipAttachment.class, ChatRoomMsgViewHolderTip.class);
|
||||
}
|
||||
|
||||
public static void register(Class<? extends MsgAttachment> attach, Class<? extends ChatRoomMsgViewHolderBase> viewHolder) {
|
||||
viewHolders.put(attach, viewHolder);
|
||||
}
|
||||
|
||||
public static Class<? extends ChatRoomMsgViewHolderBase> getViewHolderByType(ChatRoomMessage message) {
|
||||
if (message.getMsgType() == MsgTypeEnum.text) {
|
||||
return ChatRoomMsgViewHolderText.class;
|
||||
} else {
|
||||
Class<? extends ChatRoomMsgViewHolderBase> viewHolder = null;
|
||||
if (message.getAttachment() != null) {
|
||||
Class<? extends MsgAttachment> clazz = message.getAttachment().getClass();
|
||||
while (viewHolder == null && clazz != null) {
|
||||
viewHolder = viewHolders.get(clazz);
|
||||
if (viewHolder == null) {
|
||||
clazz = getSuperClass(clazz);
|
||||
}
|
||||
}
|
||||
}
|
||||
return viewHolder == null ? ChatRoomMsgViewHolderUnknown.class : viewHolder;
|
||||
}
|
||||
}
|
||||
|
||||
private static Class<? extends MsgAttachment> getSuperClass(Class<? extends MsgAttachment> derived) {
|
||||
Class sup = derived.getSuperclass();
|
||||
if (sup != null && MsgAttachment.class.isAssignableFrom(sup)) {
|
||||
return sup;
|
||||
} else {
|
||||
for (Class itf : derived.getInterfaces()) {
|
||||
if (MsgAttachment.class.isAssignableFrom(itf)) {
|
||||
return itf;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Class<? extends ChatRoomMsgViewHolderBase>> getAllViewHolders() {
|
||||
List<Class<? extends ChatRoomMsgViewHolderBase>> list = new ArrayList<>();
|
||||
list.addAll(viewHolders.values());
|
||||
list.add(ChatRoomMsgViewHolderUnknown.class);
|
||||
list.add(ChatRoomMsgViewHolderText.class);
|
||||
list.add(ChatRoomMsgViewHolderPicture.class);
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
@@ -1,81 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMultiItemFetchLoadAdapter;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.core.gift.GiftModel;
|
||||
import com.chwl.core.gift.bean.GiftInfo;
|
||||
import com.chwl.core.gift.bean.GiftReceiveInfo;
|
||||
import com.chwl.core.im.custom.bean.GiftAttachment;
|
||||
import com.chwl.core.public_chat_hall.event.PublicChatHallPlayGiftAnimationEvent;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
public class ChatRoomMsgViewHolderGiftText extends ChatRoomMsgViewHolderBase {
|
||||
|
||||
private TextView giftTitleView;
|
||||
private ImageView giftImageView;
|
||||
private TextView giftNumView;
|
||||
private GiftReceiveInfo giftReceiveInfo;
|
||||
|
||||
public ChatRoomMsgViewHolderGiftText(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.view_holder_public_chat_hall_gift_animation;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
giftTitleView = findViewById(R.id.tv_gift_title);
|
||||
giftImageView = findViewById(R.id.iv_gift_pic);
|
||||
giftNumView = findViewById(R.id.tv_gift_num);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
GiftAttachment attachment = (GiftAttachment) message.getAttachment();
|
||||
giftReceiveInfo = attachment.getGiftReceiveInfo();
|
||||
if (giftReceiveInfo == null) return;
|
||||
giftTitleView.setText(ResUtil.getString(R.string.msg_viewholder_chatroommsgviewholdergifttext_01) + giftReceiveInfo.getTargetNick());
|
||||
giftTitleView.setTextColor(isReceivedMessage() ?
|
||||
ContextCompat.getColor(context, R.color.color_1A1A1A) :
|
||||
ContextCompat.getColor(context, R.color.color_white));
|
||||
GiftInfo giftInfo = giftReceiveInfo.getGift();
|
||||
if (giftInfo == null) {
|
||||
giftInfo = GiftModel.get().findGiftInfoById(giftReceiveInfo.getGiftId());
|
||||
}
|
||||
if (giftInfo != null) {
|
||||
ImageLoadUtils.loadImage(context, giftInfo.getGiftUrl(), giftImageView);
|
||||
}
|
||||
giftNumView.setText("x" + String.valueOf(giftReceiveInfo.getGiftNum()));
|
||||
giftNumView.setTextColor(isReceivedMessage() ?
|
||||
ContextCompat.getColor(context, R.color.color_1A1A1A) :
|
||||
ContextCompat.getColor(context, R.color.color_white));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onItemClick() {
|
||||
super.onItemClick();
|
||||
if (giftReceiveInfo != null) {
|
||||
GiftInfo giftInfo = giftReceiveInfo.getGift();
|
||||
if (giftInfo == null) {
|
||||
giftInfo = GiftModel.get().findGiftInfoById(giftReceiveInfo.getGiftId());
|
||||
}
|
||||
// 要大于等于66钻石的时候才有动画效果
|
||||
if (giftInfo.getGoldPrice() * giftReceiveInfo.getGiftNum() >= 66) {
|
||||
EventBus.getDefault()
|
||||
.post(new PublicChatHallPlayGiftAnimationEvent()
|
||||
.setGiftReceiveInfo(giftReceiveInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.business.chatroom.helper.ChatRoomNotificationHelper;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMultiItemFetchLoadAdapter;
|
||||
|
||||
public class ChatRoomMsgViewHolderNotification extends ChatRoomMsgViewHolderBase {
|
||||
|
||||
protected TextView notificationTextView;
|
||||
|
||||
public ChatRoomMsgViewHolderNotification(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.nim_message_item_notification;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldDisplayNick() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
notificationTextView = (TextView) view.findViewById(R.id.message_item_notification_label);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
notificationTextView.setText(ChatRoomNotificationHelper.getNotificationText((ChatRoomNotificationAttachment) message.getAttachment()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isMiddleItem() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,27 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.business.session.activity.WatchMessagePictureActivity;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMultiItemFetchLoadAdapter;
|
||||
|
||||
public class ChatRoomMsgViewHolderPicture extends ChatRoomMsgViewHolderThumbBase {
|
||||
|
||||
public ChatRoomMsgViewHolderPicture(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.nim_message_item_picture;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onItemClick() {
|
||||
WatchMessagePictureActivity.start(context, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String thumbFromSourceFile(String path) {
|
||||
return path;
|
||||
}
|
||||
}
|
@@ -1,105 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.business.robot.model.RobotResponseContent;
|
||||
import com.netease.nim.uikit.business.session.viewholder.robot.RobotContentLinearLayout;
|
||||
import com.netease.nim.uikit.business.session.viewholder.robot.RobotLinkViewStyle;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.netease.nim.uikit.impl.NimUIKitImpl;
|
||||
import com.netease.nimlib.sdk.robot.model.NimRobotInfo;
|
||||
import com.netease.nimlib.sdk.robot.model.RobotAttachment;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMultiItemFetchLoadAdapter;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMsgViewHolder;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by hzchenkang on 2017/8/24.
|
||||
*/
|
||||
|
||||
public class ChatRoomMsgViewHolderRobot extends ChatRoomMsgViewHolderText implements RobotContentLinearLayout.ClickableChildView {
|
||||
|
||||
private android.widget.LinearLayout containerIn;
|
||||
private RobotContentLinearLayout robotContent;
|
||||
private TextView holderFooterButton;
|
||||
private Set<Integer> onClickIds;
|
||||
|
||||
|
||||
public ChatRoomMsgViewHolderRobot(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.nim_message_item_robot;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
containerIn = findViewById(R.id.robot_in);
|
||||
bodyTextView = containerIn.findViewById(R.id.nim_message_item_text_body);
|
||||
robotContent = findViewById(R.id.robot_out);
|
||||
int dp6 = ScreenUtil.dip2px(6);
|
||||
robotContent.setPadding(dp6, 0, 0, 0);
|
||||
RobotLinkViewStyle linkStyle = new RobotLinkViewStyle();
|
||||
linkStyle.setRobotTextColor(R.color.black);
|
||||
linkStyle.setBackground(R.drawable.nim_chatroom_robot_link_view_selector);
|
||||
robotContent.setLinkStyle(linkStyle);
|
||||
holderFooterButton = findViewById(R.id.tv_robot_session_continue);
|
||||
holderFooterButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (getMsgAdapter().getEventListener() != null) {
|
||||
getMsgAdapter().getEventListener().onFooterClick(ChatRoomMsgViewHolderRobot.this, ChatRoomMsgViewHolderRobot.this.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
onClickIds = new HashSet<>(); // for child to add
|
||||
RobotAttachment attachment = (RobotAttachment) message.getAttachment();
|
||||
|
||||
if (attachment.isRobotSend()) {
|
||||
// 下行
|
||||
containerIn.setVisibility(View.GONE);
|
||||
robotContent.setVisibility(View.VISIBLE);
|
||||
holderFooterButton.setVisibility(View.VISIBLE);
|
||||
nameIconView.setVisibility(View.GONE);
|
||||
NimRobotInfo robotInfo = NimUIKitImpl.getRobotInfoProvider().getRobotByAccount(attachment.getFromRobotAccount());
|
||||
if (robotInfo != null) {
|
||||
nameTextView.setText(robotInfo.getName());
|
||||
} else {
|
||||
nameTextView.setText(attachment.getFromRobotAccount());
|
||||
}
|
||||
|
||||
robotContent.bindContentView(this, new RobotResponseContent(attachment.getResponse()));
|
||||
} else {
|
||||
// 上行
|
||||
containerIn.setVisibility(View.VISIBLE);
|
||||
robotContent.setVisibility(View.GONE);
|
||||
holderFooterButton.setVisibility(View.GONE);
|
||||
super.bindContentView();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindHolder(BaseMsgViewHolder holder) {
|
||||
holder.getChildClickViewIds().clear();
|
||||
for (int id : onClickIds) {
|
||||
holder.addOnClickListener(id);
|
||||
}
|
||||
|
||||
onClickIds.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClickableChildView(Class<? extends View> clazz, int id) {
|
||||
onClickIds.add(id);
|
||||
}
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.business.session.emoji.MoonUtil;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMultiItemFetchLoadAdapter;
|
||||
|
||||
/**
|
||||
* Created by hzxuwen on 2016/1/18.
|
||||
*/
|
||||
public class ChatRoomMsgViewHolderText extends ChatRoomMsgViewHolderBase {
|
||||
|
||||
protected TextView bodyTextView;
|
||||
|
||||
|
||||
public ChatRoomMsgViewHolderText(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.nim_message_item_text;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
bodyTextView = findViewById(R.id.nim_message_item_text_body);
|
||||
}
|
||||
|
||||
protected String getDisplayText() {
|
||||
return message.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
bodyTextView.setTextColor(isReceivedMessage() ?
|
||||
ContextCompat.getColor(context, R.color.color_1A1A1A) :
|
||||
ContextCompat.getColor(context, R.color.color_white));
|
||||
bodyTextView.setPadding(ScreenUtil.dip2px(6), 0, 0, 0);
|
||||
MoonUtil.identifyFaceExpression(NimUIKit.getContext(), bodyTextView, getDisplayText(), ImageSpan.ALIGN_BOTTOM);
|
||||
bodyTextView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
bodyTextView.setOnLongClickListener(longClickListener);
|
||||
}
|
||||
}
|
@@ -1,138 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.common.ui.imageview.MsgThumbImageView;
|
||||
import com.netease.nim.uikit.common.util.media.BitmapDecoder;
|
||||
import com.netease.nim.uikit.common.util.media.ImageUtil;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.netease.nimlib.sdk.msg.attachment.FileAttachment;
|
||||
import com.netease.nimlib.sdk.msg.attachment.ImageAttachment;
|
||||
import com.netease.nimlib.sdk.msg.attachment.VideoAttachment;
|
||||
import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMultiItemFetchLoadAdapter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class ChatRoomMsgViewHolderThumbBase extends ChatRoomMsgViewHolderBase {
|
||||
|
||||
public ChatRoomMsgViewHolderThumbBase(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
protected MsgThumbImageView thumbnail;
|
||||
protected View progressCover;
|
||||
protected TextView progressLabel;
|
||||
|
||||
@Override
|
||||
protected boolean isShowBubble() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isShowHeadImage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
thumbnail = findViewById(R.id.message_item_thumb_thumbnail);
|
||||
progressBar = findViewById(R.id.message_item_thumb_progress_bar); // 覆盖掉
|
||||
progressCover = findViewById(R.id.message_item_thumb_progress_cover);
|
||||
progressLabel = findViewById(R.id.message_item_thumb_progress_text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
FileAttachment msgAttachment = (FileAttachment) message.getAttachment();
|
||||
String path = msgAttachment.getPath();
|
||||
String thumbPath = msgAttachment.getThumbPath();
|
||||
if (!TextUtils.isEmpty(thumbPath)) {
|
||||
loadThumbnailImage(thumbPath, false, msgAttachment.getExtension());
|
||||
} else if (!TextUtils.isEmpty(path)) {
|
||||
loadThumbnailImage(thumbFromSourceFile(path), true, msgAttachment.getExtension());
|
||||
} else {
|
||||
loadThumbnailImage(null, false, msgAttachment.getExtension());
|
||||
if (message.getAttachStatus() == AttachStatusEnum.transferred
|
||||
|| message.getAttachStatus() == AttachStatusEnum.def) {
|
||||
downloadAttachment();
|
||||
}
|
||||
}
|
||||
|
||||
refreshStatus();
|
||||
}
|
||||
|
||||
private void refreshStatus() {
|
||||
FileAttachment attachment = (FileAttachment) message.getAttachment();
|
||||
if (TextUtils.isEmpty(attachment.getPath()) && TextUtils.isEmpty(attachment.getThumbPath())) {
|
||||
if (message.getAttachStatus() == AttachStatusEnum.fail || message.getStatus() == MsgStatusEnum.fail) {
|
||||
alertButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
alertButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (message.getStatus() == MsgStatusEnum.sending
|
||||
|| (isReceivedMessage() && message.getAttachStatus() == AttachStatusEnum.transferring)) {
|
||||
progressCover.setVisibility(View.VISIBLE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressLabel.setVisibility(View.VISIBLE);
|
||||
progressLabel.setText(StringUtil.getPercentString(getMsgAdapter().getProgress(message)));
|
||||
} else {
|
||||
progressCover.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
progressLabel.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadThumbnailImage(String path, boolean isOriginal, String ext) {
|
||||
setImageSize(path);
|
||||
if (path != null) {
|
||||
//thumbnail.loadAsPath(thumbPath, getImageMaxEdge(), getImageMaxEdge(), maskBg());
|
||||
thumbnail.loadAsPath(path, getImageMaxEdge(), getImageMaxEdge(), maskBg(), ext);
|
||||
} else {
|
||||
thumbnail.loadAsResource(R.drawable.nim_image_default, maskBg());
|
||||
}
|
||||
}
|
||||
|
||||
private void setImageSize(String thumbPath) {
|
||||
int[] bounds = null;
|
||||
if (thumbPath != null) {
|
||||
bounds = BitmapDecoder.decodeBound(new File(thumbPath));
|
||||
}
|
||||
if (bounds == null) {
|
||||
if (message.getMsgType() == MsgTypeEnum.image) {
|
||||
ImageAttachment attachment = (ImageAttachment) message.getAttachment();
|
||||
bounds = new int[]{attachment.getWidth(), attachment.getHeight()};
|
||||
} else if (message.getMsgType() == MsgTypeEnum.video) {
|
||||
VideoAttachment attachment = (VideoAttachment) message.getAttachment();
|
||||
bounds = new int[]{attachment.getWidth(), attachment.getHeight()};
|
||||
}
|
||||
}
|
||||
|
||||
if (bounds != null) {
|
||||
ImageUtil.ImageSize imageSize = ImageUtil.getThumbnailDisplaySize(bounds[0], bounds[1], getImageMaxEdge(), getImageMinEdge());
|
||||
setLayoutParams(imageSize.width, imageSize.height, thumbnail);
|
||||
}
|
||||
}
|
||||
|
||||
private int maskBg() {
|
||||
return R.drawable.nim_message_item_round_bg;
|
||||
}
|
||||
|
||||
public static int getImageMaxEdge() {
|
||||
return (int) (165.0 / 320.0 * ScreenUtil.screenWidth);
|
||||
}
|
||||
|
||||
public static int getImageMinEdge() {
|
||||
return (int) (76.0 / 320.0 * ScreenUtil.screenWidth);
|
||||
}
|
||||
|
||||
protected abstract String thumbFromSourceFile(String path);
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.databinding.ItemImTipsBinding;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMultiItemFetchLoadAdapter;
|
||||
import com.chwl.core.im.custom.bean.ImTipAttachment;
|
||||
|
||||
public class ChatRoomMsgViewHolderTip extends ChatRoomMsgViewHolderBase {
|
||||
|
||||
private ItemImTipsBinding mBinding;
|
||||
|
||||
public ChatRoomMsgViewHolderTip(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.item_im_tips;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isMiddleItem() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
mBinding = DataBindingUtil.bind(findViewById(R.id.root));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
ImTipAttachment attachment = (ImTipAttachment) message.getAttachment();
|
||||
if (attachment != null) {
|
||||
mBinding.tvTips.setText(attachment.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||
import com.chwl.app.public_chat_hall.msg.BaseMultiItemFetchLoadAdapter;
|
||||
|
||||
/**
|
||||
* Created by huangjun on 2016/12/27.
|
||||
*/
|
||||
public class ChatRoomMsgViewHolderUnknown extends ChatRoomMsgViewHolderBase {
|
||||
|
||||
public ChatRoomMsgViewHolderUnknown(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.nim_message_item_unknown;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isShowHeadImage() {
|
||||
if (message.getSessionType() == SessionTypeEnum.ChatRoom) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.msg.viewholder;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.business.chatroom.helper.ChatRoomHelper;
|
||||
import com.netease.nim.uikit.business.uinfo.UserInfoHelper;
|
||||
import com.netease.nim.uikit.impl.NimUIKitImpl;
|
||||
import com.netease.nimlib.sdk.chatroom.constant.MemberType;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
|
||||
|
||||
/**
|
||||
* 聊天室成员姓名
|
||||
* Created by hzxuwen on 2016/1/20.
|
||||
*/
|
||||
public class ChatRoomViewHolderHelper {
|
||||
|
||||
public static String getNameText(ChatRoomMessage message) {
|
||||
// 聊天室中显示姓名
|
||||
if (message.getChatRoomMessageExtension() != null) {
|
||||
return message.getChatRoomMessageExtension().getSenderNick();
|
||||
} else {
|
||||
ChatRoomMember member = NimUIKitImpl.getChatRoomProvider().getChatRoomMember(message.getSessionId(), message.getFromAccount());
|
||||
return member == null ? UserInfoHelper.getUserName(message.getFromAccount()) : member.getNick();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setStyleOfNameTextView(ChatRoomMessage message, TextView nameTextView, ImageView nameIconView) {
|
||||
nameTextView.setTextColor(NimUIKitImpl.getContext().getResources().getColor(R.color.color_black_ff999999));
|
||||
MemberType type = ChatRoomHelper.getMemberTypeByRemoteExt(message);
|
||||
if (type == MemberType.ADMIN) {
|
||||
nameIconView.setImageResource(R.drawable.nim_admin_icon);
|
||||
nameIconView.setVisibility(View.VISIBLE);
|
||||
} else if (type == MemberType.CREATOR) {
|
||||
nameIconView.setImageResource(R.drawable.nim_master_icon);
|
||||
nameIconView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
nameIconView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.presenter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.chwl.app.base.BaseMvpPresenter;
|
||||
import com.chwl.app.public_chat_hall.fragment.PublicChatHallMyHistoryMessageFragment;
|
||||
import com.chwl.app.public_chat_hall.view.IPublicChatHallMyMessageView;
|
||||
import com.chwl.core.bean.response.ServiceResult;
|
||||
import com.chwl.core.public_chat_hall.bean.PublicChatHallMessage;
|
||||
import com.chwl.core.public_chat_hall.model.PublicChatHallModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
public class PublicChatHallMyMessagePresenter extends BaseMvpPresenter<IPublicChatHallMyMessageView> {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void loadMessageList(int type, int page) {
|
||||
Single<ServiceResult<List<PublicChatHallMessage>>> single;
|
||||
switch (type) {
|
||||
default:
|
||||
case PublicChatHallMyHistoryMessageFragment.KEY_AIT_ME:
|
||||
single = PublicChatHallModel.get().getAitMeHistoryMessage(page);
|
||||
break;
|
||||
|
||||
case PublicChatHallMyHistoryMessageFragment.KEY_SENT:
|
||||
single = PublicChatHallModel.get().getSentHistoryMessage(page);
|
||||
break;
|
||||
}
|
||||
single.compose(bindToLifecycle())
|
||||
.subscribe((listServiceResult, throwable) -> {
|
||||
if (throwable == null) {
|
||||
if (listServiceResult != null) {
|
||||
if (listServiceResult.isSuccess()) {
|
||||
getMvpView().onGetMessageListSuccess(listServiceResult.getData(), page);
|
||||
} else {
|
||||
getMvpView().onRequestFail(listServiceResult.getCode() +
|
||||
listServiceResult.getMessage());
|
||||
}
|
||||
} else {
|
||||
getMvpView().onRequestFail("nothing is responded");
|
||||
}
|
||||
} else {
|
||||
getMvpView().onRequestFail(throwable.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.utils;
|
||||
|
||||
import com.chwl.core.utils.SharedPreferenceUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* 公聊大厅,@的次数管理
|
||||
* Created by lvzebiao on 2018/11/30.
|
||||
*/
|
||||
|
||||
public class RemainCountManager {
|
||||
|
||||
/**上一次@的时间*/
|
||||
private final static String KEY_LAST_SAY_TIME = "last_say_time";
|
||||
/**今天内已经@的次数*/
|
||||
private final static String KEY_HAS_REMAIN_COUNT = "has_remain_count";
|
||||
/**每天最多@的次数*/
|
||||
public final static int MAX_CAN_REMAIN_COUNT = 10;
|
||||
|
||||
/**统一@了一次*/
|
||||
public static void plusHasRemainCount() {
|
||||
long lastTime = (long) SharedPreferenceUtils.get(KEY_LAST_SAY_TIME, -1L);
|
||||
int lastCount = (int) SharedPreferenceUtils.get(KEY_HAS_REMAIN_COUNT, 0);
|
||||
long currTime = System.currentTimeMillis();
|
||||
//先判断上一次存的时间和现在是不是同一天
|
||||
if (isSameDay(lastTime, currTime)) {
|
||||
lastCount ++;
|
||||
} else {
|
||||
lastCount = 1;
|
||||
}
|
||||
SharedPreferenceUtils.put(KEY_LAST_SAY_TIME, currTime);
|
||||
SharedPreferenceUtils.put(KEY_HAS_REMAIN_COUNT, lastCount);
|
||||
}
|
||||
|
||||
/**判断用户能不能进行@操作*/
|
||||
public static boolean isCanRemain() {
|
||||
long lastTime = (long) SharedPreferenceUtils.get(KEY_LAST_SAY_TIME, -1L);
|
||||
if (!isSameDay(lastTime, System.currentTimeMillis())) {
|
||||
return true;
|
||||
}
|
||||
int lastCount = (int) SharedPreferenceUtils.get(KEY_HAS_REMAIN_COUNT, 0);
|
||||
return lastCount < MAX_CAN_REMAIN_COUNT;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断2个时间是不是同一天
|
||||
*/
|
||||
private static boolean isSameDay(long lastTime, long currTime) {
|
||||
if (lastTime <= 0 || currTime <= 0) {
|
||||
return false;
|
||||
}
|
||||
Calendar lastCal = Calendar.getInstance();
|
||||
lastCal.setTimeInMillis(lastTime);
|
||||
Calendar currCal = Calendar.getInstance();
|
||||
currCal.setTimeInMillis(currTime);
|
||||
boolean isSameYear = lastCal.get(Calendar.YEAR) == currCal
|
||||
.get(Calendar.YEAR);
|
||||
boolean isSameMonth = isSameYear
|
||||
&& lastCal.get(Calendar.MONTH) == currCal.get(Calendar.MONTH);
|
||||
return isSameMonth
|
||||
&& lastCal.get(Calendar.DAY_OF_MONTH) == currCal
|
||||
.get(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.view;
|
||||
|
||||
import com.chwl.core.public_chat_hall.bean.PublicChatHallMessage;
|
||||
import com.chwl.library.base.IMvpBaseView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IPublicChatHallMyMessageView extends IMvpBaseView {
|
||||
|
||||
public void onGetMessageListSuccess(List<PublicChatHallMessage> messageList, int page);
|
||||
|
||||
public void onRequestFail(String error);
|
||||
}
|
@@ -1,123 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseSdDialog;
|
||||
import com.chwl.app.common.svga.SimpleSvgaCallback;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.core.gift.GiftModel;
|
||||
import com.chwl.core.gift.bean.GiftInfo;
|
||||
import com.chwl.core.gift.bean.GiftReceiveInfo;
|
||||
import com.chwl.core.utils.ActivityUtil;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
public class PublicChatHallGiftAnimationDialog extends BaseSdDialog {
|
||||
|
||||
private GiftReceiveInfo giftReceiveInfo;
|
||||
private SVGAImageView svgaImageView;
|
||||
private ImageView senderAvatar;
|
||||
private ImageView receiverAvatar;
|
||||
private ImageView giftView;
|
||||
private TextView giftNumView;
|
||||
private SVGAParser svgaParser;
|
||||
|
||||
public PublicChatHallGiftAnimationDialog(Context context, GiftReceiveInfo giftReceiveInfo) {
|
||||
super(context);
|
||||
this.giftReceiveInfo = giftReceiveInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View inflate = LayoutInflater.from(getContext()).inflate(R.layout.layout_public_chat_hall_gift_animation, null);
|
||||
setContentView(inflate.getRootView());
|
||||
setCancelable(true);
|
||||
setCanceledOnTouchOutside(true);
|
||||
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
WindowManager.LayoutParams windowParams = window.getAttributes();
|
||||
windowParams.width = UIUtil.dip2px(getContext(), 296);
|
||||
windowParams.height = UIUtil.dip2px(getContext(), 145);
|
||||
windowParams.dimAmount = 0.0f;
|
||||
windowParams.gravity = Gravity.CENTER;
|
||||
windowParams.windowAnimations = R.style.PublicChatHallGiftAnimationDialog;
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
|
||||
window.setAttributes(windowParams);
|
||||
}
|
||||
|
||||
senderAvatar = findViewById(R.id.benefactor_avatar);
|
||||
receiverAvatar = findViewById(R.id.receiver_avatar);
|
||||
giftView = findViewById(R.id.gift_img);
|
||||
giftNumView = findViewById(R.id.gift_number);
|
||||
svgaImageView = findViewById(R.id.svga_gift_animation_background);
|
||||
svgaImageView.setLoops(1);
|
||||
svgaImageView.setClearsAfterStop(true);
|
||||
svgaImageView.setCallback(new SimpleSvgaCallback() {
|
||||
@Override
|
||||
public void onFinished() {
|
||||
if (!ActivityUtil.isValidContext(context)) {
|
||||
return;
|
||||
}
|
||||
if (isShowing()) {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
svgaParser = new SVGAParser(getContext());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
ImageLoadUtils.loadAvatar(getContext(), giftReceiveInfo.getAvatar(),
|
||||
senderAvatar, true);
|
||||
ImageLoadUtils.loadAvatar(getContext(), giftReceiveInfo.getTargetAvatar(),
|
||||
receiverAvatar, true);
|
||||
GiftInfo giftInfo = GiftModel.get().findGiftInfoById(giftReceiveInfo.getGiftId());
|
||||
if (giftInfo == null) {
|
||||
giftInfo = giftReceiveInfo.getGift();
|
||||
}
|
||||
ImageLoadUtils.loadImage(getContext(), giftInfo.getGiftUrl(), giftView);
|
||||
giftNumView.setText("x" + giftReceiveInfo.getGiftNum());
|
||||
try {
|
||||
svgaParser.parse(new URL("https://image.zhongjialx.com/public_chat_spring.svga"), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(@Nullable SVGAVideoEntity svgaVideoEntity) {
|
||||
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity);
|
||||
svgaImageView.setImageDrawable(drawable);
|
||||
svgaImageView.startAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,112 +0,0 @@
|
||||
package com.chwl.app.public_chat_hall.widget;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseBindingDialog;
|
||||
import com.chwl.app.databinding.DialogPubRoomShutupBinding;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.core.public_chat_hall.manager.PublicChatHallDataManager;
|
||||
import com.chwl.core.public_chat_hall.model.PublicChatHallModel;
|
||||
import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.zyyoona7.lib.EasyPopup;
|
||||
import com.zyyoona7.lib.HorizontalGravity;
|
||||
import com.zyyoona7.lib.VerticalGravity;
|
||||
|
||||
import io.reactivex.functions.Consumer;
|
||||
|
||||
@ActLayoutRes(R.layout.dialog_pub_room_shutup)
|
||||
public class ShutUpDialog extends BaseBindingDialog<DialogPubRoomShutupBinding> implements View.OnClickListener {
|
||||
private long uid;
|
||||
private EasyPopup easyPopup;
|
||||
private long duration = 60 * 60;
|
||||
;
|
||||
|
||||
public ShutUpDialog(Context context, long uid) {
|
||||
super(context);
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
UserModel.get().getUserInfo(uid)
|
||||
.subscribe(new Consumer<UserInfo>() {
|
||||
@Override
|
||||
public void accept(UserInfo userInfo) throws Exception {
|
||||
binding.tvNick.setText(ResUtil.getString(R.string.public_chat_hall_widget_shutupdialog_01) + userInfo.getNick());
|
||||
}
|
||||
});
|
||||
binding.tvTime.setOnClickListener(this);
|
||||
binding.btnCancel.setOnClickListener(this);
|
||||
binding.btnOk.setOnClickListener(this);
|
||||
easyPopup = new EasyPopup(getContext())
|
||||
.setContentView(R.layout.layout_shutup_time)
|
||||
.setFocusAndOutsideEnable(true)
|
||||
.createPopup();
|
||||
|
||||
easyPopup.getView(R.id.tv_one_hour).setOnClickListener(this);
|
||||
easyPopup.getView(R.id.tv_three_hour).setOnClickListener(this);
|
||||
easyPopup.getView(R.id.tv_one_day).setOnClickListener(this);
|
||||
easyPopup.getView(R.id.tv_one_month).setOnClickListener(this);
|
||||
easyPopup.getView(R.id.tv_one_year).setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.tv_time:
|
||||
easyPopup.showAtAnchorView(binding.tvTime, VerticalGravity.BELOW, HorizontalGravity.ALIGN_LEFT,
|
||||
0, -UIUtil.dip2px(context, 39));
|
||||
break;
|
||||
case R.id.btn_cancel:
|
||||
dismiss();
|
||||
break;
|
||||
case R.id.btn_ok:
|
||||
if (TextUtils.isEmpty(binding.etReason.getText().toString())) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.public_chat_hall_widget_shutupdialog_02));
|
||||
return;
|
||||
}
|
||||
PublicChatHallModel.get().userMute(PublicChatHallDataManager.get().getPublicChatHallId(),
|
||||
uid,
|
||||
duration,
|
||||
binding.etReason.getText().toString())
|
||||
.subscribe(s -> {
|
||||
closeDialog();
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.public_chat_hall_widget_shutupdialog_03));
|
||||
});
|
||||
break;
|
||||
case R.id.tv_one_hour:
|
||||
duration = 60 * 60;
|
||||
binding.tvTime.setText(ResUtil.getString(R.string.public_chat_hall_widget_shutupdialog_04));
|
||||
easyPopup.dismiss();
|
||||
break;
|
||||
case R.id.tv_three_hour:
|
||||
duration = 3 * 60 * 60;
|
||||
binding.tvTime.setText(ResUtil.getString(R.string.public_chat_hall_widget_shutupdialog_05));
|
||||
easyPopup.dismiss();
|
||||
break;
|
||||
case R.id.tv_one_day:
|
||||
duration = 24 * 60 * 60;
|
||||
binding.tvTime.setText(ResUtil.getString(R.string.public_chat_hall_widget_shutupdialog_06));
|
||||
easyPopup.dismiss();
|
||||
break;
|
||||
case R.id.tv_one_month:
|
||||
duration = 24 * 30 * 60 * 60;
|
||||
binding.tvTime.setText(ResUtil.getString(R.string.public_chat_hall_widget_shutupdialog_07));
|
||||
easyPopup.dismiss();
|
||||
break;
|
||||
case R.id.tv_one_year:
|
||||
duration = 12 * 24 * 30 * 60 * 60;
|
||||
binding.tvTime.setText(ResUtil.getString(R.string.public_chat_hall_widget_shutupdialog_08));
|
||||
easyPopup.dismiss();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 634 B |
Before Width: | Height: | Size: 764 B |
Before Width: | Height: | Size: 548 B |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 980 B |
Before Width: | Height: | Size: 998 B |
Before Width: | Height: | Size: 606 B |
Before Width: | Height: | Size: 591 B |
Before Width: | Height: | Size: 595 B |
Before Width: | Height: | Size: 908 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.4 KiB |
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/message_input_ait_pressed" android:state_pressed="true"/>
|
||||
<item android:drawable="@drawable/message_input_ait_pressed" android:state_focused="true"/>
|
||||
<item android:drawable="@drawable/message_input_ait_normal"/>
|
||||
|
||||
</selector>
|
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/message_input_voice_pressed" android:state_pressed="true"/>
|
||||
<item android:drawable="@drawable/message_input_voice_normal" android:state_focused="true"/>
|
||||
<item android:drawable="@drawable/message_input_voice_normal"/>
|
||||
|
||||
</selector>
|
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/message_input_emotion_pressed" android:state_pressed="true"/>
|
||||
<item android:drawable="@drawable/message_input_emotion_pressed" android:state_focused="true"/>
|
||||
<item android:drawable="@drawable/message_input_emotion_normal"/>
|
||||
|
||||
</selector>
|
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/message_input_keyboard_pressed" android:state_pressed="true"/>
|
||||
<item android:drawable="@drawable/message_input_keyboard_pressed" android:state_focused="true"/>
|
||||
<item android:drawable="@drawable/message_input_keyboard_normal"/>
|
||||
|
||||
</selector>
|
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/shape_round_9af5ef_radius_5dp" android:state_pressed="true"/>
|
||||
<item android:drawable="@drawable/shape_round_9af5ef_radius_5dp" android:state_enabled="false"/>
|
||||
<item android:drawable="@drawable/shape_round_app_color_radius_5dp"/>
|
||||
|
||||
</selector>
|
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="#e3e5e7" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="@color/white" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
@@ -1,79 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="giftBean"
|
||||
type="com.chwl.core.noble.bean.AllServiceGiftProtocol.DataBean" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/dp_15"
|
||||
android:src="@drawable/icon_arrow_left_black"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.flyco.tablayout.SlidingTabLayout
|
||||
android:id="@+id/stl_public_chat_hall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tl_indicator_color="@color/appColor"
|
||||
app:tl_indicator_corner_radius="2dp"
|
||||
app:tl_indicator_height="3dp"
|
||||
app:tl_indicator_margin_top="@dimen/dp_5"
|
||||
app:tl_indicator_width="25dp"
|
||||
app:tl_textSelectColor="@color/color_1A1A1A"
|
||||
app:tl_textUnselectColor="@color/text_tertiary"
|
||||
app:tl_textsize="@dimen/dp_16"
|
||||
tools:layout_editor_absoluteY="13dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_more"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/dp_15"
|
||||
android:src="@mipmap/ic_more_black"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_message_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cl_title">
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/vp_public_chat_hall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
@@ -1,87 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="android.view.View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/white"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.chwl.app.base.TitleBar
|
||||
android:id="@+id/title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_search_hints"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_below="@+id/title_bar"
|
||||
android:layout_height="49dp">
|
||||
<TextView
|
||||
android:id="@+id/tv_search_hints"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="29dp"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:layout_marginBottom="@dimen/dp_10"
|
||||
android:background="@drawable/shape_round_f5f5f5_radius_5dp"
|
||||
android:drawableStart="@mipmap/common_ic_search_black"
|
||||
android:drawablePadding="@dimen/dp_10"
|
||||
android:onClick="@{click}"
|
||||
android:gravity="center_vertical"
|
||||
android:hint="@string/family_group_search_hint" />
|
||||
</FrameLayout>
|
||||
|
||||
<com.flyco.tablayout.SlidingTabLayout
|
||||
android:id="@+id/stl_public_chat_hall"
|
||||
android:layout_below="@+id/fl_search_hints"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="49dp"
|
||||
app:tl_tab_space_equal="true"
|
||||
app:tl_indicator_color="@color/appColor"
|
||||
app:tl_indicator_corner_radius="2dp"
|
||||
app:tl_indicator_height="3dp"
|
||||
app:tl_indicator_margin_top="@dimen/dp_5"
|
||||
app:tl_indicator_width="25dp"
|
||||
app:tl_textSelectColor="@color/color_1A1A1A"
|
||||
app:tl_textUnselectColor="@color/text_tertiary"
|
||||
app:tl_textsize="@dimen/dp_16" />
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/vp_ait_friend"
|
||||
android:layout_below="@+id/stl_public_chat_hall"
|
||||
android:layout_above="@+id/btn_confirm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_confirm"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:layout_marginBottom="@dimen/dp_10"
|
||||
android:background="@drawable/shape_round_app_color_radius_19dp"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="bottom"
|
||||
android:text="@string/text_ok"
|
||||
android:textColor="@color/white"
|
||||
android:onClick="@{click}"
|
||||
android:textSize="@dimen/dp_15"
|
||||
tools:ignore="SpUsage" />
|
||||
|
||||
</RelativeLayout>
|
||||
</layout>
|
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/dp_15"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:src="@drawable/icon_arrow_left_black" />
|
||||
|
||||
<com.flyco.tablayout.SlidingTabLayout
|
||||
android:id="@+id/stl_public_chat_hall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tl_indicator_color="@color/appColor"
|
||||
app:tl_indicator_corner_radius="2dp"
|
||||
app:tl_indicator_height="3dp"
|
||||
app:tl_indicator_width="25dp"
|
||||
app:tl_textSelectColor="@color/color_1A1A1A"
|
||||
app:tl_textUnselectColor="@color/text_tertiary"
|
||||
app:tl_textsize="@dimen/dp_16" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_message_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cl_title">
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/vp_public_chat_hall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
@@ -1,101 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="@color/white"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center|start"
|
||||
android:background="@color/transparent"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/arrow_left" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="29dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_weight="1.0"
|
||||
android:background="@drawable/bg_search_edit"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/search_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:src="@mipmap/icon_little_search" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/search_edit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:hint="@string/search_hint"
|
||||
android:inputType="text"
|
||||
android:maxLength="20"
|
||||
android:maxLines="1"
|
||||
android:text=""
|
||||
android:textColor="@color/text_color_primary"
|
||||
android:textColorHint="@color/text_color_secondary"
|
||||
android:textCursorDrawable="@null"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_clear_text"
|
||||
android:layout_width="@dimen/dp_15"
|
||||
android:layout_height="@dimen/dp_15"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:src="@mipmap/ic_text_clear" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center"
|
||||
android:paddingRight="16dp"
|
||||
android:text="@string/search"
|
||||
android:textColor="@color/appColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.chwl.app.common.widget.StatusLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
</com.chwl.app.common.widget.StatusLayout>
|
||||
</LinearLayout>
|
||||
</layout>
|
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.chwl.app.common.widget.StatusLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
</com.chwl.app.common.widget.StatusLayout>
|