Skip to content

Instantly share code, notes, and snippets.

@usrbowe
usrbowe / README.md
Last active January 10, 2023 16:51
Flipper Marketplace - server

Flipper Marketplace

Used by the marketplace feature of Flipper: facebook/flipper#3491

This code needs a few changes to make it work, depending on the NPM server used. npmAdapter is written for verdaccio.co.

Usage

  1. Start server yarn && yarn start
  2. Enable marketplace in Flipper settings & set Martkeplace URL to http://localhost:4004/flipper-plugins
@zach-klippenstein
zach-klippenstein / SegmentedControl.kt
Last active June 24, 2024 01:54
iOS-style segmented control in Compose
import android.annotation.SuppressLint
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.forEachGesture
import androidx.compose.foundation.gestures.horizontalDrag
import androidx.compose.foundation.layout.Arrangement.spacedBy
import androidx.compose.foundation.layout.Box
@antonshilov
antonshilov / TreeRenderer.kt
Last active July 1, 2024 18:49
Simple tree hierarchy rendering with Jetpack Compose
package com.example.myapplication
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.Box
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
@cketti
cketti / android-26-sources.md
Last active August 14, 2019 12:08
Build your own android-26 sources

If you are annoyed that "Sources for Android 26" are not yet available via SDK manager, this might be for you:

  1. Collect source files
mkdir android-sdk-source-build
cd android-sdk-source-build

mkdir -p frameworks/base
@drewhannay
drewhannay / FinishingActivityTestRule.java
Last active June 21, 2017 18:25
Android Espresso Activity Clean Up
/**
* Copyright (C) 2017 Drew Hannay
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
@evant
evant / README.md
Created November 29, 2016 21:04
RxDiffUtil

Usage

Given a stream of collection of items to show, provide a diff callback which determines the size and differences in that collection.

Observable<List<String>> observable1 ...;
observable1.compose(RxDiffUtil.diff(new RxDiffUtil.Callback<List<String>>() {
    @Override
    public int getSize(List<String> list) {
        return list.size();
 }
@AlecKazakova
AlecKazakova / BriteDatabaseUtils.kt
Last active February 7, 2021 15:36
Extension functions on SQLBrite's BriteDatabase to make working with SQLDelight easier
fun BriteDatabase.createQuery(query: SqlDelightStatement) = createQuery(query.tables, query.statement, *query.args)
inline fun <T: SqlDelightCompiledStatement> BriteDatabase.bindAndExecute(compiledStatement: T, bind: T.() -> Unit): Long {
synchronized(compiledStatement) {
compiledStatement.bind()
return when (compiledStatement) {
is SqlDelightCompiledStatement.Insert -> {
executeInsert(compiledStatement.table, compiledStatement.program)
}
is SqlDelightCompiledStatement.Update -> {
ArrayList<WeakReference<ContentObserver>> observers = new ArrayList<WeakReference<ContentObserver>>();
public void loadCursor(final BetterCursorAdapter adapter, final Uri uri, final String[] projection, final String selection, final String[] selectionArgs, final String sortOrder) {
final FutureCallback<BetterCursorAdapter> callback = new FutureCallback<BetterCursorAdapter>() {
@Override
public void onCompleted(Exception e, BetterCursorAdapter result) {
if (e != null)
return;
View view = getView();
if (view == null)
@EricKuck
EricKuck / ButterknifeConductor.kt
Last active May 9, 2019 20:30
Kotterknife(ish) view binding for Conductor controllers
// Largely borrowed from Jake Wharton's Kotterknife (https://github.com/JakeWharton/kotterknife)
// and paweljaneczek's PR for resetting cached views (https://github.com/JakeWharton/kotterknife/pull/37)
package com.bluelinelabs.conductor.butterknife
import android.view.View
import com.bluelinelabs.conductor.Controller
import java.util.Collections
import java.util.WeakHashMap
import kotlin.properties.ReadOnlyProperty
@efrohnhoefer
efrohnhoefer / ApiMetricsInterceptor.java
Created April 5, 2016 22:55
Code demonstrating how to measure API performance using Answers and OkHttp 2.2+.
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.okhttp.Interceptor;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import java.io.IOException;