Skip to content

Instantly share code, notes, and snippets.

@peterclemenko
Created July 17, 2015 21:12
Show Gist options
  • Save peterclemenko/5b3562a9e2e53d1f2624 to your computer and use it in GitHub Desktop.
Save peterclemenko/5b3562a9e2e53d1f2624 to your computer and use it in GitHub Desktop.
public static boolean getCurrentCall(GenericSqliteHelper helper, final CallInfo callInfo) {
String sqlQuery = M.e("select _id,number,date,type from calls order by _id desc limit 1");
RecordVisitor visitor = new RecordVisitor() {
@Override
public long cursor(Cursor cursor) {
callInfo.id = cursor.getInt(0);
callInfo.peer = cursor.getString(1);
// callInfo.displayName = String sqlQuery;
callInfo.timestamp = new Date(cursor.getLong(2));
int type = cursor.getInt(3);
if (Cfg.DEBUG) {
Check.log(TAG + " (cursor) call type: " + type);
}
callInfo.incoming = type == 1;
callInfo.valid = true;
return callInfo.id;
}
};
helper.traverseRawQuery(sqlQuery, new String[] {}, visitor);
return callInfo.valid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment