use of com.pushtorefresh.storio.sample.db.entities.User in project storio by pushtorefresh.
the class UserWithTweetsGetResolver method mapFromCursor.
@NonNull
@Override
public UserWithTweets mapFromCursor(@NonNull Cursor cursor) {
final StorIOSQLite storIOSQLite = storIOSQLiteFromPerformGet.get();
// Or you can manually parse cursor (it will be sliiightly faster)
final User user = userGetResolver.mapFromCursor(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);
}
use of com.pushtorefresh.storio.sample.db.entities.User in project storio by pushtorefresh.
the class TweetWithUserGetResolver method mapFromCursor.
// We expect that cursor will contain both Tweet and User: SQL JOIN
@NonNull
@Override
public TweetWithUser mapFromCursor(@NonNull Cursor cursor) {
final Tweet tweet = Tweet.newTweet(cursor.getLong(cursor.getColumnIndexOrThrow(Relations.QUERY_COLUMN_TWEET_ID)), cursor.getString(cursor.getColumnIndexOrThrow(Relations.QUERY_COLUMN_TWEET_AUTHOR)), cursor.getString(cursor.getColumnIndexOrThrow(Relations.QUERY_COLUMN_TWEET_CONTENT)));
final User user = User.newUser(cursor.getLong(cursor.getColumnIndexOrThrow(Relations.QUERY_COLUMN_USER_ID)), cursor.getString(cursor.getColumnIndexOrThrow(Relations.QUERY_COLUMN_USER_NICK)));
return new TweetWithUser(tweet, user);
}
Aggregations