fixed bugs

This commit is contained in:
yannick.blanken@csc-online.eu 2022-07-22 11:11:39 +02:00
parent 13d269449c
commit 2a87a7d8ca
8 changed files with 193 additions and 189 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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) {

View File

@ -75,8 +75,6 @@ public class LogsFragment
recyclerView.setAdapter(new LogItemRecyclerViewAdapter(getDatabase().log().getLogs()));
}
return view;
}
}

View File

@ -138,7 +138,6 @@ public class CustomerContentRepository {
public Result<List<Vehicle>> fetchCustomerVehiclesRemote() {
return dataSource
.fetchCustomerVehicles(localStorageClient.getLoggedInUser());
}

View File

@ -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"

View File

@ -7,211 +7,215 @@
android:background="?android:windowBackground"
tools:context=".ui.fragments.UserProfileFragment">
<LinearLayout
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:nestedScrollingEnabled="true"
android:orientation="vertical"
android:verticalScrollbarPosition="right"
android:layout_height="match_parent">
>
<com.google.android.material.card.MaterialCardView
android:id="@+id/cardDevices"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Media -->
<ImageView
android:layout_width="match_parent"
android:layout_height="194dp"
android:contentDescription="@string/content_card_description_vehicle"
android:scaleType="centerCrop"
app:srcCompat="@drawable/ic_default_vehicle" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<!-- Title, secondary and supporting text -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/content_card_description_vehicle"
android:textAppearance="?attr/textAppearanceHeadline6" />
<TextView
android:id="@+id/tvVehicleUpdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/text_last_update"
android:textAppearance="?attr/textAppearanceBody2"
android:textColor="?android:attr/textColorSecondary" />
<TextView
android:id="@+id/tvVehicleCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/text_vehicles_count"
android:textAppearance="?attr/textAppearanceBody2"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
<!-- Buttons -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/btnVehicleRefresh"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="@string/action_refresh" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnVehicleDelete"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_delete" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnVehicleShow"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_show" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnVehicleAdd"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_new" />
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="8dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:nestedScrollingEnabled="true"
android:orientation="vertical"
android:verticalScrollbarPosition="right"
>
<LinearLayout
<com.google.android.material.card.MaterialCardView
android:id="@+id/cardDevices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Media -->
<ImageView
android:layout_width="match_parent"
android:layout_height="194dp"
android:contentDescription="@string/content_card_description_devices"
android:scaleType="center"
app:srcCompat="@drawable/ic_default_device" />
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
android:orientation="vertical">
<!-- Title, secondary and supporting text -->
<TextView
<!-- Media -->
<ImageView
android:layout_width="match_parent"
android:layout_height="194dp"
android:contentDescription="@string/content_card_description_vehicle"
android:scaleType="centerCrop"
app:srcCompat="@drawable/ic_default_vehicle" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<!-- Title, secondary and supporting text -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/content_card_description_vehicle"
android:textAppearance="?attr/textAppearanceHeadline6" />
<TextView
android:id="@+id/tvVehicleUpdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/text_last_update"
android:textAppearance="?attr/textAppearanceBody2"
android:textColor="?android:attr/textColorSecondary" />
<TextView
android:id="@+id/tvVehicleCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/text_vehicles_count"
android:textAppearance="?attr/textAppearanceBody2"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
<!-- Buttons -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/content_card_description_devices"
android:textAppearance="?attr/textAppearanceHeadline6" />
android:layout_margin="8dp"
<TextView
android:id="@+id/tvDeviceUpdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/text_last_update"
android:textAppearance="?attr/textAppearanceBody2"
android:textColor="?android:attr/textColorSecondary" />
android:orientation="horizontal">
<TextView
android:id="@+id/tvDeviceCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/text_devices_count"
android:textAppearance="?attr/textAppearanceBody2"
android:textColor="?android:attr/textColorSecondary" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnVehicleRefresh"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="@string/action_refresh" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnVehicleDelete"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_delete" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnVehicleShow"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_show" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnVehicleAdd"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_new" />
</LinearLayout>
</LinearLayout>
<!-- Buttons -->
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="8dp"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="vertical">
android:orientation="horizontal">
<!-- Media -->
<ImageView
android:layout_width="match_parent"
android:layout_height="194dp"
android:contentDescription="@string/content_card_description_devices"
android:scaleType="center"
app:srcCompat="@drawable/ic_default_device" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnDevicesRefresh"
style="?attr/borderlessButtonStyle"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<!-- Title, secondary and supporting text -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/content_card_description_devices"
android:textAppearance="?attr/textAppearanceHeadline6" />
<TextView
android:id="@+id/tvDeviceUpdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/text_last_update"
android:textAppearance="?attr/textAppearanceBody2"
android:textColor="?android:attr/textColorSecondary" />
<TextView
android:id="@+id/tvDeviceCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/text_devices_count"
android:textAppearance="?attr/textAppearanceBody2"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
<!-- Buttons -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="@string/action_refresh" />
android:layout_margin="8dp"
<com.google.android.material.button.MaterialButton
android:id="@+id/btnDevicesDelete"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_delete" />
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/btnDevicesShow"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_show" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnDevicesRefresh"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="@string/action_refresh" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnDevicesDelete"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_delete" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnDevicesShow"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_show" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnDevicesAdd"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_new" />
</LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/btnDevicesAdd"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_new" />
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</ScrollView>
</FrameLayout>

View File

@ -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);
}
}