Commit c49e6015 authored by Joey's avatar Joey

diab: lint cleanup

Signed-off-by: Joey's avatarJoey <bevilacquajoey@gmail.com>
parent e86f49c8
Pipeline #57600131 passed with stages
in 16 minutes and 36 seconds
......@@ -16,8 +16,7 @@
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
android:layout_height="match_parent" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
......
......@@ -8,6 +8,7 @@
*/
package it.diab.core.util
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.os.Build
......@@ -116,6 +117,7 @@ class PluginManager(context: Context) {
}
}
@SuppressLint("UseSparseArrays")
@WorkerThread
private fun parseInputStream(iStream: InputStream): HashMap<Int, Float> {
val map = HashMap<Int, Float>()
......
......@@ -14,17 +14,13 @@ import java.util.Calendar
import java.util.Date
import java.util.Locale
fun Date.asTimeFrame(): TimeFrame {
val hour = getHour()
return when (hour) {
fun Date.asTimeFrame() = when (getHour()) {
in 6..9 -> TimeFrame.MORNING
in 10..11 -> TimeFrame.LATE_MORNING
in 12..13 -> TimeFrame.LUNCH
in 14..18 -> TimeFrame.AFTERNOON
in 19..20 -> TimeFrame.DINNER
else -> TimeFrame.NIGHT
}
}
fun Date.format(format: String): String =
......
......@@ -63,8 +63,7 @@ class ExportService : Service() {
startForeground(RUNNING_NOTIFICATION_ID, notification)
val targetAction = intent?.getIntExtra(EXPORT_TARGET, -1) ?: -1
when (targetAction) {
when (intent?.getIntExtra(EXPORT_TARGET, -1)) {
TARGET_CSV -> exportCsv(this::onTaskCompleted)
TARGET_XLSX -> exportXlxs(this::onTaskCompleted)
}
......
......@@ -225,13 +225,13 @@ class EditorActivity : AppCompatActivity() {
private fun onDateSelected(timeInMillis: Long) {
if (timeInMillis > System.currentTimeMillis()) {
if (!viewModel.hasError(it.diab.glucose.viewmodels.EditorViewModel.ERROR_DATE)) {
if (!viewModel.hasError(EditorViewModel.ERROR_DATE)) {
timeView.setErrorStatus(this, true)
}
viewModel.setError(it.diab.glucose.viewmodels.EditorViewModel.ERROR_DATE)
viewModel.setError(EditorViewModel.ERROR_DATE)
} else {
viewModel.clearError(it.diab.glucose.viewmodels.EditorViewModel.ERROR_DATE)
viewModel.clearError(EditorViewModel.ERROR_DATE)
}
viewModel.glucose.date.time = timeInMillis
......@@ -248,7 +248,7 @@ class EditorActivity : AppCompatActivity() {
}
private fun checkForError(value: Int) {
val hadError = viewModel.hasError(it.diab.glucose.viewmodels.EditorViewModel.ERROR_VALUE)
val hadError = viewModel.hasError(EditorViewModel.ERROR_VALUE)
val hasError = value == 0
if (hadError != hasError) {
......@@ -256,9 +256,9 @@ class EditorActivity : AppCompatActivity() {
}
if (hasError) {
viewModel.setError(it.diab.glucose.viewmodels.EditorViewModel.ERROR_VALUE)
viewModel.setError(EditorViewModel.ERROR_VALUE)
} else {
viewModel.clearError(it.diab.glucose.viewmodels.EditorViewModel.ERROR_VALUE)
viewModel.clearError(EditorViewModel.ERROR_VALUE)
}
}
......
......@@ -27,7 +27,7 @@ import it.diab.fit.google.viewmodels.FitViewModelFactory
class FitActivity : AppCompatActivity() {
private lateinit var viewModel: it.diab.fit.google.viewmodels.FitViewModel
private lateinit var viewModel: FitViewModel
private lateinit var coordinator: CoordinatorLayout
private lateinit var headerText: TextView
......@@ -56,10 +56,7 @@ class FitActivity : AppCompatActivity() {
deleteAllButton = findViewById(R.id.fit_delete_all_button)
connectButton.setOnClickListener {
viewModel.connect(
this,
FitActivity.GOOGLE_FIT_REQUEST_CODE
)
viewModel.connect(this, GOOGLE_FIT_REQUEST_CODE)
}
disconnectButton.setOnClickListener { confirmDisconnect() }
deleteAllButton.setOnClickListener { confirmDelete() }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment