Skip to content

Instantly share code, notes, and snippets.

View artem-zinnatullin's full-sized avatar
:shipit:

Artem Zinnatullin artem-zinnatullin

:shipit:
View GitHub Profile
@artem-zinnatullin
artem-zinnatullin / build.gradle
Created July 17, 2014 07:30
Gradle & Android: Disable/Enable preDexing
// add this to the general build.gradle, not in the subproject's build.gradle
// improved version of Xavier's tip http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance.
// usage example default, preDex will be enabled: gradle clean build
// usage example disabling preDex: gradle clean build -PpreDexEnable=false
// preDexEnable parameter's value can be set as property of Continuous Integration build config
// this is the main difference from Xavier's workaround where he doing only hasProperty check
project.ext {
if (project.hasProperty('preDexEnable')) {
@artem-zinnatullin
artem-zinnatullin / MyApp.java
Last active January 15, 2023 13:04
If you need to set one font for all TextViews in android application you can use this solution. It will override ALL TextView's typefaces, includes action bar and other standard components, but EditText's password font won't be overriden.
public class MyApp extends Application {
@Override
public void onCreate() {
TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/Roboto-Regular.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf
}
}
@artem-zinnatullin
artem-zinnatullin / GradleWorkersPleaseStopTakingFocus.gradle
Created July 21, 2015 19:58
Prevent Gradle Workers from taking focus! #DevelopersLikeComfort
// You can place it in the root build.gradle
allprojects {
tasks.withType(JavaForkOptions) {
// Forked processes like GradleWorkerMain for tests won't steal focus!
jvmArgs '-Djava.awt.headless=true'
}
}
@artem-zinnatullin
artem-zinnatullin / build.gradle
Last active December 1, 2020 17:54
Ignore particular buildType in Android Project
// Variant 1: For app or library project's build.gradle
android {
variantFilter {
if (it.buildType.name.equals('debug')) {
it.ignore = true
}
}
}
// Variant 2: For root build.gradle with applying only to library projects
@artem-zinnatullin
artem-zinnatullin / gist:6916740
Last active October 26, 2020 12:15
Android support library onActivityResult() bug fix for nested fragments
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// notifying nested fragments (support library bug fix)
final FragmentManager childFragmentManager = getChildFragmentManager();
if (childFragmentManager != null) {
final List<Fragment> nestedFragments = childFragmentManager.getFragments();
@artem-zinnatullin
artem-zinnatullin / error_prone_buck.bzl
Created January 24, 2020 02:58
ErrorProne Integration with Buck
def apply_error_prone(**kwargs):
# Error Prone should be on by default in Bazel.
if IS_BAZEL:
return kwargs
has_java_files = False
for src in kwargs.get("srcs", []):
if src.endswith(".java"):
has_java_files = True
break
@artem-zinnatullin
artem-zinnatullin / build.gradle
Last active November 9, 2019 23:19
Android Unit tests logging configuration
android {
// ...
testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
}
}
@artem-zinnatullin
artem-zinnatullin / bg_common
Created January 22, 2015 21:23
Common Ripple drawable
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/bg_item_ripple">
<item>
<selector>
<item android:state_pressed="true" android:drawable="@color/bg_item_pressed"/>
<item android:state_focused="true" android:drawable="@color/bg_item_focused"/>
<item android:drawable="@color/bg_item_normal"/>
</selector>
</item>
@artem-zinnatullin
artem-zinnatullin / build.gradle
Created January 27, 2015 17:18
App's build.gradle for Kotlin
apply plugin: 'kotlin-android'
android {
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
// NOTICE: dependencies are fixed for build stability
dependencies {
@artem-zinnatullin
artem-zinnatullin / detekt-config.yml
Created March 7, 2019 03:31
detekt-config.yml for Lyft Android Project
autoCorrect: true
failFast: false
test-pattern: # Configure exclusions for test sources
active: true
patterns: # Test file regexes
- '.*/test/.*'
- '.*Test.kt'
- '.*Spec.kt'
exclude-rule-sets: