Search in sources :

Example 1 with UserWithTweets

use of com.pushtorefresh.storio3.sample.db.entities.UserWithTweets in project storio by pushtorefresh.

the class UserWithTweetsGetResolver method mapFromCursor.

@NonNull
@Override
public UserWithTweets mapFromCursor(@NonNull StorIOSQLite storIOSQLite, @NonNull Cursor cursor) {
    // Or you can manually parse cursor (it will be sliiightly faster)
    final User user = userGetResolver.mapFromCursor(storIOSQLite, cursor);
    // Yep, you can reuse StorIO here!
    // Or, you can do manual low level requests here
    // BTW, if you profiled your app and found that such queries are not very fast
    // You can always add some optimized version for particular queries to improve the performance
    final List<Tweet> tweetsOfTheUser = storIOSQLite.get().listOfObjects(Tweet.class).withQuery(Query.builder().table(TweetsTable.TABLE).where(TweetsTable.COLUMN_AUTHOR + "=?").whereArgs(user.nick()).build()).prepare().executeAsBlocking();
    return new UserWithTweets(user, tweetsOfTheUser);
}
Also used : User(com.pushtorefresh.storio3.sample.db.entities.User) Tweet(com.pushtorefresh.storio3.sample.db.entities.Tweet) UserWithTweets(com.pushtorefresh.storio3.sample.db.entities.UserWithTweets) NonNull(android.support.annotation.NonNull)

Aggregations

NonNull (android.support.annotation.NonNull)1 Tweet (com.pushtorefresh.storio3.sample.db.entities.Tweet)1 User (com.pushtorefresh.storio3.sample.db.entities.User)1 UserWithTweets (com.pushtorefresh.storio3.sample.db.entities.UserWithTweets)1