Java 类io.realm.internal.IOException 实例源码

项目:Programmers    文件:CommentsLocalDataSource.java   
@Override
public void delete(Comment comment, Callbacks.IRequestCallback callback) {
    Realm realm = Realm.getDefaultInstance();
    try {
        realm.beginTransaction();
        (comment).deleteFromRealm();
        realm.commitTransaction();

        if (callback != null)
            callback.onSuccess();
    } catch (IOException ex) {
        ex.printStackTrace();
        if (callback != null)
            callback.onError();
    }
}
项目:Programmers    文件:CommentsLocalDataSource.java   
@Override
public void getAll(String postId, Callbacks.IResultsCallback<Comment> callback) {
    Realm realm = Realm.getDefaultInstance();
    try {
        List<Comment> results = realm.where(Comment.class)
                .equalTo("postId", postId)
                .findAll();

        if (results == null || results.size() == 0) {
            callback.onDataUnavailable();
            return;
        }

        callback.onSuccess(results);
    } catch (IOException ex) {
        ex.printStackTrace();
        callback.onDataUnavailable();
    }
}
项目:Programmers    文件:CommentsLocalDataSource.java   
private void insertOrUpdate(Comment comment, Callbacks.IResultCallback<Comment> callback) {
    Realm realm = Realm.getDefaultInstance();
    try {
        realm.beginTransaction();
        realm.copyToRealmOrUpdate(comment);
        realm.commitTransaction();

        if (callback != null)
            callback.onSuccess(comment);
    } catch (IOException ex) {
        ex.printStackTrace();
        if (callback != null)
            callback.onDataUnavailable();
    }
}
项目:Programmers    文件:CommentsLocalDataSource.java   
private void insertOrUpdate(Comment comment, Callbacks.IRequestCallback callback) {
    Realm realm = Realm.getDefaultInstance();
    try {
        realm.beginTransaction();
        realm.copyToRealmOrUpdate(comment);
        realm.commitTransaction();

        if (callback != null)
            callback.onSuccess();
    } catch (IOException ex) {
        ex.printStackTrace();
        if (callback != null)
            callback.onError();
    }
}