Skip to content

Instantly share code, notes, and snippets.

View adolgiy's full-sized avatar

Aleksey Dolgiy adolgiy

View GitHub Profile
@Miha-x64
Miha-x64 / BoundService.kt
Last active January 5, 2020 14:48
Boilerplate for bound services (may become a part of http://github.com/Miha-x64/Flawless) later
package net.aquadc.flawless.service
import android.app.Service
import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.os.Binder
import android.os.IBinder
/**
@y2k
y2k / lite-moxy.kt
Created February 15, 2019 13:13
lite moxy
interface LitePresenter<T : Any> {
fun attachView(view: LiteView<T>)
fun detachView()
}
open class BaseLitePresenter<T : Any> : LitePresenter<T> {
private val buffer = ArrayList<T>()
private var view: LiteView<T>? = null
private var firstAttached = false
@cbeyls
cbeyls / MultiChoiceHelper.java
Last active September 30, 2020 14:48
Helper class to reproduce ListView's modal MultiChoice mode with a RecyclerView. Compatible with API 7+.
package be.digitalia.common.widgets;
import android.content.Context;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v4.util.LongSparseArray;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.view.ActionMode;
object a<T> {
operator fun get(vararg values:T) = values
}
a[] // empty array
a[1, 2, 3] // arrayOf(1,2,3)
@green-nick
green-nick / LocalizedString.kt
Last active April 1, 2021 20:32
Wrapper for strings without Android-dependency
package ...
private val identityMap: (String) -> String = { it }
sealed class LocalizedString
data class ResourceString(
val id: Int,
val quantity: Int? = null,
val args: List<Any> = emptyList(),
@Miha-x64
Miha-x64 / PicassoTextView.kt
Last active April 26, 2021 18:48
A TextView with Picasso targets for compound drawables
package net.aquadc.commonandroid.views
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.graphics.drawable.TransitionDrawable
import android.view.View
interface Traced<E, S : Trace.Stage> {
val trace: Trace<E, S>
}
data class EffectTracer<E : Traced<E, Trace.Stage.Out>, M : Traced<E, Trace.Stage.In>> internal constructor(
private val state: State,
private val factory: (Trace<E, Trace.Stage.Out>) -> E
) {
fun launch(): Pair<EffectTracer<E, M>, Set<E>> {
@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;
}
@mkholodnyak
mkholodnyak / remote_socks
Last active October 13, 2022 02:15
Создать socks5-прокси через удалённый сервер. Например, DigitalOcean.
ssh -D 5555 -i ~/.ssh/id_rsa login@servername -N
@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