当前位置: 首页>>代码示例>>Java>>正文


Java SqlBrite.Query方法代码示例

本文整理汇总了Java中com.squareup.sqlbrite.SqlBrite.Query方法的典型用法代码示例。如果您正苦于以下问题:Java SqlBrite.Query方法的具体用法?Java SqlBrite.Query怎么用?Java SqlBrite.Query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.sqlbrite.SqlBrite的用法示例。


在下文中一共展示了SqlBrite.Query方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import com.squareup.sqlbrite.SqlBrite; //导入方法依赖的package包/类
@Override public List<Vocabulary> call(SqlBrite.Query query) {
  Cursor cursor = query.run();
  try {
    List<Vocabulary> values = new ArrayList<>(cursor.getCount());

    while (cursor.moveToNext()) {
      values.add(new AutoParcel_Vocabulary(
          DbUtils.getLong(cursor, ID),
          DbUtils.getString(cursor, ORIGINAL),
          DbUtils.getString(cursor, TRANSLATED),
          DbUtils.getString(cursor, LANG_ORIGINAL),
          DbUtils.getString(cursor, LANG_TRANSLATED)
      ));
    }
    return values;
  } finally {
    cursor.close();
  }
}
 
开发者ID:GerardPaligot,项目名称:LearnIt,代码行数:20,代码来源:Vocabulary.java

示例2: runQuery

import com.squareup.sqlbrite.SqlBrite; //导入方法依赖的package包/类
public static Func1<SqlBrite.Query, Cursor> runQuery() {
    return new Func1<SqlBrite.Query, Cursor>() {
        @Override
        public Cursor call(SqlBrite.Query query) {
            return query.run();
        }
    };
}
 
开发者ID:MimiReader,项目名称:mimi-reader,代码行数:9,代码来源:ActiveAndroidSqlBriteBridge.java

示例3: loadBookshelf

import com.squareup.sqlbrite.SqlBrite; //导入方法依赖的package包/类
@Override
public void loadBookshelf(ApiCompleteListener listener) {
    if (db != null) {
        Observable<SqlBrite.Query> bookshelf = db.createQuery("bookshelf", "SELECT * FROM bookshelf order by orders DESC");
        subscribe = bookshelf.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<SqlBrite.Query>() {
                    @Override
                    public void call(SqlBrite.Query query) {
                        Cursor cursor = query.run();
                        if (cursor == null || cursor.getCount() < 0) {
                            return;
                        }
                        List<Bookshelf> bookshelfs = new ArrayList<>();
                        while (cursor.moveToNext()) {
                            Bookshelf bookshelfBean = new Bookshelf();
                            bookshelfBean.setId(cursor.getInt(cursor.getColumnIndex("id")));
                            bookshelfBean.setBookCount(cursor.getInt(cursor.getColumnIndex("bookCount")));
                            bookshelfBean.setTitle(cursor.getString(cursor.getColumnIndex("title")));
                            bookshelfBean.setRemark(cursor.getString(cursor.getColumnIndex("remark")));
                            bookshelfBean.setOrder(cursor.getInt(cursor.getColumnIndex("orders")));
                            bookshelfBean.setCreateTime(cursor.getString(cursor.getColumnIndex("create_at")));
                            bookshelfs.add(bookshelfBean);
                        }
                        listener.onComplected(bookshelfs);
                    }
                });
    } else {
        listener.onFailed(new BaseResponse(500, "db error : init"));
    }
}
 
开发者ID:hymanme,项目名称:MaterialHome,代码行数:32,代码来源:BookshelfModelImpl.java

示例4: loadDataFromDatabase

import com.squareup.sqlbrite.SqlBrite; //导入方法依赖的package包/类
private void loadDataFromDatabase() {
    Observable<SqlBrite.Query> observable = db.createQuery(FavSQLiteHelper.Fav.TABLE_NAME,
            QuerySQL.selectFavorite(PreferenceManager.getValue(getContext(), TOKEN),
                    PreferenceManager.getValue(getContext(), ID)));
    observable
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(query -> {
                Cursor cursor = query.run();
                if (refreshLayout.isRefreshing())
                    refreshLayout.setRefreshing(false);
                if (cursor == null) {
                    loadData(true);
                } else {
                    List<Card> cards = new ArrayList<>();
                    while (cursor.moveToNext()) {
                        cards.add(CardConverter.createCard(cursor));
                    }
                    if (cards.size() > 0) {
                        Iterator<Object> iterator = items.iterator();
                        while (iterator.hasNext()) {
                            if (!(iterator.next() instanceof SendingCard)) {
                                iterator.remove();
                            }
                        }
                        addData(adapter, cards);
                        if (appBarCallback != null) {
                            appBarCallback.setExpanded(cards.size() == 0, false);
                        }
                    } else
                        loadData(true);
                    cursor.close();
                }
            }, throwable -> {
                if (refreshLayout.isRefreshing())
                    refreshLayout.setRefreshing(false);
                throwable.printStackTrace();
                ToastUtils.shorts(getContext(), throwable.getMessage());
            });
}
 
开发者ID:oxoooo,项目名称:excited-android,代码行数:40,代码来源:FavoritesFragment.java

示例5: getStationsObservables

import com.squareup.sqlbrite.SqlBrite; //导入方法依赖的package包/类
public Observable<List<Station>> getStationsObservables() {
    Observable<SqlBrite.Query> stations = mBrite.createQuery(PisaBikeDbHelper.STATION_TABLE, "SELECT * " +
            "FROM Station");
    return stations.map(q -> {
        Cursor cursor = q.run();
        List<Station> s = new ArrayList<>(cursor.getCount());
        while (cursor.moveToNext()) {
            Station station = new Station(cursor);
            s.add(station);
        }
        cursor.close();
        return s;
    });
}
 
开发者ID:fedepaol,项目名称:BikeSharing,代码行数:15,代码来源:BikesProvider.java

示例6: call

import com.squareup.sqlbrite.SqlBrite; //导入方法依赖的package包/类
@Override public List<Language> call(SqlBrite.Query query) {
  try (Cursor cursor = query.run()) {
    List<Language> values = new ArrayList<>(cursor.getCount());

    while (cursor.moveToNext()) {
      values.add(new AutoParcel_Language(DbUtils.getLong(cursor, ID), DbUtils.getString(cursor, LANGUAGE)));
    }
    return values;
  }
}
 
开发者ID:GerardPaligot,项目名称:LearnIt,代码行数:11,代码来源:Language.java

示例7: loadBookshelf

import com.squareup.sqlbrite.SqlBrite; //导入方法依赖的package包/类
/**
 * 取出表中所有条目
 * @param listener 回调
 */
@Override
public void loadBookshelf(final ApiCompleteListener listener) {
    if(db != null){
        final Observable<SqlBrite.Query> bookshelf = db
                .createQuery("bookshelf", "SELECT * FROM bookshelf order by id DESC");
        subscribe = bookshelf.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<SqlBrite.Query>() {
                    @Override
                    public void call(SqlBrite.Query query) {
                        Cursor cursor = query.run();
                        if(cursor == null || cursor.getCount() < 0){
                            return;
                        }
                        List<Bookshelf> bookshelfs = new ArrayList<Bookshelf>();
                        while(cursor.moveToNext()){
                            Bookshelf bookshelfBean = new Bookshelf();
                            bookshelfBean.setId(cursor.getInt(cursor.getColumnIndex("id")));
                            bookshelfBean.setTitle(cursor.getString(cursor.getColumnIndex("title")));
                            bookshelfBean.setRemark(cursor.getString(cursor.getColumnIndex("remark")));
                            bookshelfBean.setCreateTime(cursor.getString(cursor.getColumnIndex("create_at")));
                            bookshelfBean.setColor(cursor.getInt(cursor.getColumnIndex("color")));
                            bookshelfBean.setFinished(cursor.getInt(cursor.getColumnIndex("finished")));
                            bookshelfBean.setProgress(cursor.getFloat(cursor.getColumnIndex("progress")));
                            bookshelfBean.setWaveratio(cursor.getFloat(cursor.getColumnIndex("waveratio")));
                            bookshelfBean.setAmpratio(cursor.getFloat(cursor.getColumnIndex("ampratio")));
                            bookshelfBean.setTotalpage(cursor.getInt(cursor.getColumnIndex("totalpage")));
                            bookshelfBean.setCurrentpage(cursor.getInt(cursor.getColumnIndex("currentpage")));
                            bookshelfBean.setRed(cursor.getInt(cursor.getColumnIndex("red")));
                            bookshelfBean.setGreen(cursor.getInt(cursor.getColumnIndex("green")));
                            bookshelfBean.setBlue(cursor.getInt(cursor.getColumnIndex("blue")));

                            bookshelfs.add(bookshelfBean);
                        }
                        listener.onCompleted(bookshelfs);
                    }
                });


    }else{
        listener.onFailed(new BaseResponse(500, "db error : not init"));
    }
}
 
开发者ID:chengkun123,项目名称:ReadMark,代码行数:48,代码来源:BookshelfModelImpl.java

示例8: createQueryForUnsentMessages

import com.squareup.sqlbrite.SqlBrite; //导入方法依赖的package包/类
public static Observable<SqlBrite.Query> createQueryForUnsentMessages(SqlBrite brite, long userId, long rootMessageId) {
    return brite.createQuery(TABLE,
            "SELECT * FROM " + TABLE + " WHERE " + USER_ID + " = ? AND " + ROOT_MESSAGE_ID + " = ?",
            String.valueOf(userId),
            String.valueOf(rootMessageId));
}
 
开发者ID:labhackercd,项目名称:edm,代码行数:7,代码来源:LocalMessage.java

示例9: executeNext

import com.squareup.sqlbrite.SqlBrite; //导入方法依赖的package包/类
private void executeNext() {
    // FIXME We can only process one item at time.
    if (running) return;

    // We're running, baby!
    running = true;

    // TODO Prioritize current user's messages? :D

    Observable<SqlBrite.Query> query = brite.createQuery(
            LocalMessage.TABLE,
            QUERY_FIRST_MESSAGE_BY_STATUS,
            LocalMessage.valueOf(LocalMessage.Status.QUEUE));

    LocalMessage message = query.map(SqlBrite.Query::run)
            .map(LocalMessage.READ_SINGLE)
            .filter(m -> m != null)
            .toBlocking()
            .firstOrDefault(null);

    if (message == null) {
        Timber.d("Stopping service...");
        stopSelf();
        return;
    }

    // TODO FIXME When the task fails, if the user keeps retrying, it'll be executing this line N+1 times for every retry.

    AddMessageTask task = new AddMessageTask(message);

    EDMApplication.get(this).getObjectGraph().inject(task);

    subscription = Schedulers.newThread().createWorker().schedule(() -> {
        try {
            task.execute();
        } catch (Throwable t) {
            task.onError(t);
        }

        running = false;
        executeNext();
    });
}
 
开发者ID:labhackercd,项目名称:edm,代码行数:44,代码来源:AddMessageService.java


注:本文中的com.squareup.sqlbrite.SqlBrite.Query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。