|
@@ -18,9 +18,34 @@ import java.util.List;
|
|
|
|
|
|
public class DatabaseHelper {
|
|
|
|
|
|
+ @SuppressLint("Range")
|
|
|
+ public static List<RecentBean> queryRecent(Context context) {
|
|
|
+ if (Macros.DEBUG_DATABASE_RECENT) {
|
|
|
+ return testRecentList();
|
|
|
+ } else {
|
|
|
+ List<RecentBean> dataList = new ArrayList<>();
|
|
|
+ ContentResolver resolver = context.getContentResolver();
|
|
|
+ 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"));
|
|
|
+ bean.caller = cursor.getString(cursor.getColumnIndex("caller"));
|
|
|
+ bean.callee = cursor.getString(cursor.getColumnIndex("callee"));
|
|
|
+ bean.userId = cursor.getString(cursor.getColumnIndex("userId"));
|
|
|
+ bean.start = cursor.getInt(cursor.getColumnIndex("start"));
|
|
|
+ bean.end = cursor.getInt(cursor.getColumnIndex("end"));
|
|
|
+ bean.type = cursor.getInt(cursor.getColumnIndex("type"));
|
|
|
+ dataList.add(bean);
|
|
|
+ }
|
|
|
+ cursor.close();
|
|
|
+ return dataList;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@SuppressLint("Range")
|
|
|
public static ArrayList<ContactBean> queryContacts(Context context) {
|
|
|
- if (Macros.DEBUG_DATABASE) {
|
|
|
+ if (Macros.DEBUG_DATABASE_CONTACT) {
|
|
|
return testContactList();
|
|
|
} else {
|
|
|
ArrayList<ContactBean> arrayList = new ArrayList<>();
|
|
@@ -48,29 +73,16 @@ public class DatabaseHelper {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @SuppressLint("Range")
|
|
|
- public static List<RecentBean> queryRecent(Context context) {
|
|
|
- if (Macros.DEBUG_DATABASE) {
|
|
|
- return testRecentList();
|
|
|
- } else {
|
|
|
- List<RecentBean> dataList = new ArrayList<>();
|
|
|
- ContentResolver resolver = context.getContentResolver();
|
|
|
- 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"));
|
|
|
- bean.caller = cursor.getString(cursor.getColumnIndex("caller"));
|
|
|
- bean.callee = cursor.getString(cursor.getColumnIndex("callee"));
|
|
|
- bean.userId = cursor.getString(cursor.getColumnIndex("userId"));
|
|
|
- bean.start = cursor.getInt(cursor.getColumnIndex("start"));
|
|
|
- bean.end = cursor.getInt(cursor.getColumnIndex("end"));
|
|
|
- bean.type = cursor.getInt(cursor.getColumnIndex("type"));
|
|
|
- dataList.add(bean);
|
|
|
- }
|
|
|
- cursor.close();
|
|
|
- return dataList;
|
|
|
+ public static ArrayList<RecentBean> testRecentList() {
|
|
|
+ ArrayList<RecentBean> recentList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
+ RecentBean model = new RecentBean();
|
|
|
+ model.caller = "Grandma";
|
|
|
+ model.type = i;
|
|
|
+ model.start = ToolsUtils.getCurrentTimeSecond();
|
|
|
+ recentList.add(model);
|
|
|
}
|
|
|
+ return recentList;
|
|
|
}
|
|
|
|
|
|
public static ArrayList<ContactBean> testContactList() {
|
|
@@ -83,16 +95,4 @@ public class DatabaseHelper {
|
|
|
}
|
|
|
return arrayList;
|
|
|
}
|
|
|
-
|
|
|
- public static ArrayList<RecentBean> testRecentList() {
|
|
|
- ArrayList<RecentBean> recentList = new ArrayList<>();
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
- RecentBean model = new RecentBean();
|
|
|
- model.caller = "Grandma";
|
|
|
- model.type = i;
|
|
|
- model.start = ToolsUtils.getCurrentTimeSecond();
|
|
|
- recentList.add(model);
|
|
|
- }
|
|
|
- return recentList;
|
|
|
- }
|
|
|
}
|