Skip to content

Commit 3c9686a

Browse files
KenChoiKenChoi
authored andcommitted
fix bug
1 parent 87032c8 commit 3c9686a

File tree

6 files changed

+64
-28
lines changed

6 files changed

+64
-28
lines changed

android/src/io/jchat/android/Constant.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class Constant {
3838
public static final String CONVERSATION_TYPE = "conversationType";
3939
public static final String TARGET = "target";
4040
public static final String TYPE = "type";
41+
static final String MESSAGE_TYPE = "messageType";
4142
public static final String FROM = "from";
4243
public static final String LIMIT = "limit";
4344
public static final String CREATE_TIME = "createTime";

android/src/io/jchat/android/JMessageModule.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public void createSendMessage(ReadableMap map, Callback callback) {
289289
try {
290290
MessageContent content;
291291
Conversation conversation = mJMessageUtils.getConversation(map);
292-
String type = map.getString(Constant.TYPE);
292+
String type = map.getString(Constant.MESSAGE_TYPE);
293293
if (type.equals(Constant.TEXT)) {
294294
content = new TextContent(map.getString(Constant.TEXT));
295295
} else if (type.equals(Constant.IMAGE)) {
@@ -645,15 +645,6 @@ public void gotResult(int status, String desc, long groupId) {
645645
}
646646
}
647647

648-
@ReactMethod
649-
public void enterConversation(String targetId, String appKey, String groupId) {
650-
if (null != targetId && !TextUtils.isEmpty(targetId)) {
651-
JMessageClient.enterSingleConversation(targetId, appKey);
652-
} else {
653-
JMessageClient.enterGroupConversation(Long.parseLong(groupId));
654-
}
655-
}
656-
657648
@ReactMethod
658649
public void getGroupIds(final Callback success, final Callback fail) {
659650
JMessageClient.getGroupIDList(new GetGroupIDListCallback() {

example/android/app/app.iml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,25 @@
7272
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
7373
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
7474
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
75+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
7576
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
7677
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
78+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
7779
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
80+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
81+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
7882
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
7983
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
8084
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
8185
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
86+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
87+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/sourceFolderJavaResources" />
8288
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
8389
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
8490
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
91+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
8592
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
93+
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
8694
</content>
8795
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
8896
<orderEntry type="sourceFolder" forTests="false" />

example/android/app/src/com/sample/application/MainApplication.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ protected List<ReactPackage> getPackages() {
3434
new MainReactPackage(),
3535
new JMessageReactPackage(SHUTDOWN_TOAST),
3636
new MyDialogPackage(),
37-
new SvgPackage(),
38-
new ReactIMUIPackage()
37+
new SvgPackage()
3938
);
4039
}
4140
};

example/react-native-android/App.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@ class JChatDemo extends React.Component {
4545
}
4646
console.log(output);
4747
});
48-
48+
var user = {
49+
username: '0001',
50+
password: '1111'
51+
}
52+
JMessageModule.login(user, () => {
53+
console.log("Login succeed");
54+
}, (error) => {
55+
console.log("Login failed, code: " + error.code + " description: " + error.description);
56+
});
4957
}
5058

5159
componentDidMount() {}

example/react-native-android/pages/conv_fragment.js

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,48 @@ export default class Conv extends React.Component {
5959
this._panResponder = PanResponder.create({
6060
onStartShouldSetPanResponder: this.handleStartShouldSetPanResponder,
6161
});
62-
JMessageModule.getConvList().then((list) => {
63-
_convList = JSON.parse(list);
64-
this.setState({
65-
dataSource: _ds.cloneWithRows(_convList),
66-
fetching: false
67-
});
68-
}).catch((e) => {
69-
console.log(e);
70-
this.setState({
71-
fetching: false
72-
});
62+
63+
var message = {
64+
type: 'single',
65+
messageType: 'image',
66+
username: '0002',
67+
path: "/storage/emulated/0/DCIM/Camera/IMG20161223160904.jpg",
68+
}
69+
JMessageModule.createSendMessage(message, (msg) => {
70+
var output = "";
71+
for (var i in msg) {
72+
var property = msg[i];
73+
output += i + " = " + property + "\n";
74+
}
75+
console.log(output);
76+
var jmsg = {
77+
id: msg.id,
78+
username: '0002',
79+
type: 'single'
80+
}
81+
console.log("message id: " + msg.id);
82+
JMessageModule.sendMessage(jmsg, (message) => {
83+
84+
}, (error) => {
85+
console.log("error code: " + error.code);
86+
}, (progress) => {
87+
console.log("now progress: " + progress);
88+
})
7389
});
7490

91+
// JMessageModule.getConvList().then((list) => {
92+
// _convList = JSON.parse(list);
93+
// this.setState({
94+
// dataSource: _ds.cloneWithRows(_convList),
95+
// fetching: false
96+
// });
97+
// }).catch((e) => {
98+
// console.log(e);
99+
// this.setState({
100+
// fetching: false
101+
// });
102+
// });
103+
75104
}
76105

77106
componentDidMount() {
@@ -96,7 +125,7 @@ export default class Conv extends React.Component {
96125
DeviceEventEmitter.addListener(RECEIVE_MSG_EVENT, (map) => {
97126
console.log("收到消息: " + map.message);
98127
let conversation = JSON.parse(map.conversation);
99-
for (let i=0; i < _convList.length; i++) {
128+
for (let i = 0; i < _convList.length; i++) {
100129
if (_convList[i].id === conversation.id) {
101130
_convList[i] = conversation;
102131
console.log("update conversation");
@@ -117,9 +146,9 @@ export default class Conv extends React.Component {
117146
}
118147

119148
by = (date) => {
120-
return function (o, p) {
149+
return function(o, p) {
121150
var a, b;
122-
if (typeof o === "object" && typeof p === "object" && o && p) {
151+
if (typeof o === "object" && typeof p === "object" && o && p) {
123152
a = o[date];
124153
b = p[date];
125154
if (a === b) {
@@ -128,7 +157,7 @@ export default class Conv extends React.Component {
128157
if (typeof a === typeof b) {
129158
return a > b ? -1 : 1;
130159
}
131-
return typeof a > typeof b ? -1: 1;
160+
return typeof a > typeof b ? -1 : 1;
132161
} else {
133162
throw ("error");
134163
}

0 commit comments

Comments
 (0)