Skip to content

Instantly share code, notes, and snippets.

View andriipanasiuk's full-sized avatar

Andrew Panasiuk andriipanasiuk

View GitHub Profile
@krossovochkin
krossovochkin / Error.kt
Created February 23, 2020 08:15
From RxJava to Kotlin Flow: Error Handling
package by.krossovochkin.testflow
import io.reactivex.Observable
import io.reactivex.exceptions.CompositeException
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import org.junit.Test
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.CountDownLatch
@arnaudgiuliani
arnaudgiuliani / JavaApp.java
Created February 27, 2018 16:04
Koin for Android Java app
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Call helper to start Koin
JavaAppKoinKt.start(this);
}
}
@ultraon
ultraon / build.gradle
Last active August 19, 2020 18:10
Good example of the merged Jacoco code covarage Gradle configuration
apply plugin: 'com.android.application'
apply from: "$rootDir/coverage.gradle"
//...
android {
//...
buildTypes {
//...
debug {
@rhoadster91
rhoadster91 / LevelTransitionDrawable.java
Last active February 5, 2019 15:45
Modified version of TransitionDrawable to let you create transition based on level (as against transition based on alpha). In this case contains a ScaleLevelTransitionDrawable implementation, but you can make your own implementation by nesting drawables.
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
@MihaelIsaev
MihaelIsaev / CameraViewController.swift
Created April 16, 2015 19:30
This is the example of camera view for iOS written in Swift
import UIKit
import AVFoundation
class ViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
@IBOutlet weak var myView: UIView!
var session: AVCaptureSession?
var device: AVCaptureDevice?
var input: AVCaptureDeviceInput?
@Albert-IV
Albert-IV / .gitconfig
Created April 2, 2015 18:46
Add `revert-file` to your git config, reverting all changes done in a commit to a specific file.
[alias]
revert-file = !sh /home/some-user/git-file-revert.sh
@ZkHaider
ZkHaider / expand-collapse.java
Last active January 30, 2022 02:31
Simple Expand / Collapse RecyclerView Item
public static class ExampleViewHolder extends RecyclerView.ViewHolder
implements View.OnClickListener {
private int originalHeight = 0;
private boolean isViewExpanded = false;
private YourCustomView yourCustomView
public ExampleViewHolder(View v) {
super(v);
v.setOnClickListener(this);
@williscool
williscool / AppStart.java
Created December 11, 2014 01:45
AppStart - Check if started for the first time Android
/**
* Distinguishes different kinds of app starts: <li>
* <ul>
* First start ever ({@link #FIRST_TIME})
* </ul>
* <ul>
* First start in this version ({@link #FIRST_TIME_VERSION})
* </ul>
* <ul>
* Normal app start ({@link #NORMAL})
@JMPergar
JMPergar / ScrollViewWithMaxHeight.java
Created November 5, 2014 13:28
ScrollView that can be configured with max height
public class ScrollViewWithMaxHeight extends ScrollView {
public static int WITHOUT_MAX_HEIGHT_VALUE = -1;
private int maxHeight = WITHOUT_MAX_HEIGHT_VALUE;
public ScrollViewWithMaxHeight(Context context) {
super(context);
}