Skip to content

Commit

Permalink
Cancel delayed transitions when InstructionView is detached (#885)
Browse files Browse the repository at this point in the history
  • Loading branch information
danesfeder authored Apr 25, 2018
1 parent f38d86b commit 8e81c16
Showing 1 changed file with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ protected void onAttachedToWindow() {
addBottomSheetListener();
}

@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
cancelDelayedTransition();
}

@Override
public void onFeedbackSelected(FeedbackItem feedbackItem) {
navigationViewModel.updateFeedback(feedbackItem);
Expand Down Expand Up @@ -320,6 +326,24 @@ public void showInstructionList() {
rvInstructions.smoothScrollToPosition(TOP);
}

/**
* Sets the locale to use for languages and default unit type
*
* @param locale to use
*/
public void setLocale(@NonNull Locale locale) {
this.locale = locale;
}

/**
* Sets the unit type to use
*
* @param unitType to use
*/
public void setUnitType(@NavigationUnitType.UnitType int unitType) {
this.unitType = unitType;
}

/**
* Inflates this layout needed for this view and initializes the locale as the device locale.
*/
Expand Down Expand Up @@ -807,6 +831,12 @@ private void beginDelayedTransition() {
}
}

private void cancelDelayedTransition() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
clearAnimation();
}
}

private void updateLandscapeConstraintsTo(int layoutRes) {
ConstraintSet collapsed = new ConstraintSet();
collapsed.clone(getContext(), layoutRes);
Expand All @@ -821,22 +851,4 @@ private void updateLandscapeConstraintsTo(int layoutRes) {
private void updateInstructionList(InstructionModel model) {
instructionListAdapter.updateSteps(getContext(), model.getProgress(), locale, unitType);
}

/**
* Sets the locale to use for languages and default unit type
*
* @param locale to use
*/
public void setLocale(@NonNull Locale locale) {
this.locale = locale;
}

/**
* Sets the unit type to use
*
* @param unitType to use
*/
public void setUnitType(@NavigationUnitType.UnitType int unitType) {
this.unitType = unitType;
}
}

0 comments on commit 8e81c16

Please sign in to comment.