Skip to content

Instantly share code, notes, and snippets.

Avatar
💀
Braindead

Artem 0phelia

💀
Braindead
View GitHub Profile
View js_flutter_communication.html
<!DOCTYPE html>
<head>
<title>JS-Flutter Communication</title>
<style>
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 20px;
}
View WeatherViewModel.kt
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() {
View gist:9d476fdb590ddfd8ca8d411cd36d9f5a
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() {
View remote_file_size
curl -sI https://dl.google.com/dl/android/aosp/nakasi-ktu84l-factory-93385880.zip | grep -i Content-Length
View room_db_migration
// add to app build file
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
}
// set expostSchema to true#
...exportSchema = true
View lifecycle.kt
// 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() {
View SingleLiveEvent.kt
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
View foooo.kt
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")
}
View android-permissions
<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" />
View Flutter channels
EventChannel(getFlutterView(),
CHANNEL_PLAYBACK_EVENTS,
JSONMethodCodec.INSTANCE)
.setStreamHandler(
object : EventChannel.StreamHandler {
override fun onListen(args: Any?,
events: EventChannel.EventSink) {
playbackEventSink = events