:first AND last_name :last") User findByName(String first, String last); } @Entity public class User { @PrimaryKey private int uid; private String firstName; private String lastName; }
:first AND last_name :last") User findByName(String first, String last); } @Entity public class User { @PrimaryKey private int uid; private String firstName; private String lastName; } @Database(entities = {User.class}, version = 1) public abstract class MyDatabase extends RoomDatabase { public abstract UserDao userDao(); }
super(DIFF_CALLBACK); } public static final DiffCallback<User> DIFF_CALLBACK = new DiffCallback<User>() { @Override public boolean areItemsTheSame(@NonNull User oldUser, @NonNull User newUser) { return oldUser.getId() == newUser.getId(); } @Override public boolean areContentsTheSame(@NonNull User oldUser, @NonNull User newUser) { // Incorrectly returning false here will result in too many animations. return oldUser.equals(newUser); } } }
super(DIFF_CALLBACK); } public static final DiffCallback<User> DIFF_CALLBACK = new DiffCallback<User>() { @Override public boolean areItemsTheSame(@NonNull User oldUser, @NonNull User newUser) { return oldUser.getId() == newUser.getId(); } @Override public boolean areContentsTheSame(@NonNull User oldUser, @NonNull User newUser) { // Incorrectly returning false here will result in too many animations. return oldUser.equals(newUser); } } }