Skip to content

Instantly share code, notes, and snippets.

@ScottPierce
ScottPierce / SmoothingResizeTransformation.kt
Last active May 18, 2021 05:45
Picasso Transformer Smooth Image Downsizing
/**
* Android has a very poor filtering algorithm when taking large images and turning them into
* thumbnails, leaving jagged edges and ugly artifacting. A work-around is to only scale down an
* image a little bit at a time until you have the needed image size.
*
* This algorithm isn't very efficient, but still only takes ~100 millis to turn a 4096x4096 image
* into a 210x210. This is acceptable if you aren't working with a large number of downsized images,
* where CPU may become a bottleneck.
*/
class SmoothingResizeTransformation(
@ScottPierce
ScottPierce / RotateScreen.kt
Created February 12, 2021 02:15
Jetpack Compose Screen Rotation
@Composable
fun RotateScreen(
rotation: ScreenRotation,
modifier: Modifier = Modifier,
contentAlignment: Alignment = Alignment.TopStart,
content: @Composable () -> Unit
) {
BoxWithConstraints {
val width: Dp
val height: Dp
@ScottPierce
ScottPierce / gist:a05b7eeae32961bcafdb
Last active November 30, 2017 13:17
RXJava Location Observable
import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Looper;
import rx.Observable;
import rx.Subscriber;