Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View sergivonavi's full-sized avatar
🏋️‍♂️
Work hard

Sergey Ivanov sergivonavi

🏋️‍♂️
Work hard
View GitHub Profile
@sergivonavi
sergivonavi / mock_android_context.java
Created April 1, 2019 20:40 — forked from marcouberti/mock_android_context.java
Mock Android Context using Mockito
import org.mockito.Mock;
import static org.mockito.Mockito.when;
@Mock
private Context mockApplicationContext;
@Mock
private Resources mockContextResources;
@Mock
private SharedPreferences mockSharedPreferences;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
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"
// LICENSE: USE IT IF YOU NEED IT, BUT PLEASE MENTION AT LEAST MY NAME, THANKS!
// (Juraj Suchán, juraj.suchan@gmail.com)
//
// PREFACE:
// So i've been building client application for one local "closed community"
// nyx.cz for year and a half where the displayed content is standard html code.
//
// There is Html.fromHtml to the rescue for that! But unfortunatelly, anyone who tried it
// have to deal with custom Html.ImageGetter implementation.
// This interface contains only one method, with only one paramter (url) and it's completelly
// LICENSE: USE IT IF YOU NEED IT, BUT PLEASE MENTION AT LEAST MY NAME, THANKS!
// (Juraj Suchán, juraj.suchan@gmail.com)
//
package sk.virtualvoid.nyxdroid.utils;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;