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 @@ ...@@ -16,8 +16,7 @@
<androidx.viewpager.widget.ViewPager <androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager" android:id="@+id/viewpager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent" />
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab" android:id="@+id/fab"
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
package it.diab.core.util package it.diab.core.util
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build import android.os.Build
...@@ -116,6 +117,7 @@ class PluginManager(context: Context) { ...@@ -116,6 +117,7 @@ class PluginManager(context: Context) {
} }
} }
@SuppressLint("UseSparseArrays")
@WorkerThread @WorkerThread
private fun parseInputStream(iStream: InputStream): HashMap<Int, Float> { private fun parseInputStream(iStream: InputStream): HashMap<Int, Float> {
val map = HashMap<Int, Float>() val map = HashMap<Int, Float>()
......
...@@ -14,17 +14,13 @@ import java.util.Calendar ...@@ -14,17 +14,13 @@ import java.util.Calendar
import java.util.Date import java.util.Date
import java.util.Locale import java.util.Locale
fun Date.asTimeFrame(): TimeFrame { fun Date.asTimeFrame() = when (getHour()) {
val hour = getHour() in 6..9 -> TimeFrame.MORNING
in 10..11 -> TimeFrame.LATE_MORNING
return when (hour) { in 12..13 -> TimeFrame.LUNCH
in 6..9 -> TimeFrame.MORNING in 14..18 -> TimeFrame.AFTERNOON
in 10..11 -> TimeFrame.LATE_MORNING in 19..20 -> TimeFrame.DINNER
in 12..13 -> TimeFrame.LUNCH else -> TimeFrame.NIGHT
in 14..18 -> TimeFrame.AFTERNOON
in 19..20 -> TimeFrame.DINNER
else -> TimeFrame.NIGHT
}
} }
fun Date.format(format: String): String = fun Date.format(format: String): String =
......
...@@ -63,8 +63,7 @@ class ExportService : Service() { ...@@ -63,8 +63,7 @@ class ExportService : Service() {
startForeground(RUNNING_NOTIFICATION_ID, notification) startForeground(RUNNING_NOTIFICATION_ID, notification)
val targetAction = intent?.getIntExtra(EXPORT_TARGET, -1) ?: -1 when (intent?.getIntExtra(EXPORT_TARGET, -1)) {
when (targetAction) {
TARGET_CSV -> exportCsv(this::onTaskCompleted) TARGET_CSV -> exportCsv(this::onTaskCompleted)
TARGET_XLSX -> exportXlxs(this::onTaskCompleted) TARGET_XLSX -> exportXlxs(this::onTaskCompleted)
} }
......
...@@ -225,13 +225,13 @@ class EditorActivity : AppCompatActivity() { ...@@ -225,13 +225,13 @@ class EditorActivity : AppCompatActivity() {
private fun onDateSelected(timeInMillis: Long) { private fun onDateSelected(timeInMillis: Long) {
if (timeInMillis > System.currentTimeMillis()) { if (timeInMillis > System.currentTimeMillis()) {
if (!viewModel.hasError(it.diab.glucose.viewmodels.EditorViewModel.ERROR_DATE)) { if (!viewModel.hasError(EditorViewModel.ERROR_DATE)) {
timeView.setErrorStatus(this, true) timeView.setErrorStatus(this, true)
} }
viewModel.setError(it.diab.glucose.viewmodels.EditorViewModel.ERROR_DATE) viewModel.setError(EditorViewModel.ERROR_DATE)
} else { } else {
viewModel.clearError(it.diab.glucose.viewmodels.EditorViewModel.ERROR_DATE) viewModel.clearError(EditorViewModel.ERROR_DATE)
} }
viewModel.glucose.date.time = timeInMillis viewModel.glucose.date.time = timeInMillis
...@@ -248,7 +248,7 @@ class EditorActivity : AppCompatActivity() { ...@@ -248,7 +248,7 @@ class EditorActivity : AppCompatActivity() {
} }
private fun checkForError(value: Int) { 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 val hasError = value == 0
if (hadError != hasError) { if (hadError != hasError) {
...@@ -256,9 +256,9 @@ class EditorActivity : AppCompatActivity() { ...@@ -256,9 +256,9 @@ class EditorActivity : AppCompatActivity() {
} }
if (hasError) { if (hasError) {
viewModel.setError(it.diab.glucose.viewmodels.EditorViewModel.ERROR_VALUE) viewModel.setError(EditorViewModel.ERROR_VALUE)
} else { } 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 ...@@ -27,7 +27,7 @@ import it.diab.fit.google.viewmodels.FitViewModelFactory
class FitActivity : AppCompatActivity() { 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 coordinator: CoordinatorLayout
private lateinit var headerText: TextView private lateinit var headerText: TextView
...@@ -56,10 +56,7 @@ class FitActivity : AppCompatActivity() { ...@@ -56,10 +56,7 @@ class FitActivity : AppCompatActivity() {
deleteAllButton = findViewById(R.id.fit_delete_all_button) deleteAllButton = findViewById(R.id.fit_delete_all_button)
connectButton.setOnClickListener { connectButton.setOnClickListener {
viewModel.connect( viewModel.connect(this, GOOGLE_FIT_REQUEST_CODE)
this,
FitActivity.GOOGLE_FIT_REQUEST_CODE
)
} }
disconnectButton.setOnClickListener { confirmDisconnect() } disconnectButton.setOnClickListener { confirmDisconnect() }
deleteAllButton.setOnClickListener { confirmDelete() } 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