fix [私聊消息-直播中无正在直播标识]
This commit is contained in:
parent
d08861a082
commit
c20708d633
@ -1297,4 +1297,8 @@ public interface PDLiveApi {
|
|||||||
@GET("/api/public/?service=Pdlinfos.getIsSet")
|
@GET("/api/public/?service=Pdlinfos.getIsSet")
|
||||||
Observable<ResponseModel<FirstLoginBean>> isFirstLogin(
|
Observable<ResponseModel<FirstLoginBean>> isFirstLogin(
|
||||||
);
|
);
|
||||||
|
@GET("/api/public/?service=Pdlinfos.getIsLive")
|
||||||
|
Observable<ResponseModel<List<Integer>>> getUserLiveStatus(
|
||||||
|
@Query("ids")String ids
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -3522,6 +3522,25 @@ public class LiveNetManager {
|
|||||||
}
|
}
|
||||||
}).isDisposed();
|
}).isDisposed();
|
||||||
}
|
}
|
||||||
|
public void getUserLiveStatus(String ids,HttpCallback<List<Integer>> callback) {
|
||||||
|
API.get().pdLiveApi(mContext)
|
||||||
|
.getUserLiveStatus(ids)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(roomMicStatusModelResponseModel -> {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo());
|
||||||
|
}
|
||||||
|
}, new Consumer<Throwable>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Throwable throwable) throws Exception {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onError(mContext.getString(R.string.net_error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).isDisposed();
|
||||||
|
}
|
||||||
private MultipartBody.Part createUploadFile(File file) {
|
private MultipartBody.Part createUploadFile(File file) {
|
||||||
RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||||
return MultipartBody.Part.createFormData("file", file.getName(), requestBody);
|
return MultipartBody.Part.createFormData("file", file.getName(), requestBody);
|
||||||
|
@ -36,6 +36,17 @@ import io.rong.imlib.model.MessageContent;
|
|||||||
* 会话页面更改已读未读
|
* 会话页面更改已读未读
|
||||||
*/
|
*/
|
||||||
public class PDLiveMessageListAdapter extends MessageListAdapter {
|
public class PDLiveMessageListAdapter extends MessageListAdapter {
|
||||||
|
private boolean isLeftLive = false;
|
||||||
|
private boolean isRightLive = false;
|
||||||
|
|
||||||
|
public void setLeftLive(boolean leftLive) {
|
||||||
|
isLeftLive = leftLive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRightLive(boolean rightLive) {
|
||||||
|
isRightLive = rightLive;
|
||||||
|
}
|
||||||
|
|
||||||
public PDLiveMessageListAdapter(IViewProviderListener<UiMessage> listener) {
|
public PDLiveMessageListAdapter(IViewProviderListener<UiMessage> listener) {
|
||||||
super(listener);
|
super(listener);
|
||||||
}
|
}
|
||||||
@ -47,28 +58,28 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
|
|||||||
MessageContent content = mDataList.get(position).getMessage().getContent();
|
MessageContent content = mDataList.get(position).getMessage().getContent();
|
||||||
ImageView readReceipt = holder.getConvertView().findViewById(R.id.rc_read_receipt);
|
ImageView readReceipt = holder.getConvertView().findViewById(R.id.rc_read_receipt);
|
||||||
TextView rcEdit = holder.getConvertView().findViewById(R.id.rc_edit);
|
TextView rcEdit = holder.getConvertView().findViewById(R.id.rc_edit);
|
||||||
if (rcEdit!=null){
|
if (rcEdit != null) {
|
||||||
rcEdit.setVisibility(View.GONE);
|
rcEdit.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
holder.getConvertView().setBackgroundColor(Color.parseColor("#00000000"));
|
holder.getConvertView().setBackgroundColor(Color.parseColor("#00000000"));
|
||||||
holder.itemView.setBackgroundColor(Color.parseColor("#00000000"));
|
holder.itemView.setBackgroundColor(Color.parseColor("#00000000"));
|
||||||
ImageView readReceiptNew = holder.getConvertView().findViewById(R.id.rc_read_receipt_new);
|
ImageView readReceiptNew = holder.getConvertView().findViewById(R.id.rc_read_receipt_new);
|
||||||
|
|
||||||
if (readReceiptNew!=null){
|
if (readReceiptNew != null) {
|
||||||
if (messageDirection==Message.MessageDirection.SEND){
|
if (messageDirection == Message.MessageDirection.SEND) {
|
||||||
readReceiptNew.setVisibility(View.VISIBLE);
|
readReceiptNew.setVisibility(View.VISIBLE);
|
||||||
}else {
|
} else {
|
||||||
readReceiptNew.setVisibility(View.GONE);
|
readReceiptNew.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if (readReceipt.getVisibility()==View.VISIBLE) {
|
if (readReceipt.getVisibility() == View.VISIBLE) {
|
||||||
readReceiptNew.setBackgroundResource(R.mipmap.icon_message_read);
|
readReceiptNew.setBackgroundResource(R.mipmap.icon_message_read);
|
||||||
} else {
|
} else {
|
||||||
readReceiptNew.setBackgroundResource(R.mipmap.icon_message_unread);
|
readReceiptNew.setBackgroundResource(R.mipmap.icon_message_unread);
|
||||||
}
|
}
|
||||||
if (readReceipt!=null){
|
if (readReceipt != null) {
|
||||||
readReceipt.setVisibility(View.GONE);
|
readReceipt.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if(content instanceof MessageChatTipsContent){
|
if (content instanceof MessageChatTipsContent) {
|
||||||
readReceiptNew.setVisibility(View.GONE);
|
readReceiptNew.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,8 +94,22 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
|
|||||||
});
|
});
|
||||||
TextView tv = holder.getView(R.id.rc_time);
|
TextView tv = holder.getView(R.id.rc_time);
|
||||||
long sentTime = mDataList.get(position).getSentTime();
|
long sentTime = mDataList.get(position).getSentTime();
|
||||||
tv.setText(getDateTimeString(sentTime,true, holder.getContext()));
|
boolean isSender = mDataList.get(position).getMessage().getMessageDirection().equals(Message.MessageDirection.SEND);
|
||||||
|
tv.setText(getDateTimeString(sentTime, true, holder.getContext()));
|
||||||
|
if (holder.getView(R.id.left_liveStatus) != null) {
|
||||||
|
if (isLeftLive && !isSender) {
|
||||||
|
holder.getView(R.id.left_liveStatus).setVisibility(View.VISIBLE);
|
||||||
|
} else if (!isSender) {
|
||||||
|
holder.getView(R.id.left_liveStatus).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (holder.getView(R.id.right_liveStatus)!=null) {
|
||||||
|
if (isRightLive && isSender) {
|
||||||
|
holder.getView(R.id.right_liveStatus).setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
holder.getView(R.id.right_liveStatus).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -137,6 +162,7 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
|
|||||||
return formatDate;
|
return formatDate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int judgeDate(Date date) {
|
public static int judgeDate(Date date) {
|
||||||
Calendar calendarToday = Calendar.getInstance();
|
Calendar calendarToday = Calendar.getInstance();
|
||||||
calendarToday.set(11, 0);
|
calendarToday.set(11, 0);
|
||||||
@ -198,13 +224,14 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
|
|||||||
String timeFormat = Settings.System.getString(context.getContentResolver(), "time_12_24");
|
String timeFormat = Settings.System.getString(context.getContentResolver(), "time_12_24");
|
||||||
return timeFormat != null && timeFormat.equals("24");
|
return timeFormat != null && timeFormat.equals("24");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTimeString(long dateMillis, Context context) {
|
private static String getTimeString(long dateMillis, Context context) {
|
||||||
if (dateMillis <= 0L) {
|
if (dateMillis <= 0L) {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
Date date = new Date(dateMillis);
|
Date date = new Date(dateMillis);
|
||||||
String formatTime;
|
String formatTime;
|
||||||
if (isTime24Hour(context)||true) {
|
if (isTime24Hour(context) || true) {
|
||||||
formatTime = formatDate(date, "HH:mm");
|
formatTime = formatDate(date, "HH:mm");
|
||||||
} else {
|
} else {
|
||||||
Calendar calendarTime = Calendar.getInstance();
|
Calendar calendarTime = Calendar.getInstance();
|
||||||
@ -246,6 +273,7 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
|
|||||||
return formatTime;
|
return formatTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatDate(Date date, String fromat) {
|
public static String formatDate(Date date, String fromat) {
|
||||||
if (TextUtils.isEmpty(fromat)) {
|
if (TextUtils.isEmpty(fromat)) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -10,10 +10,15 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
|
|
||||||
import com.yunbao.common.event.PDChatInputModeEvent;
|
import com.yunbao.common.event.PDChatInputModeEvent;
|
||||||
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
|
import com.yunbao.common.http.live.LiveNetManager;
|
||||||
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
import com.yunbao.live.dialog.PDLiveMessageListAdapter;
|
import com.yunbao.live.dialog.PDLiveMessageListAdapter;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import io.rong.imkit.conversation.ConversationFragment;
|
import io.rong.imkit.conversation.ConversationFragment;
|
||||||
import io.rong.imkit.conversation.MessageListAdapter;
|
import io.rong.imkit.conversation.MessageListAdapter;
|
||||||
import io.rong.imkit.conversation.extension.InputMode;
|
import io.rong.imkit.conversation.extension.InputMode;
|
||||||
@ -23,6 +28,16 @@ import io.rong.imkit.conversation.extension.RongExtensionViewModel;
|
|||||||
* 聊天详情页面
|
* 聊天详情页面
|
||||||
*/
|
*/
|
||||||
public class PDLiveConversationFragment extends ConversationFragment {
|
public class PDLiveConversationFragment extends ConversationFragment {
|
||||||
|
PDLiveMessageListAdapter adapter;
|
||||||
|
private String targetId = "";
|
||||||
|
|
||||||
|
public PDLiveConversationFragment(String targetId) {
|
||||||
|
this.targetId = targetId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PDLiveConversationFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
@ -47,9 +62,36 @@ public class PDLiveConversationFragment extends ConversationFragment {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
String ids = String.format("%s,%s", targetId, IMLoginManager.get(getContext()).getUserInfo().getId());
|
||||||
|
LiveNetManager.get(getContext())
|
||||||
|
.getUserLiveStatus(ids, new HttpCallback<List<Integer>>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<Integer> data) {
|
||||||
|
if(data.isEmpty()){
|
||||||
|
adapter.setLeftLive(false);
|
||||||
|
adapter.setRightLive(false);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
adapter.setLeftLive(data.contains(Integer.parseInt(targetId)));
|
||||||
|
adapter.setRightLive(data.contains((int) IMLoginManager.get(getContext()).getUserInfo().getId()));
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MessageListAdapter onResolveAdapter() {
|
protected MessageListAdapter onResolveAdapter() {
|
||||||
return new PDLiveMessageListAdapter(this);
|
adapter = new PDLiveMessageListAdapter(this);
|
||||||
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,25 +32,60 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@id/ll_content" />
|
app:layout_constraintTop_toTopOf="@id/ll_content" />
|
||||||
|
|
||||||
<ImageView
|
<RelativeLayout
|
||||||
android:id="@+id/rc_left_portrait"
|
|
||||||
android:layout_width="@dimen/rc_message_portrait_size"
|
android:layout_width="@dimen/rc_message_portrait_size"
|
||||||
android:layout_height="@dimen/rc_message_portrait_size"
|
android:layout_height="@dimen/rc_message_portrait_size"
|
||||||
android:layout_marginStart="@dimen/rc_margin_size_4"
|
android:id="@+id/rc_left_portrait_layout"
|
||||||
android:src="@color/rc_secondary_color"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/rc_selected"
|
app:layout_constraintStart_toEndOf="@id/rc_selected"
|
||||||
app:layout_constraintTop_toTopOf="@id/ll_content"
|
app:layout_constraintTop_toTopOf="@id/ll_content"
|
||||||
app:layout_goneMarginStart="@dimen/rc_margin_size_12" />
|
app:layout_goneMarginStart="@dimen/rc_margin_size_12">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/rc_right_portrait"
|
android:id="@+id/rc_left_portrait"
|
||||||
|
android:layout_width="@dimen/rc_message_portrait_size"
|
||||||
|
android:layout_height="@dimen/rc_message_portrait_size"
|
||||||
|
android:src="@color/rc_secondary_color" />
|
||||||
|
|
||||||
|
<pl.droidsonroids.gif.GifImageView
|
||||||
|
android:id="@+id/left_liveStatus"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="12dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:src="@mipmap/icon_liveing"
|
||||||
|
tools:visibility="visible"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
android:layout_width="@dimen/rc_message_portrait_size"
|
android:layout_width="@dimen/rc_message_portrait_size"
|
||||||
android:layout_height="@dimen/rc_message_portrait_size"
|
android:layout_height="@dimen/rc_message_portrait_size"
|
||||||
android:layout_marginEnd="@dimen/rc_margin_size_12"
|
android:layout_marginEnd="@dimen/rc_margin_size_12"
|
||||||
android:src="@color/rc_secondary_color"
|
android:id="@+id/rc_right_portrait_layout"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@id/ll_content"
|
app:layout_constraintTop_toTopOf="@id/ll_content"
|
||||||
app:layout_goneMarginTop="@dimen/rc_margin_size_20" />
|
app:layout_goneMarginTop="@dimen/rc_margin_size_20" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/rc_right_portrait"
|
||||||
|
android:layout_width="@dimen/rc_message_portrait_size"
|
||||||
|
android:layout_height="@dimen/rc_message_portrait_size"
|
||||||
|
android:src="@color/rc_secondary_color"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<pl.droidsonroids.gif.GifImageView
|
||||||
|
android:id="@+id/right_liveStatus"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="12dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:src="@mipmap/icon_liveing"
|
||||||
|
tools:visibility="visible"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/ll_content"
|
android:id="@+id/ll_content"
|
||||||
@ -59,8 +94,8 @@
|
|||||||
android:layout_marginStart="@dimen/rc_margin_size_8"
|
android:layout_marginStart="@dimen/rc_margin_size_8"
|
||||||
android:layout_marginEnd="@dimen/rc_margin_size_8"
|
android:layout_marginEnd="@dimen/rc_margin_size_8"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:layout_constraintEnd_toStartOf="@id/rc_right_portrait"
|
app:layout_constraintEnd_toStartOf="@id/rc_right_portrait_layout"
|
||||||
app:layout_constraintStart_toEndOf="@id/rc_left_portrait"
|
app:layout_constraintStart_toEndOf="@id/rc_left_portrait_layout"
|
||||||
app:layout_constraintTop_toBottomOf="@id/rc_time">
|
app:layout_constraintTop_toBottomOf="@id/rc_time">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -182,7 +182,6 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
|
|||||||
* 数据的设置
|
* 数据的设置
|
||||||
*/
|
*/
|
||||||
private void initData() {
|
private void initData() {
|
||||||
targetId = getIntent().getStringExtra("targetId");
|
|
||||||
NoviceInstructorModel model = NoviceInstructorManager.get(this).getNoviceInstructor();
|
NoviceInstructorModel model = NoviceInstructorManager.get(this).getNoviceInstructor();
|
||||||
|
|
||||||
//绑定聊天用户id
|
//绑定聊天用户id
|
||||||
@ -219,7 +218,8 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
|
|||||||
private void initView() {
|
private void initView() {
|
||||||
try {
|
try {
|
||||||
// 添加会话界面
|
// 添加会话界面
|
||||||
conversationFragment = new PDLiveConversationFragment();
|
targetId = getIntent().getStringExtra("targetId");
|
||||||
|
conversationFragment = new PDLiveConversationFragment(targetId);
|
||||||
FragmentManager manager = getSupportFragmentManager();
|
FragmentManager manager = getSupportFragmentManager();
|
||||||
FragmentTransaction transaction = manager.beginTransaction();
|
FragmentTransaction transaction = manager.beginTransaction();
|
||||||
transaction.replace(R.id.container, conversationFragment);
|
transaction.replace(R.id.container, conversationFragment);
|
||||||
|
Loading…
Reference in New Issue
Block a user