Skip to content

Instantly share code, notes, and snippets.

View almosr's full-sized avatar

Almos Rajnai almosr

View GitHub Profile
@almosr
almosr / build.gradle
Created October 1, 2018 03:36
Add dependency version checking task (dependencyUpdates) to gradle
plugins {
//Gradle dependency check plugin
//See: https://github.com/ben-manes/gradle-versions-plugin
//Run: gradlew dependencyUpdates
id "com.github.ben-manes.versions" version "0.17.0"
}
//Configure dependency updates plugin to ignore all non-stable releases
dependencyUpdates.resolutionStrategy = {
componentSelection { rules ->
@almosr
almosr / gist:d750a40577cc822bd9681b335c33f8b6
Last active June 24, 2016 08:34
Typical ProGuard rules
# Remove logging
-assumenosideeffects class android.util.Log {
public static int v(...);
public static int d(...);
public static int i(...);
public static int w(...);
public static int e(...);
}
-assumenosideeffects class java.lang.Throwable {
public void printStackTrace();
@almosr
almosr / PathFollowerAnimator.java
Created February 22, 2016 06:53
Android animator class for following a path, target also rotated to align with the path.
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.graphics.Path;
import android.graphics.PathMeasure;
public class PathFollowerAnimator {
public static Animator create(Object target, String xPropertyName, String yPropertyName, String rotationPropertyName, Path path) {
@almosr
almosr / language level problem
Created January 18, 2016 20:35
Generating IDEA workspace files with language level setting is not working from this gradle
buildscript {
repositories {
mavenCentral()
}
}
group '...'
version '1.0-SNAPSHOT'
apply plugin: 'java'
@almosr
almosr / EnumUtils.java
Created January 12, 2016 07:38
Generic Enum parsing from string
public class EnumUtils {
public static <T extends Enum<T> & EnumWithId> T parseId(String id, Class<T> enumType) {
for (T type : enumType.getEnumConstants()) {
if (type.getId().equals(id)) {
return type;
}
}
throw new RuntimeException(String.format("Unknown ID for enum type: '%s': %s", enumType.getName(), id));
}
@almosr
almosr / gist:2f8f40678e823eee67b3
Last active December 12, 2017 07:51
Rename APK file in Gradle build and copy it to the root of the build folder
android {
applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "newfilename${variant.versionName}-${variant.name}.apk"
}
variant.assemble?.doLast {
//Copy mapping file after obfuscation, but for release build only
if (variant.buildType.name == "release") {
@almosr
almosr / gist:3c609ac5c84eb2bf8c33
Last active April 1, 2016 22:30
Suppress Warnings in Android Studio
@SuppressWarnings("ConstantConditions") - @Nullable which will not be null
@SuppressWarnings("unused") - components which are initialized or used indirectly (through Reflection or by external injection, etc.)
@SuppressWarnings("SameParameterValue") - for parameters of utility methods which are used by with one parameter only at the moment, but will be extended in the future (not necessarily good pratice, though)
@SuppressWarnings({"ResourceType"} - for suppressing non-handled permission request error
@almosr
almosr / gist:91b62991a3b80053518e
Created January 3, 2016 01:47
ButterKnife: ignore access can be weaker warning
.idea/misc.xml
<component name="EntryPointsManager">
<entry_points version="2.0" />
<list size="1">
<item index="0" class="java.lang.String" itemvalue="butterknife.*" />
</list>
</component>