发送登录消息
这个提交包含在:
父节点
a12b9d305e
当前提交
03a5b6ecb3
@ -1,6 +1,5 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id "io.sentry.android.gradle" version "3.4.2"
|
||||
}
|
||||
|
||||
def versionCode = 1
|
||||
|
||||
@ -1,32 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<!-- Required: set your sentry.io project identifier (DSN) -->
|
||||
<meta-data
|
||||
android:name="io.sentry.dsn"
|
||||
android:value="https://e0308587cb2041d4909b97f3e4549d8d@sentry.51trust.net/9" />
|
||||
|
||||
<!-- enable automatic breadcrumbs for user interactions (clicks, swipes, scrolls) -->
|
||||
<meta-data
|
||||
android:name="io.sentry.traces.user-interaction.enable"
|
||||
android:value="true" />
|
||||
<!-- enable screenshot for crashes -->
|
||||
<meta-data
|
||||
android:name="io.sentry.attach-screenshot"
|
||||
android:value="true" />
|
||||
<!-- enable view hierarchy for crashes -->
|
||||
<meta-data
|
||||
android:name="io.sentry.attach-view-hierarchy"
|
||||
android:value="true" />
|
||||
|
||||
<!-- enable the performance API by setting a sample-rate, adjust in production env -->
|
||||
<meta-data
|
||||
android:name="io.sentry.traces.sample-rate"
|
||||
android:value="1.0" />
|
||||
<!-- enable profiling when starting transactions, adjust in production env -->
|
||||
<meta-data
|
||||
android:name="io.sentry.traces.profiling.sample-rate"
|
||||
android:value="1.0" />
|
||||
</application>
|
||||
</manifest>
|
||||
@ -45,7 +45,7 @@ public class DeviceHelper {
|
||||
device.setSupportedAbis(CommonHelper.anyToString(field.get(null)));
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cn.org.bjca.trust.android.lib.im.im.kit;
|
||||
|
||||
import cn.org.bjca.trust.android.lib.im.im.msg.SZYXMessage;
|
||||
import cn.org.bjca.trust.android.lib.im.im.opt.ImConnectOptions;
|
||||
import cn.org.bjca.trust.android.lib.im.kit.IMSDKCallback;
|
||||
import cn.org.bjca.trust.android.lib.im.kit.IMSDKListener;
|
||||
import cn.org.bjca.trust.android.lib.im.kit.MsgListener;
|
||||
|
||||
@ -13,5 +15,6 @@ public interface IMInterface {
|
||||
void logout();
|
||||
boolean isConnect();
|
||||
boolean isConnecting();
|
||||
void sendSZYXMessage(SZYXMessage message, IMSDKCallback callback);
|
||||
|
||||
}
|
||||
|
||||
@ -11,9 +11,12 @@ import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
|
||||
import cn.org.bjca.trust.android.lib.im.cfg.Constant;
|
||||
import cn.org.bjca.trust.android.lib.im.common.DeviceHelper;
|
||||
import cn.org.bjca.trust.android.lib.im.common.json.GsonImplHelp;
|
||||
import cn.org.bjca.trust.android.lib.im.im.bean.PacketMessage;
|
||||
import cn.org.bjca.trust.android.lib.im.im.kit.IMInterface;
|
||||
import cn.org.bjca.trust.android.lib.im.im.msg.ConnectMessage;
|
||||
import cn.org.bjca.trust.android.lib.im.im.msg.SZYXMessage;
|
||||
import cn.org.bjca.trust.android.lib.im.im.opt.ImConnectOptions;
|
||||
import cn.org.bjca.trust.android.lib.im.kit.IMSDKCallback;
|
||||
import cn.org.bjca.trust.android.lib.im.kit.IMSDKListener;
|
||||
@ -81,6 +84,8 @@ public class ImManager implements IMInterface {
|
||||
} catch (MqttException e) {
|
||||
Log.e(TAG, "=====>connectComplete", e);
|
||||
}
|
||||
// 发送登录消息
|
||||
sendConnectMsg();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -140,6 +145,16 @@ public class ImManager implements IMInterface {
|
||||
return this.status == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSZYXMessage(SZYXMessage message, IMSDKCallback callback) {
|
||||
sendPacketMessage(message, callback);
|
||||
}
|
||||
|
||||
private void sendConnectMsg() {
|
||||
ConnectMessage message = new ConnectMessage(DeviceHelper.getDevice());
|
||||
sendPacketMessage(message, null);
|
||||
}
|
||||
|
||||
private void sendPacketMessage(PacketMessage message, IMSDKCallback callback) {
|
||||
if (null == connectOptions) {
|
||||
if (null != callback) callback.failed(204, "未登录");
|
||||
@ -153,7 +168,7 @@ public class ImManager implements IMInterface {
|
||||
try {
|
||||
mqttClient.publish("server", msg.getBytes(Charsets.UTF_8), 2, false);
|
||||
} catch (MqttException e) {
|
||||
|
||||
if (null != callback) callback.failed(206, e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,4 +9,17 @@ public class ConnectMessage extends PacketMessage {
|
||||
super(PacketType.CONNECT);
|
||||
}
|
||||
private DeviceEntity device;
|
||||
|
||||
public ConnectMessage(DeviceEntity device) {
|
||||
super(PacketType.CONNECT);
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
public DeviceEntity getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
public void setDevice(DeviceEntity device) {
|
||||
this.device = device;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package cn.org.bjca.trust.android.lib.im.im.msg;
|
||||
|
||||
import cn.org.bjca.trust.android.lib.im.enums.PacketType;
|
||||
import cn.org.bjca.trust.android.lib.im.im.bean.PacketMessage;
|
||||
|
||||
public class SZYXMessage extends PacketMessage {
|
||||
public SZYXMessage() {
|
||||
super(PacketType.SEND);
|
||||
}
|
||||
}
|
||||
@ -86,7 +86,7 @@ public class SZYXImManager implements SdkInterface {
|
||||
|
||||
@Override
|
||||
public void sendMsgForTextToC(String toUserId, String text, IMSDKCallback callback) {
|
||||
|
||||
// IMHelper.getInstance().sendSZYXMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
@ -14,6 +15,9 @@
|
||||
android:theme="@style/Theme.ImAndroid"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".ui.ChatActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.login.LoginActivity"
|
||||
android:exported="true"
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package cn.org.bjca.trust.android.imdemo.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.xuqm.base.ui.BaseActivity;
|
||||
|
||||
import cn.org.bjca.trust.android.imdemo.R;
|
||||
import cn.org.bjca.trust.android.imdemo.databinding.ActivityChatBinding;
|
||||
|
||||
public class ChatActivity extends BaseActivity<ActivityChatBinding> {
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_chat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(Bundle savedInstanceState) {
|
||||
super.initView(savedInstanceState);
|
||||
String userId = getIntent().getStringExtra("userId");
|
||||
getBinding().text.setText(userId);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
package cn.org.bjca.trust.android.imdemo.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import com.xuqm.base.adapter.BasePagedAdapter;
|
||||
import com.xuqm.base.adapter.CommonPagedAdapter;
|
||||
@ -21,15 +23,32 @@ public class FriendsActivity extends BaseListActivity<UserItem, FriendsVM> {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemClicked(View view, UserItem item, int position) {
|
||||
if (item.getUserId().equals("001")) {
|
||||
|
||||
} else {
|
||||
Intent intent = new Intent(mContext, ChatActivity.class);
|
||||
intent.putExtra("userId", item.getUserId());
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasePagedAdapter<UserItem> adapter() {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
private final CommonPagedAdapter<UserItem> adapter = new CommonPagedAdapter<UserItem>(R.layout.item_main) {
|
||||
private final CommonPagedAdapter<UserItem> adapter = new CommonPagedAdapter<UserItem>(R.layout.item_friends) {
|
||||
@Override
|
||||
protected void convert(ViewHolder holder, UserItem item, int position) {
|
||||
holder.setText(R.id.title, item.getNickName());
|
||||
holder.setImage(R.id.icon, item.getFaceUrl());
|
||||
holder.setText(R.id.des, item.getUserId());
|
||||
if (item.getUserId().equals("001"))
|
||||
holder.setBackgroundColor(R.id.root, 0x999999ff);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
@ -20,8 +21,8 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import cn.org.bjca.trust.android.imdemo.ui.MainActivity;
|
||||
import cn.org.bjca.trust.android.imdemo.databinding.ActivityLoginBinding;
|
||||
import cn.org.bjca.trust.android.imdemo.ui.MainActivity;
|
||||
import cn.org.bjca.trust.android.lib.im.SZYXImSdk;
|
||||
import cn.org.bjca.trust.android.lib.im.kit.IMSDKCallback;
|
||||
|
||||
@ -69,6 +70,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
}
|
||||
loadingProgressBar.setVisibility(View.GONE);
|
||||
if (loginResult.getError() != null) {
|
||||
Log.e("=======>", loginResult.toString());
|
||||
showLoginFailed(loginResult.getError());
|
||||
}
|
||||
if (loginResult.getSuccess() != null) {
|
||||
|
||||
@ -6,12 +6,20 @@ import com.xuqm.base.viewmodel.callback.Response;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.org.bjca.trust.android.imdemo.data.item.UserItem;
|
||||
import cn.org.bjca.trust.android.lib.im.bean.UserInfo;
|
||||
|
||||
public class FriendsVM extends BaseListViewModel<UserItem> {
|
||||
|
||||
private final ArrayList<UserItem> list = new ArrayList<UserItem>() {
|
||||
{
|
||||
add(new UserItem("001", "群组", "https://i.buyiju.com/img/zidian2/766.jpg", "男"));
|
||||
add(new UserItem("13666666666", "张小明", "https://c-ssl.dtstatic.com/uploads/item/201912/15/20191215202849_uvcka.thumb.1000_0.jpg", "男"));
|
||||
add(new UserItem("13811111111", "王二三", "https://c-ssl.dtstatic.com/uploads/blog/202101/03/20210103220618_31c95.thumb.1000_0.jpg", "男"));
|
||||
add(new UserItem("13222222222", "赵晓旭", "https://up.enterdesk.com/edpic/47/48/90/4748902b2485376b7735cfbaecb12ad3.jpg", "男"));
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void loadData(int page, Response<UserItem> onResponse) {
|
||||
onResponse.onResponse(new ArrayList<>());
|
||||
onResponse.onResponse(list);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
<?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">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.ChatActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="hello"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
@ -1,32 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.MainActivity">
|
||||
android:layout_height="65dp"
|
||||
android:id="@+id/root"
|
||||
android:paddingHorizontal="15dp">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/baseRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:tag="layout/activity_base_list_0">
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:text="title"
|
||||
android:textColor="#666666"
|
||||
android:scaleType="center"
|
||||
android:textSize="21sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.xuqm.base.view.EmptyView
|
||||
android:id="@+id/baseEmptyView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:text="title"
|
||||
android:textColor="#666666"
|
||||
android:textSize="21sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/icon"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/baseRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="never" />
|
||||
|
||||
</com.xuqm.base.view.EmptyView>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
<TextView
|
||||
android:id="@+id/des"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="des"
|
||||
android:textColor="#999999"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
@ -1,5 +1,5 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id 'com.android.application' version '8.0.1' apply false
|
||||
id 'com.android.library' version '8.0.1' apply false
|
||||
id 'com.android.application' version '8.0.2' apply false
|
||||
id 'com.android.library' version '8.0.2' apply false
|
||||
}
|
||||
@ -1,24 +1,25 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
url 'http://nexus.51trust.net/repository/android-group/'
|
||||
url 'http://127.0.0.1:1022/repository/maven-public/'
|
||||
allowInsecureProtocol true
|
||||
}
|
||||
maven {
|
||||
url 'http://nexus.51trust.net/repository/gradle-plugin/'
|
||||
url 'http://127.0.0.1:1022/repository/gradle-plugin/'
|
||||
allowInsecureProtocol true
|
||||
}
|
||||
// google()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
maven {
|
||||
url 'http://nexus.51trust.net/repository/android-group/'
|
||||
url 'http://127.0.0.1:1022/repository/maven-public/'
|
||||
allowInsecureProtocol true
|
||||
}
|
||||
maven {
|
||||
url 'http://nexus.51trust.net/repository/gradle-plugin/'
|
||||
url 'http://127.0.0.1:1022/repository/gradle-plugin/'
|
||||
allowInsecureProtocol true
|
||||
}
|
||||
}
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户