The document discusses Google's Architecture Components, which are a collection of libraries that help handle common tasks in Android development. It covers the main components like Lifecycle, LiveData, ViewModel, and Room. Lifecycle allows activities and fragments to observe lifecycle changes of other objects like LiveData. LiveData is an observable data holder that is lifecycle-aware. ViewModel stores UI-related data to survive configuration changes like screen rotations. Room provides an abstraction layer over SQLite to allow for more robust database access.
Alexey Buzdin "Maslow's Pyramid of Android Testing"IT Event
You all know what tests are. You all know you need to write them. But also you know it’s hard to start writing tests for mobile app thus you usually neglect it. Let’s look into Android automation testing, what technologies and approaches we can use to have a complete Maslow's Pyramid for testing. Unit Testing, Integration Testing, UI Automation, Mocking etc.
Presentation from GWT.create 2015 on how to easily build a REST API that can be consumed via GWT or native mobile clients. Presentation video here: http://gwtcreate.com/videos/#rpc-jersey-resty-gwt
Testing Android apps based on Dagger and RxJavaFabio Collini
In this talk, you will learn:
how to take advantage of Mockito and other libraries to write good JVM and Espresso tests
how to use DaggerMock (an open source library available on github https://github.com/fabioCollini/DaggerMock) to avoid boilerplate code in tests
how to test asynchronous RxJava code using a JVM test
Writing reliable tests is not easy for many reasons, especially when asynchronous code is involved. Some libraries can be used to create a testable architecture (for example Dagger and RxJava) and to simplify testing (Mockito, AssertJ and DaggerMock). In this talk we’ll see how to write JVM and Espresso tests with particular attention on how to replace real objects with mocks and how to test asynchronous RxJava code.
Testing Android apps based on Dagger and RxJava Droidcon UKFabio Collini
Writing reliable tests is not easy for many reasons, especially when asynchronous code is involved. Some libraries can be used to create a testable architecture (for example Dagger and RxJava) and to simplify testing (Mockito, AssertJ and DaggerMock). In this talk you'll learn how to write JVM and Espresso tests with particular attention on how to replace real objects with mocks and how to test asynchronous RxJava code. In this talk, you will also explore:
how to take advantage of Mockito and other libraries to write good JVM and Espresso tests in both Java and Kotlin
how to use DaggerMock (an open source library available on github to avoid boilerplate code in tests
how to test asynchronous RxJava code using a JVM test
Alexey Buzdin "Maslow's Pyramid of Android Testing"IT Event
You all know what tests are. You all know you need to write them. But also you know it’s hard to start writing tests for mobile app thus you usually neglect it. Let’s look into Android automation testing, what technologies and approaches we can use to have a complete Maslow's Pyramid for testing. Unit Testing, Integration Testing, UI Automation, Mocking etc.
Presentation from GWT.create 2015 on how to easily build a REST API that can be consumed via GWT or native mobile clients. Presentation video here: http://gwtcreate.com/videos/#rpc-jersey-resty-gwt
Testing Android apps based on Dagger and RxJavaFabio Collini
In this talk, you will learn:
how to take advantage of Mockito and other libraries to write good JVM and Espresso tests
how to use DaggerMock (an open source library available on github https://github.com/fabioCollini/DaggerMock) to avoid boilerplate code in tests
how to test asynchronous RxJava code using a JVM test
Writing reliable tests is not easy for many reasons, especially when asynchronous code is involved. Some libraries can be used to create a testable architecture (for example Dagger and RxJava) and to simplify testing (Mockito, AssertJ and DaggerMock). In this talk we’ll see how to write JVM and Espresso tests with particular attention on how to replace real objects with mocks and how to test asynchronous RxJava code.
Testing Android apps based on Dagger and RxJava Droidcon UKFabio Collini
Writing reliable tests is not easy for many reasons, especially when asynchronous code is involved. Some libraries can be used to create a testable architecture (for example Dagger and RxJava) and to simplify testing (Mockito, AssertJ and DaggerMock). In this talk you'll learn how to write JVM and Espresso tests with particular attention on how to replace real objects with mocks and how to test asynchronous RxJava code. In this talk, you will also explore:
how to take advantage of Mockito and other libraries to write good JVM and Espresso tests in both Java and Kotlin
how to use DaggerMock (an open source library available on github to avoid boilerplate code in tests
how to test asynchronous RxJava code using a JVM test
In scope of this presentation I'm reviewing the latest developments in Java: how has it changed, what makes a real difference in it. Here I cover nice additions to java, as well as some gotchas that you may face while working with it.
A collection of libraries that help you design robust, testable, and maintainable apps. Start with classes for managing your UI component lifecycle and handling data persistence.
Лаконічні та елегантні автоматизовані тести? Безболісний (майже) тестовий стек для UI веб-додатків? Більше часу, щоб випити кави/пограти у Cuphead/ подивитись у порожнечу?
Ми поговоримо про Lombok, Vavr, Owner, чому вам варто використовувати готові рішення та як зробити тести більш лаконічними та читабельними. Вам знадобиться Vaper та/або гіроборд.
By now, you’ve probably heard of Akka, the JVM toolkit for building scalable, resilient and resource efficient applications in Java or Scala. With over 12 open-source and commercial modules in the toolkit, Akka takes developers from actors on a single JVM, all the way out to network partition healing and clusters of servers distributed across fleets of JVMs.
In this technical webinar, O’Reilly author and Lightbend Developer Advocate, Hugh McKee, takes you on a deep dive into advanced Akka features for enhanced application resilience, elasticity, and responsiveness.
Building on real-world examples from his past experience as an Akka developer, Hugh will show how you can take advantage of:
• Akka Multi-Data Center Clustering improves reliability across multiple data centers, availability zones or regions.
• Logically grouping related nodes in large clusters to improve stability and scalability.
• Akka Multi-Data Center Persistence for increased fault tolerance, locate data near the user, and balance the load across data centers.
• Akka Cluster Sharding in a multi data center environment, to optimize shard locality within a single data center and go Active-Active for improved resilience and availability.
Accessibility Testing is one of the important types of testing that add value to your business and deliver user friendly applications. Axe Core is a very powerful framework that can help the team to build web products that are inclusive. In this article, different ways to test the Accessibility and the automation part have been discussed in full length. You can achieve Accessibility Testing with the help of the following methods/approaches
The talk presents how we established a TDD cycle within the complex AEM technology stack using a "unified testing API". It illustrates how such an API can be built and discusses various advantages over other approaches such as the Sling Testing API.
Unit testing your code can be hard and confusing. Particularly, for complex object structures you mock away functionality of collaborators and stub in expected return values, but covering every interaction seems difficult and pointless. In all your code, some parts call APIs to implement a functionality while they also provide an interface that can be used by others. A class' interface can be seen as a boundary with a contract to distinguish client code that uses the class, from service code that implements it's interface. Following this distinction, unit tests can be separated into collaboration and contract tests. In this talk, you'll see examples for different APIs and learn what is tested by existing tests to distinguish between collaboration and contract tests. You'll learn how to use mock objects to implement collaboration and contract tests, and see how integrated tests can be replaced with selected unit tests.
In scope of this presentation I'm reviewing the latest developments in Java: how has it changed, what makes a real difference in it. Here I cover nice additions to java, as well as some gotchas that you may face while working with it.
A collection of libraries that help you design robust, testable, and maintainable apps. Start with classes for managing your UI component lifecycle and handling data persistence.
Лаконічні та елегантні автоматизовані тести? Безболісний (майже) тестовий стек для UI веб-додатків? Більше часу, щоб випити кави/пограти у Cuphead/ подивитись у порожнечу?
Ми поговоримо про Lombok, Vavr, Owner, чому вам варто використовувати готові рішення та як зробити тести більш лаконічними та читабельними. Вам знадобиться Vaper та/або гіроборд.
By now, you’ve probably heard of Akka, the JVM toolkit for building scalable, resilient and resource efficient applications in Java or Scala. With over 12 open-source and commercial modules in the toolkit, Akka takes developers from actors on a single JVM, all the way out to network partition healing and clusters of servers distributed across fleets of JVMs.
In this technical webinar, O’Reilly author and Lightbend Developer Advocate, Hugh McKee, takes you on a deep dive into advanced Akka features for enhanced application resilience, elasticity, and responsiveness.
Building on real-world examples from his past experience as an Akka developer, Hugh will show how you can take advantage of:
• Akka Multi-Data Center Clustering improves reliability across multiple data centers, availability zones or regions.
• Logically grouping related nodes in large clusters to improve stability and scalability.
• Akka Multi-Data Center Persistence for increased fault tolerance, locate data near the user, and balance the load across data centers.
• Akka Cluster Sharding in a multi data center environment, to optimize shard locality within a single data center and go Active-Active for improved resilience and availability.
Accessibility Testing is one of the important types of testing that add value to your business and deliver user friendly applications. Axe Core is a very powerful framework that can help the team to build web products that are inclusive. In this article, different ways to test the Accessibility and the automation part have been discussed in full length. You can achieve Accessibility Testing with the help of the following methods/approaches
The talk presents how we established a TDD cycle within the complex AEM technology stack using a "unified testing API". It illustrates how such an API can be built and discusses various advantages over other approaches such as the Sling Testing API.
Unit testing your code can be hard and confusing. Particularly, for complex object structures you mock away functionality of collaborators and stub in expected return values, but covering every interaction seems difficult and pointless. In all your code, some parts call APIs to implement a functionality while they also provide an interface that can be used by others. A class' interface can be seen as a boundary with a contract to distinguish client code that uses the class, from service code that implements it's interface. Following this distinction, unit tests can be separated into collaboration and contract tests. In this talk, you'll see examples for different APIs and learn what is tested by existing tests to distinguish between collaboration and contract tests. You'll learn how to use mock objects to implement collaboration and contract tests, and see how integrated tests can be replaced with selected unit tests.
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Red Hat Developers
JBoss EAP7 brings support for the most recent industry standards and technologies, including Java EE7, the latest edition of the premier enterprise development standard. This session will provide an overview of the major additions to Java EE7, and how your team can use these capabilities on the advanced EAP7 runtime to produce better applications with less code.
Building Modern Apps using Android Architecture ComponentsHassan Abid
Android architecture components are part of Android Jetpack. They are a collection of libraries that help you design robust, testable, and maintainable apps. In this talk, We will cover LiveData, ViewModel, Room and lifecycle components. We will go through practical code example to understand modern android app architecture especially MVVM architecture.
Quality assurance and testing are very important in a life cycle of any application. Although, by far not all developers understand the significance of tests.
In this presentation, we cover the basic testing practices for developers. The following tools are discussed: JUnit, Mockito, Hamcrest, JsTestDriver, DBUnit, Arquillian, SoapUI, Selenium.
Struts has outgrown its reputation as a simple web framework and has become more of a brand. Because of this, two next generation frameworks are being developed within the project: Shale and Action 2.0. Action 2.0 is based on WebWork, and though its backing beans are similar to JSF, its architecture is much simpler, and easier to use.
Migrating to Struts Action 2.0 is more about unlearning Struts than it is about learning the "WebWork Way". Once you understand how simple WebWork is, you'll find that Struts Action 2.0 is a powerful framework that supports action-based navigation, page-based navigation, AOP/Interceptors, components and rich Ajax support.
Come to this session to see code comparisons and learn about migration strategies to use the kick-ass web framework of 2006.
The easy way to develop Java applications has always been the standard stack (Spring, JEE, SQL) that confirms the LAMP equivalent in Java-speak. This presentation compares this model with a real use case based on Guice, Jersey and AppEngine.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
13. public class MyActivity extends CustomActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
14. public class LifecycleActivity extends FragmentActivity
implements LifecycleRegistryOwner {
private final LifecycleRegistry mRegistry
= new LifecycleRegistry(this);
@Override
public LifecycleRegistry getLifecycle() {
return mRegistry;
}
}
15. public class MyActivity extends CustomActivity implements LifecycleRegistryOwner {
private final LifecycleRegistry lifecycleRegistry = new LifecycleRegistry(this);
@Override
public LifecycleRegistry getLifecycle() {
return lifecycleRegistry;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lifecycle);
TestListener testListener = new TestListener(getLifecycle(), state -> {
// update Ui
});
}
}
16.
17. public class MyActivity extends LifecycleActivity {
private TestListener testListener;
@Override
protected void onStart() {
super.onStart();
Utils.checkUserStatus(state -> {
if (state.equals("OK")) {
testListener.start();
}
});
}
18. public class MyActivity extends LifecycleActivity {
private TestListener testListener;
@Override
protected void onStart() {
super.onStart();
// ?
Utils.checkUserStatus(state -> {
if (state.equals("OK")) {
testListener.start();
}
});
}
30. ViewModel
The ViewModel class is designed to store
and manage UI-related data so that the
data survives configuration changes such
as screen rotations.
”
“
31. public class UserViewModel extends ViewModel {
}
public class UserViewModel extends AndroidViewModel {
// Application ViewModel
}
39. id name create_time
@Entity
public class User {
@PrimaryKey(autoGenerate = true)
private Long id;
String name;
@ColumnInfo(name = "created_time")
private long createdTime;
@Ignore
Bitmap profile;
}
Entity
40. DAO
@Dao
public interface UserDao {
@Query("SELECT * FROM user")
List<User> getAll();
@Query("SELECT * FROM user WHERE id IN (:userIds)")
List<User> loadAllByIds(int[] userIds);
@Query("SELECT * FROM user WHERE name LIKE :first LIMIT 1")
User findByName(String first);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(User... users);
@Delete
void delete(User user);
@Update
void updateUser(User user);
41. DAO (Rx, LiveData)
@Query("SELECT * FROM user")
LiveData<List<User>> getAllSync();
@Query("SELECT * FROM user WHERE id = :userId")
LiveData<User> fetchUser(String userId);
@Query("SELECT * from user where id = :id LIMIT 1")
Flowable<User> loadUserByIdRx(int id);
@Query("SELECT * FROM user WHERE age > :minAge LIMIT 5")
Cursor loadRawUsersOlderThan(int minAge);
42. Database
@Database(entities = {User.class, Book.class}, version = 1)
public abstract class AppDatabase extends RoomDatabase {
public abstract UserDao userDao();
public abstract BookDao bookDao();
}
43. Entity - Embedded
id name created_time image_id image_width image_height
public class Image {
String id;
Integer width;
Integer height;
}
@Entity
public class User {
@PrimaryKey(autoGenerate = true)
private Long id;
String name;
@Embedded(prefix = "image_")
private Image image;
@ColumnInfo(name = "created_time")
private long createdTime;
44. Entity - TypeConverter
public class User {
@PrimaryKey
private Long id;
@TypeConverters(Converters.class)
private Date date;
public class Converters {
@TypeConverter
public static Date toDate(Long timestamp) {
return timestamp == null ? null :
new Date(timestamp);
}
@TypeConverter
public static Long toTimestamp(Date date) {
return date == null ? null : date.getTime();
}
}
45. Entity - Relation
@Entity(indices = {@Index(value = "id", unique = true)},
foreignKeys = {
@ForeignKey(entity = Book.class,
parentColumns = "id",
childColumns = "bookId",
onDelete = ForeignKey.CASCADE)
})
public class User {
@PrimaryKey(autoGenerate = true)
private Long id;
public Long bookId;
}
46. public class UserDao_Impl implements UserDao {
private final RoomDatabase __db;
private final EntityInsertionAdapter __insertionAdapterOfUser;
private final EntityDeletionOrUpdateAdapter __deletionAdapterOfUser;
private final EntityDeletionOrUpdateAdapter __updateAdapterOfUser;
public UserDao_Impl(RoomDatabase __db) {
this.__db = __db;
this.__insertionAdapterOfUser = new EntityInsertionAdapter<User>(__db) {
@Override
public String createQuery() {
return "INSERT OR REPLACE INTO
`User`(`id`,`name`,`created_time`,`updated_time`,`age`,`bookId`,`image_id`,`image_width`,`image_height`) VALUES
(?,?,?,?,?,?,?,?,?)";
}
@Override
public void bind(SupportSQLiteStatement stmt, User value) {
if (value.getId() == null) {
stmt.bindNull(1);
} else {
stmt.bindLong(1, value.getId());
}
if (value.getName() == null) {
stmt.bindNull(2);
} else {
stmt.bindString(2, value.getName());
}
stmt.bindLong(3, value.getCreatedTime());
if (value.getUpdatedTime() == null) {
stmt.bindNull(4);
} else {
stmt.bindLong(4, value.getUpdatedTime());
}
56. @Entity
public class RoomUser {
@PrimaryKey
private long id;
// getter & setter
}
Room
greenDAO
Realm
@Entity
public class GreenUser {
@Id
private long id;
// getter & setter
}
public class RealmUser extends RealmObject {
@PrimaryKey
private long id;
// getter & setter
}
57. @Entity(tableName = "user")
public class RoomUser {
@ColumnInfo(name = “first_name")
private String firstName;
}
@Entity(nameInDb = "user")
public class GreenUser {
@Property(nameInDb = “first_name")
private String firstName;
}
Room
greenDAO
Realm
58. @Entity(indices = @Index(“address"))
public class RoomUser {
private String address;
@Ignore
private String sessionId;
}
@Entity(indexes = @Index("address DESC"))
public class GreenUser {
private String address;
@Transient
private String sessionId;
}
public class RealmUser extends RealmObject {
@Index
private String address;
@Ignore
private String sessionId;
}
Room
greenDAO
Realm
59. @Dao
public interface RoomUserDao {
@Query("SELECT * FROM RoomUser WHERE id > 10 ORDER BY id DESC”)
List<RoomUser> getUsers();
}
public class GreenUseCase {
public List<GreenUser> getUsers() {
// get DaoSession
return new daoSession.getGreenUserDao().queryBuilder()
.where(GreenUserDao.Properties.Id.gt(10))
.orderDesc(GreenUserDao.Properties.Id)
.list();
}
}
public class RealmUseCase {
public RealmResults<RealmUser> getUsers() {
// get realm instance
return realm.where(RealmUser.class)
.greaterThan("id", 10)
.findAllSorted("id", Sort.DESCENDING);
}
}
Room
greenDAO
Realm
60. public class AndroidUser {
private String userId;
private String groupID;
}
public class AndroidGroup {
private String groupId;
private String groupName;
private List<AndroidUser> roomUser;
}
Relation
61. @Entity
public class RoomGroup {
@PrimaryKey
private long id;
}
@Entity(foreignKeys = @ForeignKey(
entity = RoomGroup.class,
parentColumns = "id",
childColumns = "groupId"))
public class RoomUser {
@PrimaryKey
private long id;
private long groupId;
}
https://developer.android.com/topic/libraries/architecture/room.html#no-object-references
Relation - Room
@Dao
public interface RoomGroupDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertGroup(RoomGroup group);
@Query("SELECT * FROM RoomGroup WHERE id = :id")
LiveData<RoomGroup> getGroup(long id);
}
@Dao
public interface RoomUserDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertUsers(List<RoomUser> users);
@Query("SELECT * FROM RoomUser WHERE groupId = :groupId")
LiveData<List<RoomUser>> getUsers(long groupId);
}
62. @Entity
public class GreenGroup {
@Id
private long id;
@ToMany(referencedJoinProperty
= "groupId")
private List<GreenUser> users;
}
@Entity
public class GreenUser {
@Id
private long id;
private long groupId;
}
Relation - greenDAO
public class GreenUseCase {
public void insertGroup(GreenGroup group) {
daoSession.getGreenGroupDao()
.insertOrReplace(group);
daoSession.getGreenUserDao()
.insertOrReplaceInTx(group.getUsers());
}
public GreenGroup getGroup(long groupId) {
return daoSession.getGreenGroupDao()
.queryBuilder()
.where(GreenGroupDao.Properties.Id.eq(groupId))
.build()
.unique();
}
}
63. public class RealmGroup extends RealmObject {
@PrimaryKey
private long id;
RealmList<RealmUser> users;
}
public class RealmUser extends RealmObject {
@PrimaryKey
private long id;
}
Relation - Realm
public class RealmUseCase {
public void insertGroup(RealmGroup group) {
realm.insertOrUpdate(group);
}
public RealmGroup getGroup(long groupId) {
return realm.where(RealmGroup.class)
.equalTo("id", groupId)
.findFirst();
}
}
64. Realm GreenDao Room
Core Native Library SQLite SQLite
Performance Realm Realm
Relation
.
QueryBuilder X
DeepInsert X X
LazyLoading X
Integration Rx Rx, LiveData, Cursor