Skip to content

Instantly share code, notes, and snippets.

View ntngel1's full-sized avatar
🌻
Chilling

Kirill Shepelev ntngel1

🌻
Chilling
  • Kinoplan
  • Rostov-on-Don, Russia
View GitHub Profile
package routing
import Readers._
import cats.implicits._
import errors.internal.base.AppError
import play.api.libs.json.{Json, OWrites}
sealed trait PathSegment
object PathSegment {
sealed trait AcquiringOrder extends Product with Serializable {
val id: BSONObjectID
val info: AcquiringOrder.Info
val createdAt: OffsetDateTime
val updatedAt: OffsetDateTime
}
object AcquiringOrder {
@ntngel1
ntngel1 / t.kt
Last active November 21, 2019 12:09
/************ 1 ******************/
class LaunchesSceneController @Inject constructor(
private val dateTimeFormatter: DateTimeFormatter
) : SceneController() {
var launches = emptyList<LaunchEntity>()
var isProgressBarVisible = false
var onLaunchClicked: ((launch: LaunchEntity) -> Unit)? = null
@ntngel1
ntngel1 / a
Last active April 7, 2020 08:57
1
class FullscreenImagesDialogFragment : DialogFragment() {
sealed class Params {
@Parcelize
data class Images(
val images: List<String>,
val offset: Int = 0
) : Params(), Parcelable
inline fun <reified T> Fragment.argument(name: String? = null): ReadOnlyProperty<Fragment, T> =
object : ReadOnlyProperty<Fragment, T> {
override operator fun getValue(thisRef: Fragment, property: KProperty<*>): T {
return thisRef.arguments?.get(name ?: property.name) as T
}
}
class FullscreenImagesDialogFragment : DialogFragment() {
private val something by argument<String>(SOMETHING_KEY)
@ntngel1
ntngel1 / t.kt
Created November 14, 2019 08:26
override fun findSnapView(layoutManager: RecyclerView.LayoutManager) =
if (layoutManager is LinearLayoutManager) {
if (layoutManager.canScrollHorizontally()) {
getStartView(layoutManager, getHorizontalHelper(layoutManager))
} else {
getStartView(layoutManager, getVerticalHelper(layoutManager))
}
} else {
super.findSnapView(layoutManager)
}
override fun currentUserCollection(page: Int?, limit: Int?): Single<PaginationResponse<UserCurrentEntity>> =
Single.create<PaginationResponse<UserCurrentEntity>> { emitter ->
realm.executeTransaction { realm ->
realm.where(RealmUserCurrentEntity::class.java)
.findAll()
.run {
val items = this.drop(page * limit)
.take(limit)
.let { realm.copyFromRealm(it) }
.map { it.toDomain() }
override fun deletePhotoItem(id: String): Completable {
return network.deletePhotoItem(id)
.andThen(local.deletePhotoItem(id))
}
//
// просто берем параметры и подставляем в запрос realm'а
// нейминг здесь корявый, но он берется из Api дока, так что тут уже не наша сторона
override fun deletePhotoItem(id: String) = Completable.create { emitter ->
realm.executeTransaction { realm ->
val photo = realm.where(RealmPhotoEntity::class.java)
.equalTo("id", id)
.findFirst()
if (photo != null) {