Skip to content

Instantly share code, notes, and snippets.

View adolgiy's full-sized avatar

Aleksey Dolgiy adolgiy

View GitHub Profile

Singleton

  1. Roll-your-own lazy singleton

    public final class Single {
        private static Single INSTANCE;
        private Single() {}
        
@evantoli
evantoli / GitConfigHttpProxy.md
Last active April 26, 2024 17:21
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@chrisbanes
chrisbanes / SystemUiHelper.java
Last active March 2, 2024 18:57
SystemUiHelper
/*
* Copyright (C) 2014 The Android Open Source Project
*
* 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
@Miha-x64
Miha-x64 / EditableAdapter.kt
Last active July 10, 2023 09:24
Another approach to EditTexts inside RecyclerView
import android.text.Editable
import android.text.SpannableStringBuilder
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.widget.EditText
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
@Miha-x64
Miha-x64 / SpanningLinearLayoutManager.java
Last active May 24, 2023 16:37 — forked from heinrichreimer/LICENSE
LinearLayoutManager which distributes available space equally between all items. Changed: works also when items are added or removed.
package net.aquadc.recycler;
import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
/**
@Miha-x64
Miha-x64 / proguard-rules.pro
Last active March 13, 2023 07:27
Healthy person's ProGuard rules for Android and Kotlin.
# preverify is useful only for J2ME
# R8 doesn't preverify by default
#-dontpreverify
-optimizationpasses 5
# this seems to be enough
# remove indirection
-allowaccessmodification
@gabrielemariotti
gabrielemariotti / README.md
Last active March 9, 2023 06:02
A SectionedGridRecyclerViewAdapter: use this class to realize a simple sectioned grid `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned grid RecyclerView.Adapter without changing your code.

Screen

The RecyclerView has to use a GridLayoutManager.

This is a porting of the class SimpleSectionedListAdapter provided by Google

If you are looking for a sectioned list RecyclerView.Adapter you can take a look here

@mkholodnyak
mkholodnyak / remote_socks
Last active October 13, 2022 02:15
Создать socks5-прокси через удалённый сервер. Например, DigitalOcean.
ssh -D 5555 -i ~/.ssh/id_rsa login@servername -N
@techyourchance
techyourchance / MyPermission.java
Last active January 11, 2022 08:01
Abstraction for clean management of runtime permissions in Android applications
public enum MyPermission {
// declare runtime permissions specific to your app here (don't keep unused ones)
READ_PHONE_STATE(Manifest.permission.READ_PHONE_STATE),
FINE_LOCATION(Manifest.permission.ACCESS_FINE_LOCATION);
public static MyPermission fromAndroidPermission(String androidPermission) {
for (MyPermission permission : MyPermission.values()) {
if (permission.getAndroidPermission().equals(androidPermission)) {
return permission;
}