Skip to content

Instantly share code, notes, and snippets.

View android-web-app-interface.kt
typealias Listener = () -> Unit
class WebViewActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_webview)
setupWebView()
loadWebView("[your-web-url]")
}
View lmwn.kt
import java.util.Base64
fun main() {
val secret = "aWFuZ25vVzpOQU06RU5JTDp0YTpzdTpuaW9K"
val mysteriousCode = String(Base64.getDecoder().decode(secret)).reversed()
println("Mysterious Code: $mysteriousCode")
}
View AndroidMarqueeAnimationActivity.kt
val marquee = AnimationUtils.loadAnimation(context, R.anim.marquee)
textView.startAnimation(marquee)
View viewstub_ex.kt
viewStub.setVisibility(View.VISIBLE);
// หรือ
val layoutBannedUser: View = viewStub.inflate();
View viewstub_usage.kt
class UserActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
.
.
if(user.isBanned()) {
stub.inflate()
}
View activity_user_viewstub.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageview_avatar"
android:layout_width="150dp"
android:layout_height="150dp"
View banned_user.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#CC000000"
android:gravity="center"
android:orientation="vertical">
<TextView
View activity_user_overlay.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout>
<ImageView />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#CC000000"
android:gravity="center"
android:orientation="vertical">
View activity_user.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageview_avatar"
android:layout_width="150dp"
android:layout_height="150dp"
View viewstub_ex.xml
<ViewStub android:id="@+id/stub"
android:inflatedId="@+id/layout_banned_user"
android:layout="@layout/banned_user"
android:layout_width="match_parent"
android:layout_height="wrap_content" />