Exemple #1
0
 public VehicleViewModel(VehicleActivityViewInterface view,
                         VehicleInteractor interactor)
 {
     mView = view;
     mView.setViewModel(this);
     mInteractor = interactor;
 }
Exemple #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.vehicle_activity);

            mInteractor = new VehicleInteractor(ApplicationContext);
            mViewModel  = new VehicleViewModel(this, mInteractor);


            SupportToolbar toolbar = FindViewById <SupportToolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            // Remover título de la action bar
            SupportActionBar.Title = "";

            mStatusFilterSpinner = FindViewById <Spinner>(Resource.Id.toolbar_spinner);

            statusFilterAdapter = new ArrayAdapter <string>(context, Android.Resource.Layout.SimpleSpinnerItem, STATES_VALUES);

            statusFilterAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            mStatusFilterSpinner.Adapter = statusFilterAdapter;

            mStatusFilterSpinner.ItemSelected += (o, e) =>
            {
                String status = mStatusFilterSpinner.GetItemAtPosition(e.Position).ToString();
                Log.Info(TAG, "Se seleccionó: " + status);
                cargarVehiculos(status);
            };

            mEmptyStateContainer = FindViewById <LinearLayout>(Resource.Id.empty_state_container);
            Progreso             = FindViewById <ProgressBar>(Resource.Id.pb_progreso);

            mVehiculo = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            // Plug in the linear layout manager:
            mLayoutManager = new LinearLayoutManager(this);
            mVehiculo.SetLayoutManager(mLayoutManager);
            // Plug in my adapter:
            listItemVehicleAdapter = new ListItemVehicleAdapter(this, new List <Vehicle>());

            showVehicleList(mViewModel.ObtenerListaVehiculosBDI());

            listItemVehicleAdapter.ItemClick += OnItemClick;

            mVehiculo.SetAdapter(listItemVehicleAdapter);

            Preparar_FloatingActionButton();
        }