Skip to content

Instantly share code, notes, and snippets.

@abhaysood
abhaysood / medium_rider_redesign_blog_example.kt
Created March 18, 2018 20:04
A simple component which is created when user clicks the cancel order button in the app. It is responsible for showing a confirmation dialog and actually cancelling the order by making an API call.
class OrderCancellationComponent(private val context: Context,
private val api: Api,
private val orderNumber: String) {
interface Callbacks {
fun onOrderCancelledSuccessfully()
fun onOrderCancellationFailed()
}
var callbacks: Callbacks? = null // Callbacks for communication with the parent component
@abhaysood
abhaysood / order_cancelation_component.kt
Last active March 18, 2018 20:02
A simple component which is created when user clicks the cancel order button in the app. It is responsible for showing a confirmation dialog and actually cancelling the order by making an API call.
class OrderCancellationComponent(private val context: Context,
private val api: Api,
private val orderNumber: String) {
interface Callbacks {
fun onOrderCancelledSuccessfully()
fun onOrderCancellationFailed()
}
var callbacks: Callbacks? = null // Callbacks for communication with the parent component
class RootComponent(...) {
val locationSelection = LocationSelectionComponent(...)
fun launchLocationSelection() {
// Create the component
locationSelection = LocationSelectionComponent(...)
// Register callbacks
locationSelection.callbacks = object: LocationSelectionComponent.Callbacks() {
@abhaysood
abhaysood / scripts
Created May 16, 2017 11:36
Useful Scripts
// Add a PREFIX to all file names in a directory
ls | xargs -I {} mv {} PREFIX_{}
@abhaysood
abhaysood / OnMapAndLayoutReady.java
Created April 15, 2017 08:04
GoogleMaps onReadyCallback + GlobalLayoutListener to avoid `Map size should not be 0`
import android.util.Log;
import android.view.ViewTreeObserver;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Func2;