This file contains hidden or 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 Fragment : Fragment() { | |
| @Inject | |
| lateinit var viewModel: ViewModel | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| viewModel.liveData.observe(this, Observer { data -> /* update the view */ }) |
This file contains hidden or 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
| data class ModelData( | |
| val progressVisible: Boolean, | |
| ) | |
| class ViewModel( | |
| private val repository: Repository, | |
| private val navigator: Navigator | |
| ) : ViewModel() { | |
| private val _liveData = MutableLiveData<ModelData>() |
This file contains hidden or 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
| object RepositoryData | |
| class Repository { | |
| fun observeChanges(observer: (RepositoryData) -> Unit) { | |
| //some logic | |
| observer.invoke(RepositoryData) | |
| } | |
| } |
This file contains hidden or 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
| sealed class Interaction { | |
| object BackButtonClick : Interaction() | |
| object SkipButtonClick : Interaction() | |
| object SaveButtonClick : Interaction() | |
| data class NameChange(val name: String) : Interaction() | |
| } |
This file contains hidden or 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"?> | |
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:gravity="center" | |
| android:orientation="vertical" | |
| tools:context=".MainActivity"> |
This file contains hidden or 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
| package com.makor.compoundviewexample | |
| import android.content.Context | |
| import android.util.AttributeSet | |
| import android.view.Gravity | |
| import android.view.LayoutInflater | |
| import android.view.View | |
| import android.widget.LinearLayout | |
| import kotlinx.android.synthetic.main.consents_view.view.* |
This file contains hidden or 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"?> | |
| <resources> | |
| <declare-styleable name="ConsentsView"> | |
| <attr name="separatorVisibility" format="boolean"/> | |
| </declare-styleable> | |
| </resources> |
This file contains hidden or 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"?> | |
| <merge xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| tools:parentTag="android.widget.LinearLayout" | |
| tools:orientation="vertical" | |
| tools:gravity="center"> | |
| <TextView |
This file contains hidden or 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"?> | |
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:gravity="center" | |
| android:orientation="vertical" | |
| tools:context=".MainActivity"> | |
| <com.makor.compoundviewexample.ConsentsView |
This file contains hidden or 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 MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| consentsView.onConsentsCheckedChangeListener = { allConsentsChecked -> | |
| confirmButton.isEnabled = allConsentsChecked | |
| } | |
| } |