Skip to content

Instantly share code, notes, and snippets.

View TWiStErRob's full-sized avatar

Róbert Papp TWiStErRob

View GitHub Profile
@TWiStErRob
TWiStErRob / SquareFrameLayout.java
Created September 30, 2015 23:33
Make GridView or GridLayoutManager items square.
package net.twisterrob.android.view;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
public class SquareFrameLayout extends FrameLayout {
public SquareFrameLayout(Context context) {
super(context);
}
@TWiStErRob
TWiStErRob / README.md
Last active June 12, 2023 00:21
Kotlin Script (kts) 1.3.21 with dependencies to call a JSON web endpoint, including tests
@TWiStErRob
TWiStErRob / OkHttpProgressGlideModule.java
Last active January 31, 2024 13:37
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));
}
@TWiStErRob
TWiStErRob / BitmapBitmapResourceDecoder.java
Last active February 5, 2024 21:36
Glide 3.6.0 proof of concept for loading a Bitmap as Bitmap through Glide
class BitmapBitmapResourceDecoder implements ResourceDecoder<Bitmap, Bitmap> {
private final BitmapPool pool;
public BitmapBitmapResourceDecoder(Context context) {
this(Glide.get(context).getBitmapPool());
}
public BitmapBitmapResourceDecoder(BitmapPool pool) {
this.pool = pool;
}
@Override public Resource<Bitmap> decode(Bitmap source, int width, int height) throws IOException {