Skip to content

Instantly share code, notes, and snippets.

View jungilhan's full-sized avatar
🏠
Working from home

Jungil Han jungilhan

🏠
Working from home
View GitHub Profile
@VincentSit
VincentSit / CustomizedObjectTypeAdapter.kt
Last active February 23, 2021 00:24
Prevent GSON from converting integers to doubles in Kotlin
import com.google.gson.Gson
import com.google.gson.TypeAdapter
import com.google.gson.internal.LinkedTreeMap
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter
import java.io.IOException
import java.util.*
class CustomizedObjectTypeAdapter : TypeAdapter<Any>() {
@kingori
kingori / ConstraintLayout.xml
Last active April 20, 2022 08:43
Live template for ConstraintLayout xml attributes for Android
<templateSet group="ConstraintLayout">
<template name="cbb" value="app:layout_constraintBottom_toBottomOf=&quot;$cursor$&quot;" description="constraint bottom to bottom of id" toReformat="true" toShortenFQNames="true">
<variable name="cursor" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="XML" value="true" />
<option name="XML_TEXT" value="false" />
</context>
</template>
<template name="cbp" value="app:layout_constraintBottom_toBottomOf=&quot;parent&quot;" description="constraint bottom to bottom of parent" toReformat="true" toShortenFQNames="true">
<context>
/*
* Copyright (C) 2016 Jeff Gilfelt.
*
* 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
@imran0101
imran0101 / EndlessRecyclerOnScrollListener.java
Last active February 22, 2022 12:50
RecyclerView position helper to get first and last visible positions
/**
* Custom Scroll listener for RecyclerView.
* Based on implementation https://gist.github.com/ssinss/e06f12ef66c51252563e
*/
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = "EndlessScrollListener";
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.
@xadh00m
xadh00m / BackgroundManager.java
Last active March 1, 2023 17:49
BackgroundManager
package com.android.utils;
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.os.Handler;
import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
@JakeWharton
JakeWharton / ForegroundImageView.java
Created July 10, 2014 16:42
An ImageView which supports a foreground drawable.
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
public class ForegroundImageView extends ImageView {
private Drawable foreground;
@libinbensin
libinbensin / MainActivity.java
Last active December 9, 2023 14:44
Facebook Popup using PopupWindow
public class MainActivity extends
private PopupWindow popWindow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@JakeWharton
JakeWharton / Truss.java
Last active June 9, 2023 07:35
Extremely simple wrapper around SpannableStringBuilder to make the API more logical and less awful. Apache 2 licensed.
import android.text.SpannableStringBuilder;
import java.util.ArrayDeque;
import java.util.Deque;
import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
/** A {@link SpannableStringBuilder} wrapper whose API doesn't make me want to stab my eyes out. */
public class Truss {
private final SpannableStringBuilder builder;
private final Deque<Span> stack;
@chrisbanes
chrisbanes / FloatLabelLayout.java
Last active March 15, 2024 06:39
FloatLabelLayout
/*
* Copyright 2014 Chris Banes
*
* 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
@steveliles
steveliles / Foreground.java
Last active January 22, 2024 18:06
Class for detecting and eventing whether an Android app is currently foreground or background (requires API level 14+)
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;