Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16632 show items on group selection #17404

Merged
merged 12 commits into from
Jun 27, 2023
Merged

Conversation

Corwin-Kh
Copy link
Contributor

No description provided.

@Corwin-Kh Corwin-Kh linked an issue Jun 12, 2023 that may be closed by this pull request
@@ -324,10 +325,17 @@ public void fileVisibilityChanged() {
this.fileVisibilityChanged = true;
}

public void setAndroidAutoPoints(@Nullable Set<PoiUIFilter> points){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setAndroidAutoPoiFilters ?

}
val favoriteGroupsSize = favoriteGroups.size
val limitedFavoriteGroups =
favoriteGroups.subList(0, favoriteGroupsSize.coerceAtMost(contentLimit - 2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why -2 if other screens -1?

public void onDestroy(@NonNull LifecycleOwner owner) {
DefaultLifecycleObserver.super.onDestroy(owner);
getApp().getOsmandMap().getMapLayers().getFavouritesLayer().setAndroidAutoFavouritePoints(null);
getApp().getOsmandMap().refreshMap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we should move this two rows in separate methods in each screen, also add getOsmandMap in base screen class

override fun onCreate(owner: LifecycleOwner) {
super.onCreate(owner)
isLoading = true
loadGpxFilesThread = Thread {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AsyncTask is easier to support than thread, use it and replace isLoading flag with method to check asyncTask

NativeUtilities.clipLineInVisibleRect(mapRenderer, tileBox, center31, marker31);
if (line == null) {
continue;
if (!getMapView().isCarView()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use local variable isCarView from above

@@ -370,7 +384,8 @@ public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode
OsmandApplication app = getApplication();
OsmandSettings settings = app.getSettings();

if (tileBox.getZoom() < 3 || !settings.SHOW_MAP_MARKERS.get()) {
boolean isCarView = getMapView().isCarView();
if ((tileBox.getZoom() < 3 || !settings.SHOW_MAP_MARKERS.get()) && !isCarView || isCarView && Algorithms.isEmpty(androidAutoMarkers)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Markers in AA do not depend on zoom level?

@@ -130,7 +140,20 @@ public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSett
boolean favoritesChanged = this.favoritesChangedTime != favoritesChangedTime;
this.favoritesChangedTime = favoritesChangedTime;

if (hasMapRenderer()) {
if (androidAutoFavouritePoints != null) {
Copy link
Member

@Chumva Chumva Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AA check isn`t necessary as in other places? Also no zoom check?

@@ -337,7 +338,16 @@ private void drawMovableWpt(@NonNull Canvas canvas, @NonNull RotatedTileBox tile
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
super.onPrepareBufferImage(canvas, tileBox, settings);
List<SelectedGpxFile> visibleGPXFiles = new ArrayList<>(selectedGpxHelper.getSelectedGPXFiles());
List<SelectedGpxFile> visibleGPXFiles;
if (getMapView().isCarView()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably getMapView().isCarView() we could move to method in base class

public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvider,
IContextMenuProviderSelection, ContextMenuLayer.IMoveObjectProvider {

private static final Log LOG = PlatformUtil.getLog(FavouritesLayer.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not FavouritesLayer

@@ -58,6 +58,6 @@ abstract class BaseOsmAndAndroidAutoScreen(carContext: CarContext) : Screen(carC
}

companion object {
private const val DEFAULT_CONTENT_LIMIT = 12
private const val DEFAULT_CONTENT_LIMIT = 100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 100? Possible crash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use system value from ConstraintManager. This value limits that value to reduce probability of crash

if (collectionSize == contentLimit) {
break
}
if (contentLimit < 2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically yes. If ConstraintManager gives such value

@@ -111,6 +117,10 @@ public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings)
}
}

public void setAndroidAutoFavouritePoints(@Nullable List<FavouritePoint> points) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad approach. Do not inject AA specific code in layers. For example you may introduce some custom data iterator and assign it to layer(s).

@Chumva Chumva requested a review from alex-osm June 19, 2023 15:25
@@ -25,9 +34,35 @@ class TracksScreen(
private val trackTab: TrackTab
) : BaseOsmAndAndroidAutoScreen(carContext) {
val gpxDbHelper: GpxDbHelper = app.gpxDbHelper
var loadGpxFilesThread: Thread? = null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullable property must be initialized

@@ -48,14 +86,20 @@ class TracksScreen(
}

private fun prepareTrackItems() {
loadedGpxFiles.clear()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible concurrency

}
}
invalidate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it legal to call it in non-ui thread?

@Chumva Chumva merged commit b35c1c9 into master Jun 27, 2023
3 checks passed
@Chumva Chumva deleted the 16632-show_items_on_group_selection branch June 27, 2023 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Landing screen allow to choose data by type – Android Auto
3 participants