Skip to content

Instantly share code, notes, and snippets.

View nontravis's full-sized avatar

Nonthawit Doungsodsri nontravis

View GitHub Profile
@nontravis
nontravis / test
Created February 11, 2018 15:26
test
function updateAll(){
updateBxPrice();
updateDcrPrice();
updateUSDtoBAHT();
updateRig();
updateStat();
updateHashflare();
}
function updateRig(){
@nontravis
nontravis / javascriptinterface.html
Last active January 15, 2018 10:54
javascriptinterface.html
<html>
<head>
<script type="text/javascript">
function someMethodOnAndroid() {
WebViewJS.someMethodOnAndroid('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>');
}
</script>
</head>
<body>
<input type="button" value="Say hello" onClick="someMethodOnAndroid()" />
@nontravis
nontravis / changeHintInput.kt
Created January 15, 2018 07:40
changeHintInput.kt
private fun changeHintInput() {
webview.loadUrl("javascript:" +
"var input = document.getElementById('lst-ib');" +
"var placeholder = document.createAttribute('placeholder');" +
"placeholder.value = 'The Khaeng placeholder';" +
"input.setAttributeNode(placeholder);")
}
@nontravis
nontravis / onHeight.kt
Created January 15, 2018 07:33
onHeight.kt
webview.loadUrl(
"javascript:$WEBVIEW_JS.onHeight(document.body.getBoundingClientRect().height)")
@nontravis
nontravis / printHeightOnWebView.kt
Last active January 15, 2018 07:50
printHeightOnWebView.kt
@JavascriptInterface
fun onHeight(height: Float) {
runOnUiThread {
printHeightOnWebView(height)
}
}
...
private fun printHeightOnWebView(height: Float) {
@nontravis
nontravis / MainActivity.kt
Created January 15, 2018 04:54
MainActivity.kt
class MainActivity
: AppCompatActivity() {
companion object {
val WEBVIEW_JS = "WebViewJS"
}
private val webViewClient: WebViewClient = object : WebViewClient() {
override
@nontravis
nontravis / slide_example.xml
Created December 26, 2017 09:59
slide_example.xml
[ slide_in_from_right.xml ]
<?xml version="1.0" encoding="utf-8"?>
<set>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/fragment_transition_time"
android:fromXDelta="100%"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0" />
</set>
@nontravis
nontravis / lollipop_round_primary_mask.xml
Created December 8, 2017 04:51
lollipop_round_primary_mask.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="30dp"/>
<solid android:color="@android:color/black"/>
</shape>
@nontravis
nontravis / lollipop_round_primary_selector.xml
Created December 8, 2017 04:47
lollipop_round_primary_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/colorAccent">
<item
android:id="@android:id/mask"
android:drawable="@drawable/lollipop_round_primary_mask"/>
<item>
<selector>
<item android:drawable="@drawable/lollipop_round_primary_focused"
android:state_focused="true" />
@nontravis
nontravis / font-xml-example.xml
Created October 25, 2017 05:02
font-xml-example
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedAttribute">
<font
android:font="@font/productsans_regular"
android:fontStyle="normal"
android:fontWeight="400"