Skip to content

Instantly share code, notes, and snippets.

View dawidhyzy's full-sized avatar

Dawid Hyży dawidhyzy

View GitHub Profile
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun PositionFocusedItemInLazyLayout(
parentFraction: Float = 0.3f,
childFraction: Float = 0f,
content: @Composable () -> Unit,
) {
// This bring-into-view spec pivots around the center of the scrollable container
val bringIntoViewSpec = object : BringIntoViewSpec {
override fun calculateScrollDistance(
@Composable
fun SampleImmersiveList(movies: List<Movie>, modifier = Modifier) {
val selectedMovie = remember { mutableStateOf<Movie?>(movies.firstOrNull()) }
// Container
Box(
modifier = Modifier
.fillMaxWidth()
.height(400.dp)
) {
import androidx.compose.animation.core.EaseInOut
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.MutableInteractionSource
@chrisbanes
chrisbanes / bash_aliases
Created March 30, 2020 13:23
Shell function to set default JDK to Android Studio's bundled JDK
function set-studio-jdk() {
export JAVA_HOME=$1/Contents/jre/jdk/Contents/home/
}
@chrisbanes
chrisbanes / KotterKnife.kt
Last active February 7, 2021 15:25
LifecycleAware KotterKnife
package kotterknife
import android.app.Activity
import android.app.Dialog
import android.app.DialogFragment
import android.app.Fragment
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleObserver
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.OnLifecycleEvent
@lopspower
lopspower / README.md
Last active May 11, 2022 02:47
Android Tools Attributes

Android Tools Attributes

Twitter

Android has a dedicated XML namespace intended for tools to be able to record information in XML files, and have that information stripped when the application is packaged such that there is no runtime or download size penalty. The namespace URI is http://schemas.android.com/tools and is usually bound to the tools: prefix:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
@williamwebb
williamwebb / BindingRecyclerView.java
Last active January 20, 2023 13:05
RecyclerView & Adapter init in XML
We couldn’t find that file to show.
@paolorotolo
paolorotolo / LabelledSpinner.java
Last active January 11, 2024 16:42 — forked from farbodsz/ LabelledSpinner.md
A Spinner component with a floating label for Android, similar to EditText components wrapped in a TextInputLayout.
/*
* Copyright 2015 Farbod Salamat-Zadeh
*
* 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
@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active January 19, 2024 08:52
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing