mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
Code cleanup.
This commit is contained in:
@@ -27,6 +27,7 @@ import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragme
|
||||
import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller;
|
||||
import com.google.android.apps.mytracks.fragments.ConfirmDeleteDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.MarkerDetailFragment;
|
||||
import com.google.android.apps.mytracks.fragments.StatsFragment;
|
||||
import com.google.android.apps.mytracks.io.file.TrackFileFormat;
|
||||
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
|
||||
|
||||
+11
-15
@@ -477,23 +477,19 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (waypoint != null) {
|
||||
String photoUrl = waypoint.getPhotoUrl();
|
||||
if (photoUrl != null && !photoUrl.equals("")) {
|
||||
Uri uri = Uri.parse(photoUrl);
|
||||
File file = new File(uri.getPath());
|
||||
if (file.exists()) {
|
||||
File parent = file.getParentFile();
|
||||
file.delete();
|
||||
FileUtils.updateMediaScanner(context, uri);
|
||||
if (parent.listFiles().length == 0) {
|
||||
parent.delete();
|
||||
}
|
||||
}
|
||||
if (waypoint != null && waypoint.hasPhoto()) {
|
||||
Uri uri = waypoint.getPhotoURI();
|
||||
File file = new File(uri.getPath());
|
||||
if (file.exists()) {
|
||||
File parent = file.getParentFile();
|
||||
file.delete();
|
||||
FileUtils.updateMediaScanner(context, uri);
|
||||
if (parent.listFiles().length == 0) {
|
||||
parent.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns._ID + "=?",
|
||||
new String[] { Long.toString(waypointId) });
|
||||
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns._ID + "=?", new String[] { Long.toString(waypointId) });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-2
@@ -32,8 +32,7 @@ import android.provider.BaseColumns;
|
||||
public interface TrackPointsColumns extends BaseColumns {
|
||||
|
||||
String TABLE_NAME = "trackpoints";
|
||||
Uri CONTENT_URI = Uri.parse(
|
||||
"content://com.google.android.maps.mytracks/trackpoints");
|
||||
Uri CONTENT_URI = Uri.parse("content://com.google.android.maps.mytracks/trackpoints");
|
||||
String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.trackpoint";
|
||||
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.trackpoint";
|
||||
String DEFAULT_SORT_ORDER = "_id";
|
||||
|
||||
@@ -31,8 +31,7 @@ public interface TracksColumns extends BaseColumns {
|
||||
/**
|
||||
* Tracks provider uri.
|
||||
*/
|
||||
Uri CONTENT_URI = Uri.parse(
|
||||
"content://com.google.android.maps.mytracks/tracks");
|
||||
Uri CONTENT_URI = Uri.parse("content://com.google.android.maps.mytracks/tracks");
|
||||
|
||||
/**
|
||||
* Track content type.
|
||||
|
||||
@@ -16,12 +16,15 @@
|
||||
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* A waypoint.
|
||||
*
|
||||
@@ -243,6 +246,14 @@ public final class Waypoint implements Parcelable {
|
||||
return photoUrl;
|
||||
}
|
||||
|
||||
public Uri getPhotoURI() {
|
||||
return Uri.parse(photoUrl);
|
||||
}
|
||||
|
||||
public boolean hasPhoto() {
|
||||
return photoUrl != null && !"".equals(photoUrl);
|
||||
}
|
||||
|
||||
public void setPhotoUrl(String photoUrl) {
|
||||
this.photoUrl = photoUrl;
|
||||
}
|
||||
|
||||
+4
-9
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.google.android.apps.mytracks.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
@@ -184,9 +183,7 @@ public class MarkerDetailFragment extends Fragment {
|
||||
|
||||
updateWaypoint(false);
|
||||
|
||||
String photoUrl = waypoint.getPhotoUrl();
|
||||
boolean hasPhoto = photoUrl != null && !photoUrl.equals("");
|
||||
menu.findItem(R.id.marker_detail_view_photo).setVisible(hasPhoto);
|
||||
menu.findItem(R.id.marker_detail_view_photo).setVisible(waypoint.hasPhoto());
|
||||
|
||||
TrackIconUtils.setMenuIconColor(menu);
|
||||
}
|
||||
@@ -215,7 +212,7 @@ public class MarkerDetailFragment extends Fragment {
|
||||
case R.id.marker_detail_view_photo:
|
||||
intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(Uri.parse(waypoint.getPhotoUrl()), "image/*");
|
||||
intent.setDataAndType(waypoint.getPhotoURI(), "image/*");
|
||||
startActivity(intent);
|
||||
return true;
|
||||
default:
|
||||
@@ -250,8 +247,7 @@ public class MarkerDetailFragment extends Fragment {
|
||||
statisticsView.setVisibility(isWaypoint ? View.GONE : View.VISIBLE);
|
||||
|
||||
if (isWaypoint) {
|
||||
String photoUrl = waypoint.getPhotoUrl();
|
||||
boolean hasPhoto = photoUrl != null && !photoUrl.equals("");
|
||||
boolean hasPhoto = waypoint.hasPhoto();
|
||||
photo.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
|
||||
textGradient.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
|
||||
waypointInfo.setVisibility(View.VISIBLE);
|
||||
@@ -259,8 +255,7 @@ public class MarkerDetailFragment extends Fragment {
|
||||
if (hasPhoto) {
|
||||
handler.removeCallbacks(hideText);
|
||||
Display defaultDisplay = getActivity().getWindowManager().getDefaultDisplay();
|
||||
PhotoUtils.setImageVew(photo, Uri.parse(photoUrl), defaultDisplay.getWidth(),
|
||||
defaultDisplay.getHeight(), true);
|
||||
PhotoUtils.setImageView(photo, waypoint.getPhotoURI(), defaultDisplay.getWidth(), defaultDisplay.getHeight(), true);
|
||||
handler.postDelayed(hideText, HIDE_TEXT_DELAY);
|
||||
}
|
||||
|
||||
|
||||
+4
-8
@@ -169,16 +169,12 @@ public class KmlTrackWriter implements TrackWriter {
|
||||
@Override
|
||||
public void writeWaypoint(Waypoint waypoint) {
|
||||
if (printWriter != null) {
|
||||
String styleName = waypoint.getType() == WaypointType.STATISTICS ? STATISTICS_STYLE
|
||||
: WAYPOINT_STYLE;
|
||||
String photoUrl = waypoint.getPhotoUrl();
|
||||
if (photoUrl != null && !photoUrl.equals("")) {
|
||||
String styleName = waypoint.getType() == WaypointType.STATISTICS ? STATISTICS_STYLE : WAYPOINT_STYLE;
|
||||
if (waypoint.hasPhoto()) {
|
||||
float heading = getHeading(waypoint.getTrackId(), waypoint.getLocation());
|
||||
writePhotoOverlay(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(),
|
||||
styleName, waypoint.getLocation(), photoUrl, heading);
|
||||
writePhotoOverlay(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(), styleName, waypoint.getLocation(), waypoint.getPhotoUrl(), heading);
|
||||
} else {
|
||||
writePlacemark(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(),
|
||||
styleName, waypoint.getLocation());
|
||||
writePlacemark(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(), styleName, waypoint.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -122,9 +122,8 @@ public class KmzTrackExporter implements TrackExporter {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
Waypoint waypoint = myTracksProviderUtils.createWaypoint(cursor);
|
||||
String photoUrl = waypoint.getPhotoUrl();
|
||||
if (photoUrl != null && !photoUrl.equals("")) {
|
||||
addImage(zipOutputStream, photoUrl);
|
||||
if (waypoint.hasPhoto()) {
|
||||
addImage(zipOutputStream, waypoint.getPhotoUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,8 +79,7 @@ public class ListItemUtils {
|
||||
photo.getLayoutParams().height = photoHeight;
|
||||
photo.setImageResource(android.R.color.transparent);
|
||||
Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
|
||||
PhotoUtils.setImageVew(
|
||||
photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), photoHeight, false);
|
||||
PhotoUtils.setImageView(photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), photoHeight, false);
|
||||
}
|
||||
|
||||
// Set icon
|
||||
|
||||
@@ -43,13 +43,10 @@ public class PhotoUtils {
|
||||
* entire image (no cropping). False to fill the entire target area.
|
||||
* (allow cropping).
|
||||
*/
|
||||
public static void setImageVew(
|
||||
ImageView imageView, Uri uri, int targetWidth, int targetHeight, boolean fitWithin) {
|
||||
public static void setImageView(ImageView imageView, Uri uri, int targetWidth, int targetHeight, boolean fitWithin) {
|
||||
if (cancelBitmapLoader(imageView, uri)) {
|
||||
BitmapLoader bitmapLoader = new BitmapLoader(
|
||||
imageView, uri, targetWidth, targetHeight, fitWithin);
|
||||
WeakReference<BitmapLoader> bitmapLoaderReference = new WeakReference<>(
|
||||
bitmapLoader);
|
||||
BitmapLoader bitmapLoader = new BitmapLoader(imageView, uri, targetWidth, targetHeight, fitWithin);
|
||||
WeakReference<BitmapLoader> bitmapLoaderReference = new WeakReference<>(bitmapLoader);
|
||||
imageView.setTag(bitmapLoaderReference);
|
||||
bitmapLoader.execute();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user