- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.zulip.android.ZulipApp.getDao()
方法的一些代码示例,展示了ZulipApp.getDao()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZulipApp.getDao()
方法的具体详情如下:
包路径:com.zulip.android.ZulipApp
类名称:ZulipApp
方法名:getDao
暂无
代码示例来源:origin: zulip/zulip-android
public <C, T> RuntimeExceptionDao<C, T> getDao(Class<C> cls) {
return getDao(cls, false);
}
代码示例来源:origin: zulip/zulip-android
public static Person getById(ZulipApp app, int id) {
RuntimeExceptionDao<Person, Object> dao = app.getDao(Person.class);
return dao.queryForId(id);
}
代码示例来源:origin: zulip/zulip-android
@Override
public Cursor call() throws Exception {
String query = "SELECT s.id as _id, s.name, s.color"
+ " FROM streams as s LEFT JOIN messages as m ON s.id=m.stream ";
String selectArg = null;
if (!etSearchStream.getText().toString().equals("") && !etSearchStream.getText().toString().isEmpty()) {
//append where clause
selectArg = etSearchStream.getText().toString() + '%';
query += " WHERE s.name LIKE ? " + " and s." + Stream.SUBSCRIBED_FIELD + " = " + "1 ";
//set visibility of this image false
ivSearchStreamCancel.setVisibility(View.VISIBLE);
} else {
//set visibility of this image false
query += " WHERE s." + Stream.SUBSCRIBED_FIELD + " = " + "1 ";
ivSearchStreamCancel.setVisibility(View.GONE);
}
//append group by
query += " group by s.name order by s.name COLLATE NOCASE";
if (selectArg != null) {
return ((AndroidDatabaseResults) app.getDao(Stream.class).queryRaw(query, selectArg).closeableIterator().getRawResults()).getRawCursor();
} else {
return ((AndroidDatabaseResults) app.getDao(Stream.class).queryRaw(query).closeableIterator().getRawResults()).getRawCursor();
}
}
};
代码示例来源:origin: zulip/zulip-android
public static Stream getByName(ZulipApp app, String name) {
Stream stream = null;
try {
RuntimeExceptionDao<Stream, Object> streams = app.getDao(Stream.class);
stream = streams.queryBuilder().where()
.eq(Stream.NAME_FIELD, new SelectArg(name)).queryForFirst();
if (stream == null) {
Log.w("Stream.getByName",
"We received a stream message for a stream we don't have data for. Fake it until you make it.");
stream = new Stream(name);
app.getDao(Stream.class).createIfNotExists(stream);
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
return stream;
}
代码示例来源:origin: zulip/zulip-android
@Override
public Cursor getChildrenCursor(Cursor groupCursor) {
List<String[]> results = new ArrayList<>();
try {
results = ZulipApp.get().getDao(Message.class).queryRaw("SELECT DISTINCT subject FROM messages " +
"JOIN streams ON streams.id=messages.stream " +
"WHERE streams.id=" + groupCursor.getInt(0) + " and streams." + Stream.SUBSCRIBED_FIELD + " = " + "1 group by subject").getResults();
} catch (SQLException e) {
ZLog.logException(e);
}
MatrixCursor matrixCursor = new MatrixCursor(new String[]{"subject", "_id"});
for (String[] result : results) {
try {
matrixCursor.addRow(new String[]{result[0], String.valueOf(groupCursor.getInt(0))});
} catch (Exception e) {
ZLog.logException(e);
}
}
return matrixCursor;
}
}
代码示例来源:origin: zulip/zulip-android
public static List<Person> getAllPeople(ZulipApp app) throws SQLException {
RuntimeExceptionDao<Person, Object> dao = app.getDao(Person.class);
return dao.queryBuilder().where().eq(Person.ISBOT_FIELD, false).query();
}
代码示例来源:origin: zulip/zulip-android
public void processStreams(List<EventsBranch> events) {
for (EventsBranch event : events) {
StreamWrapper streamEvent = (StreamWrapper) event;
if (streamEvent.getOperation().equalsIgnoreCase(StreamWrapper.OP_OCCUPY)) {
Dao<Stream, Integer> streamDao = app.getDao(Stream.class);
List<Stream> streams = streamEvent.getStreams();
for (Stream stream : streams) {
try {
// use default color for not subscribed streams
stream.setDefaultColor();
streamDao.createIfNotExists(stream);
} catch (SQLException e) {
ZLog.logException(e);
}
}
} else {
// TODO: handle other operations of stream event
Log.d("AsyncEvents", "unhandled operation for stream type event");
return;
}
}
}
代码示例来源:origin: zulip/zulip-android
private Cursor makePeopleNameCursor(CharSequence name) throws SQLException {
if (name == null) {
name = "";
}
return ((AndroidDatabaseResults) app
.getDao(Person.class)
.queryRaw(
"SELECT rowid _id, * FROM people WHERE "
+ Person.ISBOT_FIELD + " = 0 AND "
+ Person.ISACTIVE_FIELD + " = 1 AND "
+ Person.NAME_FIELD
+ " LIKE ? ESCAPE '\\' ORDER BY "
+ Person.NAME_FIELD + " COLLATE NOCASE",
DatabaseHelper.likeEscape(name.toString()) + "%")
.closeableIterator().getRawResults()).getRawCursor();
}
代码示例来源:origin: zulip/zulip-android
/**
* Returns a cursor for the combinedAdapter used to suggest Emoji when ':' is typed in the {@link #messageEt}
*
* @param emoji A string to search in the existing database
*/
private Cursor makeEmojiCursor(CharSequence emoji)
throws SQLException {
if (emoji == null) {
emoji = "";
}
return ((AndroidDatabaseResults) app
.getDao(Emoji.class)
.queryRaw("SELECT rowid _id,name FROM emoji WHERE name LIKE '%" + emoji + "%'")
.closeableIterator().getRawResults()).getRawCursor();
}
代码示例来源:origin: zulip/zulip-android
@Override
public void onDataSetChanged() {
Log.i("ZULIP_WIDGET", "onDataSetChanged() = Data reloaded");
QueryBuilder<Message, Object> queryBuilder = ZulipApp.get().getDao(Message.class).queryBuilder();
String filter;
filter = setupWhere();
if (!filter.equals("")) {
queryBuilder.where().raw(filter);
}
try {
messageList = queryBuilder.query();
} catch (SQLException e) {
ZLog.logException(e);
}
}
代码示例来源:origin: zulip/zulip-android
/**
* Creates a cursor to get the streams saved in the database
*
* @param streamName Filter out streams name containing this string
*/
private Cursor makeStreamCursor(CharSequence streamName)
throws SQLException {
if (streamName == null) {
streamName = "";
}
return ((AndroidDatabaseResults) app
.getDao(Stream.class)
.queryRaw(
"SELECT rowid _id, * FROM streams WHERE "
+ Stream.SUBSCRIBED_FIELD + " = 1 AND "
+ Stream.NAME_FIELD
+ " LIKE ? ESCAPE '\\' ORDER BY "
+ Stream.NAME_FIELD + " COLLATE NOCASE",
DatabaseHelper.likeEscape(streamName.toString()) + "%")
.closeableIterator().getRawResults()).getRawCursor();
}
代码示例来源:origin: zulip/zulip-android
public Void call() throws Exception {
for (int i = 1; i <= 300; i++) {
sampleMessage(app, i);
}
for (int i = 501; i <= 800; i++) {
sampleMessage(app, i);
}
app.getDao(MessageRange.class).create(new MessageRange(1, 300));
app.getDao(MessageRange.class).create(
new MessageRange(501, 800));
return null;
}
});
代码示例来源:origin: zulip/zulip-android
/**
* Fills the Emoji Table with the existing emoticons saved in the assets folder.
*/
private void setupEmoji() {
try {
final RuntimeExceptionDao<Emoji, Object> dao = getDao(Emoji.class);
if (dao.queryForAll().size() != 0) return;
final String emojis[] = getAssets().list("emoji");
TransactionManager.callInTransaction(getDatabaseHelper()
.getConnectionSource(),
new Callable<Void>() {
public Void call() throws Exception {
for (String newEmoji : emojis) {
//currently emojis are in png format
newEmoji = newEmoji.replace(".png", "");
dao.create(new Emoji(newEmoji));
}
return null;
}
});
} catch (SQLException | IOException e) {
ZLog.logException(e);
}
}
代码示例来源:origin: zulip/zulip-android
/**
* Checks stream name is valid or not
*
* @param app ZulipApp
* @param streamName Checks this stream name is valid or not
* @return null if stream does not exist else cursor
*/
public static Stream streamCheckBeforeMessageSend(ZulipApp app, CharSequence streamName) {
if (streamName == null) {
return null;
}
try {
return app.getDao(Stream.class)
.queryBuilder().where()
.eq(Stream.NAME_FIELD, new SelectArg(Stream.NAME_FIELD, streamName)).queryForFirst();
} catch (SQLException e) {
ZLog.logException(e);
}
return null;
}
代码示例来源:origin: zulip/zulip-android
public static void updateNewMessagesRange(ZulipApp app, int maxId) {
synchronized (app.updateRangeLock) {
RuntimeExceptionDao<MessageRange, Integer> rangeDao = app
.getDao(MessageRange.class);
MessageRange currentRange = MessageRange.getRangeContaining(
app.getMaxMessageId(), rangeDao);
if (currentRange == null) {
currentRange = new MessageRange(app.getMaxMessageId(),
app.getMaxMessageId());
}
if (currentRange.high <= maxId) {
currentRange.high = maxId;
rangeDao.createOrUpdate(currentRange);
}
}
app.setMaxMessageId(maxId);
}
代码示例来源:origin: zulip/zulip-android
private void checkRanges(String rangestr) throws SQLException {
List<MessageRange> ranges = app.getDao(MessageRange.class)
.queryBuilder().orderBy("low", true).query();
String s = "";
for (MessageRange rng : ranges) {
s += "(" + rng.low + "," + rng.high + ")";
}
assertEquals(rangestr, s);
}
代码示例来源:origin: zulip/zulip-android
private void selectPointer() {
if (filter != null) {
Where<Message, Object> filteredWhere;
try {
filteredWhere = filter.modWhere(app.getDao(Message.class)
.queryBuilder().where());
filteredWhere.and().le(Message.ID_FIELD, app.getPointer());
QueryBuilder<Message, Object> closestQuery = app.getDao(
Message.class).queryBuilder();
closestQuery.orderBy(Message.TIMESTAMP_FIELD, false).setWhere(
filteredWhere);
Message closestMessage = closestQuery.queryForFirst();
// use anchor message id if message was narrowed
if (anchorId != -1) {
selectMessage(getMessageById(anchorId));
} else {
recyclerView.scrollToPosition(adapter.getItemIndex(closestMessage));
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
} else {
int anc = app.getPointer();
selectMessage(getMessageById(anc));
}
}
代码示例来源:origin: zulip/zulip-android
public Void call() throws Exception {
RuntimeExceptionDao<Message, Object> messageDao = app.getDao(Message.class);
for (Message m : messages) {
Person person = Person.getOrUpdate(app, m.getSenderEmail(), m.getSenderFullName(), m.getAvatarUrl(), m.getSenderId());
m.setSender(person);
Stream stream = null;
if (m.getType() == MessageType.STREAM_MESSAGE) {
stream = Stream.getByName(app, m.getRecipients());
}
m.setStream(stream);
messageDao.createOrUpdate(m);
}
return null;
}
});
代码示例来源:origin: zulip/zulip-android
/**
* Returns old form of edited message.
*
* @return {@link Message} message
*/
public Message getMessage(int messageId) {
try {
Dao<Message, Integer> messageDao = ZulipApp.get().getDao(Message.class);
Message message = messageDao.queryBuilder().where().eq(Message.ID_FIELD, messageId).queryForFirst();
if (message != null) {
if (this.formattedContent != null) {
message.setFormattedContent(this.formattedContent);
message.setHasBeenEdited(true);
}
if (containsSubject()) {
message.setSubject(this.subject);
}
return message;
}
} catch (SQLException e) {
ZLog.logException(e);
}
return null;
}
代码示例来源:origin: zulip/zulip-android
/**
* Run this before each test to set up the activity.
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void prepTests() {
setApplication(app);
this.startActivity(new Intent(getInstrumentation().getTargetContext(),
ZulipActivity.class), null, null);
this.getInstrumentation().waitForIdleSync();
app.setContext(getInstrumentation().getTargetContext());
// Need to setEmail twice to reinitialise the database after destroying
// it.
app.setEmail(TESTUSER_EXAMPLE_COM);
app.deleteDatabase(app.getDatabaseHelper().getDatabaseName());
app.setEmail(TESTUSER_EXAMPLE_COM);
messageDao = app.getDao(Message.class);
}
我想了解 Ruby 方法 methods() 是如何工作的。 我尝试使用“ruby 方法”在 Google 上搜索,但这不是我需要的。 我也看过 ruby-doc.org,但我没有找到这种方法。
Test 方法 对指定的字符串执行一个正则表达式搜索,并返回一个 Boolean 值指示是否找到匹配的模式。 object.Test(string) 参数 object 必选项。总是一个
Replace 方法 替换在正则表达式查找中找到的文本。 object.Replace(string1, string2) 参数 object 必选项。总是一个 RegExp 对象的名称。
Raise 方法 生成运行时错误 object.Raise(number, source, description, helpfile, helpcontext) 参数 object 应为
Execute 方法 对指定的字符串执行正则表达式搜索。 object.Execute(string) 参数 object 必选项。总是一个 RegExp 对象的名称。 string
Clear 方法 清除 Err 对象的所有属性设置。 object.Clear object 应为 Err 对象的名称。 说明 在错误处理后,使用 Clear 显式地清除 Err 对象。此
CopyFile 方法 将一个或多个文件从某位置复制到另一位置。 object.CopyFile source, destination[, overwrite] 参数 object 必选
Copy 方法 将指定的文件或文件夹从某位置复制到另一位置。 object.Copy destination[, overwrite] 参数 object 必选项。应为 File 或 F
Close 方法 关闭打开的 TextStream 文件。 object.Close object 应为 TextStream 对象的名称。 说明 下面例子举例说明如何使用 Close 方
BuildPath 方法 向现有路径后添加名称。 object.BuildPath(path, name) 参数 object 必选项。应为 FileSystemObject 对象的名称
GetFolder 方法 返回与指定的路径中某文件夹相应的 Folder 对象。 object.GetFolder(folderspec) 参数 object 必选项。应为 FileSy
GetFileName 方法 返回指定路径(不是指定驱动器路径部分)的最后一个文件或文件夹。 object.GetFileName(pathspec) 参数 object 必选项。应为
GetFile 方法 返回与指定路径中某文件相应的 File 对象。 object.GetFile(filespec) 参数 object 必选项。应为 FileSystemObject
GetExtensionName 方法 返回字符串,该字符串包含路径最后一个组成部分的扩展名。 object.GetExtensionName(path) 参数 object 必选项。应
GetDriveName 方法 返回包含指定路径中驱动器名的字符串。 object.GetDriveName(path) 参数 object 必选项。应为 FileSystemObjec
GetDrive 方法 返回与指定的路径中驱动器相对应的 Drive 对象。 object.GetDrive drivespec 参数 object 必选项。应为 FileSystemO
GetBaseName 方法 返回字符串,其中包含文件的基本名 (不带扩展名), 或者提供的路径说明中的文件夹。 object.GetBaseName(path) 参数 object 必
GetAbsolutePathName 方法 从提供的指定路径中返回完整且含义明确的路径。 object.GetAbsolutePathName(pathspec) 参数 object
FolderExists 方法 如果指定的文件夹存在,则返回 True;否则返回 False。 object.FolderExists(folderspec) 参数 object 必选项
FileExists 方法 如果指定的文件存在返回 True;否则返回 False。 object.FileExists(filespec) 参数 object 必选项。应为 FileS
我是一名优秀的程序员,十分优秀!