Skip to content

Instantly share code, notes, and snippets.

public class DelayAutoCompleteTextView extends AutoCompleteTextView {
private static final int MESSAGE_TEXT_CHANGED = 100;
private static final int DEFAULT_AUTOCOMPLETE_DELAY = 1000;
private int mAutoCompleteDelay = DEFAULT_AUTOCOMPLETE_DELAY;
private static class AvoidingMemoryLeakHandler extends Handler {
private final WeakReference<DelayAutoCompleteTextView> delayAutoCompleteTextViewWeakReference;
import android.graphics.Bitmap;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import java.util.Arrays;
/**
* This is copied from https://stackoverflow.com/a/10028267/3050249
* and optimized for less memory consumption & better locality, and creates less GC pressure.