Skip to content

Instantly share code, notes, and snippets.

View HugoGresse's full-sized avatar

Hugo Gresse HugoGresse

View GitHub Profile
@HugoGresse
HugoGresse / 1 DynamicExoPlayer
Last active September 5, 2018 03:42
ExoPlayer implementation with a persisten TextureView & SurfaceTexture among context
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Color;
import android.graphics.SurfaceTexture;
import android.os.Build;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Surface;
import android.view.TextureView;
@HugoGresse
HugoGresse / ServerClientTest
Created May 22, 2015 08:06
Robolectric 3 rc2 asynchronous test
@RunWith(RobolectricGradleTestRunner.class)
@Config(emulateSdk = 21, reportSdk = 21, constants = BuildConfig.class)
public class ServerClientTest extends GetAdResponseHandler {
private Transcript mTranscript;
public static final String LOG_TAG = "ServerClientTest";
public static final String SERVER_URL = "/rich/";
public static final String CONNECTION_NO_SETTINGS = "vastConnectionWithoutSettings.json";
@HugoGresse
HugoGresse / ClearSurface API16
Created May 28, 2015 09:57
ClearSurface API16
private void clearSurface(SurfaceTexture texture) {
EGL10 egl = (EGL10) EGLContext.getEGL();
EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
egl.eglInitialize(display, null);
int[] attribList = {
EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_ALPHA_SIZE, 8,
@HugoGresse
HugoGresse / gist:fb0b33c27537202df13c
Created May 29, 2015 14:25
RenderScript Blur with fallback
/**
* Blur the given bitmap and convert it to BitmapDrawable
* @param context the application context to use getRessources
* @param bitmapOriginal the bitmap you want to blur
* @param radius the blur radius (amount of blur)
* @return blured BitmapDrawable
*/
public static Bitmap blur(Context context, Bitmap bitmapOriginal, int radius){
try {
@HugoGresse
HugoGresse / getLastLocation
Last active December 31, 2018 18:39
Location Google Api Client play services using reflection
private void getLocation(Context context) {
Log.d(LOG_TAG, "getLocation");
if (context.getPackageManager().checkPermission(
Manifest.permission.ACCESS_FINE_LOCATION, context.getPackageName()) == PackageManager.PERMISSION_GRANTED ||
context.getPackageManager().checkPermission(
Manifest.permission.ACCESS_COARSE_LOCATION, context.getPackageName()) == PackageManager.PERMISSION_GRANTED) {
@HugoGresse
HugoGresse / MainActivity
Created September 21, 2015 14:31
Method to add fragment to activity. It will take care of already registered fragment, and poping fragment if they are in back stack
private void changeFragment(Fragment frag, boolean saveInBackstack) {
String backStateName = ((Object) frag).getClass().getName();
try {
FragmentManager manager = getSupportFragmentManager();
boolean fragmentPopped = manager.popBackStackImmediate(backStateName, 0);
if (!fragmentPopped && manager.findFragmentByTag(backStateName) == null) { //fragment not in back stack, create it.
FragmentTransaction transaction = manager.beginTransaction();
@HugoGresse
HugoGresse / MainApplication.java
Created November 19, 2015 10:14
Fresco custom initialize with disk cache
/**
* Configure fresco using ONLY disk cache
*/
public void configFresco() {
Supplier<File> diskSupplier = new Supplier<File>() {
public File get() {
return getApplicationContext().getCacheDir();
}
};
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
mStartNativeX = event.getX();
mStartNativeY = event.getY();
mIsNativeClick = true;
@HugoGresse
HugoGresse / MainActivity.java
Created March 2, 2016 11:06
changeFragment
/**
* Change the current displayed fragment by a new one.
* - if the fragment is in backstack, it will pop it
* - if the fragment is already displayed (trying to change the fragment with the same), it will not do anything
*
* @param frag the new fragment to display
* @param saveInBackstack if we want the fragment to be in backstack
* @param animate if we want a nice animation or not
*/
@HugoGresse
HugoGresse / FFMPEG command meetup.md
Last active March 19, 2024 18:57
FFMPEG personal list to cut & normalize video

Setup

brew install ffmpeg

Normalize audio in place (easiest solution) EBU R128

pip install ffmpeg-normalize
ffmpeg-normalize input.mp4 -o output.mp4 -c:a aac -b:a 192k --progress