wangxiang 2 years ago
parent
commit
cf50f51afd
  1. 16
      app/src/main/java/com/kanglai/push/ui/activity/InstantActivity.java
  2. 15
      app/src/main/java/com/kanglai/push/ui/vm/InstantViewModel.java

16
app/src/main/java/com/kanglai/push/ui/activity/InstantActivity.java

@ -31,7 +31,6 @@ import com.kanglai.push.ui.vm.InstantViewModel;
import com.kanglai.push.util.ViewFilterUtil; import com.kanglai.push.util.ViewFilterUtil;
import com.scwang.smart.refresh.layout.api.RefreshLayout; import com.scwang.smart.refresh.layout.api.RefreshLayout;
import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import java.util.Objects; import java.util.Objects;
@ -53,7 +52,6 @@ public class InstantActivity extends BaseActivity<ActivityInstantBinding, Instan
public GridLayout bottom_grid; public GridLayout bottom_grid;
public LinearLayout layout_footer; public LinearLayout layout_footer;
public Boolean isShowBottom = false; public Boolean isShowBottom = false;
public LocalPushChatMsg localPushChatMsg;
private Disposable mSubscription; private Disposable mSubscription;
@Override @Override
@ -87,9 +85,9 @@ public class InstantActivity extends BaseActivity<ActivityInstantBinding, Instan
more_fill.setOnClickListener(view -> changBottomType()); more_fill.setOnClickListener(view -> changBottomType());
bottom_grid = findViewById(R.id.instant_grid); bottom_grid = findViewById(R.id.instant_grid);
layout_footer = findViewById(R.id.layout_footer); layout_footer = findViewById(R.id.layout_footer);
mViewModel.adverseData = getIntent().getParcelableExtra(CommonConstant.INSTANT_LAUNCHER_RESULT_KEY); mViewModel.localPushChatMsg = getIntent().getParcelableExtra(CommonConstant.INSTANT_LAUNCHER_RESULT_KEY);
mViewModel.setTitleText(localPushChatMsg.getUserName()); mViewModel.setTitleText(mViewModel.localPushChatMsg.getUserName());
if ("2".equals(localPushChatMsg.getUserType()) || "5".equals(localPushChatMsg.getUserType()) || "0".equals(localPushChatMsg.getUserType())){ if ("2".equals(mViewModel.localPushChatMsg.getUserType()) || "5".equals(mViewModel.localPushChatMsg.getUserType()) || "0".equals(mViewModel.localPushChatMsg.getUserType())){
layout_footer.setVisibility(View.INVISIBLE); layout_footer.setVisibility(View.INVISIBLE);
} }
mViewModel.initData(refreshLayout); mViewModel.initData(refreshLayout);
@ -116,10 +114,10 @@ public class InstantActivity extends BaseActivity<ActivityInstantBinding, Instan
public void setActivitieResult() { public void setActivitieResult() {
if (!mAdapter.mItemList.isEmpty()) { if (!mAdapter.mItemList.isEmpty()) {
setResult(RESULT_OK, new Intent().putExtra(CommonConstant.INSTANT_LAUNCHER_RESULT_KEY, new LocalPushChatMsg() setResult(RESULT_OK, new Intent().putExtra(CommonConstant.INSTANT_LAUNCHER_RESULT_KEY, new LocalPushChatMsg()
.setId(localPushChatMsg.getId()) .setId(mViewModel.localPushChatMsg.getId())
.setUserName(localPushChatMsg.getUserName()) .setUserName(mViewModel.localPushChatMsg.getUserName())
.setUserType(localPushChatMsg.getUserType()) .setUserType(mViewModel.localPushChatMsg.getUserType())
.setAvatar(localPushChatMsg.getAvatar()) .setAvatar(mViewModel.localPushChatMsg.getAvatar())
.setSendTime(mAdapter.mItemList.get(mAdapter.getItemCount() - 1).getCreateTime()) .setSendTime(mAdapter.mItemList.get(mAdapter.getItemCount() - 1).getCreateTime())
.setLastContent(mAdapter.mItemList.get(mAdapter.getItemCount() - 1).getText()) .setLastContent(mAdapter.mItemList.get(mAdapter.getItemCount() - 1).getText())
)); ));

15
app/src/main/java/com/kanglai/push/ui/vm/InstantViewModel.java

@ -52,7 +52,8 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{
PushService pushService; PushService pushService;
public User user = CacheDiskUtils.getInstance().getParcelable(CacheConstant.USER_INFO, User.CREATOR, new User()); public User user = CacheDiskUtils.getInstance().getParcelable(CacheConstant.USER_INFO, User.CREATOR, new User());
public LocalPushChatMsg adverseData; // 对方用户基础信息
public LocalPushChatMsg localPushChatMsg;
public String cursor = ""; public String cursor = "";
@ -104,11 +105,11 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{
return; return;
} }
PushChatMessage chatMessage = new PushChatMessage(); PushChatMessage chatMessage = new PushChatMessage();
if ("1".equals(adverseData.getFocusType())) chatMessage.setConcernFanStatus("1"); // 从关注列表中进入聊天页界面则需要做特殊处理 if ("1".equals(localPushChatMsg.getFocusType())) chatMessage.setConcernFanStatus("1"); // 从关注列表中进入聊天页界面则需要做特殊处理
chatMessage.setText(msg); chatMessage.setText(msg);
chatMessage.setRemarks("普通消息"); chatMessage.setRemarks("普通消息");
chatMessage.setTitle("APP端消息发送-" + user.getNickName() + "到" + adverseData.getUserName()); chatMessage.setTitle("APP端消息发送-" + user.getNickName() + "到" + localPushChatMsg.getUserName());
chatMessage.setAlias(adverseData.getId()); chatMessage.setAlias(localPushChatMsg.getId());
chatMessage.setUserId(user.getId()); chatMessage.setUserId(user.getId());
pushService.concernFanSend(chatMessage) pushService.concernFanSend(chatMessage)
.compose(RxUtil.schedulersTransformer()) .compose(RxUtil.schedulersTransformer())
@ -134,7 +135,7 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{
@Override @Override
public void onError(Throwable e) { public void onError(Throwable e) {
if ("1".equals(adverseData.getFocusType())) { if ("1".equals(localPushChatMsg.getFocusType())) {
ToastUtil.show("对方还未关注你,你只能发送一条消息,发送失败"); ToastUtil.show("对方还未关注你,你只能发送一条消息,发送失败");
}else ExceptionHandle.baseExceptionMsg(e); }else ExceptionHandle.baseExceptionMsg(e);
} }
@ -151,7 +152,7 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{
pushService.listFriendHistoryMessage( pushService.listFriendHistoryMessage(
MapUtils.newHashMap( MapUtils.newHashMap(
Pair.create("size", pageSize), Pair.create("size", pageSize),
Pair.create("alias", adverseData.getId()), Pair.create("alias", localPushChatMsg.getId()),
Pair.create("userId", user.getId()) Pair.create("userId", user.getId())
)) ))
.compose(RxUtil.schedulersTransformer()) .compose(RxUtil.schedulersTransformer())
@ -188,7 +189,7 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{
MapUtils.newHashMap( MapUtils.newHashMap(
Pair.create("size", pageSize), Pair.create("size", pageSize),
Pair.create("current", pageCurrent += 1), Pair.create("current", pageCurrent += 1),
Pair.create("alias", adverseData.getId()), Pair.create("alias", localPushChatMsg.getId()),
Pair.create("userId", user.getId()) Pair.create("userId", user.getId())
)) ))
.compose(RxUtil.schedulersTransformer()) .compose(RxUtil.schedulersTransformer())

Loading…
Cancel
Save