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
| /** | |
| * Used as a wrapper for data that is exposed via an observable that represents an event. | |
| * Developed by Jose Alcérreca. | |
| * See [https://gist.github.com/JoseAlcerreca/5b661f1800e1e654f07cc54fe87441af#file-event-kt] | |
| */ | |
| open class Event<out T>(private val content: T) { | |
| var hasBeenHandled = false | |
| private set // Allow external read but not write |
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
| class OverlappingPanelsLayout: FrameLayout { | |
| private lateinit var startPanel: View | |
| private lateinit var centerPanel: View | |
| private lateinit var endPanel: View | |
| private var pendingUpdate: (() -> Unit)? = null | |
| ... | |
| private fun openStartPanel() { | |
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
| class PanelsChildGestureRegionObserver : View.OnLayoutChangeListener { | |
| ... | |
| override fun onLayoutChange( | |
| view: View?, | |
| left: Int, | |
| top: Int, | |
| right: Int, | |
| bottom: Int, | |
| oldLeft: Int, | |
| oldTop: Int, |
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
| class OverlappingPanelsLayout : FrameLayout { | |
| private var scrollingSlopPx: Float = 0f | |
| private var velocityTracker: VelocityTracker? = null | |
| private var isScrollingHorizontally = false | |
| private var xFromInterceptActionDown: Float = 0f | |
| private var yFromInterceptActionDown: Float = 0f | |
| ... // initialize scrollingSlopPx and VelocityTracker |
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
| import android.os.Bundle | |
| import androidx.fragment.app.Fragment | |
| import androidx.fragment.app.activityViewModels | |
| import androidx.fragment.app.viewModels | |
| import androidx.lifecycle.AbstractSavedStateViewModelFactory | |
| import androidx.lifecycle.SavedStateHandle | |
| import androidx.lifecycle.ViewModel | |
| import androidx.lifecycle.ViewModelProvider | |
| import androidx.savedstate.SavedStateRegistryOwner |
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
| @Scope | |
| @Retention(AnnotationRetention.RUNTIME) | |
| annotation class ActivityScope |
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
| /* Copyright 2019 The Android Open Source Project | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * https://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, |
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
| /* | |
| ModelBinding<T>: a simple class for binding a Flutter app to a immutable | |
| model of type T. | |
| This is a complete application. The app shows the state of an instance of | |
| MyModel in a button's label, and replaces its MyModel instance when the | |
| button is pressed. | |
| ModelBinding is an inherited widget that must be created in a context above |
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 MyGeneralObserver<T> { | |
| void notifyUpdate(T value); | |
| } | |
| interface ObservableViewState { | |
| void observeTitle(LifecycleOwner lifecycleOwner, MyGeneralObserver<String> observer); | |
| } | |
| interface IScreenPresenter extends ObservableViewState { | |
| void loadData(); |
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
| /** | |
| * Delegate that sets and disposes the fragment's listener by casting it to the fragment's activity. | |
| */ | |
| class ParentActivityDelegate<T>(fragment: Fragment) : BaseParentDelegate<T>(fragment) { | |
| override fun extractValue(fragment: Fragment): T? = fragment.activity as? T | |
| } | |
| /** | |
| * Delegate that sets and disposes the fragment's listener by casting it to the fragment's |
NewerOlder