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
| android { | |
| ... | |
| dataBinding{ | |
| enabled = true | |
| } | |
| } | |
| dependencies { | |
| def lifecycle_version = "2.0.0" | |
| ... |
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
| public class LoginActivity extends AppCompatActivity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| //ActivityLoginBinding is generated after build project | |
| //and set layout and view model | |
| ActivityLoginBinding activityLoginBinding | |
| = DataBindingUtil.setContentView(this,R.layout.activity_login); |
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
| public class LoginModel { | |
| private String email; | |
| private String password; | |
| public LoginModel(String email, String password) { | |
| this.email = email; | |
| this.password = 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
| public class LoginViewModel extends BaseObservable { | |
| private final int PASSWORD_MIN_LENGTH = 8; | |
| private LoginModel loginModel; | |
| private boolean isSuccess; | |
| public LoginViewModel(){ | |
| this.loginModel = new LoginModel("",""); |
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"?> | |
| <!--Root element maybe Layout--> | |
| <layout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:bind="http://schemas.android.com/tools"> | |
| <data> | |
| <!--Login view model--> | |
| <variable | |
| name="viewModel" | |
| type="com.example.mvvm_ac.viewmodels.LoginViewModel" /> |
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
| public class AppInformation : IAppInformation | |
| { | |
| public string Version | |
| { | |
| get | |
| { | |
| var context = Application.Context; | |
| PackageManager manager = context.PackageManager; | |
| PackageInfo info = manager.GetPackageInfo( context.PackageName, default(int) ); |
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
| namespace DependencyInjection.iOS.Dependencies | |
| { | |
| public class AppInformation : IAppInformation | |
| { | |
| public string Version => | |
| NSBundle.MainBundle.ObjectForInfoDictionary( "CFBundleShortVersionString" ).ToString(); | |
| } | |
| } |
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
| public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate | |
| { | |
| public override bool FinishedLaunching(UIApplication app, NSDictionary options) | |
| { | |
| this.registerDependencies(); | |
| LoadApplication(new App()); | |
| return base.FinishedLaunching(app, options); | |
| } |
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
| public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity | |
| { | |
| protected override void OnCreate(Bundle savedInstanceState) | |
| { | |
| //... | |
| this.registerDependencies(); | |
| LoadApplication(new App()); | |
| } |
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
| public partial class MainPage : ContentPage | |
| { | |
| public MainPage() | |
| { | |
| InitializeComponent(); | |
| //Resolve ViewModel instance and his dependencies | |
| BindingContext = App.Container.Resolve(typeof(MainViewModel)); | |
| } | |
| } |
NewerOlder