Skip to content

Instantly share code, notes, and snippets.

View prabel's full-sized avatar

Paweł Rąbel prabel

  • Poznań, Poland
View GitHub Profile
@prabel
prabel / gist:a63c2e83cae5795eba1e79c336c7d6c9
Created September 1, 2017 09:47
FixedHoloDatePickerDialog
public final class FixedHoloDatePickerDialog extends DatePickerDialog {
public FixedHoloDatePickerDialog(Context context, OnDateSetListener callBack,
int year, int monthOfYear, int dayOfMonth) {
super(context, callBack, year, monthOfYear, dayOfMonth);
// Force spinners on Android 7.0 only (SDK 24).
// Note: I'm using a naked SDK value of 24 here, because I'm
// targeting SDK 23, and Build.VERSION_CODES.N is not available yet.
// But if you target SDK >= 24, you should have it.
if (Build.VERSION.SDK_INT == 24) {
@prabel
prabel / gist:ba044f9d643995de9de46aa2588b0d93
Created April 24, 2017 19:35 — forked from brunodles/gist:badaa6de2ad3a84138d517795f15efc7
This is a test to show how to use expresso to check if a toast was displayed.
package com.github.brunodles.toastespresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@prabel
prabel / Android Lollipop Widget Tinting Guide
Last active August 29, 2015 14:26 — forked from seanKenkeremath/Android Lollipop Widget Tinting Guide
How base colors in Lollipop apply to different UI elements
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21. To use the support version of these attributes, remove the android namespace. For instance, "android:colorControlNormal" becomes "colorControlNormal". These attributes will be propagated to their corresponding attributes within the android namespace for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
-----------
* ripple effect (Lollipop only) -- "colorControlHighlight"
Status Bar:
------------
* background (Lollipop only) - "colorPrimaryDark"
@prabel
prabel / MediaAlbumFragment.java
Created November 20, 2014 14:37
Dynamic cut text in TextView
mItemHeaderDescribe.setText(Strings.nullToEmpty(mMediaAlbum.description));
ViewTreeObserver vto = mItemHeaderDescribe.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
private int maxLines = -1;
@Override
public void onGlobalLayout() {
if (maxLines < 0 && mItemHeaderDescribe.getHeight() > 0 && mItemHeaderDescribe.getLineHeight() > 0) {
int height = mItemHeaderDescribe.getHeight();
int lineHeight = mItemHeaderDescribe.getLineHeight();