checkpoint

This commit is contained in:
voussoir 2023-03-11 21:07:16 -08:00
parent 63d2b073d2
commit 2c33cc88f7
16 changed files with 27 additions and 144 deletions

View file

@ -18,8 +18,6 @@ package org.y20k.trackbook
import android.Manifest import android.Manifest
import android.app.Activity import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Build import android.os.Build
@ -28,19 +26,16 @@ import android.os.StrictMode
import android.os.StrictMode.VmPolicy import android.os.StrictMode.VmPolicy
import android.util.Log import android.util.Log
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.navigation.fragment.NavHostFragment import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController import androidx.navigation.ui.setupWithNavController
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import org.osmdroid.config.Configuration import org.osmdroid.config.Configuration
import org.y20k.trackbook.helpers.AppThemeHelper import org.y20k.trackbook.helpers.AppThemeHelper
import org.y20k.trackbook.helpers.LogHelper
import org.y20k.trackbook.helpers.PreferencesHelper import org.y20k.trackbook.helpers.PreferencesHelper
class MainActivity: AppCompatActivity() class MainActivity: AppCompatActivity()
{ {
/* Main class variables */
lateinit var trackbook: Trackbook lateinit var trackbook: Trackbook
private lateinit var navHostFragment: NavHostFragment private lateinit var navHostFragment: NavHostFragment
private lateinit var bottomNavigationView: BottomNavigationView private lateinit var bottomNavigationView: BottomNavigationView
@ -118,7 +113,7 @@ class MainActivity: AppCompatActivity()
permissions_needed.add(permission) permissions_needed.add(permission)
} }
} }
val result = requestPermissions(permissions_wanted, 1); val result = requestPermissions(permissions_wanted, 1)
Log.i("VOUSSOIR", "Permissions result " + result) Log.i("VOUSSOIR", "Permissions result " + result)
} }

View file

@ -156,7 +156,7 @@ class MapFragment : Fragment()
val compassOverlay = CompassOverlay(requireContext(), InternalCompassOrientationProvider(requireContext()), mapView) val compassOverlay = CompassOverlay(requireContext(), InternalCompassOrientationProvider(requireContext()), mapView)
compassOverlay.enableCompass() compassOverlay.enableCompass()
// compassOverlay.setCompassCenter(36f, 36f + (statusBarHeight / densityScalingFactor)) // TODO uncomment when transparent status bar is re-implemented // compassOverlay.setCompassCenter(36f, 36f + (statusBarHeight / densityScalingFactor)) // TODO uncomment when transparent status bar is re-implemented
val screen_width = Resources.getSystem().displayMetrics.widthPixels; val screen_width = Resources.getSystem().displayMetrics.widthPixels
compassOverlay.setCompassCenter((screen_width / densityScalingFactor) - 36f, 36f) compassOverlay.setCompassCenter((screen_width / densityScalingFactor) - 36f, 36f)
mapView.overlays.add(compassOverlay) mapView.overlays.add(compassOverlay)
@ -416,7 +416,7 @@ class MapFragment : Fragment()
mapView.overlays.remove(ov) mapView.overlays.remove(ov)
} }
} }
current_position_overlays.clear(); current_position_overlays.clear()
} }
/* Mark current position on map */ /* Mark current position on map */
@ -483,7 +483,7 @@ class MapFragment : Fragment()
mapView.overlays.remove(ov) mapView.overlays.remove(ov)
} }
} }
homepoints_overlays.clear(); homepoints_overlays.clear()
} }
fun create_homepoint_overlays(context: Context, map_view: MapView, homepoints: List<Homepoint>) fun create_homepoint_overlays(context: Context, map_view: MapView, homepoints: List<Homepoint>)
@ -629,8 +629,8 @@ class MapFragment : Fragment()
} }
private val periodicLocationRequestRunnable: Runnable = object : Runnable { private val periodicLocationRequestRunnable: Runnable = object : Runnable {
override fun run() { override fun run()
// pull current state from service {
currentBestLocation = trackerService.currentBestLocation currentBestLocation = trackerService.currentBestLocation
track = trackerService.track track = trackerService.track
gpsProviderActive = trackerService.gpsProviderActive gpsProviderActive = trackerService.gpsProviderActive
@ -644,9 +644,6 @@ class MapFragment : Fragment()
{ {
centerMap(currentBestLocation, true) centerMap(currentBestLocation, true)
} }
// show error snackbar if necessary
// toggleLocationErrorBar(gpsProviderActive, networkProviderActive)
// use the handler to start runnable again after specified delay
handler.postDelayed(this, Keys.REQUEST_CURRENT_LOCATION_INTERVAL) handler.postDelayed(this, Keys.REQUEST_CURRENT_LOCATION_INTERVAL)
} }
} }

