Skip to content

Instantly share code, notes, and snippets.

View MaTriXy's full-sized avatar

Yossi Elkrief MaTriXy

View GitHub Profile
@MaTriXy
MaTriXy / checkMediacodecAbility.java
Created March 12, 2018 12:17 — forked from wangchauyan/checkMediacodecAbility.java
Check How Many MediaCodec Instance Your Device Support
public static int getMaxCodecInstanceByName(String name) {
final Vector<MediaCodec> codecs = new Vector<>();
final MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, 1920, 1080);
MediaCodec codec = null;
for (int i = 0; i < max; i++) {
try {
codec = MediaCodec.createDecoderByType(MediaFormat.MIMETYPE_VIDEO_AVC);
codec.configure(format, null, null, 0);
codec.start();
@MaTriXy
MaTriXy / DemoModeEnabler.kt
Created January 29, 2018 07:44 — forked from hvisser/DemoModeEnabler.kt
Enables demo mode on a device for the purpose of taking screenshots
class DemoModeEnabler {
fun enable() {
executeShellCommand("settings put global sysui_demo_allowed 1")
sendCommand("exit")
sendCommand("enter")
sendCommand("notifications", "visible" to "false")
sendCommand("network", "wifi" to "hide")
sendCommand("battery", "level" to "100", "plugged" to "false")
sendCommand("clock", "hhmm" to "1000")
@MaTriXy
MaTriXy / Data.kt
Created January 17, 2018 16:48 — forked from florina-muntenescu/Data.kt
Using RoomDatabase#Callback to pre-populate the database - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* 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
package com.mtsahakis.mediaprojectiondemo;
import android.app.Activity;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.hardware.display.DisplayManager;
@MaTriXy
MaTriXy / AndroidManifest.xml
Created November 25, 2017 22:03 — forked from bjoernQ/AndroidManifest.xml
Creating a System Overlay (Always on Top over all Apps) in Android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.mobilej.overlay"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application android:label="SystemOverlay" >
<activity
@MaTriXy
MaTriXy / code.kt
Created November 23, 2017 22:30 — forked from chrisbanes/code.kt
Night Mode inflater
/*
* 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
@MaTriXy
MaTriXy / code.kt
Created November 23, 2017 22:30 — forked from chrisbanes/code.kt
Night Mode inflater
/*
* 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
@MaTriXy
MaTriXy / NetUtils.kt
Created November 14, 2017 12:47
Get Local IP Address in kotlin
private fun getLocalIpAddress(): String? {
try {
val wifiManager: WifiManager = context?.getSystemService(WIFI_SERVICE) as WifiManager
return ipToString(wifiManager.connectionInfo.ipAddress)
} catch (ex: Exception) {
Log.e("IP Address", ex.toString())
}
@MaTriXy
MaTriXy / GifDecoder.java
Created August 10, 2017 17:39 — forked from devunwired/GifDecoder.java
An optimized implementation of GifDecoder for Android devices.
/**
* Copyright (c) 2013 Xcellent Creations, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@MaTriXy
MaTriXy / RepeatRule.java
Created July 14, 2017 11:20
Obeying the rules ? Challenge accepted. Blog post about using TestRules and Parameterized tests in Android
public class RepeatRule implements TestRule {
@Retention(RetentionPolicy.RUNTIME)
@Target({METHOD, ANNOTATION_TYPE})
public @interface Repeat {
int value() default 1;
}
private static class RepeatStatement extends Statement {