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; @@ -31,7 +31,6 @@ import com.kanglai.push.ui.vm.InstantViewModel;
import com.kanglai.push.util.ViewFilterUtil;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Objects;
@ -53,7 +52,6 @@ public class InstantActivity extends BaseActivity<ActivityInstantBinding, Instan @@ -53,7 +52,6 @@ public class InstantActivity extends BaseActivity<ActivityInstantBinding, Instan
public GridLayout bottom_grid;
public LinearLayout layout_footer;
public Boolean isShowBottom = false;
public LocalPushChatMsg localPushChatMsg;
private Disposable mSubscription;
@Override
@ -87,9 +85,9 @@ public class InstantActivity extends BaseActivity<ActivityInstantBinding, Instan @@ -87,9 +85,9 @@ public class InstantActivity extends BaseActivity<ActivityInstantBinding, Instan
more_fill.setOnClickListener(view -> changBottomType());
bottom_grid = findViewById(R.id.instant_grid);
layout_footer = findViewById(R.id.layout_footer);
mViewModel.adverseData = getIntent().getParcelableExtra(CommonConstant.INSTANT_LAUNCHER_RESULT_KEY);
mViewModel.setTitleText(localPushChatMsg.getUserName());
if ("2".equals(localPushChatMsg.getUserType()) || "5".equals(localPushChatMsg.getUserType()) || "0".equals(localPushChatMsg.getUserType())){
mViewModel.localPushChatMsg = getIntent().getParcelableExtra(CommonConstant.INSTANT_LAUNCHER_RESULT_KEY);
mViewModel.setTitleText(mViewModel.localPushChatMsg.getUserName());
if ("2".equals(mViewModel.localPushChatMsg.getUserType()) || "5".equals(mViewModel.localPushChatMsg.getUserType()) || "0".equals(mViewModel.localPushChatMsg.getUserType())){
layout_footer.setVisibility(View.INVISIBLE);
}
mViewModel.initData(refreshLayout);
@ -116,10 +114,10 @@ public class InstantActivity extends BaseActivity<ActivityInstantBinding, Instan @@ -116,10 +114,10 @@ public class InstantActivity extends BaseActivity<ActivityInstantBinding, Instan
public void setActivitieResult() {
if (!mAdapter.mItemList.isEmpty()) {
setResult(RESULT_OK, new Intent().putExtra(CommonConstant.INSTANT_LAUNCHER_RESULT_KEY, new LocalPushChatMsg()
.setId(localPushChatMsg.getId())
.setUserName(localPushChatMsg.getUserName())
.setUserType(localPushChatMsg.getUserType())
.setAvatar(localPushChatMsg.getAvatar())
.setId(mViewModel.localPushChatMsg.getId())
.setUserName(mViewModel.localPushChatMsg.getUserName())
.setUserType(mViewModel.localPushChatMsg.getUserType())
.setAvatar(mViewModel.localPushChatMsg.getAvatar())
.setSendTime(mAdapter.mItemList.get(mAdapter.getItemCount() - 1).getCreateTime())
.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>{ @@ -52,7 +52,8 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{
PushService pushService;
public User user = CacheDiskUtils.getInstance().getParcelable(CacheConstant.USER_INFO, User.CREATOR, new User());
public LocalPushChatMsg adverseData; // 对方用户基础信息
public LocalPushChatMsg localPushChatMsg;
public String cursor = "";
@ -104,11 +105,11 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{ @@ -104,11 +105,11 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{
return;
}
PushChatMessage chatMessage = new PushChatMessage();
if ("1".equals(adverseData.getFocusType())) chatMessage.setConcernFanStatus("1"); // 从关注列表中进入聊天页界面则需要做特殊处理
if ("1".equals(localPushChatMsg.getFocusType())) chatMessage.setConcernFanStatus("1"); // 从关注列表中进入聊天页界面则需要做特殊处理
chatMessage.setText(msg);
chatMessage.setRemarks("普通消息");
chatMessage.setTitle("APP端消息发送-" + user.getNickName() + "到" + adverseData.getUserName());
chatMessage.setAlias(adverseData.getId());
chatMessage.setTitle("APP端消息发送-" + user.getNickName() + "到" + localPushChatMsg.getUserName());
chatMessage.setAlias(localPushChatMsg.getId());
chatMessage.setUserId(user.getId());
pushService.concernFanSend(chatMessage)
.compose(RxUtil.schedulersTransformer())
@ -134,7 +135,7 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{ @@ -134,7 +135,7 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{
@Override
public void onError(Throwable e) {
if ("1".equals(adverseData.getFocusType())) {
if ("1".equals(localPushChatMsg.getFocusType())) {
ToastUtil.show("对方还未关注你,你只能发送一条消息,发送失败");
}else ExceptionHandle.baseExceptionMsg(e);
}
@ -151,7 +152,7 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{ @@ -151,7 +152,7 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{
pushService.listFriendHistoryMessage(
MapUtils.newHashMap(
Pair.create("size", pageSize),
Pair.create("alias", adverseData.getId()),
Pair.create("alias", localPushChatMsg.getId()),
Pair.create("userId", user.getId())
))
.compose(RxUtil.schedulersTransformer())
@ -188,7 +189,7 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{ @@ -188,7 +189,7 @@ public class InstantViewModel extends ToolbarViewModel<InstantActivity>{
MapUtils.newHashMap(
Pair.create("size", pageSize),
Pair.create("current", pageCurrent += 1),
Pair.create("alias", adverseData.getId()),
Pair.create("alias", localPushChatMsg.getId()),
Pair.create("userId", user.getId())
))
.compose(RxUtil.schedulersTransformer())

Loading…
Cancel
Save