Skip to content

Instantly share code, notes, and snippets.

object Logger {
@JvmStatic
inline fun log(crossinline configure: Log.() -> Unit) {
if (isWritersAvailable) {
Log().let {
configure(it)
write(it)
}
}
inline fun info(crossinline message: () -> String?) {
level { Level.INFO }
this.message = message.invoke()
}
inline fun tag(crossinline tag: () -> String) {
this.tag = tag.invoke()
}
inline fun throwable(crossinline throwable: () -> Throwable) {
this.throwable = throwable.invoke()
}
inline fun level(crossinline level: () -> Level) {
this.level = level.invoke()
class Log {
var level: Level = Level.DEBUG
var tag: String? = null
var throwable: Throwable? = null
var message: String? = null
}
listOf(42).foreach { inc() }
fun <T> Iterable<T>.foreach(action: T.() -> Unit) {
for (element in this) element.action()
}
fun <T> Iterable<T>.foreach(action: (T) -> Unit) {
for (element in this) action(element)
}
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
final String messageViewId = "android:id/message";
final String buttonViewId = "android:id/button1";
// get root layout node of dialog
AccessibilityNodeInfo rootNode = event.getSource();
// find textview with message & button nodes
List<AccessibilityNodeInfo> ussdResponseTextViewNodesList =
@dybarsky
dybarsky / service_config.xml
Created March 16, 2017 13:14
accessibility service config
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/accessibility_service_description"
android:packageNames="com.android.phone"
android:accessibilityEventTypes="typeWindowStateChanged"
android:accessibilityFeedbackType="feedbackGeneric"
android:canRetrieveWindowContent="true"
/>
-keep class dmax.dialog.** {
*;
}