Skip to content

Instantly share code, notes, and snippets.

View 0phelia's full-sized avatar
💀
Braindead

Artem 0phelia

💀
Braindead
View GitHub Profile
EventChannel(getFlutterView(),
CHANNEL_PLAYBACK_EVENTS,
JSONMethodCodec.INSTANCE)
.setStreamHandler(
object : EventChannel.StreamHandler {
override fun onListen(args: Any?,
events: EventChannel.EventSink) {
playbackEventSink = events
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
class ViewModelFactory(private val mApplication: App,
private val irepo: IRepo) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return when (modelClass) {
GVM::class.java -> GVM(irepo) as T
VVM::class.java -> VVM(mApplication, irepo) as T
AVM::class.java -> AVM(irepo) as T
else -> throw IllegalArgumentException("Use standard ViewModelProvider to retrieve this ViewModel")
}
import android.util.Log
import androidx.annotation.MainThread
import androidx.annotation.Nullable
import com.google.ads.interactivemedia.v3.internal.w
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import java.util.concurrent.atomic.AtomicBoolean
// create observer
class ActivityLifecycleObserver: LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
fun lifecycleResume() {
Log.d(MainActivity.TAG, "$this on resume")
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
fun lifecyclePause() {
// add to app build file
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
}
// set expostSchema to true#
...exportSchema = true
curl -sI https://dl.google.com/dl/android/aosp/nakasi-ktu84l-factory-93385880.zip | grep -i Content-Length
package de.stroeer.androiddevapplicant
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
class WeatherViewModel : ViewModel() {
package de.stroeer.androiddevapplicant
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
class WeatherViewModel : ViewModel() {
<!DOCTYPE html>
<head>
<title>JS-Flutter Communication</title>
<style>
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 20px;
}