Java Code Examples for com.lzy.okgo.utils.OkLogger#v()

The following examples show how to use com.lzy.okgo.utils.OkLogger#v() . These examples are extracted from open source projects. 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 Project: okhttp-OkGo   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 插入一条记录 */
public boolean insert(T t) {
    if (t == null) return false;
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        database.insert(getTableName(), null, getContentValues(t));
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " insertT");
    }
    return false;
}
 
Example 2
Source Project: okhttp-OkGo   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 插入多条记录 */
public boolean insert(List<T> ts) {
    if (ts == null) return false;
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        for (T t : ts) {
            database.insert(getTableName(), null, getContentValues(t));
        }
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " insertList");
    }
    return false;
}
 
Example 3
Source Project: okhttp-OkGo   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 根据条件删除数据库中的数据 */
public boolean delete(String whereClause, String[] whereArgs) {
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        database.delete(getTableName(), whereClause, whereArgs);
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " delete");
    }
    return false;
}
 
Example 4
Source Project: okhttp-OkGo   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
public boolean deleteList(List<Pair<String, String[]>> where) {
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        for (Pair<String, String[]> pair : where) {
            database.delete(getTableName(), pair.first, pair.second);
        }
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " deleteList");
    }
    return false;
}
 
Example 5
Source Project: okhttp-OkGo   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * replace 语句有如下行为特点
 * 1. replace语句会删除原有的一条记录, 并且插入一条新的记录来替换原记录。
 * 2. 一般用replace语句替换一条记录的所有列, 如果在replace语句中没有指定某列, 在replace之后这列的值被置空 。
 * 3. replace语句根据主键的值确定被替换的是哪一条记录
 * 4. 如果执行replace语句时, 不存在要替换的记录, 那么就会插入一条新的记录。
 * 5. replace语句不能根据where子句来定位要被替换的记录
 * 6. 如果新插入的或替换的记录中, 有字段和表中的其他记录冲突, 那么会删除那条其他记录。
 */
public boolean replace(T t) {
    if (t == null) return false;
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        database.replace(getTableName(), null, getContentValues(t));
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " replaceT");
    }
    return false;
}
 
Example 6
Source Project: okhttp-OkGo   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
public boolean replace(List<T> ts) {
    if (ts == null) return false;
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        for (T t : ts) {
            database.replace(getTableName(), null, getContentValues(t));
        }
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " replaceList");
    }
    return false;
}
 
Example 7
Source Project: okhttp-OkGo   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 更新一条记录 */
public boolean update(T t, String whereClause, String[] whereArgs) {
    if (t == null) return false;
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        database.update(getTableName(), getContentValues(t), whereClause, whereArgs);
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " updateT");
    }
    return false;
}
 
Example 8
Source Project: okhttp-OkGo   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 更新一条记录 */
public boolean update(ContentValues contentValues, String whereClause, String[] whereArgs) {
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        database.update(getTableName(), contentValues, whereClause, whereArgs);
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " updateContentValues");
    }
    return false;
}
 
Example 9
Source Project: okhttp-OkGo   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 按条件查询对象并返回集合 */
public List<T> query(String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) {
    long start = System.currentTimeMillis();
    lock.lock();
    List<T> list = new ArrayList<>();
    Cursor cursor = null;
    try {
        database.beginTransaction();
        cursor = database.query(getTableName(), columns, selection, selectionArgs, groupBy, having, orderBy, limit);
        while (!cursor.isClosed() && cursor.moveToNext()) {
            list.add(parseCursorToBean(cursor));
        }
        database.setTransactionSuccessful();
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        closeDatabase(null, cursor);
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " query");
    }
    return list;
}
 
Example 10
Source Project: BaseProject   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 插入一条记录 */
public boolean insert(T t) {
    if (t == null) return false;
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        database.insert(getTableName(), null, getContentValues(t));
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " insertT");
    }
    return false;
}
 
