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
| private var emailField: AutoCompleteTextView? = null | |
| private var passwordField: EditText? = null | |
| private var signInButton: Button? = null | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_login) | |
| emailField = findViewById(R.id.email) as AutoCompleteTextView | |
| passwordField = findViewById(R.id.password) as EditText |
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
| <AutoCompleteTextView | |
| android:id="@+id/email" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:hint="@string/prompt_email" | |
| android:inputType="textEmailAddress" | |
| android:maxLines="1" /> | |
| <EditText | |
| android:id="@+id/password" |
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 LoginDataBindingViewModel : BaseObservable() { | |
| @get:Bindable | |
| var email: String? = "" | |
| set(email) { | |
| field = email | |
| notifyPropertyChanged(BR.email) | |
| notifyPropertyChanged(BR.readyToLogin) | |
| } | |
| @get:Bindable |
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> | |
| <variable | |
| name="viewModel" | |
| type="ta.com.workshop1.feature._2_databinding.LoginDataBindingViewModel"/> | |
| </data> | |
| <AutoCompleteTextView | |
| android:id="@+id/email" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" |
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 LoginWithBindingPresenter(var viewModel: LoginDataBindingViewModel?, | |
| var view: LoginWithBindingInf.ViewInf) | |
| : LoginWithBindingInf.PresenterInf { | |
| override fun onInit() { | |
| viewModel?.onClickLogin = View.OnClickListener { _ -> | |
| view.performLogin(viewModel?.email + " " + viewModel?.password) | |
| viewModel?.email = "" | |
| viewModel?.password = "" | |
| } | |
| } |
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 LoginWithBindingActivity : AppCompatActivity(), LoginWithBindingInf.ViewInf { | |
| var binding: ActivityLoginWithBindingBinding? = null | |
| var viewModel: LoginDataBindingViewModel? = null | |
| var presenter: LoginWithBindingInf.PresenterInf? = null | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| initView() | |
| initViewModel() |
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 LoginArchViewModel : ViewModel() { | |
| var email: ObservableField<String>? = ObservableField("") | |
| var password: ObservableField<String>? = ObservableField("") | |
| var onClickLogin: ObservableField<View.OnClickListener>? = ObservableField() | |
| var readyToLogin: ObservableField<Boolean>? = ObservableField(false) | |
| } |
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
| <AutoCompleteTextView | |
| android:id="@+id/email" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:hint="@string/prompt_email" | |
| android:inputType="textEmailAddress" | |
| android:text="@{viewModel.email}" | |
| android:maxLines="1" /> | |
| <EditText |
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
| override fun onInit() { | |
| viewModel?.readyToLogin?.set(false) | |
| viewModel?.onClickLogin?.set(View.OnClickListener { _ -> | |
| view.performLogin(viewModel?.email?.get() + " " + viewModel?.password?.get()) | |
| viewModel?.email?.set("") | |
| viewModel?.password?.set("") | |
| }) | |
| } | |
| override fun setReadyToClick(isReady: Boolean) { |
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
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| initView() | |
| initViewModel() | |
| initPresenter() | |
| initEvent() | |
| } | |
| . | |
| . | |
| . |
OlderNewer