This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:dist="http://schemas.android.com/apk/distribution" | |
package="com.test.dynamic" | |
split="dynamic-feature-test"> | |
<dist:module | |
dist:onDemand="true" | |
dist:title="@string/title_test"> | |
<dist:fusing include="true" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<application | |
android:hasCode="true" | |
tools:replace="android:hasCode"> | |
... | |
</application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SplitInstallManager splitInstallManager = | |
SplitInstallManagerFactory.create(context); | |
SplitInstallRequest request = SplitInstallRequest.newBuilder() | |
.addModule("dynamic-module-1") | |
.addModule("dynamic-module-2") | |
.build(); | |
splitInstallManager.startInstall(request) | |
.addOnSuccessListener(sessionId -> { ... }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int mySessionId = 0; | |
// Creates a listener for request status updates. | |
SplitInstallStateUpdatedListener listener = state -> { | |
if (state.status() == SplitInstallSessionStatus.FAILED | |
&& state.errorCode() == SplitInstallErrorCode.SERVICE_DIES) { | |
// Retry the request. | |
return; | |
} | |
if (state.sessionId() == mySessionId) { | |
switch (state.status()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Database(entities = arrayOf(User::class), version = 1) | |
abstract class UserDatabase : RoomDatabase() { | |
abstract fun userDao(): UserDao | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
data class User( | |
@PrimaryKey val uid: Int, | |
@ColumnInfo(name = "first_name") val firstName: String?, | |
@ColumnInfo(name = "last_name") val lastName: String? | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Dao | |
interface UserDao { | |
@Query("SELECT * FROM user") | |
fun getAll(): List<User> | |
@Query("SELECT * FROM user WHERE uid IN (:userIds)") | |
fun loadAllByIds(userIds: IntArray): List<User> | |
@Insert | |
fun insertAll(vararg users: User) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val db = Room.databaseBuilder( | |
applicationContext, | |
UserDatabase::class.java, "users-db" | |
).build() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Converters { | |
@TypeConverter | |
fun fromTimestamp(value: Long?): Date? { | |
return value?.let { Date(it) } | |
} | |
@TypeConverter | |
fun dateToTimestamp(date: Date?): Long? { | |
return date?.time?.toLong() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Address( | |
val street: String?, | |
val state: String?, | |
val city: String?, | |
val postCode: Int | |
) | |
@Entity | |
data class User( | |
@PrimaryKey val id: Int, |
OlderNewer