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
class BottomSheetScrollView(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs), | |
NestedScrollingParent2 { | |
private val TAG = "NestedScroll3" | |
private val childHelper = NestedScrollingChildHelper(this).apply { | |
isNestedScrollingEnabled = true | |
} | |
private var behavior: BottomSheetBehavior<*>? = null | |
var started = false | |
var canScroll = 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
fun main(args: Array<String>) { | |
val handler = CoroutineExceptionHandler { context, exception -> | |
println("CoroutineExceptionHandler got $exception with suppressed ${exception.suppressed.contentToString()}") | |
} | |
val parentScope = CoroutineScope(Dispatchers.Default + Job() + handler) | |
// val parentScope = MyScope() | |
parentScope.launch { | |
println("one job: " + this.coroutineContext[Job].toString()) | |
println("Hello") |
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
// Using Jetpack Compose Transition v1 | |
enum class FabState { | |
Initial, | |
Normal, | |
Exploded, | |
} | |
val fabSizeKey = DpPropKey() | |
val fabColorKey = ColorPropKey() |
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
class ForegroundServiceLauncher(private val serviceClass: Class<out Service>) { | |
private var isStarting = false | |
private var shouldStop = false | |
private var isCreated = false | |
@Synchronized | |
fun startService(context: Context, block: Intent.() -> Unit = {}) { | |
if (!isCreated) { | |
isStarting = true |
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
#!/usr/bin/env python3 | |
""" | |
Android11 | |
Pair and connect devices for wireless debug on terminal | |
python-zeroconf: A pure python implementation of multicast DNS service discovery | |
https://github.com/jstasiak/python-zeroconf | |
""" |
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 ALL_FAKES = listOf( | |
FakePostLoginUseCase::class, | |
// all fake classes go here | |
) | |
/** | |
* Finds and initializes an instance of | |
* class [T] if it exists in [ALL_FAKES]. | |
* | |
* If it doesn't, a [FakeNotFoundException] is thrown |
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
package com.test | |
class DatabaseSyncer() { | |
// Updated thanks to @gildor | |
private fun findUpdatedNotes( | |
allLocalNotes: List<Note>, | |
allRemoteNotes: List<Note> | |
): List<Note> { |
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
/** | |
* Constructs a ViewModelFactory with dependencies | |
*/ | |
@Singleton | |
class ViewModelFactory @Inject constructor( | |
private val creators: Map<Class<out ViewModel>, @JvmSuppressWildcards Provider<ViewModel>> | |
) : ViewModelProvider.Factory { | |
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |
var creator = creators[modelClass] |
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
public class LocaleChanger { | |
public static void setLocale(ArrayList<Locale> arrayList) { | |
try { | |
Class cls = Class.forName("android.app.ActivityManagerNative"); | |
Method method = cls.getMethod("getDefault", new Class[0]); | |
method.setAccessible(true); | |
Object invoke = method.invoke(cls, new Object[0]); | |
method = cls.getMethod("getConfiguration", new Class[0]); | |
method.setAccessible(true); |