<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />
+
<permission
android:name="com.enqualcomm.support.permission.MIPUSH_RECEIVE"
android:protectionLevel="signature" />
android:name=".provider.FZDMembersProvider"
android:authorities="com.ic.fzd.video-call"
android:exported="true" />
+
<provider
android:name=".provider.FZDMessageProvider"
android:authorities="com.ic.fzd.we-talk"
android:exported="true" />
+ <provider
+ android:name=".provider.FZDFollowProvider"
+ android:authorities="com.ic.fzd.follow"
+ android:exported="true" />
+
</application>
</manifest>
\ No newline at end of file
--- /dev/null
+package com.enqualcomm.support.provider;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.net.Uri;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+public class FZDFollowProvider extends ContentProvider {
+
+ public static final String PATH = "follow";
+ public static final String AUTHORITY = "com.ic.fzd.follow";
+ public static final String FOLLOW = "content://" + AUTHORITY + "/" + PATH;
+ public static final String FOLLOW_ITEM = "content://" + AUTHORITY + ".item" + "/" + PATH;
+
+ private FZDDatabaseHelper mDatabase;
+
+ private static final UriMatcher sUriMatcher;
+
+ private static final int MATH_CODE_TABLE = 0x1;
+
+ static {
+ sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+ sUriMatcher.addURI(AUTHORITY, PATH, MATH_CODE_TABLE);
+ }
+
+ @Override
+ public boolean onCreate() {
+ mDatabase = new FZDDatabaseHelper(getContext());
+ return false;
+ }
+
+ @Nullable
+ @Override
+ public Cursor query(@NonNull Uri uri,
+ @Nullable String[] projection,
+ @Nullable String selection,
+ @Nullable String[] selectionArgs,
+ @Nullable String sortOrder) {
+ //规则匹配
+ if (sUriMatcher.match(uri) == MATH_CODE_TABLE) {
+ SQLiteDatabase readableDatabase = mDatabase.getReadableDatabase();
+ return readableDatabase.query(FZDDatabaseHelper.tFollow, projection,
+ selection, selectionArgs, null, null, sortOrder);
+ }
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public String getType(@NonNull Uri uri) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
+ if (sUriMatcher.match(uri) == MATH_CODE_TABLE) {
+ SQLiteDatabase writableDatabase = mDatabase.getWritableDatabase();
+ //插入的时候通知更新
+ long id = writableDatabase.insert(FZDDatabaseHelper.tFollow, null, values);
+ if (getContext() != null) {
+ getContext().getContentResolver().notifyChange(
+ Uri.parse(FOLLOW_ITEM), null
+ );
+ }
+ return Uri.parse(FOLLOW + "/" + id);
+ }
+ return null;
+ }
+
+ @Override
+ public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
+ if (sUriMatcher.match(uri) == MATH_CODE_TABLE) {
+ SQLiteDatabase writableDatabase = mDatabase.getWritableDatabase();
+ return writableDatabase.delete(FZDDatabaseHelper.tFollow, selection, selectionArgs);
+ }
+ return 0;
+ }
+
+ @Override
+ public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
+ if (sUriMatcher.match(uri) == MATH_CODE_TABLE) {
+ SQLiteDatabase writableDatabase = mDatabase.getWritableDatabase();
+ //通知更新
+ Object state = values.get("state");
+ if (state != null && getContext() != null) {
+ getContext().getContentResolver().notifyChange(
+ Uri.parse(FOLLOW_ITEM), null
+ );
+ }
+ return writableDatabase.update(FZDDatabaseHelper.tFollow, values, selection, selectionArgs);
+ }
+ return 0;
+ }
+}