Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alexey Korolev Pulimet

🏠
Working from home
View GitHub Profile
@RubyLichtenstein
RubyLichtenstein / PainlessFragmentArguments.md
Last active Feb 11, 2021
Painless android fragments with Kotlin
View PainlessFragmentArguments.md

Starting new fragments with Kotlin is easy

Example

val user = User(id = "id", name = "Ruby")
val userFragment: UserFragment = newFragment<User, UserFragment>(user)

How this magic works

View FromRxJavaToKotlinCoroutines-LifeCycle.kt
class LifeCycle {
open class BaseActivity : Activity(), CoroutineScope {
private val job = SupervisorJob()
override val coroutineContext: CoroutineContext
get() = job + Dispatchers.Main
override fun onDestroy() {
super.onDestroy()
job.cancel()
View SimpleRecyclerView.java
package com.saber.customstickyheader;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
@dors
dors / LogUtil.java
Last active Mar 9, 2017
Cool log util for Android apps that prints each log with the thread, class name and method name from which the log was made
View LogUtil.java
import android.util.Log;
import java.text.MessageFormat;
/*
* Copyright 2015 Dor Sakal
*
* 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
@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active Feb 22, 2022
Endless RecyclerView OnScrollListener
View EndlessRecyclerOnScrollListener.java
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
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.
int firstVisibleItem, visibleItemCount, totalItemCount;
@emil2k
emil2k / Connectivity.java
Last active Sep 18, 2022
Android utility class for checking device's network connectivity and speed.
View Connectivity.java
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions: