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


Java Query类代码示例

本文整理汇总了Java中de.greenrobot.dao.query.Query的典型用法代码示例。如果您正苦于以下问题:Java Query类的具体用法?Java Query怎么用?Java Query使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getSchoolmateFriendState

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
public Task<Integer> getSchoolmateFriendState(String uid){
    if (caches.get(uid) == null){
        return Task.callInBackground(() -> {
            QueryBuilder<Schoolmate> schoolmateQueryBuilder = DaoHelper.getInstance().getSchoolmateDao().queryBuilder();
            schoolmateQueryBuilder.where(schoolmateQueryBuilder.and(SchoolmateDao.Properties.UserId.eq(uid),
                    SchoolmateDao.Properties.ReleatedId.eq(HiTalkHelper.getInstance().getCurrentUserId())));
            Query<Schoolmate> build = schoolmateQueryBuilder.build();
            int friendState = REQUEST_STATE_FAILED;
            try{
                friendState = build.unique().getFriendState();
            }catch (Exception e){
                NLog.e(TagUtil.makeTag(getClass()),"getSchoolmateFriendState failed ",e);
            }
            caches.put(uid,friendState);
            return friendState;
        });
    }else {
        return Task.forResult(caches.get(uid));
    }
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:21,代码来源:SchoolmatesCacheHelper.java

示例2: readCitySync

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
public Observable<List<String>> readCitySync(final String province) {
    return Observable.create(new Observable.OnSubscribe<List<String>>() {
        @Override
        public void call(Subscriber<? super List<String>> subscriber) {
            CityDao cityDao = CityDB.getCityDao(m_context);
            Query<CityWrapper> query = cityDao.queryBuilder()
                    .where(CityDao.Properties.PROVINCE.eq(province)).build();
            List<CityWrapper> cityWrapperList = query.list();
            List<String> cities = new ArrayList<String>();
            try {
                final int size = cityWrapperList.size();
                for (int i = 0; i < size; ++i) {
                    cities.add(cityWrapperList.get(i).getCity());
                }
                subscriber.onNext(cities);
            } catch (Exception e) {
                subscriber.onError(e);
                return;
            }
            subscriber.onCompleted();
        }
    }).onBackpressureDrop();
}
 
开发者ID:ChanJLee,项目名称:YunShuWeather,代码行数:24,代码来源:RxReadSettingItems.java

示例3: getPrinterFromDbByName

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
public PrinterDbEntity getPrinterFromDbByName(String name) {
    Query<PrinterDbEntity> query = mNameSearchQueryMap.get(name);
    if (query == null) {
        query = mPrinterDbEntityDao.queryBuilder()
                .where(PrinterDbEntityDao.Properties.Name.eq(name))
                .build();
        mNameSearchQueryMap.put(name, query);
    }

    try {
        synchronized (sLock) {
            // Need to call forCurrentThread or else it will throw DaoException
            return query.forCurrentThread().unique();
        }
    } catch (DaoException e) {
        return null; // Shouldn't happen
    }
}
 
开发者ID:nairbspace,项目名称:octoandroid,代码行数:19,代码来源:DbHelper.java

示例4: getPrinterFromDbById

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
public PrinterDbEntity getPrinterFromDbById(long printerId) {
    Query<PrinterDbEntity> query = mIdSearchQueryMap.get(printerId);
    if (query == null) {
        query = mPrinterDbEntityDao.queryBuilder()
                .where(PrinterDbEntityDao.Properties.Id.eq(printerId))
                .build();
        mIdSearchQueryMap.put(printerId, query);
    }
    try {
        synchronized (sLock) {
            // Need to call forCurrentThread or else it will throw DaoException
            return query.forCurrentThread().unique();
        }
    } catch (DaoException e) {
        return null; // Shouldn't happen
    }
}
 
开发者ID:nairbspace,项目名称:octoandroid,代码行数:18,代码来源:DbHelper.java

示例5: __getDataList

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
private List<GenericDataDB> __getDataList(long deviceId, long startTimestamp, long endTimestamp)
{
    log.info(Thread.currentThread().toString() + "##getDataList(startTimestamp=["
        + TimeUtil.getDateStr(startTimestamp, null) + "],endTimestamp=[" + TimeUtil.getDateStr(endTimestamp, null)
        + "]): start");
    Query<GenericDataDB> query =
        genericDataDao.queryBuilder()
            .where(Properties.Timestamp.ge(startTimestamp),
                Properties.Timestamp.lt(endTimestamp),
                Properties.DeviceId.eq(deviceId))
            .orderAsc(Properties.Timestamp)
            .build();
    List<GenericDataDB> result = query.list();
    log.info(Thread.currentThread().toString() + "##getDataList(startTimestamp=["
        + TimeUtil.getDateStr(startTimestamp, null) + "],endTimestamp=[" + TimeUtil.getDateStr(endTimestamp, null)
        + "]): end");
    return result;
}
 
开发者ID:EspressifApp,项目名称:IOT-Espressif-Android,代码行数:19,代码来源:IOTGenericDataDBManager.java

示例6: changeUserInfo

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
/**
 * change User info in local db
 * 
 * @param id user's id
 * @param email user's email
 * @param key user's key
 * @param name user name
 */
@Override
public void changeUserInfo(long id, String email, String key, String name)
{
    log.info(Thread.currentThread().toString() + "##changeUserInfo(id=[" + id + "],email=[" + email
        + "],key=[" + key + "]");
    Query<UserDB> query = userDao.queryBuilder().where(Properties.IsLastLogin.eq(true)).build();
    UserDB result = query.unique();
    if (result != null)
    {
        // clear the old login info
        result.setIsLastLogin(false);
        userDao.update(result);
    }
    result = new UserDB(id, email, key, name, true);
    userDao.insertOrReplace(result);
}
 
开发者ID:EspressifApp,项目名称:IOT-Espressif-Android,代码行数:25,代码来源:IOTUserDBManager.java

示例7: load

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
/**
 * load the UserDB from local db
 * 
 * @return UserDB info
 */
@Override
public IUserDB load()
{
    UserDB result = null;
    
    Query<UserDB> query = userDao.queryBuilder().where(Properties.IsLastLogin.eq(true)).build();
    result = query.unique();
    if (result != null)
    {
        log.debug(Thread.currentThread().toString() + "##load(): " + result);
        return result;
    }
    // the app hasn't been login yet
    log.debug(Thread.currentThread().toString() + "##load(): " + result);
    return result;
}
 
开发者ID:EspressifApp,项目名称:IOT-Espressif-Android,代码行数:22,代码来源:IOTUserDBManager.java

示例8: __getUserDeviceList

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
private List<IDeviceDB> __getUserDeviceList(long userId)
{
    Query<UserDB> query = userDao.queryBuilder().where(Properties.Id.eq(userId)).build();
    UserDB user = query.unique();
    List<DeviceDB> result = null;
    if (user != null)
    {
        user.resetDevices();
        result = user.getDevices();
    }
    log.debug(Thread.currentThread().toString() + "##getUserDeviceList(userId=[" + userId + "]): " + result);
    if (result != null)
    {
        List<IDeviceDB> deviceList = new ArrayList<IDeviceDB>();
        deviceList.addAll(result);
        return deviceList;
    }
    else
    {
        return Collections.emptyList();
    }
}
 
开发者ID:EspressifApp,项目名称:IOT-Espressif-Android,代码行数:23,代码来源:IOTUserDBManager.java

示例9: getNextNegativeId

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
/**
 * get the next negative id for activating device used as device id
 * 
 * @return
 */
private long getNextNegativeId()
{
    Query<DeviceDB> query = deviceDao.queryBuilder().where(Properties.Id.lt(0)).build();
    long nextId = 0;
    List<DeviceDB> deviceList = query.list();
    for (DeviceDB device : deviceList)
    {
        long deviceId = device.getId();
        if (deviceId < nextId)
        {
            nextId = deviceId;
        }
    }
    // the nextId should be less than the most min device id
    --nextId;
    log.debug(Thread.currentThread().toString() + "##getNextNegativeId(): " + nextId);
    return nextId;
}
 
开发者ID:EspressifApp,项目名称:IOT-Espressif-Android,代码行数:24,代码来源:IOTDeviceDBManager.java

示例10: getNegativeDeviceIdByBssid

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
private long getNegativeDeviceIdByBssid(String bssid)
{
    Query<DeviceDB> query = deviceDao.queryBuilder().where(Properties.Bssid.eq(bssid)).build();
    DeviceDB device = query.unique();
    if (device == null)
    {
        log.info(Thread.currentThread().toString() + "##getNegativeDeviceIdByBssid(bssid=[" + bssid + "]): 0");
        return 0;
    }
    else
    {
        long result = device.getId();
        log.info(Thread.currentThread().toString() + "##getNegativeDeviceIdByBssid(bssid=[" + bssid + "]): "
            + result);
        return result;
    }
}
 
开发者ID:EspressifApp,项目名称:IOT-Espressif-Android,代码行数:18,代码来源:IOTDeviceDBManager.java

示例11: delete

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
@Override
public synchronized void delete(long deviceId)
{
    Query<DeviceDB> query = deviceDao.queryBuilder().where(Properties.Id.eq(deviceId)).build();
    DeviceDB result = query.unique();
    if (result != null)
    {
        deviceDao.delete(result);
        log.info(Thread.currentThread().toString() + "##delete(deviceId=[" + deviceId + "]): " + result);
    }
    else
    {
        log.debug(Thread.currentThread().toString() + "##delete(deviceId=[" + deviceId
            + "]): the device isn't exist");
    }
}
 
开发者ID:EspressifApp,项目名称:IOT-Espressif-Android,代码行数:17,代码来源:IOTDeviceDBManager.java

示例12: deleteDevicesByDeviceId

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
@Override
public void deleteDevicesByDeviceId(long deviceId)
{
    Query<DeviceDB> query = deviceDao.queryBuilder().where(Properties.Id.eq(deviceId)).build();
    DeviceDB result = query.unique();
    if (result != null)
    {
        String bssid = result.getBssid();
        deleteDevicesByBssid(bssid);
    }
    else
    {
        log.debug(Thread.currentThread().toString() + "##deleteDevicesByDeviceId(deviceId=[" + deviceId
            + "]): the device isn't exist");
    }
}
 
开发者ID:EspressifApp,项目名称:IOT-Espressif-Android,代码行数:17,代码来源:IOTDeviceDBManager.java

示例13: findAllBeans

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
public static Task<List<Bean>> findAllBeans(final Collection<String> excludeLocalIds) {

        return Task.callInBackground(new Callable<List<Bean>>() {
            @Override
            public List<Bean> call() throws Exception {
                BeanDao beansDao = DaoHelper.getInstance().getBeansDao();
                Query<Bean> build = beansDao.queryBuilder().where(BeanDao.Properties.LocalId.notIn(excludeLocalIds))
                        .orderDesc(BeanDao.Properties.CreateAt)
                        .build();
                return build.list();
            }
        });
    }
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:14,代码来源:BeanHelper.java

示例14: queryBean

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
public static Task<Bean> queryBean(final String id){
    return Task.callInBackground(new Callable<Bean>() {
        @Override
        public Bean call() throws Exception {
            BeanDao beanDao = DaoHelper.getInstance().getBeansDao();
            Query<Bean> build = beanDao.queryBuilder().where(BeanDao.Properties.LocalId.eq(id)).build();
            return build.unique();
        }
    });
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:11,代码来源:BeanHelper.java

示例15: queryAsync

import de.greenrobot.dao.query.Query; //导入依赖的package包/类
public <T> void queryAsync(final Query<T> query, final AVCallback<List<T>> callback){
    RxjavaUtils.AsyncJob(new Runnable() {
        @Override
        public void run() {
            try {
                Query<T> tQuery = query.forCurrentThread();
                callback.internalDone(tQuery.list(),null);
            }catch (Exception e){
                callback.internalDone(null,new AVException(new Throwable("queryAsync failed")));
            }


        }
    });
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:16,代码来源:DaoHelper.java


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