gpt4 book ai didi

com.zulip.android.ZulipApp.getDatabaseHelper()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:45:59 28 4
gpt4 key购买 nike

本文整理了Java中com.zulip.android.ZulipApp.getDatabaseHelper()方法的一些代码示例,展示了ZulipApp.getDatabaseHelper()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZulipApp.getDatabaseHelper()方法的具体详情如下:
包路径:com.zulip.android.ZulipApp
类名称:ZulipApp
方法名:getDatabaseHelper

ZulipApp.getDatabaseHelper介绍

暂无

代码示例

代码示例来源:origin: zulip/zulip-android

public static Stream getById(ZulipApp app, int id) {
  try {
    Dao<Stream, Integer> streams = app.getDatabaseHelper().getDao(
        Stream.class);
    return streams.queryForId(id);
  } catch (SQLException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: zulip/zulip-android

public static void createMessages(final ZulipApp app,
                 final List<Message> messages) {
  try {
    TransactionManager.callInTransaction(app.getDatabaseHelper()
        .getConnectionSource(), new Callable<Void>() {
      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;
      }
    });
  } catch (SQLException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: zulip/zulip-android

public static Person getByEmail(ZulipApp app, String email) {
  try {
    return getByEmail(app.getDatabaseHelper().getDao(
        Person.class), email);
  } catch (SQLException e) {
    ZLog.logException(e);
  }
  return null;
}

代码示例来源:origin: zulip/zulip-android

try {
  synchronized (app.updateRangeLock) {
    TransactionManager.callInTransaction(app.getDatabaseHelper()
        .getConnectionSource(), new Callable<Void>() {
      public Void call() throws Exception {

代码示例来源: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

TransactionManager.callInTransaction(app.getDatabaseHelper()
    .getConnectionSource(), new Callable<Void>() {
  public Void call() throws Exception {

代码示例来源:origin: zulip/zulip-android

TransactionManager.callInTransaction(app.getDatabaseHelper()
    .getConnectionSource(), new Callable<Void>() {
  public Void call() throws Exception {

代码示例来源:origin: zulip/zulip-android

/**
 * This function returns the last message read in {@param streamName} stream.
 *
 * @param app        {@link ZulipApp}
 * @param streamName name of stream
 * @return last message {@link Message} read
 */
public static Message getLastMessageRead(ZulipApp app, String streamName) {
  try {
    Dao<Message, Integer> messageDao = app.getDatabaseHelper().getDao(Message.class);
    // query for message in given stream and orderby timestamp decreasingly
    return messageDao.queryBuilder().orderBy(Message.TIMESTAMP_FIELD, false)
        .where().eq(Message.RECIPIENTS_FIELD, new SelectArg(Message.RECIPIENTS_FIELD, streamName))
        .queryForFirst();
  } 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);
}

代码示例来源:origin: zulip/zulip-android

public void testMessageTrim() throws SQLException {
  prepTests();
  TransactionManager.callInTransaction(app.getDatabaseHelper()
      .getConnectionSource(), new Callable<Void>() {
    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;
    }
  });
  RuntimeExceptionDao<MessageRange, Integer> messageRangeDao = app
      .getDao(MessageRange.class);
  assertEquals(600, messageDao.countOf());
  Message.trim(100, app);
  this.messageDao.queryForAll();
  assertEquals(100, messageDao.countOf());
  assertEquals(1, messageRangeDao.countOf());
  MessageRange r = messageRangeDao.queryBuilder().queryForFirst();
  // We have messages 701 through 800, which is 100 messages.
  assertEquals(800, r.high);
  assertEquals(800 - 99, r.low);
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com