Skip to content

Instantly share code, notes, and snippets.

Avatar

Jarosław rozkminiacz

View GitHub Profile
@rozkminiacz
rozkminiacz / memoized.kt
Created May 21, 2019
Memoized based on Spek implementation
View memoized.kt
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
interface Memoized {
fun <T> memoized(factory: () -> T): Memoizable<T>
}
class DefaultMemoized : Memoized {
override fun <T> memoized(factory: () -> T): Memoizable<T> {
return MemoizableAdapter(factory)
View ImageManager.java
public interface ImageManager {
void loadImage(String imageUrl, ImageView target, Context context);
}
View activity-with-image.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.rozkmin.flavorshowcase.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
View flavor-debug-compile.gradle
picassoDebugCompile 'com.squareup.picasso:picasso:2.5.2'
picassoReleaseCompile 'com.squareup.picasso:picasso:2.5.2'
View flavor-compile.gradle
picassoCompile 'com.squareup.picasso:picasso:2.5.2'
glideCompile 'com.github.bumptech.glide:glide:4.1.1'
compile 'com.google.dagger:dagger:2.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.2'
View flavors.gradle
android {
/**/
flavorDimensions "default"
productFlavors {
glide {
versionName defaultConfig.versionName + ".glide." + defaultConfig.versionCode
applicationId "com.rozkmin.flavorshowcaseglide"
dimension "default"
View PromotionListViewRobot.kt
class PromotionListViewRobot(presenter: PromotionListContract.Presenter) {
private val initSubject = BehaviorSubject.create<Any>()
private val renderedViewStates: MutableList<PromotionListContract.ViewState> = mutableListOf()
private val view: PromotionListContract.View = object : PromotionListContract.View {
override fun listInit(): Observable<Any> = initSubject
override fun render(viewState: PromotionListContract.ViewState) {
View PromotionListPresenterTest.kt
class PromotionListPresenterTest : Spek({
describe("promotion presenter") {
//mock interactor methods
on("view attach") {
//attach presenter
it("should display promotion list") {
//assertion
}
}
on("load more click") {
View PromotionListContract.kt
interface PromotionListContract {
interface View : MvpView {
fun listInit(): Observable<Any>
fun render(viewState: ViewState)
}
abstract class Presenter : MviBasePresenter<View, ViewState>()
data class ViewState(
val promotionList: List<PromotionViewModel> = emptyList(),
View mapof-test-cases.kt
val testCases = mapOf(
61888.123 to ">50 km",
38777.23 to "38.8 km",
16984.44 to "17.0 km",
987.98 to "988 m"
)
You can’t perform that action at this time.