Skip to content

Instantly share code, notes, and snippets.

@aaalaniz
aaalaniz / UiInternetConnectivitySettingsPanel.kt
Created July 8, 2021 19:10
Toggling Internet Connectivity in Android Instrumentation Test
import android.annotation.TargetApi
import android.content.Context
import android.content.Intent
import android.provider.Settings
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.StaleObjectException
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiObject2
import androidx.test.uiautomator.Until
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import com.twilio.video.I420Frame;
import com.twilio.video.VideoTextureView;
/*
* VideoTextureView that notifies Listener of the first frame rendered and the first frame after a reset
@aaalaniz
aaalaniz / CustomVideoView.java
Created February 15, 2018 15:54
VideoView that notifies of a frame rendered after requesting a reset
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import com.twilio.video.I420Frame;
import com.twilio.video.VideoView;
/*
* VideoView that notifies Listener of the first frame rendered and the first frame after a reset
@aaalaniz
aaalaniz / VideoViewRecyclerViewAdapter.java
Created September 15, 2017 14:36
VideoView used in RecyclerView
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.twilio.video.LocalVideoTrack;
import com.twilio.video.VideoScaleType;
@aaalaniz
aaalaniz / EglBaseProviderReflectionUtils.java
Last active November 30, 2020 17:25
Rendering with a TextureView
import org.webrtc.EglBase;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/*
* Uses reflection to interact with non public class EglBaseProvider.
*/
public class EglBaseProviderReflectionUtils {
@aaalaniz
aaalaniz / CameraCapturerTest.java
Last active August 31, 2017 22:11
Twilio Video Android Bug 1060453
@Test
public void canBeRenderedToView() throws InterruptedException {
VideoView localVideo = (VideoView) cameraCapturerActivity.findViewById(R.id.local_video);
VideoView localVideoTwo = (VideoView) cameraCapturerActivity.findViewById(R.id.local_video_two);
VideoView localVideoThree = (VideoView) cameraCapturerActivity.findViewById(R.id.local_video_three);
VideoView localVideoFour = (VideoView) cameraCapturerActivity.findViewById(R.id.local_video_four);
VideoView localVideoFive = (VideoView) cameraCapturerActivity.findViewById(R.id.local_video_five);
final CountDownLatch renderedFirstFrame = new CountDownLatch(5);
VideoRenderer.Listener rendererListener = new VideoRenderer.Listener() {
@Override
@aaalaniz
aaalaniz / LinkerFlagsRuleSource.groovy
Last active February 22, 2016 16:02
Mutate Link Task Flags
class LinkerFlagsRuleSource extends RuleSource {
@Mutate
void modifyLinkerFlags(@Path('tasks.linkMy_moduleArmeabi-v7aDebugSharedLibrary') Task linkTask) {
linkTask.doFirst {
def newLinkerArgs = []
properties["linkerArgs"].each { linkerArg ->
def newLinkerArg = linkerArg.replaceAll(/ARCH/, 'armeabi-v7a')
newLinkerArgs.add(newLinkerArg)
}
setProperty("linkerArgs", newLinkerArgs)
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import io.realm.RealmObject;
import io.realm.RealmResults;
public abstract class RealmAdapter<E extends RealmObject, VH extends RealmAdapter.ViewHolder>
extends BaseAdapter {
@aaalaniz
aaalaniz / install_java6.sh
Created October 27, 2014 13:31
Install Java 6
WORKING_DIR=`pwd`
# Download the jdk 1.6
wget http://ghaffarian.net/downloads/Java/JDK/jdk-6u45-linux-x64.bin
# Install the jdk
sudo mkdir /usr/lib/jvm
cd /usr/lib/jvm && sudo sh $WORKING_DIR/jdk-6u45-linux-x64.bin -noregister
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_45/bin/javac 50000
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_45/bin/java 50000
@aaalaniz
aaalaniz / install_mvn_3_1_1.sh
Created October 13, 2014 18:09
Install Maven 3.1.1
# Install to home directory
cd ~
# Extract the package
wget http://mirror.metrocast.net/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz
tar -xf apache-maven-3.1.1-bin.tar.gz
# Install mvn to path
M2_HOME=$HOME/apache-maven-3.1.1
echo -e "\n# Maven 3.1.1 Setup" >> ~/.bashrc