Skip to content

Instantly share code, notes, and snippets.

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;
@IRMobydick
IRMobydick / OkHttpProgressGlideModule.java
Created July 16, 2016 12:48 — forked from TWiStErRob/OkHttpProgressGlideModule.java
Full POC for showing progress of loading in Glide v3 via OkHttp v2
// TODO add <meta-data android:value="GlideModule" android:name="....OkHttpProgressGlideModule" />
// TODO add <meta-data android:value="GlideModule" tools:node="remove" android:name="com.bumptech.glide.integration.okhttp.OkHttpGlideModule" />
// or not use 'okhttp@aar' in Gradle depdendencies
public class OkHttpProgressGlideModule implements GlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { }
@Override public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
@IRMobydick
IRMobydick / ObjectAnimator Change Icon Color
Created July 17, 2016 19:57 — forked from Jawnnypoo/ ObjectAnimator Change Icon Color
Use ObjectAnimator to change color of an icon dynamically
We couldn’t find that file to show.
@IRMobydick
IRMobydick / TopCropImageView.java
Created September 18, 2016 11:19 — forked from arriolac/TopCropImageView.java
Custom Android ImageView for top-crop scaling of the contained drawable.
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* Created by chris on 7/27/16.
@IRMobydick
IRMobydick / GlideGravatarImageLoader.java
Created November 1, 2016 18:40 — forked from psh/GlideGravatarImageLoader.java
Glide + Gravatar integration to display a user's Gravatar image in an Android ImageView.
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@IRMobydick
IRMobydick / AppHelper.java
Created July 10, 2017 14:19 — forked from anggadarkprince/AppHelper.java
Upload file with Multipart Request Volley Android
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import java.io.ByteArrayOutputStream;
/**
* Sketch Project Studio
* Created by Angga on 12/04/2016 14.27.
*/
public class AppHelper {
@IRMobydick
IRMobydick / MainActivity.java
Created April 3, 2020 11:45
Custom Android AppBarLayout$ScrollingViewBehavior: Prevent Toolbar from scrolling when RecyclerView doesn't have enough items to scroll.
/*
* Copyright 2016 Alireza Eskandarpour Shoferi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@IRMobydick
IRMobydick / MainActivity.kt
Created April 4, 2020 11:29 — forked from nickbutcher/MainActivity.kt
Demonstrating how to tile a (Vector) Drawable
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@IRMobydick
IRMobydick / ExpandableTextView.java
Created April 30, 2023 11:57 — forked from yuriyskulskiy/ExpandableTextView.java
ExpandableTV with static layout, solution code
public class ExpandableTextView extends AppCompatTextView
implements View.OnClickListener {
private final int COLLAPSED_MAX_LINES = 3;
private final static String POSTFIX = "...see more ";
private ValueAnimator mAnimator;
private boolean isCollapsing;
private CharSequence mOriginalText;