Skip to content

Instantly share code, notes, and snippets.

View Tanapruk's full-sized avatar
🎯
Focusing

Tanapruk Tanapruk

🎯
Focusing
View GitHub Profile
@Tanapruk
Tanapruk / kotlin01.md
Last active September 7, 2016 06:07
Kotliner

###Extension Functions

####Kotlin

fun CharSequence.isEmail() = this.matches("[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+".toRegex())


val stringImpl : String = "foo@email.com"
@Tanapruk
Tanapruk / kotlin02.md
Last active August 31, 2016 07:00
RxBinding

###Validate Your Login Email & Password With RxBinding and Kotlin

Variables

val emailChgObs = RxTextView.textChangeEvents(etEmail).publish().autoConnect(2)
val pwdChgObs = RxTextView.textChangeEvents(etPassword)

btnLogin.isEnabled = false

var subscriptionEmailValid = emailChgObs
@Tanapruk
Tanapruk / android01.md
Last active June 17, 2017 12:04
Status Bar and Navigation bar

Complete Transparent Status Bar & Navigation Bar

In your theme

<item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item>
<item name="android:navigationBarColor" tools:targetApi="lollipop">@android:color/transparent</item>

In your layout

@Tanapruk
Tanapruk / test01.md
Last active September 7, 2016 07:05
Test Framework verifyStatic
  1. dependencies
testCompile 'org.powermock:powermock-api-mockito:1.6.5'
testCompile 'org.powermock:powermock-module-junit4-rule-agent:1.6.5'
testCompile 'org.powermock:powermock-module-junit4-rule:1.6.5'
testCompile 'org.powermock:powermock-module-junit4:1.6.5'
  1. ใส่ tag บน class
@Tanapruk
Tanapruk / Proguard
Created October 23, 2016 09:32
Proguard guide
#I copy this from various places
#Debug when crashing by looking at:
#/app/build/outputs/mapping/normal/release
#mapping.txt use the class to search in here.
#
@Tanapruk
Tanapruk / bashscript
Created November 5, 2016 08:10
My Personal bash script as an Android Developer
#export path for android
export ANDROID_HOME=/Users/username/Documents/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tool
#to capture screen from android phone
function cap() {
LOCATIONPHONE=sdcard/screen_$(date "+%Y%m%d%H%M%S").png
@Tanapruk
Tanapruk / xvim for xcode 8.1.md
Last active November 27, 2016 06:26
installing xVim for xcode
@Tanapruk
Tanapruk / FingerPrintValidation.java
Last active January 19, 2017 10:41
Fingerprint scanner API
/**
*init service to check whether the phone use any security
*/
KeyguardManager keyguardManager = getSystemService(KeyguardManager.class);
/**
* if no keyguard then you cannot use fingerprint scanner.
*/
if (!keyguardManager.isKeyguardSecure()) {
// Show a message that the user hasn't set up a fingerprint or lock screen.
@Tanapruk
Tanapruk / OpenCVForAndroid.md
Last active August 20, 2018 13:52
Attach openCV sdk to your Android Studio project.

###There is no official maven-based way to install OpenCV on Android. You have to download and set it up to your project.

  1. Download the sdk and extract it somewhere.

  2. File>New>Import Module and select sdk/java

└── sdk
    ├── etc
    ├── java
 └── native
@Tanapruk
Tanapruk / Camera2.md
Last active October 20, 2022 07:49
Camera2 API

TextureView

You need to initialize TextureView before opening a camera. TextureView is for displaying the image from camera on the device. However, you cannot use it unless the texture is ready, either because the screen is currently off or it is initializing.

You should check mTextureView.isAvailable() before opening your camera. Else you will mTextureView.setSurfaceTextureListener(). And open your camera in the callback method onSurfaceTextureListener.

Camera

Before opening your camera you should check for a camera permission first.