This file contains hidden or 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
| // Make Logcat clickable | |
| private class LinkingDebugTree : Timber.DebugTree() { | |
| override fun createStackElementTag(e: StackTraceElement): String { | |
| val tag = "(${e.fileName}:${e.lineNumber})" | |
| return if (tag.length <= MAX_TAG_LENGTH) tag else super.createStackElementTag(e) | |
| } | |
| companion object { | |
| private val MAX_TAG_LENGTH = 23 | |
| } |
This file contains hidden or 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
| Abbreviation: logm | |
| Description: Log method name and its arguments | |
| Template: android.util.Log.d(TAG, $content$) | |
| content: groovyScript("'\"' + _1.collect { it + ' = [$' + it + ']'}.join(', ') + '\"'", functionParameters()) |
This file contains hidden or 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
| /* | |
| You can setup an interceptor to read the raw HttpResponse, but it is an InputStream | |
| 1) Implement ClientHttpRequestInterceptor to execute the request, the log the response body InputStream | |
| */ | |
| class LoggingInterecptor : ClientHttpRequestInterceptor { | |
| private val LOG = LoggerFactory.getLogger(javaClass) | |
| override fun intercept(request: HttpRequest?, body: ByteArray?, execution: ClientHttpRequestExecution): ClientHttpResponse { | |
| val response = execution.execute(request, body) |
This file contains hidden or 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
| # Export a git project to a zip file | |
| git archive --format=zip -o project.zip master | |
| # Delete merged branches | |
| git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d |
This file contains hidden or 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
| # util project | |
| uploadArchives { | |
| repositories { | |
| mavenLocal() | |
| } | |
| } | |
| # now util can ./gradlew uploadArchives | |
This file contains hidden or 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
| rootProject.name = 'my-app' | |
| if (file("../my-utils").exists()) { | |
| includeBuild "../my-utils" | |
| } | |
| file('modules').listFiles().findAll { it.directory }.each { File moduleBuild -> | |
| includeBuild moduleBuild | |
| } |
This file contains hidden or 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
| Today I learned that FCM (formerly GCM) has a fun quirk. The payload of a push notification can contain two elements, "notification" and "data". You can read these payloads in a callback called onMessageReceived(). | |
| If the app is in the forgeround, everything works as you'd expect. However, if the app is in the background, and the "notification" element is in the payload, onMessageReceived() is NOT called and Firebase handles the push notification and generates a system notification. | |
| If you want onMessageReceived() to always be called, then you can only have "data" notification. Awesome! | |
| https://firebase.google.com/docs/notifications/android/console-audience#receive_and_handle_notifications | |
| Also, a very frustrating read: https://github.com/firebase/quickstart-android/issues/4 | |
| https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages | |
| https://firebase.google.com/docs/cloud-messaging/android/receive#sample-receive |