微调
这个提交包含在:
父节点
e4307d5d32
当前提交
a12b9d305e
1
.idea/gradle.xml
自动生成的
1
.idea/gradle.xml
自动生成的
@ -10,7 +10,6 @@
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/SzyxBaseSdk" />
|
||||
<option value="$PROJECT_DIR$/SzyxImSdk" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
|
||||
3
.idea/misc.xml
自动生成的
3
.idea/misc.xml
自动生成的
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
1
SzyxBaseSdk/.gitignore
vendored
1
SzyxBaseSdk/.gitignore
vendored
@ -1 +0,0 @@
|
||||
/build
|
||||
@ -1,36 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'cn.org.bjca.trust.android.lib.base'
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
targetSdk 33
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
}
|
||||
21
SzyxBaseSdk/proguard-rules.pro
vendored
21
SzyxBaseSdk/proguard-rules.pro
vendored
@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@ -1,26 +0,0 @@
|
||||
package cn.org.bjca.trust.android.lib.base;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("cn.org.bjca.trust.android.lib.base.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@ -1,17 +0,0 @@
|
||||
package cn.org.bjca.trust.android.lib.base;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
@ -34,8 +34,6 @@ android {
|
||||
|
||||
dependencies {
|
||||
|
||||
api project(path: ':SzyxBaseSdk')
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
|
||||
@ -10,6 +10,13 @@ public class UserInfo {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public UserInfo(String userId, String nickName, String faceUrl, String gender) {
|
||||
this.userId = userId;
|
||||
this.nickName = nickName;
|
||||
this.faceUrl = faceUrl;
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
@ -3,15 +3,18 @@ package cn.org.bjca.trust.android.lib.im.enums;
|
||||
public enum PacketType {
|
||||
//连接请求
|
||||
CONNECT(10),
|
||||
CONNACK(11),
|
||||
CONNECTED(11),
|
||||
//发送消息
|
||||
SEND(20),
|
||||
SENDACK(21),
|
||||
ARRIVE(21),
|
||||
//心跳包
|
||||
PING(30),
|
||||
PANG(31),
|
||||
// 离线通知
|
||||
DISCONNECT(40),
|
||||
//数据请求
|
||||
REQUEST(40),
|
||||
RESULT(41),
|
||||
//系统通知
|
||||
SYSTEM(50),
|
||||
UNKNOWN(-1);
|
||||
|
||||
private int type = -1;
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package cn.org.bjca.trust.android.lib.im.im.bean;
|
||||
|
||||
import cn.org.bjca.trust.android.lib.im.cfg.Constant;
|
||||
import cn.org.bjca.trust.android.lib.im.enums.PacketType;
|
||||
|
||||
public abstract class PacketMessage {
|
||||
private PacketType packetType;
|
||||
private long timestamp = System.currentTimeMillis();
|
||||
private String appId = Constant.getSdkAppID();
|
||||
private String userName = Constant.getUserId();
|
||||
|
||||
public PacketMessage(PacketType packetType) {
|
||||
this.packetType = packetType;
|
||||
}
|
||||
|
||||
public PacketType getPacketType() {
|
||||
return packetType;
|
||||
}
|
||||
|
||||
public void setPacketType(PacketType packetType) {
|
||||
this.packetType = packetType;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
}
|
||||
@ -13,4 +13,5 @@ public interface IMInterface {
|
||||
void logout();
|
||||
boolean isConnect();
|
||||
boolean isConnecting();
|
||||
|
||||
}
|
||||
|
||||
@ -11,10 +11,14 @@ 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.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.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;
|
||||
import kotlin.text.Charsets;
|
||||
|
||||
public class ImManager implements IMInterface {
|
||||
private final String TAG = "ImManager";
|
||||
@ -69,10 +73,11 @@ public class ImManager implements IMInterface {
|
||||
status = 0;
|
||||
if (reconnect) return;
|
||||
try {
|
||||
mqttClient.subscribe(Constant.getSdkAppID() + "/message" + Constant.getUserId(), 2);
|
||||
mqttClient.subscribe(Constant.getSdkAppID() + "/pang" + Constant.getUserId(), 2);
|
||||
mqttClient.subscribe(Constant.getSdkAppID() + "/login" + Constant.getUserId(), 2);
|
||||
mqttClient.subscribe(Constant.getSdkAppID() + "/data" + Constant.getUserId(), 2);
|
||||
mqttClient.subscribe(Constant.getSdkAppID() + "/message:" + Constant.getUserId(), 2);
|
||||
mqttClient.subscribe(Constant.getSdkAppID() + "/pang:" + Constant.getUserId(), 2);
|
||||
mqttClient.subscribe(Constant.getSdkAppID() + "/connect:" + Constant.getUserId(), 2);
|
||||
mqttClient.subscribe(Constant.getSdkAppID() + "/result:" + Constant.getUserId(), 2);
|
||||
mqttClient.subscribe(Constant.getSdkAppID() + "/notice:" + Constant.getUserId(), 2);
|
||||
} catch (MqttException e) {
|
||||
Log.e(TAG, "=====>connectComplete", e);
|
||||
}
|
||||
@ -87,7 +92,7 @@ public class ImManager implements IMInterface {
|
||||
|
||||
@Override
|
||||
public void messageArrived(String topic, MqttMessage message) throws Exception {
|
||||
Log.e("======>messageArrived", topic + "::" + message.getPayload().toString());
|
||||
Log.e("======>messageArrived", topic + "::" + new String(message.getPayload(), Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -134,4 +139,22 @@ public class ImManager implements IMInterface {
|
||||
public boolean isConnecting() {
|
||||
return this.status == 1;
|
||||
}
|
||||
|
||||
private void sendPacketMessage(PacketMessage message, IMSDKCallback callback) {
|
||||
if (null == connectOptions) {
|
||||
if (null != callback) callback.failed(204, "未登录");
|
||||
return;
|
||||
}
|
||||
if (!isConnect() || isConnecting()) {
|
||||
if (null != callback) callback.failed(205, "im未连接");
|
||||
return;
|
||||
}
|
||||
String msg = GsonImplHelp.get().toJson(message);
|
||||
try {
|
||||
mqttClient.publish("server", msg.getBytes(Charsets.UTF_8), 2, false);
|
||||
} catch (MqttException e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package cn.org.bjca.trust.android.lib.im.im.msg;
|
||||
|
||||
import cn.org.bjca.trust.android.lib.im.db.device.DeviceEntity;
|
||||
import cn.org.bjca.trust.android.lib.im.enums.PacketType;
|
||||
import cn.org.bjca.trust.android.lib.im.im.bean.PacketMessage;
|
||||
|
||||
public class ConnectMessage extends PacketMessage {
|
||||
public ConnectMessage() {
|
||||
super(PacketType.CONNECT);
|
||||
}
|
||||
private DeviceEntity device;
|
||||
}
|
||||
@ -45,9 +45,12 @@ public class SZYXImManager implements SdkInterface {
|
||||
|
||||
@Override
|
||||
public void login(String userID, String userSig, IMSDKCallback callback) {
|
||||
if (null == Constant.getSdkAppID()) {
|
||||
if (null != callback) callback.failed(203, "未初始化");
|
||||
}
|
||||
Constant.setUserId(userID);
|
||||
Disposable d = HttpManage.getApi(Service.class)
|
||||
.login(new LoginData(userID, userSig))
|
||||
.register(new LoginData(userID, userSig))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(httpResult -> {
|
||||
|
||||
@ -15,6 +15,6 @@ public interface Service {
|
||||
@GET("hello/{id}")
|
||||
Observable<HttpResult<String>> test(@Path("id") String id);
|
||||
|
||||
@POST("user/v1/login")
|
||||
Observable<HttpResult<LoginBean>> login(@Body LoginData loginData);
|
||||
@POST("user/v1/register")
|
||||
Observable<HttpResult<LoginBean>> register(@Body LoginData loginData);
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ plugins {
|
||||
android {
|
||||
namespace 'cn.org.bjca.trust.android.imdemo'
|
||||
compileSdk 33
|
||||
buildFeatures.dataBinding = true
|
||||
|
||||
defaultConfig {
|
||||
applicationId "cn.org.bjca.trust.android.imdemo"
|
||||
@ -43,4 +44,7 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
||||
//基础库
|
||||
implementation 'cn.org.bjca.trust.android:base:0.0.1.101'
|
||||
}
|
||||
@ -12,6 +12,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.ImAndroid"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".ui.login.LoginActivity"
|
||||
@ -24,7 +25,10 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:name=".ui.MainActivity"
|
||||
android:exported="true" />
|
||||
<activity
|
||||
android:name=".ui.FriendsActivity"
|
||||
android:exported="true" />
|
||||
</application>
|
||||
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
package cn.org.bjca.trust.android.imdemo;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
}
|
||||
}
|
||||
@ -3,12 +3,14 @@ package cn.org.bjca.trust.android.imdemo;
|
||||
import android.app.Application;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.xuqm.base.App;
|
||||
|
||||
import cn.org.bjca.trust.android.lib.im.SZYXImSdk;
|
||||
import cn.org.bjca.trust.android.lib.im.bean.IMUserFullInfo;
|
||||
import cn.org.bjca.trust.android.lib.im.kit.IMSDKCallback;
|
||||
import cn.org.bjca.trust.android.lib.im.kit.IMSDKListener;
|
||||
|
||||
public class MyApplication extends Application {
|
||||
public class MyApplication extends App {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
@ -43,7 +45,7 @@ public class MyApplication extends Application {
|
||||
|
||||
}
|
||||
});
|
||||
SZYXImSdk.getInstance().init(this, "202305181830247", new IMSDKCallback() {
|
||||
SZYXImSdk.getInstance().init(this, "202305191821982941292", new IMSDKCallback() {
|
||||
@Override
|
||||
public void success() {
|
||||
Toast.makeText(MyApplication.this, "IM初始化完成", Toast.LENGTH_SHORT).show();
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
package cn.org.bjca.trust.android.imdemo.data.item;
|
||||
|
||||
import com.xuqm.base.adapter.BaseItem;
|
||||
|
||||
public class MainItem extends BaseItem {
|
||||
private int id;
|
||||
private String name;
|
||||
private String des;
|
||||
|
||||
public MainItem() {
|
||||
}
|
||||
|
||||
public MainItem(int id, String name, String des) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.des = des;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDes() {
|
||||
return des;
|
||||
}
|
||||
|
||||
public void setDes(String des) {
|
||||
this.des = des;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package cn.org.bjca.trust.android.imdemo.data.item;
|
||||
|
||||
import com.xuqm.base.adapter.BaseItem;
|
||||
|
||||
public class UserItem extends BaseItem {
|
||||
private String userId;
|
||||
private String nickName;
|
||||
private String faceUrl;
|
||||
private String gender;
|
||||
|
||||
public UserItem(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public UserItem(String userId, String nickName, String faceUrl, String gender) {
|
||||
this.userId = userId;
|
||||
this.nickName = nickName;
|
||||
this.faceUrl = faceUrl;
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getFaceUrl() {
|
||||
return faceUrl;
|
||||
}
|
||||
|
||||
public void setFaceUrl(String faceUrl) {
|
||||
this.faceUrl = faceUrl;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package cn.org.bjca.trust.android.imdemo.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.xuqm.base.adapter.BasePagedAdapter;
|
||||
import com.xuqm.base.adapter.CommonPagedAdapter;
|
||||
import com.xuqm.base.adapter.ViewHolder;
|
||||
import com.xuqm.base.ui.BaseListActivity;
|
||||
|
||||
import cn.org.bjca.trust.android.imdemo.R;
|
||||
import cn.org.bjca.trust.android.imdemo.data.item.UserItem;
|
||||
import cn.org.bjca.trust.android.imdemo.vm.FriendsVM;
|
||||
|
||||
public class FriendsActivity extends BaseListActivity<UserItem, FriendsVM> {
|
||||
@Override
|
||||
public void initView(Bundle savedInstanceState) {
|
||||
super.initView(savedInstanceState);
|
||||
setTitleText("好友列表");
|
||||
setConfirmText("添加好友", v -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasePagedAdapter<UserItem> adapter() {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
private final CommonPagedAdapter<UserItem> adapter = new CommonPagedAdapter<UserItem>(R.layout.item_main) {
|
||||
@Override
|
||||
protected void convert(ViewHolder holder, UserItem item, int position) {
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
package cn.org.bjca.trust.android.imdemo.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
|
||||
import com.xuqm.base.adapter.BasePagedAdapter;
|
||||
import com.xuqm.base.adapter.CommonPagedAdapter;
|
||||
import com.xuqm.base.adapter.ViewHolder;
|
||||
import com.xuqm.base.ui.BaseListFormLayoutActivity;
|
||||
|
||||
import cn.org.bjca.trust.android.imdemo.R;
|
||||
import cn.org.bjca.trust.android.imdemo.data.item.MainItem;
|
||||
import cn.org.bjca.trust.android.imdemo.databinding.ActivityMainBinding;
|
||||
import cn.org.bjca.trust.android.imdemo.vm.MainVM;
|
||||
import cn.org.bjca.trust.android.lib.im.SZYXImSdk;
|
||||
import cn.org.bjca.trust.android.lib.im.kit.IMSDKCallback;
|
||||
|
||||
public class MainActivity extends BaseListFormLayoutActivity<MainItem, MainVM, ActivityMainBinding> {
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(Bundle savedInstanceState) {
|
||||
super.initView(savedInstanceState);
|
||||
showBack(false);
|
||||
setTitleText("工作台");
|
||||
setConfirmText("退出", v -> SZYXImSdk.getInstance().logout(new IMSDKCallback() {
|
||||
@Override
|
||||
public void success() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(int code, String error) {
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
getBinding().baseRecyclerView.addItemDecoration(new DividerItemDecoration(MainActivity.this, DividerItemDecoration.VERTICAL));
|
||||
|
||||
adapter.setItemClickListener((view, item, position) -> {
|
||||
switch (item.getId()) {
|
||||
case 3:
|
||||
// startActivity(new Intent(mContext, FriendsActivity.class));
|
||||
break;
|
||||
case 4:
|
||||
startActivity(new Intent(mContext, FriendsActivity.class));
|
||||
break;
|
||||
case 5:
|
||||
// startActivity(new Intent(mContext, FriendsActivity.class));
|
||||
break;
|
||||
}
|
||||
});
|
||||
getBinding().baseRefreshLayout.setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasePagedAdapter<MainItem> adapter() {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
private final CommonPagedAdapter<MainItem> adapter = new CommonPagedAdapter<MainItem>(R.layout.item_main) {
|
||||
@Override
|
||||
protected void convert(ViewHolder holder, MainItem item, int position) {
|
||||
holder.setText(R.id.title, item.getName());
|
||||
holder.setText(R.id.des, item.getDes());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@ -20,7 +20,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import cn.org.bjca.trust.android.imdemo.MainActivity;
|
||||
import cn.org.bjca.trust.android.imdemo.ui.MainActivity;
|
||||
import cn.org.bjca.trust.android.imdemo.databinding.ActivityLoginBinding;
|
||||
import cn.org.bjca.trust.android.lib.im.SZYXImSdk;
|
||||
import cn.org.bjca.trust.android.lib.im.kit.IMSDKCallback;
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package cn.org.bjca.trust.android.imdemo.vm;
|
||||
|
||||
import com.xuqm.base.viewmodel.BaseListViewModel;
|
||||
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> {
|
||||
|
||||
@Override
|
||||
public void loadData(int page, Response<UserItem> onResponse) {
|
||||
onResponse.onResponse(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.org.bjca.trust.android.imdemo.vm;
|
||||
|
||||
import com.xuqm.base.viewmodel.BaseListViewModel;
|
||||
import com.xuqm.base.viewmodel.callback.Response;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.org.bjca.trust.android.imdemo.data.item.MainItem;
|
||||
|
||||
public class MainVM extends BaseListViewModel<MainItem> {
|
||||
private final ArrayList<MainItem> list = new ArrayList<MainItem>() {
|
||||
{
|
||||
// add(new MainItem(1,"初始化","初始化sdk"));
|
||||
// add(new MainItem(2,"登录","登录"));
|
||||
// add(new MainItem(2,"登出","登出"));
|
||||
add(new MainItem(3,"会话相关","会话相关"));
|
||||
add(new MainItem(4,"好友相关","好友列表&群组列表"));
|
||||
add(new MainItem(5,"个人配置","个人配置"));
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void loadData(int page, Response<MainItem> onResponse) {
|
||||
onResponse.onResponse(list);
|
||||
}
|
||||
}
|
||||
@ -1,18 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
<layout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.MainActivity">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<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">
|
||||
|
||||
<com.xuqm.base.view.EmptyView
|
||||
android:id="@+id/baseEmptyView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_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>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
@ -0,0 +1,32 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.MainActivity">
|
||||
|
||||
<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">
|
||||
|
||||
<com.xuqm.base.view.EmptyView
|
||||
android:id="@+id/baseEmptyView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_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>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="65dp"
|
||||
android:paddingHorizontal="15dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="21sp"
|
||||
android:textColor="#666666"
|
||||
android:text="title"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/des"
|
||||
android:layout_width="wrap_content"
|
||||
android:textSize="15sp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="des"
|
||||
android:textColor="#999999"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -20,4 +20,5 @@ android.useAndroidX=true
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
android.defaults.buildfeatures.buildconfig=true
|
||||
android.nonFinalResIds=false
|
||||
android.nonFinalResIds=false
|
||||
android.enableJetifier=true
|
||||
@ -26,4 +26,3 @@ dependencyResolutionManagement {
|
||||
rootProject.name = "ImAndroid"
|
||||
include ':app'
|
||||
include ':SzyxImSdk'
|
||||
include ':SzyxBaseSdk'
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户