Skip to content

Instantly share code, notes, and snippets.

View davinctor's full-sized avatar
🎯
Focusing

Viktor Ponomarenko davinctor

🎯
Focusing
View GitHub Profile
@davinctor
davinctor / ScalableVideoView.java
Created June 21, 2018 08:41 — forked from anry200/ScalableVideoView.java
Android : How to stretch video to use whole area of VideoView (code snippets)
import android.content.Context;
import android.util.AttributeSet;
import android.widget.VideoView;
public class ScalableVideoView extends VideoView {
private int mVideoWidth;
private int mVideoHeight;
private DisplayMode displayMode = DisplayMode.ORIGINAL;
@davinctor
davinctor / AmazonS3RequestFactory.java
Created March 14, 2017 11:59 — forked from NightlyNexus/AmazonS3RequestFactory.java
Creates okhttp3.Requests for uploading files to an Amazon S3 storage bucket. Implements https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-authentication-HTTPPOST.html
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import okio.BufferedSource;
import okio.ByteString;
@davinctor
davinctor / AddWifiNetwork.java
Created February 13, 2017 22:45 — forked from tiwiz/AddWifiNetwork.java
Add your Wi-Fi Network to Android Things
String networkSSID = "Your Network SSID here";
String networkPasskey = "YourNetworkPasswordHere";
WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.SSID = "\"" + networkSSID + "\"";
wifiConfiguration.preSharedKey = "\"" + networkPasskey + "\"";
WifiManager manager = (WifiManager) getSystemService(WIFI_SERVICE);
manager.addNetwork(wifiConfiguration);
@davinctor
davinctor / AppBarStateChangedListener.java
Created February 13, 2017 12:20 — forked from ed-george/AppBarStateChangedListener.java
Simple listener to determine if the AppBarLayout of a view is collapsed or expanded
public abstract class AppBarStateChangedListener implements AppBarLayout.OnOffsetChangedListener {
public enum State {
EXPANDED,
COLLAPSED,
IDLE
}
private State mCurrentState = State.IDLE;
import android.util.Log;
import com.crashlytics.android.Crashlytics;
import timber.log.Timber;
/**
* A logging implementation which reports 'info', 'warning', and 'error' logs to Crashlytics.
*/
public final class CrashlyticsTree extends Timber.Tree {
@Override
@davinctor
davinctor / MainActivity
Created December 25, 2016 15:34 — forked from gsysko/MainActivity
Setting imeActionId with a predefined ID resource creates an error.
package com.me.keyboard.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
@davinctor
davinctor / screenrecord.sh
Created December 12, 2016 19:29 — forked from tasomaniac/screenrecord.sh
Screen Record for Android
#!/bin/sh
set -e
if [ -z "$1" ]; then
shot_path=$(date +%Y-%m-%d-%H-%M-%S).mp4
else
shot_path="$*"
fi
import android.app.Service;
import android.content.Intent;
import android.graphics.ImageFormat;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureRequest;
import android.media.Image;
@davinctor
davinctor / build.gradle
Created October 23, 2016 21:10 — forked from twocity/build.gradle
android gradle change output apk file name.
android.applicationVariants.all { variant ->
println "*********" + variant.description + "**********";
def variants = variant.baseName.split("-");
def apkName = "ricebook-";
apkName += variants[0];
apkName += "-v" + android.defaultConfig.versionName;
if (!variant.zipAlign) {
apkName += "-unaligned";
}
if (variant.buildType.name == "release") {
@davinctor
davinctor / GifDecoder.java
Created September 30, 2016 09: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: