// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java
// public class Navigator {
//   protected final AppCompatActivity activity;
// 
//   public Navigator(AppCompatActivity activity) {
//     this.activity = activity;
//   }
// 
//   public void startCreatePassword() {
//     activity.startActivity(new Intent(activity, PasswordCreateActivity.class));
//   }
// 
//   public void finish() {
//     activity.finish();
//   }
// 
//   public void startReadPassword(int passwordId) {
//     activity.startActivity(
//         new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId));
//   }
// 
//   public void startUpdatePassword(int passwordId) {
//     activity.startActivity(
//         new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId));
//   }
// 
//   public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) {
//     new IconSelectDialog.Builder(activity).setIcons(Icons.ALL)
//         .setTitle("Choose icon")
//         .setSortIconsByName(true)
//         .setOnIconSelectedListener(onIconSelectedListener)
//         .build()
//         .show(activity.getSupportFragmentManager(), "icons");
//   }
// 
//   public void startCreateCustomField(
//       CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener) {
//     CustomFieldDialog.newInstance("Create custom field", "", "", customFieldSubmitListener, null)
//         .show(activity.getSupportFragmentManager(), "field");
//   }
// 
//   public void startUpdateCustomField(String name, String value,
//       CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener,
//       CustomFieldDialog.OnCustomFieldDeleteListener customFieldDeleteListener) {
//     CustomFieldDialog.newInstance("Update custom field", name, value, customFieldSubmitListener,
//         customFieldDeleteListener).show(activity.getSupportFragmentManager(), "field");
//   }
// }
// 
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/PasswordManagerActivity.java
// public abstract class PasswordManagerActivity<B extends ViewDataBinding, VM extends ViewModel>
//     extends ToolbarActivity<B, VM> {
// 
//   @CallSuper @Override protected void onInitBinding() {
//     binding.setVariable(BR.viewModel, viewModel);
//   }
// }
// 
// Path: app/src/main/java/gdg/devfest/passwordmanager/model/PasswordInteractor.java
// public class PasswordInteractor {
//   private final Realm realm;
// 
//   public PasswordInteractor(Realm realm) {
//     this.realm = realm;
//   }
// 
//   public RealmResults<Password> readPasswords() {
//     return realm.where(Password.class).findAll();
//   }
// 
//   public void createPassword(String icon, String name, String userName, String password,
//       List<CustomField> customFields) {
//     Password passwordEntity = new Password(id(), icon, name, userName, password, customFields);
//     realm.executeTransaction(realm1 -> realm1.copyToRealm(passwordEntity));
//   }
// 
//   public Password readPassword(int id) {
//     return realm.where(Password.class).equalTo("id", id).findFirst();
//   }
// 
//   public void updatePassword(Password realmPassword, String icon, String name, String userName,
//       String password, List<CustomField> customFields) {
//     realm.executeTransaction(realm1 -> {
//       realmPassword.setIcon(icon);
//       realmPassword.setName(name);
//       realmPassword.setUserName(userName);
//       realmPassword.setPassword(password);
//       realmPassword.getCustomFields().deleteAllFromRealm();
//       realmPassword.getCustomFields().addAll(customFields);
//     });
//   }
// 
//   public void deletePassword(Password password) {
//     realm.executeTransaction(realm1 -> {
//       password.getCustomFields().deleteAllFromRealm();
//       password.deleteFromRealm();
//     });
//   }
// 
//   private int id() {
//     Number number = realm.where(Password.class).max("id");
//     return number != null ? number.intValue() + 1 : 0;
//   }
// }
// 
// Path: app/src/main/java/gdg/devfest/passwordmanager/viewmodel/PasswordListViewModel.java
// public class PasswordListViewModel implements ViewModel {
//   private final Navigator navigator;
//   private final RealmResults<Password> realmPasswords;
// 
//   public ObservableList<PasswordItemViewModel> passwords;
// 
//   public PasswordListViewModel(Navigator navigator, PasswordInteractor interactor) {
//     this.navigator = navigator;
// 
//     passwords = new ObservableArrayList<>();
//     realmPasswords = interactor.readPasswords();
//     realmPasswords.addChangeListener(this::updateList);
// 
//     updateList(realmPasswords);
//   }
// 
//   public void navigateToCreatePassword() {
//     navigator.startCreatePassword();
//   }
// 
//   private void updateList(RealmResults<Password> realmPasswords) {
//     passwords.clear();
//     passwords.addAll(PasswordItemViewModel.toViewModels(realmPasswords, navigator));
//   }
// }


import gdg.devfest.passwordmanager.databinding.PasswordListActivityBinding;
import gdg.devfest.passwordmanager.framework.Navigator;
import gdg.devfest.passwordmanager.framework.PasswordManagerActivity;
import gdg.devfest.passwordmanager.model.PasswordInteractor;
import gdg.devfest.passwordmanager.viewmodel.PasswordListViewModel;
package gdg.devfest.passwordmanager.view;


public class PasswordListActivity
    extends PasswordManagerActivity<PasswordListActivityBinding, PasswordListViewModel> {

  @Override protected PasswordListViewModel createViewModel() {
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java
// public class Navigator {
//   protected final AppCompatActivity activity;
// 
//   public Navigator(AppCompatActivity activity) {
//     this.activity = activity;
//   }
// 
//   public void startCreatePassword() {
//     activity.startActivity(new Intent(activity, PasswordCreateActivity.class));
//   }
// 
//   public void finish() {
//     activity.finish();
//   }
// 
//   public void startReadPassword(int passwordId) {
//     activity.startActivity(
//         new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId));
//   }
// 
//   public void startUpdatePassword(int passwordId) {
//     activity.startActivity(
//         new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId));
//   }
// 
//   public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) {
//     new IconSelectDialog.Builder(activity).setIcons(Icons.ALL)
//         .setTitle("Choose icon")
//         .setSortIconsByName(true)
//         .setOnIconSelectedListener(onIconSelectedListener)
//         .build()
//         .show(activity.getSupportFragmentManager(), "icons");
//   }
// 
//   public void startCreateCustomField(
//       CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener) {
//     CustomFieldDialog.newInstance("Create custom field", "", "", customFieldSubmitListener, null)
//         .show(activity.getSupportFragmentManager(), "field");
//   }
// 
//   public void startUpdateCustomField(String name, String value,
//       CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener,
//       CustomFieldDialog.OnCustomFieldDeleteListener customFieldDeleteListener) {
//     CustomFieldDialog.newInstance("Update custom field", name, value, customFieldSubmitListener,
//         customFieldDeleteListener).show(activity.getSupportFragmentManager(), "field");
//   }
// }
// 
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/PasswordManagerActivity.java
// public abstract class PasswordManagerActivity<B extends ViewDataBinding, VM extends ViewModel>
//     extends ToolbarActivity<B, VM> {
// 
//   @CallSuper @Override protected void onInitBinding() {
//     binding.setVariable(BR.viewModel, viewModel);
//   }
// }
// 
// Path: app/src/main/java/gdg/devfest/passwordmanager/model/PasswordInteractor.java
// public class PasswordInteractor {
//   private final Realm realm;
// 
//   public PasswordInteractor(Realm realm) {
//     this.realm = realm;
//   }
// 
//   public RealmResults<Password> readPasswords() {
//     return realm.where(Password.class).findAll();
//   }
// 
//   public void createPassword(String icon, String name, String userName, String password,
//       List<CustomField> customFields) {
//     Password passwordEntity = new Password(id(), icon, name, userName, password, customFields);
//     realm.executeTransaction(realm1 -> realm1.copyToRealm(passwordEntity));
//   }
// 
//   public Password readPassword(int id) {
//     return realm.where(Password.class).equalTo("id", id).findFirst();
//   }
// 
//   public void updatePassword(Password realmPassword, String icon, String name, String userName,
//       String password, List<CustomField> customFields) {
//     realm.executeTransaction(realm1 -> {
//       realmPassword.setIcon(icon);
//       realmPassword.setName(name);
//       realmPassword.setUserName(userName);
//       realmPassword.setPassword(password);
//       realmPassword.getCustomFields().deleteAllFromRealm();
//       realmPassword.getCustomFields().addAll(customFields);
//     });
//   }
// 
//   public void deletePassword(Password password) {
//     realm.executeTransaction(realm1 -> {
//       password.getCustomFields().deleteAllFromRealm();
//       password.deleteFromRealm();
//     });
//   }
// 
//   private int id() {
//     Number number = realm.where(Password.class).max("id");
//     return number != null ? number.intValue() + 1 : 0;
//   }
// }
// 
// Path: app/src/main/java/gdg/devfest/passwordmanager/viewmodel/PasswordListViewModel.java
// public class PasswordListViewModel implements ViewModel {
//   private final Navigator navigator;
//   private final RealmResults<Password> realmPasswords;
// 
//   public ObservableList<PasswordItemViewModel> passwords;
// 
//   public PasswordListViewModel(Navigator navigator, PasswordInteractor interactor) {
//     this.navigator = navigator;
// 
//     passwords = new ObservableArrayList<>();
//     realmPasswords = interactor.readPasswords();
//     realmPasswords.addChangeListener(this::updateList);
// 
//     updateList(realmPasswords);
//   }
// 
//   public void navigateToCreatePassword() {
//     navigator.startCreatePassword();
//   }
// 
//   private void updateList(RealmResults<Password> realmPasswords) {
//     passwords.clear();
//     passwords.addAll(PasswordItemViewModel.toViewModels(realmPasswords, navigator));
//   }
// }


// Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordListActivity.java
import gdg.devfest.passwordmanager.databinding.PasswordListActivityBinding;
import gdg.devfest.passwordmanager.framework.Navigator;
import gdg.devfest.passwordmanager.framework.PasswordManagerActivity;
import gdg.devfest.passwordmanager.model.PasswordInteractor;
import gdg.devfest.passwordmanager.viewmodel.PasswordListViewModel;

package gdg.devfest.passwordmanager.view;


public class PasswordListActivity
    extends PasswordManagerActivity<PasswordListActivityBinding, PasswordListViewModel> {

  @Override protected PasswordListViewModel createViewModel() {
    return new PasswordListViewModel(new Navigator(this), new PasswordInteractor(realm));