Skip to content

Instantly share code, notes, and snippets.

Oleksii Malovanyi almozavr

View GitHub Profile
@almozavr
almozavr / jacoco.gradle
Last active Apr 4, 2020
Gradle Jacoco config for Android (3.x plugin) with kotlin and custom excludes support
View jacoco.gradle
apply plugin: "jacoco"
jacoco {
toolVersion = deps.test.jacocoVersion
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
@almozavr
almozavr / UnsafeCast.kt
Created Feb 5, 2018
Custom UnsafeCast rule for detekt
View UnsafeCast.kt
package io.techery.detekt.extensions.rules
import io.gitlab.arturbosch.detekt.api.*
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
/**
* Whitelist-able unsafe cast check. E.g.
*
* UnsafeCast:
View jenkins-android-pipeline-utils.groovy
#!/usr/bin/env groovy
def runBuild(String nodeName = null, notifyGithub = true, Closure<Void> job) {
if (nodeName) node(nodeName) { runBuildInternally(job, notifyGithub) }
else runBuildInternally(job, notifyGithub)
}
private def runBuildInternally(Closure<Void> job, boolean notifyGithub) {
withGithubNotifier(notifyGithub) {
decorateBuild {
@almozavr
almozavr / TimberServiceWrapper.java
Last active May 17, 2016
Timber logger service wrapper for Janet ActionService
View TimberServiceWrapper.java
public class TimberServiceWrapper extends ActionServiceWrapper {
private final String serviceTag;
public TimberServiceWrapper(ActionService actionService) {
this(actionService, null);
}
public TimberServiceWrapper(ActionService actionService, String tag) {
super(actionService);
@almozavr
almozavr / build.gradle
Created May 5, 2016
AndroidTDDBootStrap app Flavor Dimensions test
View build.gradle
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Piasy
*
* 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
View gist:fc76f605c03822a3ee14
public static Intent newSmsIntent(Context context, String body, String... phoneNumber) {
Uri smsUri;
if (phoneNumber == null) {
smsUri = Uri.parse("smsto:");
} else {
smsUri = Uri.parse("smsto:" + Uri.encode(TextUtils.join(",", phoneNumber)));
}
Intent intent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
intent = new Intent(Intent.ACTION_SENDTO, smsUri);
@almozavr
almozavr / ModalUrl
Last active Aug 29, 2015
Modal which preserves unique url via query, best with with routeProvider's reloadOnSearch: false
View ModalUrl
angular.module("services").factory('ModalUrl', [
'$rootScope', '$modal', '$location', '$routeParams', '$window', '$timeout',
($rootScope, $modal, $location, $routeParams, $window, $timeout) ->
modalInstance = null
checkModal = () ->
modalParam = decodeURIComponent($routeParams.modal)
if (modalParam != 'undefined')
optionsParam = decodeURIComponent($routeParams.options)
if (optionsParam != 'undefined')
options = JSON.parse(optionsParam)
@almozavr
almozavr / AndroidPaletteCallback
Last active Aug 29, 2015 — forked from imminent/ExampleActivity.java
Gist for a modified approach to integrating Palette with Picasso proposed by Jake Wharton for the interim while Picasso doesn't have a supported way to pass meta data along the pipeline. http://jakewharton.com/coercing-picasso-to-play-with-palette/ Fork provides diff RoundedImageView support
View AndroidPaletteCallback
package your.package;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.NonNull;
import android.widget.ImageView;
public abstract class AndroidPaletteCallback extends PaletteCallback<ImageView> {
public AndroidPaletteCallback(@NonNull ImageView imageView) {
@almozavr
almozavr / ObjectGsonParceler.java
Last active May 30, 2020
Parcelable helper to wrap object convertable with gson
View ObjectGsonParceler.java
public class ObjectGsonParceler {
private final Gson gson;
public ObjectGsonParceler(Gson gson) {
this.gson = gson;
}
public Parcelable wrap(Object instance) {
try {
String json = encode(instance);
@almozavr
almozavr / FixedSwitchPreference.java
Last active Aug 29, 2015
FixedSwitchPreference
View FixedSwitchPreference.java
public class FixedSwitchPreference extends SwitchPreference {
/**
* Construct a new SwitchPreference with the given style options.
*
* @param context The Context that will style this preference
* @param attrs Style attributes that differ from the default
* @param defStyle Theme attribute defining the default style options
*/
public FixedSwitchPreference(Context context, AttributeSet attrs, int defStyle) {
You can’t perform that action at this time.