Skip to content

Instantly share code, notes, and snippets.

View whitipet's full-sized avatar
👨‍💻
Code Every Day

Petro Bilyi whitipet

👨‍💻
Code Every Day
View GitHub Profile
@JulienArzul
JulienArzul / FadingEdgeRecyclerView.kt
Created July 11, 2018 06:09
RecyclerView class that supports drawing fading edges with clipToPadding=false
package com.julienarzul.android.recyclerview
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.util.AttributeSet
class FadingEdgeRecyclerView : RecyclerView {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
@chrisbanes
chrisbanes / ScopedViewModel.kt
Last active March 20, 2025 17:42
ScopedViewModel
open class ScopedViewModel : ViewModel() {
private val job = Job()
protected val scope: CoroutineScope = job + Dispatchers.Main
override fun onCleared() {
super.onCleared()
job.cancel()
}
}
@NathanHowell
NathanHowell / settings.gradle
Created June 25, 2019 20:04
Example settings.gradle to dynamically derive projects from build.gradle files
// find all build.gradle files in the expected locations in the build tree
fileTree('.')
.matching {
exclude '**/src/**', '**/build/**', '**/.*'
include '**/build.gradle'
}
.each {
// then convert the file path to a project path
final relative = rootProject.projectDir.relativePath(it.parentFile)
final project = ":${relative.replace('/', ':')}"
@dzolnai
dzolnai / DisallowToolbarExpand.kt
Created December 28, 2020 15:20
Disallow the toolbar expand on a collapsible toolbar layout
internal fun disallowToolbarExpand() {
// Taken from: https://stackoverflow.com/a/49218710/1395437
binding.appBar.setExpanded(false, false)
ViewCompat.setNestedScrollingEnabled(binding.content, false)
val params = binding.appBar.layoutParams as CoordinatorLayout.LayoutParams
if (params.behavior == null) {
params.behavior = AppBarLayout.Behavior()
}
val behaviour = params.behavior as AppBarLayout.Behavior
behaviour.setDragCallback(object : AppBarLayout.Behavior.DragCallback() {
@dzolnai
dzolnai / View.kt
Last active August 2, 2023 15:12
Expandable TextView with clickable '...read more'
import android.annotation.SuppressLint
import android.content.Context
import android.text.Layout
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.StaticLayout
import android.text.TextPaint
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
@whitipet
whitipet / adb_connect_to_hotspot.sh
Created May 24, 2023 18:18
Connect adb to the device that acts as a hotspot
adb connect $(route -n get default | grep gateway | awk '{ print $2 }')