Requirements:
-
Device should be a rooted (simulator’s are rooted by default)
-
adbd should be started as root. (Rub command:
adb root
)
Now, send local push message using command:
//app build.gradle | |
apply plugin: 'kotlin-kapt' | |
... | |
dependencies { | |
{ | |
//Moshi Core | |
implementation "com.squareup.moshi:moshi:1.8.0" | |
//Moshi Codegen |
Requirements:
Device should be a rooted (simulator’s are rooted by default)
adbd should be started as root. (Rub command: adb root
)
Now, send local push message using command:
fun <T> unsafeLazy(initializer: () -> T) = lazy(LazyThreadSafetyMode.NONE, initializer) | |
@JvmOverloads @Dimension(unit = Dimension.PX) fun Number.dpToPx( | |
metrics: DisplayMetrics = Resources.getSystem().displayMetrics | |
): Float { | |
return toFloat() * metrics.density | |
} | |
@JvmOverloads @Dimension(unit = Dimension.DP) fun Number.pxToDp( | |
metrics: DisplayMetrics = Resources.getSystem().displayMetrics |
/** | |
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has | |
* already been handled. | |
* | |
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled. | |
*/ | |
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> { | |
override fun onChanged(event: Event<T>?) { | |
event?.getContentIfNotHandled()?.let { value -> | |
onEventUnhandledContent(value) |
/** | |
* Used as a wrapper for data that is exposed via a LiveData that represents an event. | |
*/ | |
open class Event<out T>(private val content: T) { | |
var hasBeenHandled = false | |
private set // Allow external read but not write | |
/** | |
* Returns the content and prevents its use again. |
public interface Consumer<T> { | |
void accept(T value); | |
} |
import kotlinx.coroutines.experimental.channels.BroadcastChannel | |
import kotlinx.coroutines.experimental.channels.ConflatedBroadcastChannel | |
import kotlinx.coroutines.experimental.channels.ReceiveChannel | |
import kotlinx.coroutines.experimental.channels.filter | |
import kotlinx.coroutines.experimental.channels.map | |
import kotlinx.coroutines.experimental.launch | |
import javax.inject.Inject | |
import javax.inject.Singleton |
# fromhex A52A2A | |
# fromhex "#A52A2A" | |
# BLUE_VIOLET=$(fromhex "#8A2BE2") | |
# http://unix.stackexchange.com/a/269085/67282 | |
function fromhex() { | |
hex=$1 | |
if [[ $hex == "#"* ]]; then | |
hex=$(echo $1 | awk '{print substr($0,2)}') | |
fi | |
r=$(printf '0x%0.2s' "$hex") |