@@ -42,7 +42,7 @@ class PedometerService : Service(), SensorEventListener {
4242
4343 private fun startNotification () {
4444 val input = " Counting your steps..."
45- val notificationIntent = Intent (this , Bridge .myActivity.javaClass)
45+ val notificationIntent = Intent (this , BridgeApplication .myActivity.javaClass)
4646 val pendingIntent = PendingIntent .getActivity(
4747 this ,
4848 0 , notificationIntent, PendingIntent .FLAG_IMMUTABLE or PendingIntent .FLAG_UPDATE_CURRENT
@@ -57,15 +57,15 @@ class PedometerService : Service(), SensorEventListener {
5757 }
5858
5959 override fun onCreate () {
60- Log .i(TAG , " onCreate: CREATED" + Bridge .steps)
60+ Log .i(TAG , " onCreate: CREATED" + BridgeApplication .steps)
6161 sharedPreferences = PreferenceManager .getDefaultSharedPreferences(this )
6262 loadData()
63- saveSummarySteps(Bridge .summarySteps + Bridge .steps)
63+ saveSummarySteps(BridgeApplication .summarySteps + BridgeApplication .steps)
6464 }
6565
6666 override fun onTaskRemoved (rootIntent : Intent ) {
6767 super .onTaskRemoved(rootIntent)
68- Log .i(TAG , " onTaskRemoved: REMOVED" + Bridge .steps)
68+ Log .i(TAG , " onTaskRemoved: REMOVED" + BridgeApplication .steps)
6969 initSensorManager()
7070 }
7171
@@ -74,11 +74,11 @@ class PedometerService : Service(), SensorEventListener {
7474 createNotificationChannel()
7575 startNotification()
7676 super .onCreate()
77- Bridge .initialSteps = 0
77+ BridgeApplication .initialSteps = 0
7878 initSensorManager()
7979 val editor = sharedPreferences!! .edit()
8080 initialDate = Calendar .getInstance().time
81- editor.putString(Bridge .INIT_DATE , currentDate.toString())
81+ editor.putString(BridgeApplication .INIT_DATE , currentDate.toString())
8282 editor.apply ()
8383 return START_NOT_STICKY
8484 }
@@ -88,19 +88,19 @@ class PedometerService : Service(), SensorEventListener {
8888 Log .i(TAG , " onDestroy: DESTROYED" )
8989 disposeSensorManager()
9090 loadData()
91- saveSummarySteps(Bridge .summarySteps + Bridge .steps)
91+ saveSummarySteps(BridgeApplication .summarySteps + BridgeApplication .steps)
9292 }
9393
9494 override fun onSensorChanged (sensorEvent : SensorEvent ) {
9595 Log .i(TAG , " onSensorChanged!!!!!!: " + sensorEvent.values[0 ])
96- if (Bridge .initialSteps == 0 ) {
96+ if (BridgeApplication .initialSteps == 0 ) {
9797 Log .i(TAG , " onSensorChanged: AWAKE" )
98- Bridge .initialSteps = sensorEvent.values[0 ].toInt()
98+ BridgeApplication .initialSteps = sensorEvent.values[0 ].toInt()
9999 }
100100 if (running) {
101- Bridge .steps = sensorEvent.values[0 ].toInt() - Bridge .initialSteps
102- Log .i(TAG , " onSensorChanged: current steps: " + Bridge .steps)
103- saveData(Bridge .steps)
101+ BridgeApplication .steps = sensorEvent.values[0 ].toInt() - BridgeApplication .initialSteps
102+ Log .i(TAG , " onSensorChanged: current steps: " + BridgeApplication .steps)
103+ saveData(BridgeApplication .steps)
104104 }
105105 }
106106
@@ -113,7 +113,7 @@ class PedometerService : Service(), SensorEventListener {
113113 if (countSensor != null ) {
114114 sensorManager!! .registerListener(this , countSensor, SensorManager .SENSOR_DELAY_UI )
115115 } else {
116- Toast .makeText(Bridge .myActivity, " Sensor Not Found (" , Toast .LENGTH_LONG ).show()
116+ Toast .makeText(BridgeApplication .myActivity, " Sensor Not Found (" , Toast .LENGTH_LONG ).show()
117117 }
118118 }
119119
@@ -125,25 +125,25 @@ class PedometerService : Service(), SensorEventListener {
125125 fun saveData (currentSteps : Int ) {
126126 val editor = sharedPreferences!! .edit()
127127 currentDate = Calendar .getInstance().time
128- editor.putString(Bridge .DATE , currentDate.toString())
128+ editor.putString(BridgeApplication .DATE , currentDate.toString())
129129 Log .i(TAG , " saveData: saved! $currentSteps " )
130- editor.putInt(Bridge .STEPS , currentSteps)
130+ editor.putInt(BridgeApplication .STEPS , currentSteps)
131131 editor.apply ()
132132 }
133133
134134 fun saveSummarySteps (stepsToSave : Int ) {
135135 val editor = sharedPreferences!! .edit()
136136 currentDate = Calendar .getInstance().time
137- editor.putString(Bridge .DATE , currentDate.toString())
137+ editor.putString(BridgeApplication .DATE , currentDate.toString())
138138 Log .i(TAG , " saveSummarySteps: saved! $stepsToSave " )
139139 editor.putInt(" summarySteps" , stepsToSave)
140140 editor.apply ()
141141 }
142142
143143 fun loadData () {
144- Bridge .steps = sharedPreferences!! .getInt(Bridge .STEPS , 0 )
145- Bridge .summarySteps = sharedPreferences!! .getInt(" summarySteps" , 0 )
146- Log .i(TAG , " loadData: steps" + Bridge .steps)
147- Log .i(TAG , " loadData: summarySteps " + Bridge .summarySteps)
144+ BridgeApplication .steps = sharedPreferences!! .getInt(BridgeApplication .STEPS , 0 )
145+ BridgeApplication .summarySteps = sharedPreferences!! .getInt(" summarySteps" , 0 )
146+ Log .i(TAG , " loadData: steps" + BridgeApplication .steps)
147+ Log .i(TAG , " loadData: summarySteps " + BridgeApplication .summarySteps)
148148 }
149149}
0 commit comments