mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Added a function to clear the database #79
This commit is contained in:
1 parent
a7427f3632
commit
e9dc166e1e
8 files changed
+44
-6
No files matched your search
@@ -69,4 +69,9 @@ class LocalSource(
|
|||||||
override suspend fun updateTransmitters(transmitters: List<Transmitter>) {
|
override suspend fun updateTransmitters(transmitters: List<Transmitter>) {
|
||||||
transmittersDao.updateTransmitters(transmitters.toFramework())
|
transmittersDao.updateTransmitters(transmitters.toFramework())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun clearData() {
|
||||||
|
entriesDao.deleteEntries()
|
||||||
|
transmittersDao.deleteTransmitters()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
@@ -116,6 +116,7 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
|||||||
binding.prefsData.updateBtnWeb.setOnClickListener {
|
binding.prefsData.updateBtnWeb.setOnClickListener {
|
||||||
findNavController().navigateSafe(R.id.action_prefs_to_sources)
|
findNavController().navigateSafe(R.id.action_prefs_to_sources)
|
||||||
}
|
}
|
||||||
|
binding.prefsData.updateBtnClear.setOnClickListener { viewModel.clearData() }
|
||||||
getNavResult<List<String>>(R.id.nav_settings, "sources") { sources ->
|
getNavResult<List<String>>(R.id.nav_settings, "sources") { sources ->
|
||||||
viewModel.updateDataFromWeb(sources)
|
viewModel.updateDataFromWeb(sources)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -25,6 +25,10 @@ class SettingsViewModel @Inject constructor(
|
|||||||
repository.updateDataFromWeb(sources)
|
repository.updateDataFromWeb(sources)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clearData() {
|
||||||
|
repository.clearData()
|
||||||
|
}
|
||||||
|
|
||||||
fun getUseUTC(): Boolean = settings.getUseUTC()
|
fun getUseUTC(): Boolean = settings.getUseUTC()
|
||||||
|
|
||||||
fun setUseUTC(value: Boolean) = settings.setUseUTC(value)
|
fun setUseUTC(value: Boolean) = settings.setUseUTC(value)
|
||||||
|
|||||||
@@ -35,11 +35,11 @@
|
|||||||
style="@style/AppButton"
|
style="@style/AppButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginBottom="4dp"
|
android:layout_marginBottom="4dp"
|
||||||
android:drawableStart="@drawable/ic_update_web"
|
android:drawableStart="@drawable/ic_update_web"
|
||||||
android:text="@string/update_web"
|
android:text="Web"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/update_btn_file"
|
app:layout_constraintEnd_toStartOf="@+id/update_btn_file"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
@@ -51,13 +51,27 @@
|
|||||||
style="@style/AppButton"
|
style="@style/AppButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="4dp"
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
android:drawableStart="@drawable/ic_update_file"
|
android:drawableStart="@drawable/ic_update_file"
|
||||||
android:text="@string/update_file"
|
android:text="File"
|
||||||
|
app:layout_constraintBaseline_toBaselineOf="@+id/update_btn_web"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/update_btn_clear"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/update_btn_web" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/update_btn_clear"
|
||||||
|
style="@style/AppButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:drawableStart="@drawable/ic_update_file"
|
||||||
|
android:text="Clear"
|
||||||
app:layout_constraintBaseline_toBaselineOf="@+id/update_btn_web"
|
app:layout_constraintBaseline_toBaselineOf="@+id/update_btn_web"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toEndOf="@+id/update_btn_web" />
|
app:layout_constraintStart_toEndOf="@+id/update_btn_file" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,11 @@
|
|||||||
<item name="android:windowBackground">@color/surfaceBg</item>
|
<item name="android:windowBackground">@color/surfaceBg</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppButton">
|
<style name="AppButton" parent="Widget.Material3.Button">
|
||||||
<item name="android:backgroundTint">@color/surfaceButton</item>
|
<item name="android:backgroundTint">@color/surfaceButton</item>
|
||||||
<item name="android:ellipsize">end</item>
|
<item name="android:ellipsize">end</item>
|
||||||
|
<item name="cornerRadius">@dimen/card_corner_high</item>
|
||||||
|
<item name="rippleColor">@color/themeLight</item>
|
||||||
<item name="android:maxLines">1</item>
|
<item name="android:maxLines">1</item>
|
||||||
<item name="android:textAllCaps">false</item>
|
<item name="android:textAllCaps">false</item>
|
||||||
<item name="android:textColor">@color/themeLight</item>
|
<item name="android:textColor">@color/themeLight</item>
|
||||||
|
|||||||
@@ -102,6 +102,14 @@ class DataRepository(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun clearData() {
|
||||||
|
repositoryScope.launch {
|
||||||
|
_updateState.value = DataState.Loading
|
||||||
|
localSource.clearData()
|
||||||
|
_updateState.value = DataState.Success(0L)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun getSatelliteItems(): Flow<List<SatItem>> = localSource.getSatelliteItems()
|
override fun getSatelliteItems(): Flow<List<SatItem>> = localSource.getSatelliteItems()
|
||||||
|
|
||||||
override suspend fun getSelectedSatellites() = localSource.getSelectedSatellites()
|
override suspend fun getSelectedSatellites() = localSource.getSelectedSatellites()
|
||||||
|
|||||||
@@ -39,4 +39,6 @@ interface ILocalSource {
|
|||||||
suspend fun updateEntriesSelection(catnums: List<Int>, isSelected: Boolean)
|
suspend fun updateEntriesSelection(catnums: List<Int>, isSelected: Boolean)
|
||||||
|
|
||||||
suspend fun updateTransmitters(transmitters: List<Transmitter>)
|
suspend fun updateTransmitters(transmitters: List<Transmitter>)
|
||||||
|
|
||||||
|
suspend fun clearData()
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,8 @@ interface IDataRepository {
|
|||||||
|
|
||||||
fun updateDataFromWeb(sources: List<String>)
|
fun updateDataFromWeb(sources: List<String>)
|
||||||
|
|
||||||
|
fun clearData()
|
||||||
|
|
||||||
fun getSatelliteItems(): Flow<List<SatItem>>
|
fun getSatelliteItems(): Flow<List<SatItem>>
|
||||||
|
|
||||||
suspend fun getSelectedSatellites(): List<Satellite>
|
suspend fun getSelectedSatellites(): List<Satellite>
|
||||||
|
|||||||
Reference in new issue
Block a user