Example from Android Jetpack: LiveData
MutableLiveData Example |
---|
![]() |
val context = LocalContext.current | |
val scope = rememberCoroutineScope() | |
var data by remember { mutableStateOf<SensorData?>(null) } | |
DisposableEffect(Unit) { | |
val dataManager = SensorDataManager(context) | |
dataManager.init() | |
scope.launch { |
import android.content.Context; | |
import android.graphics.Color; | |
import android.graphics.Paint; | |
import android.graphics.Rect; | |
import android.graphics.Typeface; | |
import android.graphics.drawable.Drawable; | |
import android.graphics.drawable.LayerDrawable; | |
import android.graphics.drawable.ShapeDrawable; | |
import android.graphics.drawable.shapes.RectShape; | |
import android.graphics.drawable.shapes.Shape; |
public class HttpStatusCodeHelper { | |
/** | |
* Gets Http Status Code Information for given Code. No Reflection, No Enum | |
* @param code | |
* @return type + text | |
*/ | |
public static String getHttpTypeAndTextByCode(final int code) { | |
//region 1xx |
val spanned = spannable{ bold("some") + italic(" formatted") + color(Color.RED, " text") } | |
val nested = spannable{ bold(italic("nested ")) + url("www.google.com", "text") } | |
val noWrapping = bold("no ") + sub("wrapping ) + sup("also ") + "works" | |
text_view.text = spanned + nested + noWrapping |
MutableLiveData Example |
---|
![]() |
package com.filipkowicz.headeritemdecorator | |
/* | |
solution based on - based on Sevastyan answer on StackOverflow | |
changes: | |
- take to account views offsets | |
- transformed to Kotlin | |
- now works on viewHolders |
The Material Components Library introduced with the 1.2.0-alpha03
the new ShapeableImageView
.
In your layout you can use:
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image_view"
app:srcCompat="@drawable/..." />
Then in your code apply the ShapeAppearanceModel
to define your custom corners:
/* | |
* Copyright (C) 2015 Hooked On Play | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
import android.annotation.SuppressLint | |
import android.content.Context | |
import android.util.AttributeSet | |
import android.view.View | |
import androidx.annotation.AttrRes | |
import androidx.coordinatorlayout.widget.CoordinatorLayout | |
import androidx.core.view.NestedScrollingChild3 | |
import androidx.core.view.NestedScrollingChildHelper | |
import com.redmadrobot.plazius.R |
import android.hardware.Sensor; | |
import android.hardware.SensorEvent; | |
import android.hardware.SensorEventListener; | |
import android.hardware.SensorManager; | |
import android.media.ExifInterface; | |
/** | |
* Created by abdelhady on 9/23/14. | |
* | |
* to use this class do the following 3 steps in your activity: |