This file contains 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
import android.bluetooth.BluetoothGatt; | |
import android.bluetooth.BluetoothGattCharacteristic; | |
import android.bluetooth.BluetoothGattDescriptor; | |
import android.support.annotation.NonNull; | |
import android.util.Log; | |
import java.util.UUID; | |
/** | |
* Helper which enables or disables BLE gatt updates from connected peripheral, not tested in production | |
*/ |
This file contains 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
package xD; | |
import android.content.Context; | |
import android.content.res.AssetFileDescriptor; | |
import android.media.MediaPlayer; | |
import android.util.Log; | |
import hugo.weaving.DebugLog; | |
import io.reactivex.Observable; | |
import io.reactivex.ObservableEmitter; |
This file contains 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
CatPresenter{ | |
BehaviorSubject<List<Cat>> catsSubject = BehaviorSubject.create(); | |
Disposable catsDisposable; | |
void onCreate(){ | |
someClient.subscribe( cats -> { catsSubject.onNext(cats) }) |
This file contains 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
package evalu.com.evalu.utils.rx; | |
import android.content.Context; | |
import android.os.Build; | |
import android.support.annotation.RequiresApi; | |
import android.util.AttributeSet; | |
import android.view.MotionEvent; | |
import android.widget.ScrollView; | |
import io.reactivex.subjects.PublishSubject; |
This file contains 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
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical"> | |
<TextView | |
style="@style/textview_bold" | |
android:layout_marginBottom="@dimen/activity_small_padding" | |
android:layout_marginLeft="@dimen/activity_default_padding" | |
android:layout_marginRight="@dimen/activity_default_padding" |
This file contains 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 StarWarsApi { | |
@GET("people/") | |
fun getPeople(@Query("page") page: Int): Deferred<PeopleResponse> | |
} |
This file contains 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 GetPeopleUseCase(private val api: StarWarsApi) { | |
fun execute(page: Int): Deferred<List<Person?>?> { | |
return async { transform(page) } | |
} | |
private suspend fun transform(page: Int): List<Person?> { | |
val response = api.getPeople(page).await() | |
return response.results ?: emptyList() |
This file contains 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 SwapiPeopleDataSource(val useCase: GetPeopleUseCase) : PageKeyedDataSource<Int, Person?>() { | |
override fun loadInitial(params: LoadInitialParams<Int>, callback: LoadInitialCallback<Int, Person?>) { | |
async { | |
val items = useCase.execute(page = 1).await() | |
callback.onResult(items.orEmpty(), null, 2) | |
} | |
} | |
override fun loadAfter(params: LoadParams<Int>, callback: LoadCallback<Int, Person?>) { |
This file contains 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 PagedListProvider<Value> { | |
fun provide() : LiveData<PagedList<Value>> | |
} |
This file contains 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 SwapiPeoplePagedListProvider(private val factory: DataSource.Factory<Int, Person?>) : PagedListProvider<Person?> { | |
override fun provide(): LiveData<PagedList<Person?>> { | |
return LivePagedListBuilder(factory, PagedList.Config.Builder() | |
.setEnablePlaceholders(false) | |
.setPageSize(20) | |
.setInitialLoadSizeHint(20) | |
.build() | |
).setFetchExecutor(createFetchExecutor()) |