public static final String fUpdateTime = "update_time";
//语音相关的表,字段有:id:ID,content:内容,type:类型,1表示语音,2表示文本,3表示图片
- //state:状态,0表示未读,1表示已读,in_or_out:1表示来信,2表示发出去的内容,remote_num:对方的手机号码
+ //状态:应用端去处理(0表示未读,1表示已读,2表示未发送)协议处理的地方去修改(3表示发送中,4表示发送失败,5表示发送成功)
+ // in_or_out:1表示来信,2表示发出去的内容,remote_num:对方的手机号码
//create_time:创建时间,update_time:更新时间
public static final String tMessage = "message";
public static final String mId = "_id";
//处理查询
SQLiteDatabase readableDatabase = mDatabase.getReadableDatabase();
return readableDatabase.query(FZDDatabaseHelper.tMessage, projection,
- selection, selectionArgs, sortOrder, null, null);
+ selection, selectionArgs, null, null, sortOrder);
}
return null;
}
//发出通知
Objects.requireNonNull(getContext()).getContentResolver().notifyChange(sendNotify, null);
}
+ ICLogger.d("notify item change..." + id);
//不管怎么样,都要通知UI更新的
Uri itemNotify = Uri.parse(MESSAGES_ITEM + "/" + id);
Objects.requireNonNull(getContext()).getContentResolver().notifyChange(itemNotify, null);
-
}
- ICLogger.d("notify other observer..." + parse);
- Objects.requireNonNull(getContext()).getContentResolver().notifyChange(parse, null);
return parse;
}
return null;
//fos.flush();
//fos.close();
//以上代码,验证成功,说明转换是对的
- //更新数据库状态
- //TODO:
//发送消息
ByteArrayOutputStream bos = new ByteArrayOutputStream();
String cmd = cmdMap.get(CMD_TYPE.TK);
//追加结尾
bos.write(CMDEND.getBytes());
mConnection.send(cmd, bos.toByteArray());
+ //更新数据库状态
+ ContentValues contentValues = new ContentValues();
+ contentValues.put("state", 5);
+ mRuntime.getContextProxy().getResolver().update(
+ Uri.parse(FZDMessageProvider.MESSAGES),
+ contentValues,
+ "_id=?",
+ new String[]{voiceId}
+ );
} catch (Exception e) {
e.printStackTrace();
+ ContentValues contentValues = new ContentValues();
+ contentValues.put("state", 4);
+ mRuntime.getContextProxy().getResolver().update(
+ Uri.parse(FZDMessageProvider.MESSAGES),
+ contentValues,
+ "_id=?",
+ new String[]{voiceId}
+ );
}
- //TODO:
- //更新状态
}
}
ICLogger.d("voice length == > " + bytes.length);
String cmdStr = new String(bytes);
String[] split = cmdStr.split(",");
- ICLogger.d("split[0].length() == > " + split[0].length());
+ int cmdLength = split[0].length();
+ ICLogger.d("split[0].length() == > " + cmdLength);
if (split[1].length() == 2) {
- //TODO:更新发送状态
+ //更新发送状态
+ String value = cmdStr.substring(cmdLength, cmdLength + 1);
+ ICLogger.d("value is == > " + cmdLength);
+ if ("1".equals(value)) {
+ //修改为发送成功
+ //不知道ID,所以无法修改消息的状态
+ //所以交互上,调用发送的方法,就当发送了。
+ }
return;
}
//处理数据