Skip to content

Instantly share code, notes, and snippets.

View DjakaTechnology's full-sized avatar
🏠

Djaka Pradana Jaya Priambudi DjakaTechnology

🏠
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
...
class MainActivity : AppCompatActivity() {
lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
}
}
@DjakaTechnology
DjakaTechnology / activity_main.xml
Last active June 5, 2020 02:50
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="name"
type="String" />
</data>
<LinearLayout
class MainActivity : AppCompatActivity() {
lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
binding.buttonContinue.setOnClickListener {
binding.name = Random.nextInt(100).toString()
}
object ViewBindingAdapter {
@BindingAdapter("visibilityGone")
@JvmStatic
fun visibilityGone(view: View, isShouldGone: Boolean) {
if (isShouldGone) {
view.visibility = View.GONE
} else {
view.visibility = View.VISIBLE
}
}
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:text="@{name}"
visibilityGone="@{name == null}"/>
binding.buttonReset.setOnClickListener {
binding.name = null
}
<com.google.android.material.button.MaterialButton
android:id="@+id/button_reset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:text="Reset" />
@DjakaTechnology
DjakaTechnology / migrate_to_moshi.main.kts
Last active August 1, 2022 06:14
This will migrate file from gson or regular POJO to moshi
#!/usr/bin/env kotlin
import java.io.File
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
/**
* How to use:
* Run script
echo "This script will copy the WordPress installation into"
echo "/var/www/yourNewSubDomain/html"
echo "--------------------------------------------------"
echo "This setup requires a domain name. If you do not have one yet, you may"
echo "cancel this setup, press Ctrl+C. This script will run again on your next login"
echo "--------------------------------------------------"
echo "Enter the domain name for your new WordPress site."
echo "(ex. example.org or test.example.org) do not include www or http/s"
echo "--------------------------------------------------"