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
private val eventHandler = object : EventHandler { | |
override fun onEvent(mqttEvent: MqttEvent) { | |
when (mqttEvent) { | |
is MqttConnectSuccessEvent -> { | |
// handle MqttConnectSuccessEvent | |
} | |
is MqttConnectFailureEvent -> { | |
// handle MqttConnectFailureEvent | |
} | |
is MqttSubscribeSuccessEvent -> { |
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 configuration = Courier.Configuration( | |
client = mqttClient, | |
streamAdapterFactories = listOf(RxJava2StreamAdapterFactory()), | |
messageAdapterFactories = listOf(MoshiMessageAdapter.Factory()) | |
) |
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
interface MqttClient { | |
fun connect(connectOptions: MqttConnectOptions) | |
fun disconnect() | |
fun reconnect() | |
} |
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
interface MessageService { | |
@Send(topic = "messages/send", qos = QoS.TWO) | |
fun send(@Data message: Message) | |
@Receive(topic = "messages/receive") | |
fun receive(): Observable<Message> | |
@Subscribe(topic = "messages/receive", qos = QoS.ONE) | |
fun subscribe(): Observable<Message> |
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
@Override | |
public void insertUsers(final User... users) { | |
__db.assertNotSuspendingTransaction(); | |
__db.beginTransaction(); | |
try { | |
__insertionAdapterOfUser.insert(users); | |
__db.setTransactionSuccessful(); | |
} finally { | |
__db.endTransaction(); | |
} |
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
@Override | |
public LiveData<List<User>> getAllLiveData() { | |
final String _sql = "SELECT * FROM users"; | |
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0); | |
return __db.getInvalidationTracker().createLiveData(new String[]{"users"}, false, new Callable<List<User>>() { | |
@Override | |
public List<User> call() throws Exception { | |
final Cursor _cursor = DBUtil.query(__db, _statement, false, null); | |
try { | |
final int _cursorIndexOfUid = CursorUtil.getColumnIndexOrThrow(_cursor, "uid"); |
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
@Override | |
public Completable insertLargeNumberOfUsers(final User... users) { | |
return Completable.fromCallable(new Callable<Void>() { | |
@Override | |
public Void call() throws Exception { | |
__db.beginTransaction(); | |
try { | |
__insertionAdapterOfUser.insert(users); | |
__db.setTransactionSuccessful(); | |
return null; |
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
@Override | |
public Object insertUsers(final User[] users, final Continuation<? super Unit> p1) { | |
return CoroutinesRoom.execute(__db, true, new Callable<Unit>() { | |
@Override | |
public Unit call() throws Exception { | |
__db.beginTransaction(); | |
try { | |
__insertionAdapterOfUser.insert(users); | |
__db.setTransactionSuccessful(); | |
return Unit.INSTANCE; |
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 { | |
@Insert(onConflict = OnConflictStrategy.REPLACE) | |
suspend fun insertUsers(vararg users: User) | |
@Update | |
suspend fun updateUsers(vararg users: User) | |
@Delete | |
suspend fun deleteUsers(vararg users: User) | |
@Query("SELECT * FROM users") | |
suspend fun loadAllUsers(): Array<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
@Dao | |
interface UserDao { | |
@Query("SELECT * from users where uid = :id LIMIT 1") | |
fun loadUserById(id: Int): Flowable<User> | |
@Insert | |
fun insertUsers(vararg users: User): Completable | |
@Delete | |
fun deleteAllUsers(users: List<User>): Single<Int> | |
} |
NewerOlder