Skip to content

Instantly share code, notes, and snippets.

View realityexpander's full-sized avatar
🤓
Kotlin Multi-platoform, Android Native, iOS & Web

Chris Athanas realityexpander

🤓
Kotlin Multi-platoform, Android Native, iOS & Web
View GitHub Profile
@BracketCove
BracketCove / LoadingSpinner.kt
Created October 21, 2022 16:17
Easy animated loading spinner with Glide (or whatever image loading library)
//use this in your Recyclerview or whereever for asynchornous image loading
Glide.with(holder.itemView.context)
.load(avatarUrl)
.centerCrop()
.placeholder(
CircularProgressDrawable(holder.itemView.context).apply {
setColorSchemeColors(
ContextCompat.getColor(holder.itemView.context, R.color.colorPrimary)
)
@realityexpander
realityexpander / build.gradle.kts(:shared)
Last active October 17, 2022 22:56
for KMM @TypeParceler article
// build.gradle.kts(:shared
plugins {
kotlin("multiplatform")
id("com.android.library")
id("kotlin-parcelize") // add this
id("kotlin-kapt") // add this
//…rest of defintions…
}
kotlin {
@Composable
fun FlingAnimation() {
val offset = remember { Animatable(Offset(0f, 0f), Offset.VectorConverter) }
Box(
modifier = Modifier
.fillMaxSize()
.pointerInput(Unit) {
coroutineScope {
while (true) {
val position = awaitPointerEventScope {
@loehnertz
loehnertz / Extensions.kt
Created December 6, 2021 20:55
Handy Kotlin Extension Functions
/**
* Swaps the order of the elements of the given [Pair] in a type-safe manner.
*
* Example:
* ```
* Pair("David", 32).swap() // Pair(32, "David")
* ```
*/
fun <A, B> Pair<A, B>.swap(): Pair<B, A> = this.second to this.first
@Mashpoe
Mashpoe / main.c
Last active April 14, 2024 02:51
ASCII Tesseract Rotation C Program
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <windows.h>
// width and height of screen
#define ww 100
#define wh 50
void clr(CHAR_INFO* d)
@codinginflow
codinginflow / FragmentA.java
Created July 5, 2021 20:02
Fragment to Fragment ViewModel Communcation Tutorial
package com.codinginflow.sharedviewmodelexample;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
@stevdza-san
stevdza-san / Converters.kt
Last active March 31, 2024 10:09
@TypeConverter
class Converters {
@TypeConverter
fun fromBitmap(bitmap: Bitmap): ByteArray {
val outputStream = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream)
return outputStream.toByteArray()
}
@TypeConverter
@mitchtabian
mitchtabian / MainActivity.kt
Last active December 28, 2022 15:24
Basics #4: Dependencies that require dependencies (Concrete classes that you own)
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
@Inject
/*
Problem:
['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris']
// YOUR ALGORITHM
@Pulimet
Pulimet / AdbCommands
Last active May 5, 2024 13:39
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader