fixed bugs
This commit is contained in:
parent
13d269449c
commit
2a87a7d8ca
|
|
@ -68,8 +68,6 @@ public class ActivityBaseDetailContent extends AbstractAppCompatActivity {
|
|||
Intent intent = new Intent(activity, ActivityBaseDetailContent.class);
|
||||
intent.putExtra(ARG_ITEM_TYPE, ARG_ITEM_TYPE_VEHICLE_AND_DEVICE);
|
||||
return intent;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class UserProfileFragment
|
|||
getView().setEnabled(aBoolean);
|
||||
}
|
||||
|
||||
mViewModel.refreshContent();
|
||||
//mViewModel.refreshLocalContent();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ public class UserProfileFragment
|
|||
|
||||
mViewModel.storeRemoteVehicles(vehicles);
|
||||
|
||||
mViewModel.refreshContent();
|
||||
mViewModel.refreshLocalContent();
|
||||
}
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
|
@ -139,7 +139,7 @@ public class UserProfileFragment
|
|||
|
||||
//region Devices
|
||||
|
||||
mViewModel.getMStoredDevices().observe(getViewLifecycleOwner(), new Observer<List<CustomerDevice>>() {
|
||||
mViewModel.getMDevices().observe(getViewLifecycleOwner(), new Observer<List<CustomerDevice>>() {
|
||||
@Override
|
||||
public void onChanged(List<CustomerDevice> items) {
|
||||
binding.tvDeviceCount.setText(String.format(Helper.getString(getContext(), R.string.text_devices_count), items.size()));
|
||||
|
|
@ -204,7 +204,7 @@ public class UserProfileFragment
|
|||
//endregion
|
||||
|
||||
|
||||
mViewModel.refreshContent();
|
||||
mViewModel.refreshLocalContent();
|
||||
// TODO: Use the ViewModel
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ public class UserProfileViewModel extends AbstractBaseViewModel {
|
|||
@Getter
|
||||
private final MutableLiveData<List<Vehicle>> mVehicles;
|
||||
@Getter
|
||||
private final MutableLiveData<List<CustomerDevice>> mDevices;
|
||||
@Getter
|
||||
private final MutableLiveData<List<CustomerDevice>> mStoredDevices;
|
||||
|
||||
|
||||
|
|
@ -40,6 +42,7 @@ public class UserProfileViewModel extends AbstractBaseViewModel {
|
|||
mVehicles = new MutableLiveData<>();
|
||||
mRefreshVehicles = new MutableLiveData<>();
|
||||
mStoredDevices = new MutableLiveData<>();
|
||||
mDevices = new MutableLiveData<>();
|
||||
}
|
||||
|
||||
public void refreshVehicles() {
|
||||
|
|
@ -69,9 +72,9 @@ public class UserProfileViewModel extends AbstractBaseViewModel {
|
|||
mutableLiveDataSuccess.postValue(true);
|
||||
}
|
||||
|
||||
public void refreshContent() {
|
||||
refreshVehicles();
|
||||
refreshDevices();
|
||||
public void refreshLocalContent() {
|
||||
mVehicles.setValue(localStorageClient.loadVehicles());
|
||||
mDevices.setValue(localStorageClient.loadDevices());
|
||||
}
|
||||
|
||||
public void storeRemoteVehicles(List<Vehicle> items) {
|
||||
|
|
@ -84,7 +87,7 @@ public class UserProfileViewModel extends AbstractBaseViewModel {
|
|||
}
|
||||
|
||||
public void refreshDevices() {
|
||||
mStoredDevices.postValue(repository.getStoredUserDevices());
|
||||
mDevices.postValue(repository.getStoredUserDevices());
|
||||
}
|
||||
|
||||
public void storeRemoteCustomerDevices(List<CustomerDevice> items) {
|
||||
|
|
|
|||
|
|
@ -75,8 +75,6 @@ public class LogsFragment
|
|||
recyclerView.setAdapter(new LogItemRecyclerViewAdapter(getDatabase().log().getLogs()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +138,6 @@ public class CustomerContentRepository {
|
|||
|
||||
public Result<List<Vehicle>> fetchCustomerVehiclesRemote() {
|
||||
|
||||
|
||||
return dataSource
|
||||
.fetchCustomerVehicles(localStorageClient.getLoggedInUser());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/list"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
android:background="?android:windowBackground"
|
||||
tools:context=".ui.fragments.UserProfileFragment">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
@ -213,5 +217,5 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</ScrollView>
|
||||
</FrameLayout>
|
||||
|
|
@ -33,6 +33,7 @@ public class LocalStorageClientImpl implements LocalStorageClient {
|
|||
private static final String PREF_CUSTOMER = "customer";
|
||||
private static final String PREF_VEHICLES = "vehicles";
|
||||
private static final String PREF_DEVICES = "devices";
|
||||
|
||||
private final ILogger logger;
|
||||
|
||||
// private static final String KEY_LOGGEDINUSERNAME = "prefs_loggedin_username";
|
||||
|
|
@ -348,11 +349,11 @@ public class LocalStorageClientImpl implements LocalStorageClient {
|
|||
}
|
||||
|
||||
private void d(String msg) {
|
||||
|
||||
if (logger != null)
|
||||
logger.d(TAG, msg);
|
||||
else {
|
||||
Log.d(TAG, msg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue