Skip to content

Instantly share code, notes, and snippets.

View nontravis's full-sized avatar

Nonthawit Doungsodsri nontravis

View GitHub Profile
@nontravis
nontravis / drawer.xml
Last active June 1, 2018 14:37
drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.NavigationView
android:id="@+id/side_menu_layout"
@nontravis
nontravis / testConcurrencyFunction_with_let.kt
Created May 6, 2018 11:06
testConcurrencyFunction_with_let
fun testConcurrencyFunction(){
Timer("thread_name_1").schedule(0) {
string?.let {
for (i in 1..10) {
Log.i(TRREAD1, "$i")
Log.i(TRREAD1, "string len: ${it.length}")
sleep(1000)
}
}
}
@nontravis
nontravis / testConcurrencyFunction_with_let_but_use_var_directly.kt
Last active May 6, 2018 11:06
testConcurrencyFunction_with_let_but_use_var_directly
fun testConcurrencyFunction(){
Timer("thread_name_1").schedule(0) {
string?.let{
for (i in 1..10) {
Log.i(TRREAD1, "$i")
Log.i(TRREAD1, "string len: ${string!!.length}")
sleep(1000)
}
}
}
@nontravis
nontravis / testConcurrencyFunction_not_use_let.kt
Last active May 6, 2018 11:06
testConcurrencyFunction not use let
fun testConcurrencyFunction(){
Timer("thread_name_1").schedule(0) {
if (string != null) {
for (i in 1..10) {
Log.i("thread_name_1", "$i")
Log.i("thread_name_1", "string len: ${string!!.length}")
sleep(1000)
}
}
@nontravis
nontravis / build.gradle
Created April 18, 2018 15:32
build.gradle
apply plugin: 'com.android.application'
apply from: "$project.rootDir/tools/applyCommon.gradle"
apply from: "$project.rootDir/tools/improveSpeed.gradle"
android {
...
signingConfigs {
release {
@nontravis
nontravis / improveSpeed.gradle
Created April 18, 2018 15:20
improveSpeed.gradle
android {
flavorDimensions "minApi"
productFlavors {
production{
}
@nontravis
nontravis / config.gradle
Last active April 19, 2018 17:32
config.gradle
ext.config = [
applicationId : "com.example.thekhaeng.kotlinprojectstructure",
compileSdkVersion: 27,
minimumSdkVersion: 18,
targetSdkVersion : 27,
buildToolsVersion: "27.0.3"
]
def config = ext.config
@nontravis
nontravis / applyCommon.gradle
Created April 18, 2018 14:58
applyCommon.gradle
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply from: "$project.rootDir/tools/config.gradle"
android{
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
debug.java.srcDirs += 'src/debug/kotlin'
release.java.srcDirs += 'src/release/kotlin'
@nontravis
nontravis / settings.gradle
Created April 18, 2018 14:32
settings.gradle
/** Add module here **/
includeFlat 'TabCommon'
List<Module> myModuleList = new ArrayList<>()
myModuleList.with {
add(new Module(name: ":AppProjectStructure", path: ":app"))
add(new Module(name: ":Common", path: "../TabCommon/Common"))
add(new Module(name: ":CommonApplication", path: "../TabCommon/CommonApplication"))
add(new Module(name: ":Library1", path: "../TabCommon/Library1"))
@nontravis
nontravis / client_nougat.java
Created February 12, 2018 15:18
client_nougat.java
OkHttpClient.Builder builder = new OkHttpClient.Builder();
// for resolve SSLHandshakeException at Android 7.0 only
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N) {
builder.connectionSpecs(Arrays.asList(
ConnectionSpec.MODERN_TLS,
ConnectionSpec.CLEARTEXT,
new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.allEnabledTlsVersions()
.allEnabledCipherSuites()