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 UserGateway { | |
/* | |
Может вернуть response code 201, 400 или 404. | |
201 - все отлично, создали нового пользователя, нам возвращается UserModel созданого пользователя | |
400 - все хреново, возвращается обычный String с ошибкой | |
404 - все хреново, тоже возвращается String | |
Так вот, как все это обобщить? | |
Возвращать Single<Any> или Single<UserModel>??? Или что-то другое? | |
*/ |
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
// Задача состоит в том, чтобы получать через даггер одну и тот же фрагмент, но с презентером, | |
// у которого разные аргументы в конструкторе | |
@Module | |
class PhotosViewModule { | |
@Provides | |
@Named("PopularPhotos") | |
fun providePopularPhotosView(): PhotosView.View { | |
val fragment: Photos.View = PhotosFragment() | |
// Здесь бы должны как-то заинжектить вручную Presenter с определенными аргументами в конструкторе | |
fragment.inject(PhotosPresenter(popular = true, new = false)) |
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
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-android-extensions' | |
apply plugin: 'kotlin-kapt' | |
apply plugin: 'com.google.gms.google-services' |
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
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
ext { | |
rxJava = '2.2.6' | |
rxAndroid = '2.1.1' | |
retrofit = '2.5.0' | |
retrofitRx = '2.5.0' | |
retrofitGson = '2.5.0' | |
loggingInterceptor = '3.12.1' | |
threeTenABP = '1.1.2' |
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
override fun getEcgListWithOffset(offset: Int): Single<DeviceEcgList> { | |
val request = ru.cardiomarker.p1.rpc.ecg.list.Request.newBuilder() | |
.addLeads(Lead.II) | |
.addLeads(Lead.CM5) | |
.apply { | |
if (offset != 0) { | |
setOffset(offset) | |
} | |
} | |
.build() |
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
override fun getAntropometricData(): Single<AnthropometricModel> = Single.create { emitter -> | |
val weightDataType = DataType.TYPE_WEIGHT | |
val heightDataType = DataType.TYPE_HEIGHT | |
val weightSubscription = Fitness.getRecordingClient(context, account) | |
.subscribe(weightDataType) | |
Tasks.await(weightSubscription) | |
val heightSubscription = Fitness.getRecordingClient(context, account) |
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
abstract class UseCase <in P, out T> { | |
abstract fun execute(param: P): T | |
} | |
class FooUseCase : UseCase<Unit, Unit>() { | |
override fun execute(param: Unit) { | |
} | |
} |
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
@InjectViewState | |
class MainPresenter : MvpPresenter<MainView>() { | |
private val uploadFragment = UploadFragment.newInstance().apply { | |
// Задаем callback на нажатие кнопки Show после загрузки фото | |
onShowPhoto = { photoModel -> | |
viewState.openScreen(newPhotosFragment) | |
currentFragment = newPhotosFragment | |
viewState.setNavigationSelection(R.id.navigation_new) | |
newPhotosFragment.presenter.onHighlightPhoto(photoModel) | |
} |
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 FragmentTransactionHandler { | |
// withBackstack - логично, закинуть в стэк фрагментов, immediately - ждать пока фрагмент полностью не откроется | |
fun openFragment(fragment: Fragment, withBackstack: Boolean = false, immediately: Boolean = false) | |
} | |
interface MainView : MvpView, FragmentTransactionHandler { | |
@StateStrategyType(OneExecutionStateStrategy::class) | |
override fun openFragment(fragment: Fragment, withBackstack: Boolean = false, immediately: Boolean = false) |
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
val clas = KotlinClass( | |
name = "Kek", | |
modifiers = arrayListOf("open", "internal", "private"), | |
annotations = arrayListOf( | |
KotlinAnnotation(name = "WithoutArgs"), | |
KotlinAnnotation(name = "WithArgs", arguments = arrayListOf( | |
KotlinArgument(value = "someValue"), KotlinArgument(parameterName = "someName", value = "someValue") | |
)) | |
), | |
classInheritance = KotlinClassInheritance(className = "SomeClass", arguments = arrayListOf( |
OlderNewer