Skip to content

Instantly share code, notes, and snippets.

import argparse
import os
from pathlib import Path
parser = argparse.ArgumentParser(description="Create a new library module")
parser.add_argument("-n", "--name", dest="name", help="Name of the module. Use `.` for separation to nest modules.")
parser.add_argument("-c", "--compose", dest="use_compose", action='store_true', help="Add Compose dependencies to the created module.")
PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__)).rsplit('/', 1)[0]
@bgogetap
bgogetap / settings.gradle.kts
Last active November 14, 2022 22:09
Snippet to add to settings.gradle.kts to auto-add any gradle module (no more explicit Include(":mymodule") )
val modules = mutableSetOf<String>()
val ignoredDirectories = setOf("build", "buildSrc", "gradle", ".idea")
fun fillModules(files: List<File>, targetPath: String) {
files.forEach { file ->
if (file.isFile) {
if (file.name == "build.gradle" || file.name == "build.gradle.kts") {
modules.add(targetPath)
}
} else {
import android.annotation.SuppressLint
import android.content.Context
import android.os.Looper
import com.google.android.gms.location.LocationCallback
import com.google.android.gms.location.LocationRequest
import com.google.android.gms.location.LocationResult
import com.google.android.gms.location.LocationServices
import com.google.android.gms.maps.model.LatLng
import io.reactivex.BackpressureStrategy
import io.reactivex.Flowable
@bgogetap
bgogetap / ControllerExtensions.kt
Created August 6, 2017 03:05
After looking into the discussion here: https://github.com/bluelinelabs/Conductor/issues/234 I slightly modified the solution provided and came up with the below to handle binding and clearing view references in Controllers.
fun <T : View> Controller.bindView(@IdRes id: Int): ReadOnlyProperty<Controller, T> =
ResettableControllerRef(this, id, false)
fun <T: View> Controller.bindOptionalView(@IdRes id: Int): ReadOnlyProperty<Controller, T?> =
ResettableControllerRef(this, id, true)
/**
* Binds a view using a [Controller].
*
* When the [Controller]s view is destroyed, the reference is cleared and will be re-bound on the next access.
@bgogetap
bgogetap / MyDragShadowBuilder.class
Created October 20, 2015 06:11
View.DragShadowBuilder that takes in a Point ((int) event.getX(), (int) event.getY()) so your dragged shadow is positioned correctly
public static class MyDragShadowBuilder extends View.DragShadowBuilder {
private final Point offset;
public MyDragShadowBuilder(View view, Point offset) {
super(view);
this.offset = offset;
}
@Override