Java Code Examples for org.greenrobot.greendao.query.QueryBuilder#LOG_VALUES

The following examples show how to use org.greenrobot.greendao.query.QueryBuilder#LOG_VALUES . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalKinoRepository.java    From CineLog with GNU General Public License v3.0 5 votes vote down vote up
public List<LocalKino> findAllByYear(boolean asc) {
    QueryBuilder.LOG_SQL = true;
    QueryBuilder.LOG_VALUES = true;

    QueryBuilder<LocalKino> localKinoQueryBuilder = dao.queryBuilder();

    List<LocalKino> list = localKinoQueryBuilder.build().list();

    Comparator<LocalKino> comparator;
    if (asc) {
        comparator = new Comparator<LocalKino>() {
            @Override
            public int compare(LocalKino o1, LocalKino o2) {
                int o1year = o1.getKino() != null ? o1.getKino().getYear() : 0;
                int o2year = o2.getKino() != null ? o2.getKino().getYear() : 0;
                if (o1year == o2year) {
                    return 0;
                }
                return o1year < o2year ? -1 : 1;
            }
        };
    } else {
        comparator = new Comparator<LocalKino>() {
            @Override
            public int compare(LocalKino o1, LocalKino o2) {
                int o1year = o1.getKino() != null ? o1.getKino().getYear() : 0;
                int o2year = o2.getKino() != null ? o2.getKino().getYear() : 0;
                if (o1year == o2year) {
                    return 0;
                }
                return o1year < o2year ? 1 : -1;
            }
        };
    }

    Collections.sort(list, comparator);
    return list;
}
 
Example 2
Source File: BaseApplication.java    From Android-IM with Apache License 2.0 5 votes vote down vote up
private void setupDatabase() {
    //是否开启调试
    MigrationHelper.DEBUG = true;
    QueryBuilder.LOG_SQL = true;
    QueryBuilder.LOG_VALUES = true;
    //数据库升级
    helper = new MySQLiteOpenHelper(mContext, "text");
    master = new DaoMaster(helper.getWritableDb());

}
 
Example 3
Source File: GreenDaoKyHelper.java    From BitkyShop with MIT License 5 votes vote down vote up
static void init(DaoMaster.DevOpenHelper helper) {
  // do this once, for example in your Application class
  QueryBuilder.LOG_SQL = BuildConfig.BITKY_LOG_DEBUG;
  QueryBuilder.LOG_VALUES = BuildConfig.BITKY_LOG_DEBUG;

  SQLiteDatabase db = helper.getWritableDatabase();
  DaoMaster daoMaster = new DaoMaster(db);
  daoSession = daoMaster.newSession();
}
 
Example 4
Source File: DbConnection.java    From android-app with GNU General Public License v3.0 5 votes vote down vote up
public static DaoSession getSession() {
    if(Holder.session == null) {
        // enable some debugging
        if(BuildConfig.DEBUG) {
            QueryBuilder.LOG_SQL = true;
            QueryBuilder.LOG_VALUES = true;
        }

        String dbPath = new Settings(context).getDbPathForDbHelper();

        Log.d(TAG, "creating new db session");
        WallabagDbOpenHelper dbHelper = new WallabagDbOpenHelper(context, dbPath, null);
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            dbHelper.setWriteAheadLoggingEnabled(true);
        }
        Database db = dbHelper.getWritableDb();
        if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
            if(!((SQLiteDatabase)db.getRawDatabase()).enableWriteAheadLogging()) {
                Log.w(TAG, "write ahead logging was not enabled");
            }
        }
        DaoMaster daoMaster = new DaoMaster(db);
        Holder.session = daoMaster.newSession();
    } else {
        Log.d(TAG, "using existing db session");
    }

    return Holder.session;
}
 
Example 5
Source File: DaoManager.java    From Android with MIT License 4 votes vote down vote up
public void setDebug(boolean flag) {
    QueryBuilder.LOG_SQL = flag;
    QueryBuilder.LOG_VALUES = flag;
}
 
Example 6
Source File: DbCore.java    From GreenDAO3_Demo with Apache License 2.0 4 votes vote down vote up
public static void enableQueryBuilderLog(){
    QueryBuilder.LOG_SQL = true;
    QueryBuilder.LOG_VALUES = true;
}