[SOLVED] - Built MapsActivityRepository MapMarker builder (finished)
This commit is contained in:
parent
0da3570ada
commit
95b73a0b34
@ -36,6 +36,7 @@ public class MapsActivityRepository {
|
||||
public List<MapMarker> get_all_map_markers_for_this_agency(Application application) throws IOException {
|
||||
sharedPrefs = new SharedPrefs();
|
||||
propertyRepository = new PropertyRepository(application);
|
||||
agentRepository = new AgentRepository(application);
|
||||
|
||||
int logged_agent_id;
|
||||
Agency agency;
|
||||
|
||||
@ -11,7 +11,7 @@ import fr.romanet.vj.apps.myrealestateagency.database.RealEstateAgencyDatabase;
|
||||
import fr.romanet.vj.apps.myrealestateagency.entities.Agency;
|
||||
import fr.romanet.vj.apps.myrealestateagency.entities.Property;
|
||||
|
||||
public class PropertyRepository {
|
||||
public class PropertyRepository {
|
||||
|
||||
public PropertyDao propertyDao;
|
||||
public LiveData<List<Property>> allProperties;
|
||||
|
||||
@ -29,18 +29,22 @@ import fr.romanet.vj.apps.myrealestateagency.view.MapsActivity;
|
||||
|
||||
public class MapsActivityViewModel extends AndroidViewModel implements LifecycleObserver {
|
||||
|
||||
// private PropertyRepository propertyRepository;
|
||||
private Application _application;
|
||||
public MapsActivityViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
this._application = application;
|
||||
// propertyRepository = new PropertyRepository(application);
|
||||
}
|
||||
|
||||
public MutableLiveData<List<MapMarker>> markers_to_display = new MutableLiveData<>();
|
||||
|
||||
private PropertyRepository propertyRepository;
|
||||
// private PropertyRepository propertyRepository;
|
||||
|
||||
private MapsActivityRepository mapsActivityRepository;
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
||||
private void init_map(Application application) throws IOException {
|
||||
private void init_map() throws IOException {
|
||||
mapsActivityRepository = new MapsActivityRepository();
|
||||
|
||||
// LiveData<List<Property>> properties = propertyRepository.getAllProperties();
|
||||
@ -48,7 +52,7 @@ public class MapsActivityViewModel extends AndroidViewModel implements Lifecycle
|
||||
|
||||
|
||||
// List<MapMarker> mapMarkers = new ArrayList<MapMarker>();
|
||||
List<MapMarker> mapMarkers = mapsActivityRepository.get_all_map_markers_for_this_agency(application);
|
||||
List<MapMarker> mapMarkers = mapsActivityRepository.get_all_map_markers_for_this_agency(this._application);
|
||||
// List<LatLng> latLngs = null;
|
||||
|
||||
// mapMarkers.add(new MapMarker(MapsActivityRepository.get_lat_long_from_address("Paris, France", MyApp.getContext()), "Paris", BitmapDescriptorFactory.HUE_BLUE));
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
package fr.romanet.vj.apps.myrealestateagency.viewmodel;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
public class MapsActivityViewModelFactory implements ViewModelProvider.Factory {
|
||||
private Application mApplication;
|
||||
|
||||
public MapsActivityViewModelFactory(Application application) {
|
||||
mApplication = application;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T extends ViewModel> T create(Class<T> modelClass) {
|
||||
return (T) new MapsActivityViewModel(mApplication);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user