Skip to content

Instantly share code, notes, and snippets.

@Kaspic
Kaspic / main_fragment.xml
Last active April 19, 2021 16:49
ConstraintLayout + RecyclerView + NestedScrollView Tutorial
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context=".ui.main.MainFragment">
@Kaspic
Kaspic / mutable-live-data-live-template
Last active August 24, 2023 10:29
Android Studio Kotlin LiveData Function Templates
private val _$NAME$ = MutableLiveData<$PARAM_TYPE$>()
val $NAME$ : LiveData<$PARAM_TYPE$> = _$NAME$
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
#end
#parse("File Header.java")
class ${NAME} {
}
// If you don't add a number, only a badge will be displayed at the respective menu_item
var badge = findViewById<NavigationRailView>(R.id.navigation_rail).getOrCreateBadge(R.id.menu_item_account)
badge.isVisible = true
// In this case, the number 99 will be displayed in the badge
badge = findViewById<NavigationRailView>(R.id.navigation_rail).getOrCreateBadge(R.id.menu_item_moon)
badge.isVisible = true
badge.number = 99
class TestFragment : Fragment(R.layout.fragment_test) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if (savedInstanceState == null) {
childFragmentManager.commit { replace(R.id.fragmentContainerView, SubTestFragment(), SubTestFragment::class.java.canonicalName) }
}
}
}
<com.google.android.material.progressindicator.LinearProgressIndicator
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:indeterminateAnimationType="contiguous" />
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import androidx.core.util.Pair
import com.google.android.material.button.MaterialButton
import com.google.android.material.datepicker.MaterialDatePicker
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
package com.example.consumer.event;
import com.example.publisher.config.RabbitMQConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;
import java.io.IOException;
class TutorialCustomView(context: Context, attrs: AttributeSet): FrameLayout(context, attrs) {
init {
inflate(context, R.layout.tutorial_custom_view, this)
val mainText : TextView = findViewById(R.id.main_text)
context.withStyledAttributes(attrs, R.styleable.TutorialCustomView) {
mainText.apply {
setBackgroundColor(getColorOrThrow(R.styleable.TutorialCustomView_mainColor))
text = getString(R.styleable.TutorialCustomView_mainText)
@Kaspic
Kaspic / MainPage.xaml
Last active February 3, 2021 21:42
Samsung Galaxy Watch Companion App Tutorial - Part 2
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="GalaxyConsumer.MainPage">
<ContentPage.Content>
<StackLayout
HorizontalOptions="FillAndExpand"
Orientation="Vertical"
VerticalOptions="FillAndExpand">
<Button