View file

@ -67,12 +67,12 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
val context = preferenceManager.context val context = preferenceManager.context
val screen = preferenceManager.createPreferenceScreen(context) val screen = preferenceManager.createPreferenceScreen(context)
val preferenceCategoryGeneral: PreferenceCategory = PreferenceCategory(activity as Context) val preferenceCategoryGeneral = PreferenceCategory(activity as Context)
preferenceCategoryGeneral.title = getString(R.string.pref_general_title) preferenceCategoryGeneral.title = getString(R.string.pref_general_title)
screen.addPreference(preferenceCategoryGeneral) screen.addPreference(preferenceCategoryGeneral)
// set up "Restrict to GPS" preference // set up "Restrict to GPS" preference
val preferenceGpsOnly: SwitchPreferenceCompat = SwitchPreferenceCompat(activity as Context) val preferenceGpsOnly = SwitchPreferenceCompat(activity as Context)
preferenceGpsOnly.isSingleLineTitle = false preferenceGpsOnly.isSingleLineTitle = false
preferenceGpsOnly.title = getString(R.string.pref_gps_only_title) preferenceGpsOnly.title = getString(R.string.pref_gps_only_title)
preferenceGpsOnly.setIcon(R.drawable.ic_gps_24dp) preferenceGpsOnly.setIcon(R.drawable.ic_gps_24dp)
@ -84,7 +84,7 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
screen.addPreference(preferenceGpsOnly) screen.addPreference(preferenceGpsOnly)
// set up "Use Imperial Measurements" preference // set up "Use Imperial Measurements" preference
val preferenceImperialMeasurementUnits: SwitchPreferenceCompat = SwitchPreferenceCompat(activity as Context) val preferenceImperialMeasurementUnits = SwitchPreferenceCompat(activity as Context)
preferenceImperialMeasurementUnits.isSingleLineTitle = false preferenceImperialMeasurementUnits.isSingleLineTitle = false
preferenceImperialMeasurementUnits.title = getString(R.string.pref_imperial_measurement_units_title) preferenceImperialMeasurementUnits.title = getString(R.string.pref_imperial_measurement_units_title)
preferenceImperialMeasurementUnits.setIcon(R.drawable.ic_square_foot_24px) preferenceImperialMeasurementUnits.setIcon(R.drawable.ic_square_foot_24px)
@ -96,7 +96,7 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
screen.addPreference(preferenceImperialMeasurementUnits) screen.addPreference(preferenceImperialMeasurementUnits)
// set up "App Theme" preference // set up "App Theme" preference
val preferenceThemeSelection: ListPreference = ListPreference(activity as Context) val preferenceThemeSelection = ListPreference(activity as Context)
preferenceThemeSelection.title = getString(R.string.pref_theme_selection_title) preferenceThemeSelection.title = getString(R.string.pref_theme_selection_title)
preferenceThemeSelection.setIcon(R.drawable.ic_smartphone_24dp) preferenceThemeSelection.setIcon(R.drawable.ic_smartphone_24dp)
preferenceThemeSelection.key = Keys.PREF_THEME_SELECTION preferenceThemeSelection.key = Keys.PREF_THEME_SELECTION
@ -115,7 +115,7 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
screen.addPreference(preferenceThemeSelection) screen.addPreference(preferenceThemeSelection)
// set up "Recording Accuracy" preference // set up "Recording Accuracy" preference
val preferenceOmitRests: SwitchPreferenceCompat = SwitchPreferenceCompat(activity as Context) val preferenceOmitRests = SwitchPreferenceCompat(activity as Context)
preferenceOmitRests.isSingleLineTitle = false preferenceOmitRests.isSingleLineTitle = false
preferenceOmitRests.title = getString(R.string.pref_omit_rests_title) preferenceOmitRests.title = getString(R.string.pref_omit_rests_title)
preferenceOmitRests.setIcon(R.drawable.ic_timeline_24dp) preferenceOmitRests.setIcon(R.drawable.ic_timeline_24dp)
@ -126,7 +126,7 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
preferenceCategoryGeneral.contains(preferenceOmitRests) preferenceCategoryGeneral.contains(preferenceOmitRests)
screen.addPreference(preferenceOmitRests) screen.addPreference(preferenceOmitRests)
val preferenceDeviceID: EditTextPreference = EditTextPreference(activity as Context) val preferenceDeviceID = EditTextPreference(activity as Context)
preferenceDeviceID.title = getString(R.string.pref_device_id) preferenceDeviceID.title = getString(R.string.pref_device_id)
preferenceDeviceID.setIcon(R.drawable.ic_smartphone_24dp) preferenceDeviceID.setIcon(R.drawable.ic_smartphone_24dp)
preferenceDeviceID.key = Keys.PREF_DEVICE_ID preferenceDeviceID.key = Keys.PREF_DEVICE_ID
@ -139,7 +139,7 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
preferenceCategoryGeneral.contains(preferenceDeviceID) preferenceCategoryGeneral.contains(preferenceDeviceID)
screen.addPreference(preferenceDeviceID) screen.addPreference(preferenceDeviceID)
val preferenceDatabaseFolder: Preference = Preference(context) val preferenceDatabaseFolder = Preference(context)
var resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> var resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
Log.i("VOUSSOIR", "I'm not dead yet.") Log.i("VOUSSOIR", "I'm not dead yet.")
if (result.resultCode != Activity.RESULT_OK) if (result.resultCode != Activity.RESULT_OK)
@ -182,12 +182,12 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
preferenceCategoryGeneral.contains(preferenceDatabaseFolder) preferenceCategoryGeneral.contains(preferenceDatabaseFolder)
screen.addPreference(preferenceDatabaseFolder) screen.addPreference(preferenceDatabaseFolder)
val preferenceCategoryAbout: PreferenceCategory = PreferenceCategory(context) val preferenceCategoryAbout = PreferenceCategory(context)
preferenceCategoryAbout.title = getString(R.string.pref_about_title) preferenceCategoryAbout.title = getString(R.string.pref_about_title)
screen.addPreference(preferenceCategoryAbout) screen.addPreference(preferenceCategoryAbout)
// set up "App Version" preference // set up "App Version" preference
val preferenceAppVersion: Preference = Preference(context) val preferenceAppVersion = Preference(context)
preferenceAppVersion.title = getString(R.string.pref_app_version_title) preferenceAppVersion.title = getString(R.string.pref_app_version_title)
preferenceAppVersion.setIcon(R.drawable.ic_info_24dp) preferenceAppVersion.setIcon(R.drawable.ic_info_24dp)
preferenceAppVersion.summary = getString(R.string.pref_app_version_summary) preferenceAppVersion.summary = getString(R.string.pref_app_version_summary)

View file

@ -47,13 +47,6 @@ data class Track (
Log.i("VOUSSOIR", "Track.delete.") Log.i("VOUSSOIR", "Track.delete.")
} }
suspend fun delete_suspended(context: Context)
{
return suspendCoroutine { cont ->
cont.resume(this.delete())
}
}
fun export_gpx(context: Context, fileuri: Uri): Uri? fun export_gpx(context: Context, fileuri: Uri): Uri?
{ {
if (! database.ready) if (! database.ready)
@ -205,7 +198,7 @@ data class Track (
} }
finally finally
{ {
cursor.close(); cursor.close()
} }
} }
} }

View file

@ -48,7 +48,7 @@ class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDi
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
// initialize layout // initialize layout
val database: Database = (requireActivity().applicationContext as Trackbook).database val database: Database = (requireActivity().applicationContext as Trackbook).database
val track: Track = Track( val track = Track(
database=database, database=database,
name=this.requireArguments().getString(Keys.ARG_TRACK_TITLE, ""), name=this.requireArguments().getString(Keys.ARG_TRACK_TITLE, ""),
device_id= this.requireArguments().getString(Keys.ARG_TRACK_DEVICE_ID, ""), device_id= this.requireArguments().getString(Keys.ARG_TRACK_DEVICE_ID, ""),
@ -64,7 +64,7 @@ class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDi
} }
// set up delete button // set up delete button
layout.deleteButton.setOnClickListener { layout.deleteButton.setOnClickListener {
val dialogMessage: String = "${getString(R.string.dialog_yes_no_message_delete_recording)}\n\n- ${layout.trackNameView.text}" val dialogMessage = "${getString(R.string.dialog_yes_no_message_delete_recording)}\n\n- ${layout.trackNameView.text}"
YesNoDialog(this@TrackFragment as YesNoDialog.YesNoDialogListener).show( YesNoDialog(this@TrackFragment as YesNoDialog.YesNoDialogListener).show(
context = activity as Context, context = activity as Context,
type = Keys.DIALOG_DELETE_TRACK, type = Keys.DIALOG_DELETE_TRACK,
@ -86,14 +86,6 @@ class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDi
super.onResume() super.onResume()
} }
/* Overrides onPause from Fragment */
override fun onPause()
{
super.onPause()
// save zoom level and map center
layout.saveViewStateToTrack()
}
/* Register the ActivityResultLauncher for saving GPX */ /* Register the ActivityResultLauncher for saving GPX */
private val requestSaveGpxLauncher = registerForActivityResult(StartActivityForResult(), this::requestSaveGpxResult) private val requestSaveGpxLauncher = registerForActivityResult(StartActivityForResult(), this::requestSaveGpxResult)

View file

@ -37,7 +37,7 @@ interface DatabaseChangedListener
fun database_changed() fun database_changed()
} }
class Trackbook(): Application() { class Trackbook : Application() {
val database: Database = Database(this) val database: Database = Database(this)
val homepoints: ArrayList<Homepoint> = ArrayList() val homepoints: ArrayList<Homepoint> = ArrayList()
val database_changed_listeners = ArrayList<DatabaseChangedListener>() val database_changed_listeners = ArrayList<DatabaseChangedListener>()
@ -77,7 +77,7 @@ class Trackbook(): Application() {
this.database.ready = false this.database.ready = false
return return
} }
if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)
{ {
this.database.connect(File(folder + "/trkpt_${PreferencesHelper.load_device_id()}.db")) this.database.connect(File(folder + "/trkpt_${PreferencesHelper.load_device_id()}.db"))
this.load_homepoints() this.load_homepoints()
@ -129,7 +129,7 @@ class Trackbook(): Application() {
} }
finally finally
{ {
cursor.close(); cursor.close()
} }
} }

View file

@ -28,11 +28,8 @@ import org.y20k.trackbook.helpers.PreferencesHelper
/* /*
* TrackingToggleTileService class * TrackingToggleTileService class
*/ */
class TrackingToggleTileService: TileService() { class TrackingToggleTileService: TileService()
{
/* Define log tag */
private val TAG: String = LogHelper.makeLogTag(TrackingToggleTileService::class.java)
/* Main class variables */ /* Main class variables */
private var bound: Boolean = false private var bound: Boolean = false
private var trackingState: Int = Keys.STATE_TRACKING_STOPPED private var trackingState: Int = Keys.STATE_TRACKING_STOPPED

View file

@ -23,7 +23,6 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.net.toUri
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController

View file

@ -18,11 +18,7 @@ package org.y20k.trackbook
import android.location.Location import android.location.Location
import org.y20k.trackbook.helpers.getNumberOfSatellites import org.y20k.trackbook.helpers.getNumberOfSatellites
import java.util.*
/*
* WayPoint data class
*/
data class Trkpt( data class Trkpt(
val provider: String, val provider: String,
val latitude: Double, val latitude: Double,
@ -34,7 +30,6 @@ data class Trkpt(
var starred: Boolean = false var starred: Boolean = false
) )
{ {
/* Constructor using just Location */
constructor(location: Location) : this ( constructor(location: Location) : this (
provider=location.provider.toString(), provider=location.provider.toString(),
latitude=location.latitude, latitude=location.latitude,
@ -45,7 +40,6 @@ data class Trkpt(
numberSatellites=getNumberOfSatellites(location), numberSatellites=getNumberOfSatellites(location),
) )
/* Converts WayPoint into Location */
fun toLocation(): Location { fun toLocation(): Location {
val location = Location(provider) val location = Location(provider)
location.latitude = latitude location.latitude = latitude
@ -55,5 +49,4 @@ data class Trkpt(
location.time = this.time location.time = this.time
return location return location
} }
} }

View file

@ -105,5 +105,4 @@ object DateTimeHelper {
} }
return timeDifference return timeDifference
} }
} }

View file

