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

Update InstructionView with BannerMilestone only with callback #969

Merged
merged 1 commit into from
Jun 6, 2018

Conversation

danesfeder
Copy link
Contributor

Noticed this while testing:
ezgif com-video-to-gif

This PR ensures we only update the InstructionView when the milestone listener is fired and not with every update which is what was happening previously.

I also added the maneuver type and modifier from the BannerText object as well.

@danesfeder danesfeder added bug Defect to be fixed. navigation-ui labels May 23, 2018
@danesfeder danesfeder self-assigned this May 23, 2018
@danesfeder danesfeder added this to the 0.14.0 milestone May 23, 2018
Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

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

When you say

This PR ensures we only update the InstructionView when the milestone listener is fired and not with every update which is what was happening previously.

What do you mean?
Removing updateManeuverView from

navigationViewModel.instructionModel.observe(owner, new Observer<InstructionModel>() {
@Override
public void onChanged(@Nullable InstructionModel model) {
if (model != null) {
updateInstructionData(model);
}
}
});

Also added some nit picks/questions.

@@ -207,7 +206,7 @@ public void onChanged(@Nullable Boolean isOffRoute) {
});

// ViewModel set - click listeners can be set now
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT unnecessary comment

@@ -559,11 +554,11 @@ private void addBottomSheetListener() {
}
}

private void initClickListeners() {
private void initializeClickListeners() {
if (getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about extracting an explaining variable here and simplify the expression?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in #973

@@ -221,19 +220,17 @@ public void onChanged(@Nullable Boolean isOffRoute) {
public void update(RouteProgress routeProgress) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we exposing this using @SuppressWarnings("UnusedDeclaration")? 🤔

No usages found in All Places

Could you clarify how this would be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This API is used when InstructionView is used without a NavigationViewModel. If you wanted to inflate the view separate of NavigationView, you would use this API with a ProgressChangeListener to provide it data.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha. Thanks for clarifying 👍

@@ -682,7 +677,8 @@ private void distanceText(InstructionModel model) {
*
* @param model provides instruction text
*/
private void updateTextInstruction(InstructionModel model) {
private void updateBannerData(InstructionModel model) {
updateManeuverView(model);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we should extract this call from here and make it explicit wherever we call updateBannerData. At a first glance updateBannerData and updateManeuverView seem completely different things to me. Could you clarify?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ManeuverView renders the arrow based on the String maneuver type + modifier data. This is provided in the InstructionModel - maybe updateManeuverViewData would be more clear here?

Copy link
Contributor

Choose a reason for hiding this comment

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

So the ManeuverView is part of the Banner, right? In terms of Views (overall layout), could you clarify what's the Instruction, Banner, Maneuver, etc.? I think it's confusing to me because I don't have the big picture of how it's all glued together.

Copy link
Contributor Author

@danesfeder danesfeder Jun 5, 2018

Choose a reason for hiding this comment

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

device-2018-06-05-133454

@danesfeder
Copy link
Contributor Author

@Guardiola31337 yeah there are two different models that populate the InstructionView: InstructionModel and BannerInstructionModel - the BannerInstructionModel is created from the BannerInstructionMilestone, so it only fires 2-3 times a step depending on the API data. The InstructionModel fires for every Location update and updates more specific info like distance / time remaining.

@danesfeder danesfeder modified the milestones: 0.14.0, 0.15.0 May 30, 2018
@@ -11,21 +11,33 @@

public class BannerInstructionModel extends InstructionModel {

private BannerInstructionMilestone milestone;
private BannerText primaryBannerText;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not necessary. This field is already declared in its parent InstructionModel.

@@ -11,21 +11,33 @@

public class BannerInstructionModel extends InstructionModel {

private BannerInstructionMilestone milestone;
private BannerText primaryBannerText;
private BannerText secondaryBannerText;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here ☝️


public BannerInstructionModel(Context context, BannerInstructionMilestone milestone,
RouteProgress progress, Locale locale, @NavigationUnitType.UnitType int unitType) {
super(context, progress, locale, unitType);
this.milestone = milestone;
primaryBannerText = milestone.getBannerInstructions().primary();
secondaryBannerText = milestone.getBannerInstructions().secondary();
}

@Override
BannerText getPrimaryBannerText() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not necessary. This method no needs to be overridden, it's already declared in its parent InstructionModel.

}

@Override
BannerText getPrimaryBannerText() {
return milestone.getBannerInstructions().primary();
return primaryBannerText;
}

@Override
BannerText getSecondaryBannerText() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here ☝️

@Guardiola31337
Copy link
Contributor

I've noticed the same during my last test drive 👀

resizing_instruction_north

resizing_instruction_south

Hopefully this PR will solve these weird resizing issues 🤞

@danesfeder
Copy link
Contributor Author

@Guardiola31337 anything else needed to address here?

Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

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

@Guardiola31337 anything else needed to address here?

One last minor comment not blocking the PR. Great job @danesfeder 👏

@@ -222,13 +221,12 @@ public void onChanged(@Nullable Boolean isOffRoute) {
public void update(RouteProgress routeProgress) {
if (routeProgress != null && !isRerouting) {
InstructionModel model = new InstructionModel(getContext(), routeProgress, language, unitType);
updateViews(model);
updateTextInstruction(model);
updateDataFromInstructionModel(model);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor comment - what about updateDataFromInstruction(model) and updateDataFromBannerInstruction(model)? I think it'd be better for consistency and it reads well. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Guardiola31337 yeah I like that naming a lot better, thanks 💯

@danesfeder danesfeder merged commit fbda855 into master Jun 6, 2018
@danesfeder danesfeder deleted the dan-intsruction-auto branch June 6, 2018 13:23
@danesfeder danesfeder mentioned this pull request Jun 21, 2018
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defect to be fixed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants