Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Denys Nykyforov Popalay

🎯
Focusing
Block or report user

Report or block Popalay

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
View gist:ad1a598da1574fb7be05aace345bdd03
class Solution {
public List<List<Integer>> combinationSum(int[] candidates, int target) {
return new ArrayList<>(findComb(candidates, target));
}
Set<List<Integer>> findComb(int[] candidates, int target){
Set<List<Integer>> result = new HashSet<List<Integer>>();
for(int i = 0; i < candidates.length; i++){
if(candidates[i] == target){
@Popalay
Popalay / DecimalDigitsInputFilter
Created Jul 23, 2019
Set limit of digits after decimal point
View DecimalDigitsInputFilter
class DecimalDigitsInputFilter(val decimalDigits: Int) : InputFilter {
override fun filter(source: CharSequence, start: Int, end: Int, dest: Spanned, dstart: Int, dend: Int): CharSequence? =
if (dstart > dest.indexOf('.') &&
dest.toString().substringAfter('.', "").length > decimalDigits - 1
) "" else null
}
View PrefixInputFilter
class PrefixInputFilter(private val prefix: String) : InputFilter {
override fun filter(source: CharSequence, start: Int, end: Int, dest: Spanned?, dstart: Int, dend: Int): CharSequence? {
val newStart = max(prefix.length, dstart)
val newEnd = max(prefix.length, dend)
return if (newStart != dstart || newEnd != dend) {
val builder = SpannableStringBuilder(dest)
builder.replace(newStart, newEnd, source)
if (source is Spanned) {
TextUtils.copySpansFrom(source, 0, source.length, null, builder, newStart)
@Popalay
Popalay / UnselectablePrefixSpanWatcher
Last active Jul 23, 2019
Set unselectable part of text:
View UnselectablePrefixSpanWatcher
import android.text.Selection
import android.text.SpanWatcher
import android.text.Spannable
import kotlin.math.max
class UnselectablePrefixSpanWatcher(private val prefix: String) : SpanWatcher {
override fun onSpanAdded(text: Spannable, what: Any, start: Int, end: Int) = Unit
override fun onSpanRemoved(text: Spannable, what: Any, start: Int, end: Int) = Unit
@Popalay
Popalay / UnselectablePrefixSpanWatcher
Created Jul 23, 2019
Set un selectable part of text:
View UnselectablePrefixSpanWatcher
import android.text.Selection
import android.text.SpanWatcher
import android.text.Spannable
import kotlin.math.max
class UnselectablePrefixSpanWatcher(private val prefix: String) : SpanWatcher {
override fun onSpanAdded(text: Spannable, what: Any, start: Int, end: Int) = Unit
override fun onSpanRemoved(text: Spannable, what: Any, start: Int, end: Int) = Unit
View CircularReveal.kt
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.annotation.TargetApi
import android.graphics.Outline
import android.graphics.Rect
import android.os.Build
import android.transition.Transition
import android.transition.TransitionValues
@Popalay
Popalay / View
Created Jul 21, 2017
KotlinSample
View View
import android.arch.lifecycle.ViewModelProvider
import android.arch.lifecycle.ViewModelProviders
import android.content.Context
import android.content.Intent
import android.databinding.DataBindingUtil
import android.graphics.Color
import android.os.Bundle
import android.view.View
import com.popalay.cardme.R
import com.popalay.cardme.databinding.ActivityHolderDetailsBinding
View CharacterWrapTextView.java
private void refitText(String text, int textWidth) {
if (textWidth <= 0) {
return;
}
final int targetWidth = textWidth - getPaddingLeft() - getPaddingRight();
float hi = 1f;
float lo = 0f;
float textWidthCalculated;
while (hi - lo > 0.1) {
View PaginationScrollListener
public class PaginationScrollListener extends RecyclerView.OnScrollListener {
private static final int ITEMS_OFFSET_TO_LOAD_DEFAULT = 3;
private final OnRecyclerViewScrolledToPageListener mCallback;
private final int mOffset;
private LinearLayoutManager mLayoutManager;
private boolean loading;
private int previousTotal;
public interface OnRecyclerViewScrolledToPageListener {
View MaterialSpinner.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.ArrayRes;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.widget.AppCompatAutoCompleteTextView;
You can’t perform that action at this time.