Skip to content

Instantly share code, notes, and snippets.

View GregKluska's full-sized avatar
😀

Greg Kluska GregKluska

😀
  • Manchester
View GitHub Profile
@GregKluska
GregKluska / RacoonAnimation.kt
Created June 12, 2024 15:17
RacoonAnimation
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
@GregKluska
GregKluska / funkotlin.kt
Last active November 26, 2022 18:16
Loading a text file to a script
fun readFileLineByLineUsingForEachLine(fileName: String)
= File(fileName).forEachLine { println(it) }
@GregKluska
GregKluska / Animatable.kt
Last active November 21, 2021 21:43
Animatable Offset and Shake Animation
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationVector2D
import androidx.compose.animation.core.TwoWayConverter
import androidx.compose.ui.geometry.Offset
private val offsetToVector: TwoWayConverter<Offset, AnimationVector2D> =
TwoWayConverter({ AnimationVector2D(it.x, it.y) },
{ Offset(it.v1, it.v2) })
fun Animatable(initialValue: Offset): Animatable<Offset, AnimationVector2D> =
@GregKluska
GregKluska / GridLayout.kt
Last active October 28, 2021 12:02
Grid Layout for Compose
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import kotlin.math.ceil
@Composable
fun GridLayout(
modifier: Modifier = Modifier,
rowModifier: Modifier = Modifier,
@GregKluska
GregKluska / tagextension.kt
Last active November 27, 2020 09:35
TAG extension
/**
* extension function to provide TAG value
*/
val Any.TAG: String
get() {
return if (!javaClass.isAnonymousClass) {
val name = javaClass.simpleName
if (name.length <= 23) name else name.substring(0, 23)// first 23 chars
} else {
val name = javaClass.name
package com.codingwithmitch.cleannotes.business.data.util
import com.codingwithmitch.cleannotes.business.data.cache.CacheConstants.CACHE_TIMEOUT
import com.codingwithmitch.cleannotes.business.data.cache.CacheErrors.CACHE_ERROR_TIMEOUT
import com.codingwithmitch.cleannotes.business.data.cache.CacheErrors.CACHE_ERROR_UNKNOWN
import com.codingwithmitch.cleannotes.business.data.cache.CacheResult
import com.codingwithmitch.cleannotes.business.data.network.ApiResult
import com.codingwithmitch.cleannotes.business.data.network.NetworkConstants.NETWORK_TIMEOUT
import com.codingwithmitch.cleannotes.business.data.network.NetworkErrors.NETWORK_ERROR_TIMEOUT
import com.codingwithmitch.cleannotes.business.data.network.NetworkErrors.NETWORK_ERROR_UNKNOWN
/*
* Copyright (C) 2019 The Android Open Source Project
*
* 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 React, { useState, useEffect } from 'react';
import { useStaticQuery, graphql } from 'gatsby';
import { prepareBlogs, state } from './util';
const LoadingScreen = () => {
return <div>Still Loading</div>;
};
const EmptyScreen = () => {
@GregKluska
GregKluska / ListAdapter.kt
Created October 13, 2020 10:51
ListAdapter.kt
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.AsyncListDiffer
import androidx.recyclerview.widget.DiffUtil
#parse("File Header.java")
import android.app.Activity
import android.content.Context
import androidx.annotation.IdRes
import androidx.annotation.NavigationRes
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
import androidx.navigation.NavController
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment