Skip to content

Instantly share code, notes, and snippets.

@handstandsam
handstandsam / MyLifecycleOwner.kt
Last active March 30, 2024 16:59
Jetpack Compose OverlayService. You have to have all the correct permissions granted and in your manifest, but if you do, this this will show a green box with "Hello" in it!
import android.os.Bundle
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleRegistry
import androidx.savedstate.SavedStateRegistry
import androidx.savedstate.SavedStateRegistryController
import androidx.savedstate.SavedStateRegistryOwner
internal class MyLifecycleOwner : SavedStateRegistryOwner {
private var mLifecycleRegistry: LifecycleRegistry = LifecycleRegistry(this)
private var mSavedStateRegistryController: SavedStateRegistryController = SavedStateRegistryController.create(this)
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
@liberorignanese
liberorignanese / MarginSpan.java
Last active January 12, 2024 18:05
Android TextInputLayout with credit card mask
package com.liberorignanese.android.gist;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.text.style.ReplacementSpan;
/**
* Created by Libero Rignanese.
*/
@donglua
donglua / GlideImageGetter
Last active April 30, 2018 08:22 — forked from AndroidT/GlideImageGetter
GlideImageGetter uses Glide Image Library to load GIFs/JPG/PNG in HTML <img> tags into TextView
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.text.Html;
import android.view.View;
import android.widget.TextView;
import com.bumptech.glide.Glide;
@rogerhu
rogerhu / Contact.java
Last active June 9, 2022 23:32
Endless scrolling with RecyclerVIew
package codepath.com.recyclerviewfun;
import java.util.ArrayList;
import java.util.List;
public class Contact {
private String mName;
private boolean mOnline;
public Contact(String name, boolean online) {
@koesie10
koesie10 / ApiModule.java
Created October 3, 2015 07:40
Retrofit 1 error handling behaviour in Retrofit 2
// Dagger 1 example
@Module(
complete = false,
library = true
)
public final class ApiModule {
@Provides
@Singleton
Retrofit provideRetrofit(Gson gson, Application app) {
return new Retrofit.Builder()
@PurpleBooth
PurpleBooth / README-Template.md
Last active April 26, 2024 01:29
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@marcelpinto
marcelpinto / ControllableAppBarLayout.java
Last active December 12, 2019 03:42 — forked from blipinsk/ControllableAppBarLayout.java
An extension of Android AppBarLayout, that allows to programatically change the CollapsibleToolbarLayout state and receive state changes (collapsed, expanded and idle)
package com.eatfirst.android.ui.custom;
/**
* Copyright 2015 Bartosz Lipinski
*
* 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
@elevenetc
elevenetc / gist:bf795f94aaf3e92169ef
Last active March 23, 2024 17:00
Android SuppressWarnings list
//src: http://kurrytran.blogspot.ru/2014/05/android-studio-list-of-suppress-warning.html
//https://android.googlesource.com/platform/tools/adt/idea/+/jb-mr2-dev/adt-branding/src/META-INF/AndroidIdePlugin.xml
//https://android.googlesource.com/platform/tools/adt/idea/+/jb-mr2-dev/android/src/META-INF/plugin.xml
//Most Common Annotations
@SuppressWarnings("all")
@SuppressWarnings("unchecked")
@SuppressWarnings({"JavaDoc"})
@SuppressWarnings({"UnusedDeclaration"})
@dmytrodanylyk
dmytrodanylyk / res_color_btn_flat_selector.xml
Last active March 4, 2023 07:52
Material Flat Button Style
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:color="@color/flat_disabled_text"/>
<item android:color="@color/flat_normal_text"/>
</selector>