/**
* Fires events when keyboard visibility changes
*/
fun Activity.onKeyboardVisibilityChange(action: (visible: Boolean) -> Unit) {
findViewById<View>(Window.ID_ANDROID_CONTENT)?.apply {
viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
val rectangle = Rect(0, 0, 0, 0)
val heightThreshold = resources.displayMetrics.density * KEYBOARD_VISIBILITY_THRESHOLD_DP
var wasOpen = false
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
typealias Province = String | |
object Netherlands { | |
private val PathParserMap = mapOf( | |
"Drenthe" to listOf( | |
PathParser().parsePathString( | |
"m161.06 30.326-0.77463 0.38746-0.38732 0.38746v0.38747l-1.5493 0.77492-0.38732 0.38746v0.38746l-0.38731 0.38746-0.38732 0.77492-0.38732 0.38746v0.38747l-0.77463 1.9373v0.38746 1.1624h-0.38731l-0.38732 1.5498h-0.38732l-1.1619-0.38746-0.38732 0.77492 1.162 0.77493h1.162l0.77463 0.38746-0.38732 1.1624v1.1624 0.38747l2.3239 3.4872 0.38731 0.77492 0.38732 0.77492 0.38732 0.38746-1.162 1.9373v0.38746l-1.9366 1.9373-1.5493 1.1624-1.5493-1.5498h-1.162l-1.162-0.38747-0.77463 0.38747v0.38746 0.38746l-0.77463 0.38746-1.162 1.5498-0.38731 0.38747-0.38732 0.38746-1.5493 0.77492-0.77463 0.77492-1.162 0.77492 0.38731 0.77493v0.38746l1.5493 1.5498 0.77463 0.77492 0.77463 0.77493 0.38732 0.77492h0.38731l-0.38731 0.77492-1.162 1.1624v0.38746h-0.38732l-0.38731 0.38746-1.162 0.38746-0.38732 0.38746h-0.38731v0.38746l1.162 2.3248v0.38746 0.38746l0.77463 1.1 |
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
@UnstableApi | |
class StreamService : MediaSessionService(), | |
Listener, MediaSession.SessionCallback, SessionAvailabilityListener { | |
private lateinit var player: CompositePlayer | |
private lateinit var mediaSession: MediaSession | |
override fun onCreate() { | |
super.onCreate() | |
initialize() |
<uses-feature android:name="android.hardware.telephony" required="true"/>
/**
* [AppBarLayout] that monitors behavior of a scrolling view in the same layout and changes elevation on its Toolbar
*
* Usage:
*
* <ElevationAppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp"
class SomeViewHolder(override val containerView: View) : RecyclerView.ViewHolder(containerView), LayoutContainer {
fun bind(data: Data) {
myFirstTextView.text = data.foo
}
}
/**
* Invoke some action when the observable does not emit an item for longer than a given time out
* @param timeout time out
* @param timeUnit the unit for the time out
* @param scheduler the scheduler on which the action must be ran
* @param action the action to invoke
*/
fun <T> Observable<T>.startAfterDelay(timeout: Long, timeUnit: TimeUnit, scheduler: Scheduler, action: () -> Unit): Observable<T> {
return this.publish { o ->
private fun changeTouchableAreaOfView(view: View, extraSpace: Int) {
val parent = view.parent as View
parent.post {
val touchableArea = Rect()
button.getHitRect(touchableArea)
touchableArea.top -= extraSpace
touchableArea.bottom += extraSpace
touchableArea.left -= extraSpace
touchableArea.right += extraSpace
class FooFragment : DialogFragment() {
private val viewPagerAdapter by lazy { BarViewPager() }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_foo, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
NewerOlder