Example 11
Source Project: BaseProject   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 插入多条记录 */
public boolean insert(List<T> ts) {
    if (ts == null) return false;
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        for (T t : ts) {
            database.insert(getTableName(), null, getContentValues(t));
        }
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " insertList");
    }
    return false;
}
 
Example 12
Source Project: BaseProject   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 根据条件删除数据库中的数据 */
public boolean delete(String whereClause, String[] whereArgs) {
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        database.delete(getTableName(), whereClause, whereArgs);
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " delete");
    }
    return false;
}
 
Example 13
Source Project: BaseProject   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 按条件查询对象并返回集合 */
public List<T> query(String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) {
    long start = System.currentTimeMillis();
    lock.lock();
    List<T> list = new ArrayList<>();
    Cursor cursor = null;
    try {
        database.beginTransaction();
        cursor = database.query(getTableName(), columns, selection, selectionArgs, groupBy, having, orderBy, limit);
        while (!cursor.isClosed() && cursor.moveToNext()) {
            list.add(parseCursorToBean(cursor));
        }
        database.setTransactionSuccessful();
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        closeDatabase(null, cursor);
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " query");
    }
    return list;
}
 
Example 14
Source Project: BaseProject   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * replace 语句有如下行为特点
 * 1. replace语句会删除原有的一条记录, 并且插入一条新的记录来替换原记录。
 * 2. 一般用replace语句替换一条记录的所有列, 如果在replace语句中没有指定某列, 在replace之后这列的值被置空 。
 * 3. replace语句根据主键的值确定被替换的是哪一条记录
 * 4. 如果执行replace语句时, 不存在要替换的记录, 那么就会插入一条新的记录。
 * 5. replace语句不能根据where子句来定位要被替换的记录
 * 6. 如果新插入的或替换的记录中, 有字段和表中的其他记录冲突, 那么会删除那条其他记录。
 */
public boolean replace(T t) {
    if (t == null) return false;
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        database.replace(getTableName(), null, getContentValues(t));
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " replaceT");
    }
    return false;
}
 
Example 15
Source Project: BaseProject   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
public boolean replace(ContentValues contentValues) {
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        database.replace(getTableName(), null, contentValues);
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " replaceContentValues");
    }
    return false;
}
 
Example 16
Source Project: BaseProject   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
public boolean replace(List<T> ts) {
    if (ts == null) return false;
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        for (T t : ts) {
            database.replace(getTableName(), null, getContentValues(t));
        }
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " replaceList");
    }
    return false;
}
 
Example 17
Source Project: BaseProject   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 更新一条记录 */
public boolean update(T t, String whereClause, String[] whereArgs) {
    if (t == null) return false;
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        database.update(getTableName(), getContentValues(t), whereClause, whereArgs);
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " updateT");
    }
    return false;
}
 
Example 18
Source Project: BaseProject   File: BaseDao.java    License: Apache License 2.0 6 votes vote down vote up
/** 更新一条记录 */
public boolean update(ContentValues contentValues, String whereClause, String[] whereArgs) {
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        database.update(getTableName(), contentValues, whereClause, whereArgs);
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " updateContentValues");
    }
    return false;
}
 
Example 19
Source Project: BaseProject   File: BaseDao.java    License: Apache License 2.0 5 votes vote down vote up
/** 查询满足条件的一个结果 */
public T queryOne(String selection, String[] selectionArgs) {
    long start = System.currentTimeMillis();
    List<T> query = query(null, selection, selectionArgs, null, null, null, "1");
    OkLogger.v(TAG, System.currentTimeMillis() - start + " queryOne");
    return query.size() > 0 ? query.get(0) : null;
}
 
Example 20
Source Project: okhttp-OkGo   File: BaseDao.java    License: Apache License 2.0 5 votes vote down vote up
/** 查询满足条件的一个结果 */
public T queryOne(String selection, String[] selectionArgs) {
    long start = System.currentTimeMillis();
    List<T> query = query(null, selection, selectionArgs, null, null, null, "1");
    OkLogger.v(TAG, System.currentTimeMillis() - start + " queryOne");
    return query.size() > 0 ? query.get(0) : null;
}