public static final String AUTHORITY = "com.ic.fzd.we-talk";
public static final String MESSAGES = "content://" + AUTHORITY + "/" + PATH;
public static final String MESSAGES_SEND = "content://" + AUTHORITY + ".send" + "/" + PATH;
+ //一个Item添加/更新的时候,可以通过这个来通知UI
+ public static final String MESSAGES_ITEM = "content://" + AUTHORITY + ".item" + "/" + PATH;
private FZDDatabaseHelper mDatabase;
//发出通知
Objects.requireNonNull(getContext()).getContentResolver().notifyChange(sendNotify, null);
}
+ //不管怎么样,都要通知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);
synchronized (mLock) {
int match = sUriMatcher.match(uri);
if (match == MATH_CODE_TABLE) {
- //TODO:通知UI更新
- //更新数据
+ //如果是状态变化的话通知UI监听的地方
+ //让UI查询一下新的状态
+ if (values != null) {
+ Integer state = values.getAsInteger("state");
+ //还要拿到Id
+ if (getContext() != null &&
+ state != null && "_id=?".equals(selection) && selectionArgs != null) {
+ getContext().getContentResolver().notifyChange(
+ Uri.parse(MESSAGES_ITEM + "/" + selectionArgs[0]), null);
+ }
+ }
SQLiteDatabase writableDatabase = mDatabase.getWritableDatabase();
return writableDatabase.update(FZDDatabaseHelper.tMessage, values, selection, selectionArgs);
}
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Environment;
import android.os.RemoteCallbackList;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
String[] split = cmdStr.split(",");
ICLogger.d("split[0].length() == > " + split[0].length());
if (split[1].length() == 2) {
- //更新发送状态
+ //TODO:更新发送状态
return;
}
//处理数据
"receive_" + System.currentTimeMillis() + ".amr");
//播放一下吧
//后面上了UI可以注释掉
- MediaPlayer mediaPlayer = new MediaPlayer();
- try {
- mediaPlayer.setDataSource(amrFilepath);
- mediaPlayer.prepare();
- ICLogger.d("playVoice.. ");
- mediaPlayer.start();
- } catch (IOException e) {
- ICLogger.d("playVoice: ERROR ");
- }
+ //MediaPlayer mediaPlayer = new MediaPlayer();
+ //try {
+ // mediaPlayer.setDataSource(amrFilepath);
+ // mediaPlayer.prepare();
+ // ICLogger.d("playVoice.. ");
+ // mediaPlayer.start();
+ //} catch (IOException e) {
+ // ICLogger.d("playVoice: ERROR ");
+ //}
//包存到数据库中,这是群聊的内容,没有联系人的
ContentResolver resolver = mRuntime.getContextProxy().getResolver();
ContentValues contentValues = new ContentValues();
resolver.insert(Uri.parse(FZDMessageProvider.MESSAGES), contentValues);
//回复服务器状态
mConnection.send(TK("1"));
+ //通知有消息到
+ //TODO:
} catch (Exception e) {
e.printStackTrace();
//失败