Skip to content

Instantly share code, notes, and snippets.

👨‍🔬
Coding…

Simon Marquis SimonMarquis

👨‍🔬
Coding…
Block or report user

Report or block SimonMarquis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View LazyGetter.java
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
public abstract class LazyGetter<T> {
private final AtomicReference<Optional<T>> mCachedValue = new AtomicReference<>(Optional.<T>empty());
public final T get() {
Optional<T> value = mCachedValue.get();
if (!value.isPresent()) {
@SimonMarquis
SimonMarquis / PreventScreenshot.java
Created Oct 21, 2016
Prevent screenshot on Activity, Dialog, Surface, etc.
View PreventScreenshot.java
import android.app.Activity;
import android.app.Dialog;
import android.app.Fragment;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.view.SurfaceView;
import android.view.Window;
import android.view.WindowManager;
/**
View Utils.java
import android.Manifest;
import android.animation.Keyframe;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Canvas;
View screenrecord.sh
file=$(date +%Y.%m.%d-%H.%M.%S).mp4 \
&& path="/sdcard/$file" \
&& time=${1-30} \
&& bitrate=${2-20000000} \
&& adb shell screenrecord --time-limit "$time" --bit-rate "$bitrate" "$path" \
&& echo "Success" \
&& echo "Uploading..." \
&& adb pull "$path" \
&& adb shell rm "$path" \
&& echo "Screencapture saved at $(pwd)/$file" \
View screenshot.sh
file=$(date +%Y.%m.%d-%H.%M.%S).png \
&& path="/sdcard/$file" \
&& adb shell screencap -p "$path" \
&& adb pull "$path" \
&& adb shell rm "$path" \
&& echo "Screenshot saved at $(pwd)/$file" \
|| echo "Screenshot failed"
@SimonMarquis
SimonMarquis / scheme.html
Last active Aug 29, 2015
Trigger the provided url scheme or fallback to Google Play Store
View scheme.html
<!DOCTYPE html>
<html>
<head>
<script src="scheme.js"></script>
<script type="text/javascript">
// myscheme://init?param1=value1&param2=value2
var scheme = "myscheme";
var data = "init?param1=value1&param2=value2";
var packagename = "com.example.scheme";
</script>
You can’t perform that action at this time.