This file contains 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
# Your init script | |
# | |
# Atom will evaluate this file each time a new window is opened. It is run | |
# after packages are loaded/activated and after the previous editor state | |
# has been restored. | |
# | |
# An example hack to log to the console when each text editor is saved. | |
# | |
# atom.workspace.observeTextEditors (editor) -> | |
# editor.onDidSave -> |
This file contains 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
... | |
apply plugin: 'kotlin-kapt' | |
... | |
dependencies { | |
/* Other Gradle settings */ | |
implementation "com.google.dagger:dagger:$dagger2_version" | |
implementation "com.google.dagger:dagger-android:$dagger2_version" | |
implementation "com.google.dagger:dagger-android-support:$dagger2_version" | |
kapt "com.google.dagger:dagger-compiler:$dagger2_version" | |
kapt "com.google.dagger:dagger-android-processor:$dagger2_version" |
This file contains 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
buildscript { | |
ext.dagger2_version = '2.18' | |
} |
This file contains 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
public class FrombulationActivity extends Activity { | |
@Inject Frombulator frombulator; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// DO THIS FIRST. Otherwise frombulator might be null! | |
((SomeApplicationBaseType) getContext().getApplicationContext()) | |
.getApplicationComponent() | |
.newActivityComponentBuilder() |
This file contains 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
public class FrombulationActivity extends Activity { | |
@Inject Frombulator frombulator; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
AndroidInjection.inject(this); | |
} | |
} |
This file contains 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
android { | |
... | |
dataBinding { | |
enabled true | |
} | |
} | |
... | |
dependencies { | |
... | |
implementation "androidx.lifecycle:lifecycle-viewmodel:2.0.0" |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" | |
xmlns:app="http://schemas.android.com/apk/res-auto"> | |
<data> | |
<variable name="viewModel" | |
type="com.example.livedatasample.viewmodel.MainViewModel"/> | |
</data> | |
<androidx.constraintlayout.widget.ConstraintLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" |
This file contains 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
class MainViewModel : ViewModel() { | |
val eventData by lazy {MutableLiveData<String>()} | |
private val runnable = Runnable { eventData.value = "Main Thread" } | |
fun onClick() { | |
val handler = Handler() | |
handler.postDelayed(runnable, 1500) | |
} | |
... |
This file contains 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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
val viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) | |
val binding: ActivityMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main) | |
binding.viewModel = viewModel | |
viewModel.eventData.observe(this, Observer<String> { text -> text_view_1.text = text }) | |
} |
This file contains 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
val transformationData: LiveData<String> = Transformations.map(eventData) | |
{text -> "Transformation Map $text"} | |
val transformationData2: LiveData<String> = Transformations.switchMap(eventData){ | |
input -> getText(input) | |
} | |
private fun getText(text: String): LiveData<String> { | |
val data = MutableLiveData<String>() | |
data.value = "Transformation Switch Map $text" |
OlderNewer