forked from upstream-mirrors/OpenTracks
Address comments.
This commit is contained in:
@@ -68,7 +68,6 @@ public class TrackWidgetProvider
|
|||||||
private MyTracksProviderUtils providerUtils;
|
private MyTracksProviderUtils providerUtils;
|
||||||
private Context context;
|
private Context context;
|
||||||
private String unknown;
|
private String unknown;
|
||||||
private String time;
|
|
||||||
private String distance;
|
private String distance;
|
||||||
private String speed;
|
private String speed;
|
||||||
private TrackObserver trackObserver;
|
private TrackObserver trackObserver;
|
||||||
@@ -84,21 +83,10 @@ public class TrackWidgetProvider
|
|||||||
selectedTrackId = -1;
|
selectedTrackId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnabled(Context context) {
|
|
||||||
initialize(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
|
||||||
initialize(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initialize(Context context) {
|
private void initialize(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
trackObserver = new TrackObserver();
|
trackObserver = new TrackObserver();
|
||||||
providerUtils = MyTracksProviderUtils.Factory.get(context);
|
providerUtils = MyTracksProviderUtils.Factory.get(context);
|
||||||
time = context.getString(R.string.min);
|
|
||||||
unknown = context.getString(R.string.unknown);
|
unknown = context.getString(R.string.unknown);
|
||||||
|
|
||||||
sharedPreferences = context.getSharedPreferences(SETTINGS_NAME, 0);
|
sharedPreferences = context.getSharedPreferences(SETTINGS_NAME, 0);
|
||||||
@@ -132,8 +120,12 @@ public class TrackWidgetProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisabled(Context context) {
|
public void onDisabled(Context context) {
|
||||||
context.getContentResolver().unregisterContentObserver(trackObserver);
|
if (trackObserver != null) {
|
||||||
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
|
context.getContentResolver().unregisterContentObserver(trackObserver);
|
||||||
|
}
|
||||||
|
if (sharedPreferences != null) {
|
||||||
|
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTrack(String action) {
|
private void updateTrack(String action) {
|
||||||
@@ -237,9 +229,7 @@ public class TrackWidgetProvider
|
|||||||
String distance = StringUtils.formatSingleDecimalPlace(displayDistance) + " " + this.distance;
|
String distance = StringUtils.formatSingleDecimalPlace(displayDistance) + " " + this.distance;
|
||||||
|
|
||||||
// convert ms to minutes
|
// convert ms to minutes
|
||||||
String time = StringUtils.formatSingleDecimalPlace(stats.getMovingTime() / 60000d)
|
String time = StringUtils.formatTime(stats.getMovingTime());
|
||||||
+ " " + this.time;
|
|
||||||
|
|
||||||
String speed = unknown;
|
String speed = unknown;
|
||||||
if (!Double.isNaN(stats.getAverageMovingSpeed())) {
|
if (!Double.isNaN(stats.getAverageMovingSpeed())) {
|
||||||
// Convert m/s to km/h
|
// Convert m/s to km/h
|
||||||
|
|||||||
@@ -30,7 +30,10 @@ limitations under the License.
|
|||||||
|
|
||||||
<!-- TrackRecordingService actions -->
|
<!-- TrackRecordingService actions -->
|
||||||
<string name="start_new_track_action">com.google.android.apps.mytracks.START_NEW_TRACK</string>
|
<string name="start_new_track_action">com.google.android.apps.mytracks.START_NEW_TRACK</string>
|
||||||
<!-- Setting this intent makes the new track the selected track. -->
|
<!--
|
||||||
|
Setting this intent makes the new track the selected track.
|
||||||
|
This is not expected to work if the my tracks activity is currently active.
|
||||||
|
-->
|
||||||
<string name="select_new_track_extra">com.google.android.apps.mytracks.SELECT_NEW_TRACK</string>
|
<string name="select_new_track_extra">com.google.android.apps.mytracks.SELECT_NEW_TRACK</string>
|
||||||
<string name="end_current_track_action">com.google.android.apps.mytracks.END_CURRENT_TRACK</string>
|
<string name="end_current_track_action">com.google.android.apps.mytracks.END_CURRENT_TRACK</string>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user