Some linting.

This commit is contained in:
voussoir 2022-04-04 13:00:50 -07:00
parent e3bc911de4
commit 75a0a3ae40
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
6 changed files with 15 additions and 14 deletions

View file

@ -217,7 +217,7 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
/* Removes track and track files for given position - used by TracklistFragment */ /* Removes track and track files for given position - used by TracklistFragment */
private fun deleteNonStarred(context: Context) { private fun deleteNonStarred(context: Context) {
var tracklist: Tracklist = load_tracklist(context) val tracklist: Tracklist = load_tracklist(context)
tracklist.delete_non_starred(context) tracklist.delete_non_starred(context)
} }

View file

@ -40,7 +40,7 @@ class Trackbook: Application() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
LogHelper.v(TAG, "Trackbook application started.") LogHelper.v(TAG, "Trackbook application started.")
DynamicColors.applyToActivitiesIfAvailable(this); DynamicColors.applyToActivitiesIfAvailable(this)
// initialize single sharedPreferences object when app is launched // initialize single sharedPreferences object when app is launched
initPreferences() initPreferences()
// set Dark / Light theme state // set Dark / Light theme state

View file

@ -32,7 +32,6 @@ import android.location.LocationListener
import android.location.LocationManager import android.location.LocationManager
import android.Manifest import android.Manifest
import android.os.* import android.os.*
import android.util.Log
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import java.util.* import java.util.*
import kotlinx.coroutines.* import kotlinx.coroutines.*
@ -47,8 +46,8 @@ import org.y20k.trackbook.helpers.*
/* /*
* TrackerService class * TrackerService class
*/ */
class TrackerService: Service(), SensorEventListener { class TrackerService: Service(), SensorEventListener
{
/* Define log tag */ /* Define log tag */
private val TAG: String = LogHelper.makeLogTag(TrackerService::class.java) private val TAG: String = LogHelper.makeLogTag(TrackerService::class.java)
@ -80,7 +79,8 @@ class TrackerService: Service(), SensorEventListener {
private lateinit var networkLocationListener: LocationListener private lateinit var networkLocationListener: LocationListener
/* Overrides onCreate from Service */ /* Overrides onCreate from Service */
override fun onCreate() { override fun onCreate()
{
super.onCreate() super.onCreate()
gpsOnly = PreferencesHelper.loadGpsOnly() gpsOnly = PreferencesHelper.loadGpsOnly()
useImperial = PreferencesHelper.loadUseImperialUnits() useImperial = PreferencesHelper.loadUseImperialUnits()
@ -197,7 +197,8 @@ class TrackerService: Service(), SensorEventListener {
} }
/* Resume tracking after stop/pause */ /* Resume tracking after stop/pause */
fun resumeTracking() { fun resumeTracking()
{
// load temp track - returns an empty track if there is no temp file. // load temp track - returns an empty track if there is no temp file.
track = load_temp_track(this) track = load_temp_track(this)
// try to mark last waypoint as stopover // try to mark last waypoint as stopover
@ -228,10 +229,10 @@ class TrackerService: Service(), SensorEventListener {
startForeground(Keys.TRACKER_SERVICE_NOTIFICATION_ID, displayNotification()) startForeground(Keys.TRACKER_SERVICE_NOTIFICATION_ID, displayNotification())
} }
/* Stop tracking location */ fun stopTracking()
fun stopTracking() { {
track.recordingStop = GregorianCalendar.getInstance().time track.recordingStop = GregorianCalendar.getInstance().time
val context: Context = this as Context val context: Context = this
CoroutineScope(IO).launch { track.save_temp_suspended(context) } CoroutineScope(IO).launch { track.save_temp_suspended(context) }
trackingState = Keys.STATE_TRACKING_STOPPED trackingState = Keys.STATE_TRACKING_STOPPED

View file

@ -166,7 +166,7 @@ class TracklistFragment : Fragment(), TracklistAdapter.TracklistAdapterListener,
arguments?.putLong(Keys.ARG_TRACK_ID, -1L) arguments?.putLong(Keys.ARG_TRACK_ID, -1L)
if (deleteTrackId == -1L) if (deleteTrackId == -1L)
{ {
return; return
} }
CoroutineScope(Main). launch { CoroutineScope(Main). launch {
tracklistAdapter.delete_track_by_id(this@TracklistFragment.activity as Context, deleteTrackId) tracklistAdapter.delete_track_by_id(this@TracklistFragment.activity as Context, deleteTrackId)

View file

@ -76,7 +76,7 @@ data class Tracklist (
fun load_tracklist(context: Context): Tracklist { fun load_tracklist(context: Context): Tracklist {
Log.i("VOUSSOIR", "Loading tracklist.") Log.i("VOUSSOIR", "Loading tracklist.")
val folder = context.getExternalFilesDir("tracks") val folder = context.getExternalFilesDir("tracks")
var tracklist: Tracklist = Tracklist() val tracklist: Tracklist = Tracklist()
if (folder == null) if (folder == null)
{ {
return tracklist return tracklist

View file

@ -112,14 +112,14 @@ class TracklistAdapter(private val fragment: Fragment) : RecyclerView.Adapter<Re
{ {
// CASE STATISTICS ELEMENT // CASE STATISTICS ELEMENT
is ElementStatisticsViewHolder -> { is ElementStatisticsViewHolder -> {
val elementStatisticsViewHolder: ElementStatisticsViewHolder = holder as ElementStatisticsViewHolder val elementStatisticsViewHolder: ElementStatisticsViewHolder = holder
elementStatisticsViewHolder.totalDistanceView.text = LengthUnitHelper.convertDistanceToString(tracklist.get_total_distance(), useImperial) elementStatisticsViewHolder.totalDistanceView.text = LengthUnitHelper.convertDistanceToString(tracklist.get_total_distance(), useImperial)
} }
// CASE TRACK ELEMENT // CASE TRACK ELEMENT
is ElementTrackViewHolder -> { is ElementTrackViewHolder -> {
val positionInTracklist: Int = position - 1 // Element 0 is the statistics element. val positionInTracklist: Int = position - 1 // Element 0 is the statistics element.
val elementTrackViewHolder: ElementTrackViewHolder = holder as ElementTrackViewHolder val elementTrackViewHolder: ElementTrackViewHolder = holder
elementTrackViewHolder.trackNameView.text = tracklist.tracks[positionInTracklist].name elementTrackViewHolder.trackNameView.text = tracklist.tracks[positionInTracklist].name
elementTrackViewHolder.trackDataView.text = createTrackDataString(positionInTracklist) elementTrackViewHolder.trackDataView.text = createTrackDataString(positionInTracklist)
when (tracklist.tracks[positionInTracklist].starred) { when (tracklist.tracks[positionInTracklist].starred) {