|
@@ -9,8 +9,8 @@ import android.net.Uri;
|
|
|
|
|
|
import com.xplora.xplauncher.model.ContactBean;
|
|
|
import com.xplora.xplauncher.model.RecentBean;
|
|
|
-import com.xplora.xplauncher.utils.Constant;
|
|
|
import com.xplora.xplauncher.utils.Macros;
|
|
|
+import com.xplora.xplauncher.utils.MetaData;
|
|
|
import com.xplora.xplauncher.utils.ToolsUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
@@ -24,9 +24,12 @@ public class DatabaseHelper {
|
|
|
return testContactList();
|
|
|
} else {
|
|
|
ArrayList<ContactBean> arrayList = new ArrayList<>();
|
|
|
- Uri uri = Uri.parse(Constant.DB_CONTACTS);
|
|
|
- Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
|
|
|
- while (cursor.moveToNext()) {
|
|
|
+ ContentResolver resolver = context.getContentResolver();
|
|
|
+ Uri uri = Uri.parse(MetaData.DB_CONTACTS);
|
|
|
+ Cursor cursor = resolver.query(uri, null, null, null, null);
|
|
|
+ if (cursor == null || !cursor.moveToFirst())
|
|
|
+ return arrayList;
|
|
|
+ do {
|
|
|
ContactBean bean = new ContactBean();
|
|
|
bean.id = cursor.getString(cursor.getColumnIndex("id"));
|
|
|
bean.userId = cursor.getString(cursor.getColumnIndex("userId"));
|
|
@@ -39,7 +42,7 @@ public class DatabaseHelper {
|
|
|
bean.rate = cursor.getInt(cursor.getColumnIndex("rate"));
|
|
|
bean.unRead = cursor.getInt(cursor.getColumnIndex("unRead"));
|
|
|
arrayList.add(bean);
|
|
|
- }
|
|
|
+ } while (cursor.moveToNext());
|
|
|
cursor.close();
|
|
|
return arrayList;
|
|
|
}
|
|
@@ -52,7 +55,8 @@ public class DatabaseHelper {
|
|
|
} else {
|
|
|
List<RecentBean> dataList = new ArrayList<>();
|
|
|
ContentResolver resolver = context.getContentResolver();
|
|
|
- Cursor cursor = resolver.query(MetaData.TABLE_URI_RECENT, null, null, null, null);
|
|
|
+ Uri uri = Uri.parse(MetaData.DB_RECENT);
|
|
|
+ Cursor cursor = resolver.query(uri, null, null, null, null);
|
|
|
while (cursor.moveToNext()) {
|
|
|
RecentBean bean = new RecentBean();
|
|
|
bean._id = cursor.getInt(cursor.getColumnIndex("_id"));
|
|
@@ -69,30 +73,6 @@ public class DatabaseHelper {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @SuppressLint("Range")
|
|
|
- public static List querySetting(Context context) {
|
|
|
- List dataList = new ArrayList<>();
|
|
|
- ContentResolver resolver = context.getContentResolver();
|
|
|
- Cursor cursor = resolver.query(MetaData.TABLE_URI_SETTING, null, null, null, null);
|
|
|
- if (cursor.moveToNext()) {
|
|
|
- int watch_face = cursor.getInt(cursor.getColumnIndex(MetaData.KEY_SETTING_WATCHFACE));
|
|
|
- int app_name = cursor.getInt(cursor.getColumnIndex(MetaData.KEY_SETTING_APPNAME));
|
|
|
- int quick_app = cursor.getInt(cursor.getColumnIndex(MetaData.KEY_SETTING_QUICKAPP));
|
|
|
- dataList.add(watch_face);
|
|
|
- dataList.add(app_name);
|
|
|
- dataList.add(quick_app);
|
|
|
- }
|
|
|
- cursor.close();
|
|
|
- return dataList;
|
|
|
- }
|
|
|
-
|
|
|
- public static void update(Context context, String key, String value) {
|
|
|
- ContentResolver resolver = context.getContentResolver();
|
|
|
- ContentValues cv = new ContentValues();
|
|
|
- cv.put(key, value);
|
|
|
- resolver.update(MetaData.TABLE_URI_SETTING, cv, null, null);
|
|
|
- }
|
|
|
-
|
|
|
public static ArrayList<ContactBean> testContactList() {
|
|
|
ArrayList<ContactBean> arrayList = new ArrayList<>();
|
|
|
for (int i = 0; i < 3; i++) {
|