This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import xml.etree.ElementTree | |
import collections | |
xmlFile = sys.argv[1] | |
strings = collections.Counter() | |
root = xml.etree.ElementTree.parse(xmlFile).getroot() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test; | |
import static org.junit.Assert.assertEquals; | |
public class StringTest { | |
@Test | |
public void testAllTheSame() { | |
assertEquals(true, allDuplicateChars("cccccc")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Date parseRawDateWithUnhandledException(String dateString) throws ParseException { | |
// This was previously being handled with Joda (yay!), but Joda eats up nearly 5000 | |
// methods (boo!) in an already big app just to parse a timestamp...so there *is* a reason | |
// we are doing things like this... | |
if (dateString.endsWith("Z")) { | |
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); | |
dateFormat.setTimeZone(TimeZone.getTimeZone("Zulu")); | |
return dateFormat.parse(dateString); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.graphics.drawable.Drawable; | |
import android.support.annotation.ColorRes; | |
import android.support.annotation.DrawableRes; | |
import android.support.v4.content.ContextCompat; | |
import android.support.v4.graphics.drawable.DrawableCompat; | |
public class DrawableHelper { | |
public static Drawable setupTintedIcon(Context context, @DrawableRes int iconDrawableResId, @ColorRes int iconColorResId) { | |
Drawable icon = ContextCompat.getDrawable(context, iconDrawableResId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Application; | |
import com.fasterxml.jackson.databind.DeserializationFeature; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.squareup.okhttp.OkHttpClient; | |
import javax.inject.Singleton; | |
import dagger.Module; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// annotation processor will generate DevicePhoneNumberSumType (see: 4_DevicePhoneNumberSumType.java) | |
@SumType | |
public interface DevicePhoneNumber { | |
String phoneNumber(); | |
void phoneNumberNotAvailable(); | |
String[] permissionsRequired(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.support.annotation.CheckResult; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Size; | |
import android.support.v4.app.ActivityCompat; | |
import static android.content.pm.PackageManager.PERMISSION_GRANTED; | |
public class ActivityPermissionDelegate { | |
public interface PermissionRationaleRetryBehavior { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
... | |
BarcodeLoggerActivityPermissionsDispatcher.startBarcodeCaptureWithCheck(this); | |
} | |
@NeedsPermission(Manifest.permission.CAMERA) | |
void startBarcodeCapture() { | |
int orientation = WindowManagerHelper.getCurrentAccurateOrientation(this); | |
Intent intent = CaptureActivity.buildIntent(this, orientation); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
@Component(modules = { | |
AndroidModule.class, | |
BusModule.class, | |
NetworkModule.class, | |
AppModule.class | |
}) | |
public interface ApplicationComponent { | |
... | |
Bus bus(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Put this at the end of your project build.gradle | |
// Execute on your CI server with something like: | |
// ./gradlew continuousIntegration -Pfingerprint=asdf -PbuildNumber=2 -PdisablePreDex | |
evaluationDependsOnChildren(); | |
task staticAnalysis() { | |
def appProject = subprojects.find { project -> 'app' == project.name } | |
dependsOn appProject.getTasksByName('findbugs', true) |