update
This commit is contained in:
@@ -32,7 +32,7 @@ public class HotFragment extends BaseFragment {
|
||||
public void initView(View itemView) {
|
||||
recyclerView = itemView.findViewById(R.id.recyclerView);
|
||||
mRefreshLayout = itemView.findViewById(R.id.swipeRefreshLayout);
|
||||
adapter=new HomeHotListAdapter(getContext());
|
||||
adapter = new HomeHotListAdapter(getContext());
|
||||
recyclerView.setAdapter(adapter);
|
||||
mRefreshLayout.setNestedScrollingEnabled(false);
|
||||
mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
@@ -47,19 +47,24 @@ public class HotFragment extends BaseFragment {
|
||||
onConversationListLoadMore();
|
||||
}
|
||||
});
|
||||
initData();
|
||||
}
|
||||
|
||||
private void onConversationListLoadMore() {
|
||||
mRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
private void onConversationListRefresh(RefreshLayout refreshLayout) {
|
||||
|
||||
initData();
|
||||
refreshLayout.finishRefresh();
|
||||
}
|
||||
private void initData(){
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getHomeHot(new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
|
||||
adapter.setList(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,6 +73,7 @@ public class HotFragment extends BaseFragment {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_hot, container, false);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -23,7 +24,12 @@ import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.MessageChatTipsContent;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.dialog.GiftDialog;
|
||||
import com.shayu.onetoone.dialog.TipsDialog;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
import com.shayu.onetoone.listener.OnSendMessageListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.SendMessageManager;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
@@ -48,6 +54,7 @@ import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.message.ImageMessage;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
/**
|
||||
* 融云聊天UI
|
||||
@@ -55,11 +62,12 @@ import io.rong.message.ImageMessage;
|
||||
public class ChatMessageFragment extends AbsConversationFragment {
|
||||
Button mSendBtn;
|
||||
View mInputPanel;
|
||||
EditText mEditText;
|
||||
ImageView img, call, video, gift;
|
||||
ProcessImageUtil cameraUtil;
|
||||
String targetId;
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
View audioLayout;
|
||||
ViewGroup audioLayout;
|
||||
ImageView btnAudio;
|
||||
ImageView btnText;
|
||||
ImageView btnClose;
|
||||
@@ -75,6 +83,7 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
ImageView status;
|
||||
Button follow;
|
||||
|
||||
private String token;
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
@@ -83,7 +92,7 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
initChat();
|
||||
targetId = getActivity().getIntent().getStringExtra("targetId");
|
||||
cameraUtil = new ProcessImageUtil(getActivity(), "com.shayu.onetoone.fileprovider");
|
||||
mSendBtn.setOnClickListener(v -> sendText());
|
||||
|
||||
mRongExtension.setVisibility(View.VISIBLE);
|
||||
img.setOnClickListener(v -> cameraUtil.getImageByCamera());
|
||||
initCamera();
|
||||
@@ -104,12 +113,43 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
}
|
||||
});
|
||||
});
|
||||
mSendBtn.setOnClickListener(v -> {
|
||||
System.out.println("点击");
|
||||
SendMessageManager.sendMessageForText(targetId, mEditText.getText().toString(), new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token) {
|
||||
super.onSuccess(token);
|
||||
ChatMessageFragment.this.token = token;
|
||||
sendText();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
if (status == OnSendMessageListener.STATUS_NOT_PRICE) {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle("餘額不足")
|
||||
.setContent(String.format("文字聊天每條續消耗%s鑽,您可通過充值獲取更多鑽石,以便繼續聊天", msg))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
}
|
||||
}).showDialog();
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
updateMyInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getLayoutView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.rc_conversation_fragment,container,false);
|
||||
return inflater.inflate(R.layout.rc_conversation_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,21 +188,51 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
assert mVoiceToggleBtn != null;
|
||||
|
||||
mVoiceToggleBtn.setOnClickListener(v -> {
|
||||
changeAudioLayout();
|
||||
SendMessageManager.sendMessageForAudio(targetId, new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onSuccess(String token) {
|
||||
super.onSuccess(token);
|
||||
ChatMessageFragment.this.token = token;
|
||||
changeAudioLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
if (status == OnSendMessageListener.STATUS_NOT_PRICE) {
|
||||
new TipsDialog(mContext)
|
||||
.setTitle("餘額不足")
|
||||
.setContent(String.format("聊天每條續消耗%s鑽,您可通過充值獲取更多鑽石,以便繼續聊天", msg))
|
||||
.setOnDialogClickListener(new OnDialogClickListener() {
|
||||
|
||||
@Override
|
||||
public void onApply(Dialog dialog) {
|
||||
super.onApply(dialog);
|
||||
}
|
||||
}).showDialog();
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
img = mInputPanel.findViewById(R.id.input_panel_image_btn);
|
||||
video = mInputPanel.findViewById(R.id.input_panel_video_btn);
|
||||
call = mInputPanel.findViewById(R.id.input_panel_call_btn);
|
||||
gift = mInputPanel.findViewById(R.id.input_panel_gift_btn);
|
||||
audioLayout = mInputPanel.findViewById(R.id.audio_layout);
|
||||
btnAudio = mInputPanel.findViewById(R.id.audio_btn);
|
||||
btnText = mInputPanel.findViewById(R.id.text_btn);
|
||||
btnClose = mInputPanel.findViewById(R.id.close_btn);
|
||||
audioLayout.addView(LayoutInflater.from(mContext).inflate(R.layout.view_message_input_audio, (ViewGroup) mInputPanel,false));
|
||||
btnAudio = audioLayout.findViewById(R.id.audio_btn);
|
||||
btnText = audioLayout.findViewById(R.id.text_btn);
|
||||
btnClose = audioLayout.findViewById(R.id.close_btn);
|
||||
mEditText = audioLayout.findViewById(R.id.edit_btn);
|
||||
|
||||
btnText.setOnClickListener(v -> changeAudioLayout());
|
||||
btnClose.setOnClickListener(v -> changeAudioLayout());
|
||||
|
||||
btnAudio.setOnTouchListener(new View.OnTouchListener() {
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
float mOffsetLimit = 70.0F * v.getContext().getResources().getDisplayMetrics().density;
|
||||
@@ -194,8 +264,14 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
|
||||
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
|
||||
AudioRecordManager.getInstance().stopRecord();
|
||||
SendMessageManager.onCallSuccess(token, new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (mRongExtension.getConversationIdentifier().getType().equals(Conversation.ConversationType.PRIVATE)) {
|
||||
@@ -206,7 +282,9 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
gift.setOnClickListener(v -> {
|
||||
new GiftDialog(mContext).showDialog();
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
@@ -216,21 +294,49 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
private void changeAudioLayout() {
|
||||
if (audioLayout.getVisibility() == View.VISIBLE) {
|
||||
audioLayout.setVisibility(View.GONE);
|
||||
SendMessageManager.cancel(token);
|
||||
} else {
|
||||
audioLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendText() {
|
||||
try {
|
||||
Field field = mRongExtension.getInputPanel().getClass().getDeclaredField("mSendBtn");
|
||||
field.setAccessible(true);
|
||||
Button send = (Button) field.get(mRongExtension.getInputPanel());
|
||||
assert send != null;
|
||||
send.callOnClick();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
TextMessage messageContent = TextMessage.obtain(mEditText.getText().toString());
|
||||
|
||||
Message message = Message.obtain(targetId, conversationType, messageContent);
|
||||
|
||||
IMCenter.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
|
||||
|
||||
@Override
|
||||
public void onAttached(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
SendMessageManager.onCallSuccess(token, new OnSendMessageListener() {
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String token) {
|
||||
super.onSuccess(token);
|
||||
ToastUtil.show(token);
|
||||
mEditText.setText("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void sendImage(File file) {
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.shayu.onetoone.activity.message;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||
import com.shayu.onetoone.listener.OnCallStatusListener;
|
||||
|
||||
public class CallVideoActivity extends AbsOTOActivity {
|
||||
|
||||
private SurfaceView myView;
|
||||
private SurfaceView targetView;
|
||||
private ImageView callStop;
|
||||
private ImageView gift;
|
||||
private ImageView message;
|
||||
private ImageView cameraCloseSwitch;
|
||||
private ImageView cameraSwitch;
|
||||
private ImageView micSwitch;
|
||||
private ImageView money;
|
||||
private RoundedImageView avatar;
|
||||
private ImageView close;
|
||||
private ImageView follow;
|
||||
private TextView followText;
|
||||
|
||||
private OnCallStatusListener onCallStatusListener;
|
||||
|
||||
private String targetId;
|
||||
|
||||
public void setOnCallStatusListener(OnCallStatusListener onCallStatusListener) {
|
||||
this.onCallStatusListener = onCallStatusListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_call_video;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
myView = findViewById(R.id.my_view);
|
||||
targetView = findViewById(R.id.target_view);
|
||||
callStop = findViewById(R.id.call_stop);
|
||||
gift = findViewById(R.id.gift);
|
||||
message = findViewById(R.id.message);
|
||||
cameraCloseSwitch = findViewById(R.id.camera_close_switch);
|
||||
cameraSwitch = findViewById(R.id.camera_switch);
|
||||
micSwitch = findViewById(R.id.mic_switch);
|
||||
money = findViewById(R.id.money);
|
||||
avatar = findViewById(R.id.avatar);
|
||||
close = findViewById(R.id.close);
|
||||
follow = findViewById(R.id.follow);
|
||||
followText = findViewById(R.id.follow_text);
|
||||
// 为所有View设置点击事件监听器
|
||||
setClickListeners();
|
||||
}
|
||||
|
||||
private void setClickListeners() {
|
||||
// 为所有ImageView设置点击事件监听器
|
||||
callStop.setOnClickListener(onClickListener);
|
||||
gift.setOnClickListener(onClickListener);
|
||||
message.setOnClickListener(onClickListener);
|
||||
cameraCloseSwitch.setOnClickListener(onClickListener);
|
||||
cameraSwitch.setOnClickListener(onClickListener);
|
||||
micSwitch.setOnClickListener(onClickListener);
|
||||
money.setOnClickListener(onClickListener);
|
||||
|
||||
// 为其他View设置点击事件监听器
|
||||
avatar.setOnClickListener(onClickListener);
|
||||
close.setOnClickListener(onClickListener);
|
||||
follow.setOnClickListener(onClickListener);
|
||||
}
|
||||
|
||||
private View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// 在这里编写点击事件的处理逻辑
|
||||
int id = v.getId();
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user