Skip to content

Instantly share code, notes, and snippets.

View jeluchu's full-sized avatar
😎
Developing with anime

Jesús María jeluchu

😎
Developing with anime
View GitHub Profile
@bmc08gt
bmc08gt / SwipeToDelete.kt
Last active December 15, 2023 03:40
Jetpack Compose Modifier extension to implement swipe-to-delete via Modifier.draggable
import androidx.animation.IntToVectorConverter
import androidx.animation.tween
import androidx.compose.Composable
import androidx.compose.mutableStateOf
import androidx.compose.remember
import androidx.ui.animation.animatedFloat
import androidx.ui.animation.animatedValue
import androidx.ui.core.*
import androidx.ui.core.gesture.scrollorientationlocking.Orientation
import androidx.ui.foundation.animation.FlingConfig
@Treeki
Treeki / TurnipPrices.cpp
Last active May 27, 2024 15:18
AC:NH turnip price calculator
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
// munged from https://github.com/simontime/Resead
namespace sead
{
class Random
{
@PhongHuynh93
PhongHuynh93 / 1 compose
Last active August 30, 2022 07:27
jetpack compose
Supporting different screen sizes on Android with Jetpack Compose
https://proandroiddev.com/supporting-different-screen-sizes-on-android-with-jetpack-compose-f215c13081bd
Jetpack Compose — Reveal effect
https://dev.to/bmonjoie/jetpack-compose-reveal-effect-1fao
Bottom Navigation and Navigation Drawer Using Scaffold from Jetpack Compose
https://proandroiddev.com/bottom-navigation-and-navigation-drawer-using-scaffold-from-jetpack-compose-e2167440e7a9
Intro to animations with Jetpack Compose
@leamars
leamars / LinkPresentation.swift
Created January 7, 2020 00:56
LinkPresentation SwiftUI
import SwiftUI
import LinkPresentation
struct TutorialPost: UIViewRepresentable {
typealias UIViewType = LPLinkView
var url: URL
func makeUIView(context: UIViewRepresentableContext<TutorialPost>) -> TutorialPost.UIViewType {
return LPLinkView(url: url)
@gabrielemariotti
gabrielemariotti / README.MD
Last active March 7, 2024 07:50
How to use the ShapeableImageView.

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:

@jemshit
jemshit / MediaPlayerStateMachine.kt
Last active March 16, 2022 15:48
Android MediaPlayer has internal state of its own, but there is no get method for it. State diagram is here: https://developer.android.com/images/mediaplayer_state_diagram.gif. Invocation of method that is not allowed at current state results in exception. To avoid such exception and track states of MediaPlayer, MediaPlayerStateMachine is writte…
import android.util.Log
fun emptyMPStateMachineLogger(tag: String, message: String) {
// NoOp
}
fun defaultMPStateMachineLogger(tag: String, message: String) {
Log.d(tag, message)
}
// To load an image into an ImageView, use the load extension function.
imageView.load("https://www.example.com/image.jpg")
// Coil supports urls, uris, resources, drawables, bitmaps, files, and more.
imageView.load(R.drawable.image)
imageView.load(File("/path/to/image.jpg"))
imageView.load("content://com.android.externalstorage/image.jpg")
// Requests can be configured with an optional trailing lambda.
imageView.load("https://www.example.com/image.jpg") {
@sofakingforever
sofakingforever / AnimatedStarsView.kt
Last active February 3, 2022 09:21
Draw animated stars on Android view canvas - written in Kotlin - crafted with ❤️ by sofakingforever
package com.sofaking.moonworshipper.view
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.RectF
import android.util.AttributeSet
import android.view.View
import java.util.*
import java.util.concurrent.Executors
@ar-android
ar-android / ShowHideFab.java
Created January 19, 2018 18:14
Show and Hide Floating Action Button when scrolling recyclerview
// Java
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy > 0 && fab.getVisibility() == View.VISIBLE) {
fab.hide();
} else if (dy < 0 && fab.getVisibility() != View.VISIBLE) {
fab.show();
@oakkub
oakkub / DialogExtensions.kt
Last active December 27, 2023 04:32
Kotlin extension functions for creating AlertDialog in a DSL way
import android.annotation.SuppressLint
import android.app.Activity
import android.app.AlertDialog
import android.content.Context
import android.support.annotation.StringRes
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import android.widget.TextView