Remove unnecessary setters from GpxDataItem
This commit is contained in:
parent
4eabba3489
commit
b7c1fe6ba7
5 changed files with 32 additions and 56 deletions
|
@ -1,6 +1,8 @@
|
|||
|
||||
package net.osmand;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -1540,8 +1542,8 @@ public class GPXUtilities {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void setGradientScaleType(GradientScaleType gradientScaleType) {
|
||||
getExtensionsToWrite().put("gradient_scale_type", gradientScaleType != null ? gradientScaleType.name() : null);
|
||||
public void setGradientScaleType(@NotNull GradientScaleType gradientScaleType) {
|
||||
getExtensionsToWrite().put("gradient_scale_type", gradientScaleType.name());
|
||||
}
|
||||
|
||||
public GpxSplitType getSplitType() {
|
||||
|
@ -1558,8 +1560,8 @@ public class GPXUtilities {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void setSplitType(GpxSplitType gpxSplitType) {
|
||||
getExtensionsToWrite().put("split_type", gpxSplitType != null ? gpxSplitType.name() : null);
|
||||
public void setSplitType(@NotNull GpxSplitType gpxSplitType) {
|
||||
getExtensionsToWrite().put("split_type", gpxSplitType.name());
|
||||
}
|
||||
|
||||
public double getSplitInterval() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile.GradientScaleType;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.IndexConstants;
|
||||
|
@ -198,6 +199,22 @@ public class GPXDatabase {
|
|||
this.color = color;
|
||||
}
|
||||
|
||||
public GpxDataItem(File file, @NonNull GPXUtilities.GPXFile gpxFile) {
|
||||
this.file = file;
|
||||
color = gpxFile.getColor(0);
|
||||
width = gpxFile.getWidth(null);
|
||||
showArrows = gpxFile.isShowArrows();
|
||||
showStartFinish = gpxFile.isShowStartFinish();
|
||||
gradientScaleType = gpxFile.getGradientScaleType();
|
||||
gradientSpeedColor = gpxFile.getGradientScaleColor(GradientScaleType.SPEED, 0);
|
||||
gradientSlopeColor = gpxFile.getGradientScaleColor(GradientScaleType.SLOPE, 0);
|
||||
gradientAltitudeColor = gpxFile.getGradientScaleColor(GradientScaleType.ALTITUDE, 0);
|
||||
if (gpxFile.getSplitType() != null && gpxFile.getSplitInterval() != 0) {
|
||||
splitType = gpxFile.getSplitType().getType();
|
||||
splitInterval = gpxFile.getSplitInterval();
|
||||
}
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
@ -215,41 +232,22 @@ public class GPXDatabase {
|
|||
return gradientScaleType;
|
||||
}
|
||||
|
||||
public void setGradientScaleType(GradientScaleType gradientScaleType) {
|
||||
this.gradientScaleType = gradientScaleType;
|
||||
}
|
||||
|
||||
public int getGradientSpeedColor() {
|
||||
return gradientSpeedColor;
|
||||
}
|
||||
|
||||
public void setGradientSpeedColor(int gradientSpeedColor) {
|
||||
this.gradientSpeedColor = gradientSpeedColor;
|
||||
}
|
||||
|
||||
public int getGradientAltitudeColor() {
|
||||
return gradientAltitudeColor;
|
||||
}
|
||||
|
||||
public void setGradientAltitudeColor(int gradientAltitudeColor) {
|
||||
this.gradientAltitudeColor = gradientAltitudeColor;
|
||||
}
|
||||
|
||||
public int getGradientSlopeColor() {
|
||||
return gradientSlopeColor;
|
||||
}
|
||||
|
||||
public void setGradientSlopeColor(int gradientSlopeColor) {
|
||||
this.gradientSlopeColor = gradientSlopeColor;
|
||||
}
|
||||
|
||||
public String getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(String width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public long getFileLastModifiedTime() {
|
||||
return fileLastModifiedTime;
|
||||
|
@ -283,26 +281,14 @@ public class GPXDatabase {
|
|||
return joinSegments;
|
||||
}
|
||||
|
||||
public void setJoinSegments(boolean joinSegments) {
|
||||
this.joinSegments = joinSegments;
|
||||
}
|
||||
|
||||
public boolean isShowArrows() {
|
||||
return showArrows;
|
||||
}
|
||||
|
||||
public void setShowArrows(boolean showArrows) {
|
||||
this.showArrows = showArrows;
|
||||
}
|
||||
|
||||
public boolean isShowStartFinish() {
|
||||
return showStartFinish;
|
||||
}
|
||||
|
||||
public void setShowStartFinish(boolean showStartFinish) {
|
||||
this.showStartFinish = showStartFinish;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return file != null ? file.hashCode() : 0;
|
||||
|
@ -562,7 +548,7 @@ public class GPXDatabase {
|
|||
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_ARROWS + " = ? " +
|
||||
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||
new Object[] {showArrows ? 1 : 0, fileName, fileDir});
|
||||
item.setShowArrows(showArrows);
|
||||
item.showArrows = showArrows;
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
@ -580,7 +566,7 @@ public class GPXDatabase {
|
|||
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_START_FINISH + " = ? " +
|
||||
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||
new Object[] {showStartFinish ? 1 : 0, fileName, fileDir});
|
||||
item.setShowStartFinish(showStartFinish);
|
||||
item.showStartFinish = showStartFinish;
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
@ -636,7 +622,7 @@ public class GPXDatabase {
|
|||
GPX_COL_JOIN_SEGMENTS + " = ? " +
|
||||
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||
new Object[]{joinSegments ? 1 : 0, fileName, fileDir});
|
||||
item.setJoinSegments(joinSegments);
|
||||
item.joinSegments = joinSegments;
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ public class GpxDbHelper {
|
|||
}
|
||||
|
||||
private void readGpxItem(@NonNull File gpxFile, @Nullable GpxDataItem item, @Nullable GpxDataItemCallback callback) {
|
||||
readingItemsMap.put(gpxFile, item != null ? item : new GpxDataItem(null, null));
|
||||
readingItemsMap.put(gpxFile, item != null ? item : new GpxDataItem(null, (GPXTrackAnalysis) null));
|
||||
if (callback != null) {
|
||||
readingItemsCallbacks.put(gpxFile, callback);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXFile.GradientScaleType;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
|
@ -33,7 +32,7 @@ import net.osmand.data.FavouritePoint.BackgroundType;
|
|||
import net.osmand.plus.AppInitializer;
|
||||
import net.osmand.plus.CustomOsmandPlugin;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXDatabase;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -1018,21 +1017,10 @@ public class ImportHelper {
|
|||
gpxFile.path = toWrite.getAbsolutePath();
|
||||
File file = new File(gpxFile.path);
|
||||
if (!destinationExists) {
|
||||
GPXDatabase.GpxDataItem item = new GPXDatabase.GpxDataItem(file, gpxFile.getColor(0));
|
||||
item.setWidth(gpxFile.getWidth(null));
|
||||
item.setShowArrows(gpxFile.isShowArrows());
|
||||
item.setShowStartFinish(gpxFile.isShowStartFinish());
|
||||
item.setGradientScaleType(gpxFile.getGradientScaleType());
|
||||
item.setGradientSpeedColor(gpxFile.getGradientScaleColor(GradientScaleType.SPEED, 0));
|
||||
item.setGradientSlopeColor(gpxFile.getGradientScaleColor(GradientScaleType.SLOPE, 0));
|
||||
item.setGradientAltitudeColor(gpxFile.getGradientScaleColor(GradientScaleType.ALTITUDE, 0));
|
||||
GpxDataItem item = new GpxDataItem(file, gpxFile);
|
||||
app.getGpxDbHelper().add(item);
|
||||
|
||||
if (gpxFile.getSplitType() != null && gpxFile.getSplitInterval() != 0) {
|
||||
app.getGpxDbHelper().updateSplit(item, gpxFile.getSplitType(), gpxFile.getSplitInterval());
|
||||
}
|
||||
} else {
|
||||
GPXDatabase.GpxDataItem item = app.getGpxDbHelper().getItem(file);
|
||||
GpxDataItem item = app.getGpxDbHelper().getItem(file);
|
||||
if (item != null) {
|
||||
app.getGpxDbHelper().clearAnalysis(item);
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
shadowPaint.setStrokeWidth(paint.getStrokeWidth() + 2 * shadowRadius);
|
||||
}
|
||||
for (String key : cachedTrackWidth.keySet()) {
|
||||
searchTrackWidth(key, rrs, req, rc);
|
||||
acquireTrackWidth(key, rrs, req, rc);
|
||||
}
|
||||
} else {
|
||||
log.error("Rendering attribute gpx is not found !");
|
||||
|
@ -284,7 +284,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
return cachedColor;
|
||||
}
|
||||
|
||||
private void searchTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
|
||||
private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
|
||||
if (!Algorithms.isEmpty(widthKey) && Algorithms.isInt(widthKey)) {
|
||||
try {
|
||||
int widthDp = Integer.parseInt(widthKey);
|
||||
|
|
Loading…
Reference in a new issue