@ -30,7 +30,7 @@ import kotlin.math.pow
/* Get default location */ /* Get default location */
fun getDefaultLocation(): Location fun getDefaultLocation(): Location
{ {
val defaultLocation: Location = Location(LocationManager.NETWORK_PROVIDER) val defaultLocation = Location(LocationManager.NETWORK_PROVIDER)
defaultLocation.latitude = Keys.DEFAULT_LATITUDE defaultLocation.latitude = Keys.DEFAULT_LATITUDE
defaultLocation.longitude = Keys.DEFAULT_LONGITUDE defaultLocation.longitude = Keys.DEFAULT_LONGITUDE
defaultLocation.accuracy = Keys.DEFAULT_ACCURACY defaultLocation.accuracy = Keys.DEFAULT_ACCURACY
@ -125,7 +125,6 @@ fun isNetworkEnabled(locationManager: LocationManager): Boolean
} }
} }
/* Checks if given location is new */ /* Checks if given location is new */
fun isRecentEnough(location: Location): Boolean fun isRecentEnough(location: Location): Boolean
{ {

View file

@ -17,19 +17,13 @@
package org.y20k.trackbook.helpers package org.y20k.trackbook.helpers
import android.content.Context import android.content.Context
import android.graphics.Color
import android.graphics.Paint import android.graphics.Paint
import android.graphics.drawable.Drawable
import android.location.Location
import android.os.Vibrator
import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import org.osmdroid.api.IGeoPoint import org.osmdroid.api.IGeoPoint
import org.osmdroid.util.GeoPoint import org.osmdroid.util.GeoPoint
import org.osmdroid.views.MapView import org.osmdroid.views.MapView
import org.osmdroid.views.overlay.ItemizedIconOverlay import org.osmdroid.views.overlay.ItemizedIconOverlay
import org.osmdroid.views.overlay.MapEventsOverlay
import org.osmdroid.views.overlay.OverlayItem import org.osmdroid.views.overlay.OverlayItem
import org.osmdroid.views.overlay.simplefastpoint.LabelledGeoPoint import org.osmdroid.views.overlay.simplefastpoint.LabelledGeoPoint
import org.osmdroid.views.overlay.simplefastpoint.SimpleFastPointOverlay import org.osmdroid.views.overlay.simplefastpoint.SimpleFastPointOverlay
@ -43,7 +37,6 @@ import java.text.DecimalFormat
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
/* Creates icon overlay for track */ /* Creates icon overlay for track */
fun createTrackOverlay(context: Context, map_view: MapView, track: Track, trackingState: Int) fun createTrackOverlay(context: Context, map_view: MapView, track: Track, trackingState: Int)
{ {

View file

@ -34,43 +34,6 @@ import org.y20k.trackbook.tracklist.TracklistAdapter
* UiHelper object * UiHelper object
*/ */
object UiHelper { object UiHelper {
/* Define log tag */
private val TAG: String = LogHelper.makeLogTag(UiHelper::class.java)
/* Sets layout margins for given view in DP */
fun setViewMargins(context: Context, view: View, left: Int = 0, right: Int = 0, top: Int= 0, bottom: Int = 0) {
val scalingFactor: Float = context.resources.displayMetrics.density
val l: Int = (left * scalingFactor).toInt()
val r: Int = (right * scalingFactor).toInt()
val t: Int = (top * scalingFactor).toInt()
val b: Int = (bottom * scalingFactor).toInt()
if (view.layoutParams is ViewGroup.MarginLayoutParams) {
val p = view.layoutParams as ViewGroup.MarginLayoutParams
p.setMargins(l, t, r, b)
view.requestLayout()
}
}
/* Sets layout margins for given view in percent */
fun setViewMarginsPercentage(context: Context, view: View, height: Int, width: Int, left: Int = 0, right: Int = 0, top: Int= 0, bottom: Int = 0) {
val l: Int = ((width / 100.0f) * left).toInt()
val r: Int = ((width / 100.0f) * right).toInt()
val t: Int = ((height / 100.0f) * top).toInt()
val b: Int = ((height / 100.0f) * bottom).toInt()
setViewMargins(context, view, l, r, t, b)
}
/* Get the height of the system's top status bar */
fun getStatusBarHeight(context: Context): Int {
var result: Int = 0
val resourceId: Int = context.resources.getIdentifier("status_bar_height", "dimen", "android")
if (resourceId > 0) {
result = context.resources.getDimensionPixelSize(resourceId)
}
return result
}
/* Get scaling factor from display density */ /* Get scaling factor from display density */
fun getDensityScalingFactor(context: Context): Float { fun getDensityScalingFactor(context: Context): Float {
return context.resources.displayMetrics.density return context.resources.displayMetrics.density
@ -95,11 +58,6 @@ object UiHelper {
return false return false
} }
override fun getSwipeDirs(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
// disable swipe for statistics element
return super.getSwipeDirs(recyclerView, viewHolder)
}
override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) { override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) {
val itemView = viewHolder.itemView val itemView = viewHolder.itemView
val itemHeight = itemView.bottom - itemView.top val itemHeight = itemView.bottom - itemView.top

View file

@ -34,15 +34,9 @@ import org.y20k.trackbook.helpers.*
import java.text.DateFormat import java.text.DateFormat
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
/*
* TracklistAdapter class
*/
class TracklistAdapter(val fragment: Fragment, val database: Database) : RecyclerView.Adapter<RecyclerView.ViewHolder>() class TracklistAdapter(val fragment: Fragment, val database: Database) : RecyclerView.Adapter<RecyclerView.ViewHolder>()
{ {
/* Main class variables */
private val context: Context = fragment.activity as Context private val context: Context = fragment.activity as Context
private lateinit var tracklistListener: TracklistAdapterListener private lateinit var tracklistListener: TracklistAdapterListener
private var useImperial: Boolean = PreferencesHelper.loadUseImperialUnits() private var useImperial: Boolean = PreferencesHelper.loadUseImperialUnits()
@ -86,7 +80,7 @@ class TracklistAdapter(val fragment: Fragment, val database: Database) : Recycle
} }
finally finally
{ {
cursor.close(); cursor.close()
} }
} }
@ -136,13 +130,6 @@ class TracklistAdapter(val fragment: Fragment, val database: Database) : Recycle
// notifyItemRangeChanged(index, this.itemCount); // notifyItemRangeChanged(index, this.itemCount);
} }
suspend fun delete_track_at_position_suspended(context: Context, position: Int)
{
return suspendCoroutine { cont ->
cont.resume(delete_track_at_position(context, position))
}
}
fun delete_track_by_id(context: Context, trackId: Long) fun delete_track_by_id(context: Context, trackId: Long)
{ {
// val index: Int = tracklist.tracks.indexOfFirst {it.id == trackId} // val index: Int = tracklist.tracks.indexOfFirst {it.id == trackId}
@ -178,15 +165,9 @@ class TracklistAdapter(val fragment: Fragment, val database: Database) : Recycle
// return trackDataString // return trackDataString
} }
/*
* Inner class: ViewHolder for a track element
*/
inner class ElementTrackViewHolder (elementTrackLayout: View): RecyclerView.ViewHolder(elementTrackLayout) { inner class ElementTrackViewHolder (elementTrackLayout: View): RecyclerView.ViewHolder(elementTrackLayout) {
val trackElement: ConstraintLayout = elementTrackLayout.findViewById(R.id.track_element) val trackElement: ConstraintLayout = elementTrackLayout.findViewById(R.id.track_element)
val trackNameView: TextView = elementTrackLayout.findViewById(R.id.track_name) val trackNameView: TextView = elementTrackLayout.findViewById(R.id.track_name)
val trackDataView: TextView = elementTrackLayout.findViewById(R.id.track_data) val trackDataView: TextView = elementTrackLayout.findViewById(R.id.track_data)
} }
/*
* End of inner class
*/
} }

View file

@ -69,7 +69,6 @@ data class TrackFragmentLayoutHolder(
val trackNameView: MaterialTextView val trackNameView: MaterialTextView
private val mapView: MapView private val mapView: MapView
private var controller: IMapController private var controller: IMapController
//private var zoomLevel: Double
private val statisticsSheetBehavior: BottomSheetBehavior<View> private val statisticsSheetBehavior: BottomSheetBehavior<View>
private val statisticsSheet: NestedScrollView private val statisticsSheet: NestedScrollView
private val statisticsView: View private val statisticsView: View
@ -158,14 +157,6 @@ data class TrackFragmentLayoutHolder(
setupStatisticsViews() setupStatisticsViews()
} }
/* Saves zoom level and center of this map */
fun saveViewStateToTrack()
{
if (track.view_latitude != 0.0 && track.view_longitude != 0.0)
{
}
}
/* Sets up the statistics sheet */ /* Sets up the statistics sheet */
private fun setupStatisticsViews() private fun setupStatisticsViews()
{ {

View file

@ -17,10 +17,6 @@
<action <action
android:id="@+id/action_map_fragment_to_tracks_fragment" android:id="@+id/action_map_fragment_to_tracks_fragment"
app:destination="@id/tracklist_fragment" /> app:destination="@id/tracklist_fragment" />
<action
android:id="@+id/action_map_fragment_to_fragment_track"
app:destination="@id/fragment_track"
app:popUpToInclusive="false" />
</fragment> </fragment>
<!-- SETTINGS --> <!-- SETTINGS -->