Skip to content

Instantly share code, notes, and snippets.

Julian CapnSpellcheck

Block or report user

Report or block CapnSpellcheck

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
CapnSpellcheck / NewlineLimitingInputFilter.kt
Last active Dec 12, 2018
An InputFilter for Android EditText that limits the number of newlines the user can type into it.
View NewlineLimitingInputFilter.kt
import android.text.InputFilter
import android.text.Spanned
class NewlineLimitingInputFilter(val maxLines: Int) : InputFilter {
var monitor: LimitMonitor? = null
var numNewlines = 0
override fun filter(source: CharSequence, start: Int, end: Int, dest: Spanned, dstart: Int, dend: Int): CharSequence? {
// subtract all newlines in dest range
for (char in dest.subSequence(dstart, dend)) {
CapnSpellcheck / EnumAdapter.kt
Last active Feb 21, 2018
Adapter extending BaseAdapter on Android to show a Spinner based on Enum. The Enum class should also implement Displayable.
View EnumAdapter.kt
* If isOptional, then position 0 is a "No response" item.
class EnumAdapter<DispEnum>(val context: Context, enumClass: Class<DispEnum>,
@IntegerRes var resource: Int = android.R.layout.simple_spinner_item,
@IntegerRes var dropDownResource: Int = android.R.layout.simple_spinner_dropdown_item,
val isOptional: Boolean = false) :
BaseAdapter() where DispEnum : Displayable, DispEnum : Enum<DispEnum>
val inflater: LayoutInflater = LayoutInflater.from(context)
CapnSpellcheck / IntRangeAdapter.kt
Created Jan 26, 2017
IntRangeAdapter: A BaseAdapter that allows for easy handling of an integer range. Allows the minimum or maximum to be changed at any time more easily and efficiently than an ArrayAdapter can.
View IntRangeAdapter.kt
import android.content.Context
import android.util.Log
import android.view.*
import android.widget.BaseAdapter
import android.widget.TextView
class IntRangeAdapter(val context: Context,
@IntegerRes var resource: Int,
CapnSpellcheck / BetterForegroundImageView.kt
Last active Jan 24, 2017
An ImageView that allows the foreground drawable to be positioned anywhere within the view's bounds by using a floating point range 0 - 1, where 0 means the left/top edge is snug with view's left/top, and 1 means the right/bottom edge is snug with view's right/bottom.. X and Y can be positioned separately.
View BetterForegroundImageView.kt
import android.content.Context
import android.util.AttributeSet
import android.widget.ImageView
class BetterForegroundImageView : ImageView {
constructor(ctx: Context) : super(ctx)
constructor(ctx: Context, attrs: AttributeSet) : super(ctx, attrs) {
CapnSpellcheck / DialogListPicker.kt
Last active Apr 30, 2018
A class to make simple the use of DialogFragment with AlertDialog. You can set a few properties directly, or provide a delegate and deal with Builder directly. *NEW*: This now supports instance state restoration. Assigning a delegate is now deprecated. Instead, implement a provideDelegate() function. For example, Use ActivityDelegatingDialogFrag…
View DialogListPicker.kt
import android.annotation.SuppressLint
import android.os.Bundle
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.view.View
import android.view.ViewTreeObserver
CapnSpellcheck / patch.diff
Created Nov 17, 2016
Patch to chrisbanes/PhotoView for issue #444
View patch.diff
From 7ab87c7543deebb48a8c1ab482eb7cab524f2d29 Mon Sep 17 00:00:00 2001
From: Julian <>
Date: Thu, 17 Nov 2016 13:34:11 -0800
Subject: [PATCH] destroying the mid zoom
.../co/senab/photoview/ | 17 ++++++++++++-----
.../java/uk/co/senab/photoview/ | 16 +++++++++++-----
2 files changed, 23 insertions(+), 10 deletions(-)
View FadeInCircleBitmapDisplayer.kt
import android.view.View
import android.view.animation.*
import com.nostra13.universalimageloader.core.assist.LoadedFrom
import com.nostra13.universalimageloader.core.display.CircleBitmapDisplayer
import com.nostra13.universalimageloader.core.imageaware.ImageAware
You can’t perform that action at this time.