Skip to content

Instantly share code, notes, and snippets.

@shkcodes
shkcodes / LazyColumn.kt
Created July 25, 2021 15:46
ExoPlayer in LazyColumn
@Composable
fun TweetList(state: TweetListState) {
val context = LocalContext.current
val listState = rememberLazyListState()
val exoPlayer = remember {
SimpleExoPlayer.Builder(context).build().apply {
repeatMode = Player.REPEAT_MODE_ALL
}
}
@shkcodes
shkcodes / draw_circle.kt
Last active May 3, 2020 11:22
draw_circle
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
canvas.drawCircle(centerX, centerCircleY, radius, circlePaint)
val textCenterY = centerY - ((textPaint.descent() + textPaint.ascent()) / 2)
canvas.drawText(label, centerX, textCenterY, textPaint)
}
@shkcodes
shkcodes / observable_view_property.kt
Created April 26, 2020 12:06
observable_view_property
private fun <T> viewProperty(default: T) = object : ObservableProperty<T>(default) {
override fun beforeChange(property: KProperty<*>, oldValue: T, newValue: T): Boolean =
newValue != oldValue
override fun afterChange(property: KProperty<*>, oldValue: T, newValue: T) {
postInvalidateOnAnimation()
}
}
@shkcodes
shkcodes / scene.xml
Created April 4, 2020 10:53
Scene file
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@id/state_top"
motion:constraintSetStart="@id/state_mid"
motion:duration="300">
<OnSwipe
motion:dragDirection="dragUp"
@shkcodes
shkcodes / layout.xml
Created April 4, 2020 10:52
Layout file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/scene_2">
<View
android:id="@+id/rectangle"
android:layout_width="0dp"
class A {
private B objectB;
public A(B objectB) {
this.objectB = objectB;
}
public int doSomeWork() {
int result = objectB.getResult();
class A {
public int doSomeWork(int p1, int p2, String p3) {
B objectB = new B(p1, p2, p3);
int result = objectB.getResult();
int finalResult = result * 2;
return finalResult;
}
}
Class A {
public int doSomeWork() {
B objectB = new B();
int result = objectB.getResult();
int finalResult = result * 2;
return finalResult;
}
}