Skip to content

Instantly share code, notes, and snippets.

public static Bitmap getCloudPopupImage(Context context, Bitmap bitmap) {
// float cornerRadius = context.getResources().getDimension(R.dimen.cloud_popup_corner_radius); //this value was 4dp
int smallerDimen = Math.min(bitmap.getWidth(), bitmap.getHeight());
int xDiff = Math.max((bitmap.getWidth() - smallerDimen) / 2, 0);
int cornerRadius = 90;//Math.max(90, smallerDimen / 2);
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
int color = 0xff424242;
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/activity_toolbar"
layout="@layout/widget_toolbar"/>
<android.support.v7.widget.RecyclerView
//If the origin is behind the popup,
if(popupBounds.contains(origin.x, origin.y)) {
pivotX = origin.x - popupBounds.left;
pivotY = origin.y - popupBounds.top;
}
else {
//If X is not the problem, treat it normally, else either make the pivot point negative or bigger than the view
if(popupBounds.left <= origin.x && origin.x <= popupBounds.right)
pivotX = origin.x - popupBounds.left;
else if(origin.x < popupBounds.left)
{
"artists": {
"tracked": [ … ],
"untracked": [ … ],
"blocked": [ ]
},
"events": {
"going": [ … ],
"maybe": [ … ],
"declined": [ ]
public abstract class AbsClass<T> {
protected abstract void doSomething(X<T> special);
}
public class MyClass<T extends Y> extends AbsClass {
@Override
protected void doSomething(X<T> special) {
public abstract class AbsVolleyRequester<T> {
protected Context mContext;
public AbsVolleyRequester(Context context) {
mContext = context.getApplicationContext(); //To avoid leaks
// HttpsTrustManager.allowAllSSL(); //TODO implement for https?
}
public void makeGetRequest(BaseActivity activity, String url, final VolleyRequestListener<T> listener) {
@jmrboosties
jmrboosties / gist:554fc164aa58482b14c2
Last active August 29, 2015 14:23
Extends AbsClass
public class BitVolleyRequester<T extends ApiResponse> extends AbsVolleyRequester {
private static final String AUTHORIZATION_KEY = "Authorization";
private static final String AUTHORIZATION_VALUE_FORMAT = "Token token=%s, auth_method=%s, auth_login=%s";
protected Class<T> mClass;
public BitVolleyRequester(Context context, Class<T> theClass) {
super(context);
mClass = theClass;
public static final int NEW = 0;
public static final int REMOVED = 1;
public static final int CHANGED = 2;
public static HashMap<Integer, ArrayList<Integer>> calculateAdapterChanges(ArrayList<Object> oldData, ArrayList<Object> newData) {
HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
ArrayList<Integer> newItems = new ArrayList<>();
ArrayList<Integer> removedItems = new ArrayList<>();
ArrayList<Integer> changedItems = new ArrayList<>();
{ "activities":
[
{
"id": 1,
"stream_id": "a5141e80-d285-11e4-b78b-0a0469cc7060",
"verb": "rsvp",
"category": "friends",
"description": "is going to",
"is_liked": false,
"like_count": 0,
{
"activities": [
{
"group_id": "87ehgiudnvijv",
"sub_activities": [
{
"id": 5608536,
"stream_id": "d042d280-b566-11e5-8080-8001153bae6f",
"verb": "artist_tracking",
"category": "me",