Skip to content

Instantly share code, notes, and snippets.

View ursimon's full-sized avatar

Michal Ursiny ursimon

View GitHub Profile
@technoir42
technoir42 / DebugTransitionFactory.kt
Last active February 25, 2020 09:47
Glide debug indicator
import android.annotation.SuppressLint
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Matrix
import android.graphics.Paint
import android.graphics.Path
import android.graphics.drawable.Drawable
import android.util.TypedValue
import androidx.annotation.ColorInt
import androidx.appcompat.graphics.drawable.DrawableWrapper
@akaita
akaita / FavoriteToSendMorphView.kt
Created March 27, 2018 00:04
MorphView example
package com.akaita.android.morphview.example.kotlin
/**
* Created by mikel on 26/03/2018.
*/
import android.content.Context
import android.support.graphics.drawable.AnimatedVectorDrawableCompat
import android.util.AttributeSet
@dptsolutions
dptsolutions / Glide4OkHttp3Dagger2Module.java
Created July 2, 2017 22:11
Example AppGlideModule Injecting OkHttpClient using Dagger 2
/**
* {@link AppGlideModule} for the app
*/
@Excludes(OkHttpLibraryGlideModule.class)
@GlideModule
public class MyAppGlideModule extends AppGlideModule {
//Below override should only be used if not using legacy modules registered via manifest
@Override
public boolean isManifestParsingEnabled() {
@bjornson
bjornson / PositionedCropTransformation.java
Last active October 16, 2023 15:42
Custom Glide CropTransformation that allows top/center/bottom left/center/right crop with percentages
package com.extendedvision.futurehistory.images;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
@nickbutcher
nickbutcher / avd_bundle.xml
Last active December 31, 2021 01:03
An example of the Android xml bundle format for creating an AnimatedVectorDrawable. See https://plus.google.com/+NickButcher/posts/A8KKxnJdg4r
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 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
@truizlop
truizlop / GetLeaderboard.java
Last active June 6, 2017 07:29
Retrieving leaderboards to display them in a custom view
public abstract class GetLeaderboard{
private static final int MAX_RESULTS = 25;
/**
* Check documentation for LeaderboardVariant to see possible values for timeSpan and collection
*/
public void getTopScores(GoogleApiClient googleApiClient, String leaderboardID, int timeSpan, int collection) {
PendingResult<Leaderboards.LoadScoresResult> pendingScores = Games.
Leaderboards.loadTopScores(googleApiClient, leaderboardID,
timeSpan, collection, MAX_RESULTS, true);
@fkrauthan
fkrauthan / TLSSocketFactory.java
Last active January 7, 2023 04:09
Custom SSLSocketFactory Implementation to enable tls 1.1 and tls 1.2 for android 4.1 (16+)
package net.cogindo.ssl;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.SSLContext;
@alex-shpak
alex-shpak / Interceptor.java
Last active March 29, 2023 21:06
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
@ferdy182
ferdy182 / CircularRevealingFragment.java
Created March 27, 2015 17:18
Make circular reveal animations on a fragment
/**
* Our demo fragment
*/
public static class CircularRevealingFragment extends Fragment {
OnFragmentTouched listener;
public CircularRevealingFragment() {
}
@patrickhammond
patrickhammond / gist:0b13ec35160af758d98c
Created March 8, 2015 02:30
Sample for how to use the Google Play Services dynamic security provider to keep the SSL library that the app will use to up date.
package com.mycompany.myapp.app;
import android.app.Application;
import android.content.Intent;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.security.ProviderInstaller;
import com.google.android.gms.security.ProviderInstaller.ProviderInstallListener;
public class MainApplication extends Application {