Skip to content

Instantly share code, notes, and snippets.

@lowfiend
lowfiend / gist:378e4d34a6fcfad99424fdcdbc523a56
Created October 4, 2022 14:50 — forked from elyezer/gist:1505833
Find a contact name from phone number in Android
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
String[] projection = {PhoneLookup.DISPLAY_NAME};
Cursor c = contentResolver.query(uri, projection, null, null, null);
if (c.moveToFirst()) {
name = c.getString(c.getColumnIndex(PhoneLookup.DISPLAY_NAME));
}
@lowfiend
lowfiend / HeaderFooterRecyclerViewAdapter.java
Created September 27, 2017 14:20 — forked from mheras/HeaderFooterRecyclerViewAdapter.java
Header & footer support for RecyclerView.Adapter
public abstract class HeaderFooterRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_MAX_COUNT = 1000;
private static final int HEADER_VIEW_TYPE_OFFSET = 0;
private static final int FOOTER_VIEW_TYPE_OFFSET = HEADER_VIEW_TYPE_OFFSET + VIEW_TYPE_MAX_COUNT;
private static final int CONTENT_VIEW_TYPE_OFFSET = FOOTER_VIEW_TYPE_OFFSET + VIEW_TYPE_MAX_COUNT;
private int headerItemCount;
private int contentItemCount;
private int footerItemCount;
@lowfiend
lowfiend / TopCropImageView.java
Last active March 17, 2016 03:28 — forked from arriolac/TopCropImageView.java
Custom Android ImageView for top-crop scaling of the contained drawable.
import android.content.Context;
import android.graphics.Matrix;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* ImageView to display top-crop scale of an image view.
*
* @author Chris Arriola