-- applyToLapsedCardState(...)
766352
function applyToLapsedCardState(prev: LapsedCardState, ts: Date, rating: Rating): CardState {
  if (rating === 'easy' || (rating.match(/^easy|good$/) && prev.consecutiveCorrect > 0)) {
    return {
      master: prev.master,
      combination: prev.combination,

      mode: 'reviewing',
      factor: prev.factor,
      lapses: prev.lapses,
      interval: prev.consecutiveCorrect > 0 ? INITIAL_DAYS_WITHOUT_JUMP : INITIAL_DAYS_WITH_JUMP,
      lastReviewed: ts,
    };
  }
  return {
    master: prev.master,
    combination: prev.combination,

    mode: 'lapsed',
    factor: prev.factor,
    lapses: prev.lapses,
    interval: prev.interval,
    lastReviewed: ts,
    consecutiveCorrect: rating === 'again' ? 0 : prev.consecutiveCorrect + 1,
  };
}
1276892
void applyAttachment() {
		if (body == null || staticLight) return;
		
		restorePosition.setToTranslation(bodyPosition);
		rotateAroundZero.setToRotationRad(bodyAngle + bodyAngleOffset);
		for (int i = 0; i < rayNum; i++) {
			tmpVec.set(startX[i], startY[i]).mul(rotateAroundZero).mul(restorePosition);
			startX[i] = tmpVec.x;
			startY[i] = tmpVec.y;
			tmpVec.set(endX[i], endY[i]).mul(rotateAroundZero).mul(restorePosition);
			endX[i] = tmpVec.x;
			endY[i] = tmpVec.y;
		}
	}
977488
public void putViewState(@NonNull String viewId,
      @NonNull Object viewState) {

    if (viewId == null) {
      throw new NullPointerException("ViewId is null");
    }

    if (viewState == null) {
      throw new NullPointerException("ViewState is null");
    }

    PresenterHolder presenterHolder = presenterMap.get(viewId);
    if (presenterHolder == null) {
      presenterHolder = new PresenterHolder();
      presenterHolder.viewState = viewState;
      presenterMap.put(viewId, presenterHolder);
    } else {
      presenterHolder.viewState = viewState;
    }
  }
180890
public void changeCurrentAppState(String state) {

        String completeState = m_navigationStateManager.getState();
        String view = getViewName(completeState);
        String newCompleteState = view;
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(state)) {
            newCompleteState += NavigationState.PARAM_SEPARATOR + state;
        }
        m_navigationStateManager.setState(newCompleteState);

    }
415705
private void postTouchEvent(TouchState state, int eventType) {
        Window window = state.getWindow(false, null);
        View view = window == null ? null : window.getView();
        if (view != null) {
            switch (state.getPointCount()) {
                case 0:
                    postNoPoints(view);
                    break;
                case 1:
                    postPoint(window, view, eventType, state.getPoint(0));
                    break;
                default: {
                    int count = state.getPointCount();
                    int[] states = new int[count];
                    int[] ids = new int[count];
                    int[] xs = new int[count];
                    int[] ys = new int[count];
                    for (int i = 0; i < count; i++) {
                        states[i] = eventType;
                        TouchState.Point p = state.getPoint(i);
                        ids[i] = p.id;
                        xs[i] = p.x;
                        ys[i] = p.y;
                    }
                    postPoints(window, view, states, ids, xs, ys);
                }
            }
        }
    }
985524
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    recoverDraggablePanelState(savedInstanceState);
    loadLastPlaceClicked(savedInstanceState);
  }
116223
def setCollapsed(self, state):
        
        if state == self._collapsed:
            return False
        
        self._collapsed = state
        self.refreshButton()
        
        if not self.signalsBlocked():
            self.collapseToggled.emit(state)
        
        return True
1251369
private int addState(Label reattachPoint, Statement restore) {
    ReattachState create = ReattachState.create(reattachPoint, restore);
    reattaches.add(create);
    int state = reattaches.size() - 1; // the index of the ReattachState in the list
    return state;
  }
749536
function update (state) {
    assert.ifError(inRenderingTransaction, 'infinite loop detected')

    // request a redraw for next frame
    if (currentState === null && !redrawScheduled) {
      redrawScheduled = true

      raf(function redraw () {
        redrawScheduled = false
        if (!currentState) return

        inRenderingTransaction = true
        var newTree = view(currentState)
        const patches = vdom.diff(tree, newTree)
        inRenderingTransaction = false

        target = vdom.patch(target, patches)
        tree = newTree
        currentState = null
      })
    }

    // update data for redraw
    currentState = state
  }
925312
private void recoverDraggablePanelState(Bundle savedInstanceState) {
    final DraggableState draggableState =
        (DraggableState) savedInstanceState.getSerializable(DRAGGABLE_PANEL_STATE);
    if (draggableState == null) {
      draggablePanel.setVisibility(View.GONE);
      return;
    }
    updateDraggablePanelStateDelayed(draggableState);
  }
511024
protected void didStartup ()
    {
        // let our delegates know that we've started up
        applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
            @Override
            public void apply (PlaceManagerDelegate delegate) {
                delegate.didStartup(_plobj);
            }
        });
    }
960405
private void updateDrawableBounds() {
        if (mDrawableRect == null) {
            mDrawableRect = new RectF();
        }
        Drawable d = getDrawable();
        if (d != null && d.getIntrinsicHeight() > 0 && d.getIntrinsicWidth() > 0) {
            mDrawableRect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
        }
    }
37228
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
    public void apply() {
        if (editing == null) {
            return;
        }
        try {
            editing.apply();
        } catch (Exception ex) {
            editing.commit(); // Fallback in case low api lever.
        }
        editing = null;
    }
169364
public static void applyToOrTransparent(ColorHolder colorHolder, Context ctx, GradientDrawable gradientDrawable) {
        if (colorHolder != null && gradientDrawable != null) {
            colorHolder.applyTo(ctx, gradientDrawable);
        } else if (gradientDrawable != null) {
            gradientDrawable.setColor(Color.TRANSPARENT);
        }
    }
698494
private void pushState(int indentation) {
        states.push(state);
        state = new StreamStatus();
        state.setIndentationLevel(indentation);
    }
114201
public void applyExtrusions() {
        for( int i = 0; i < dwgObjects.size(); i++ ) {
            DwgObject dwgObject = (DwgObject) dwgObjects.get(i);
            if (dwgObject instanceof DwgArc) {
                double[] arcCenter = ((DwgArc) dwgObject).getCenter();
                double[] arcExt = ((DwgArc) dwgObject).getExtrusion();
                arcCenter = AcadExtrusionCalculator.CalculateAcadExtrusion(arcCenter, arcExt);
                ((DwgArc) dwgObject).setCenter(arcCenter);
            } else if (dwgObject instanceof DwgAttdef) {
                // Extrusion in DwgAttdef is not necessary
            } else if (dwgObject instanceof DwgAttrib) {
                Point2D attribInsertionPoint = ((DwgAttrib) dwgObject).getInsertionPoint();
                double attribElevation = ((DwgAttrib) dwgObject).getElevation();
                double[] attribInsertionPoint3D = new double[]{attribInsertionPoint.getX(),
                        attribInsertionPoint.getY(), attribElevation};
                double[] attribExt = ((DwgAttrib) dwgObject).getExtrusion();
                attribInsertionPoint3D = AcadExtrusionCalculator.CalculateAcadExtrusion(
                        attribInsertionPoint3D, attribExt);
                ((DwgAttrib) dwgObject).setInsertionPoint(new Point2D.Double(
                        attribInsertionPoint3D[0], attribInsertionPoint3D[1]));
                ((DwgAttrib) dwgObject).setElevation(attribInsertionPoint3D[2]);
            } else if (dwgObject instanceof DwgBlock) {
                // DwgBlock hasn't Extrusion
            } else if (dwgObject instanceof DwgBlockControl) {
                // DwgBlockControl hasn't Extrusion
            } else if (dwgObject instanceof DwgBlockHeader) {
                // DwgBlockHeader hasn't Extrusion
            } else if (dwgObject instanceof DwgCircle) {
                double[] circleCenter = ((DwgCircle) dwgObject).getCenter();
                double[] circleExt = ((DwgCircle) dwgObject).getExtrusion();
                circleCenter = AcadExtrusionCalculator.CalculateAcadExtrusion(circleCenter,
                        circleExt);
                ((DwgCircle) dwgObject).setCenter(circleCenter);
                // Seems that Autocad don't apply the extrusion to Ellipses
                /*} else if (dwgObject instanceof DwgEllipse) {
                 double[] ellipseCenter = ((DwgEllipse)dwgObject).getCenter();
                 double[] ellipseExt = ((DwgEllipse)dwgObject).getExtrusion();
                 ellipseCenter = AcadExtrusionCalculator.CalculateAcadExtrusion(ellipseCenter, ellipseExt);
                 ((DwgEllipse)dwgObject).setCenter(ellipseCenter);*/
            } else if (dwgObject instanceof DwgInsert) {
                double[] insertPoint = ((DwgInsert) dwgObject).getInsertionPoint();
                double[] insertExt = ((DwgInsert) dwgObject).getExtrusion();
                insertPoint = AcadExtrusionCalculator
                        .CalculateAcadExtrusion(insertPoint, insertExt);
                ((DwgInsert) dwgObject).setInsertionPoint(insertPoint);
            } else if (dwgObject instanceof DwgLayer) {
                // DwgLayer hasn't Extrusion
            } else if (dwgObject instanceof DwgLayerControl) {
                // DwgLayerControl hasn't Extrusion
            } else if (dwgObject instanceof DwgLine) {
                double[] lineP1 = ((DwgLine) dwgObject).getP1();
                double[] lineP2 = ((DwgLine) dwgObject).getP2();
                boolean zflag = ((DwgLine) dwgObject).isZflag();
                if (zflag) {
                    // elev = 0.0;
                    lineP1 = new double[]{lineP1[0], lineP1[1], 0.0};
                    lineP2 = new double[]{lineP2[0], lineP2[1], 0.0};
                }
                double[] lineExt = ((DwgLine) dwgObject).getExtrusion();
                lineP1 = AcadExtrusionCalculator.CalculateAcadExtrusion(lineP1, lineExt);
                lineP2 = AcadExtrusionCalculator.CalculateAcadExtrusion(lineP2, lineExt);
                ((DwgLine) dwgObject).setP1(lineP1);
                ((DwgLine) dwgObject).setP2(lineP2);
            } else if (dwgObject instanceof DwgLinearDimension) {
                // TODO: Extrusions in DwgLinearDimension elements
                // TODO: Void LwPolylines are a bug
            } else if (dwgObject instanceof DwgLwPolyline
                    && ((DwgLwPolyline) dwgObject).getVertices() != null) {
                Point2D[] vertices = ((DwgLwPolyline) dwgObject).getVertices();
                double[] lwPolylineExt = ((DwgLwPolyline) dwgObject).getNormal();
                // Normals and Extrusions aren`t the same
                if (lwPolylineExt[0] == 0 && lwPolylineExt[1] == 0 && lwPolylineExt[2] == 0)
                    lwPolylineExt[2] = 1.0;
                double elev = ((DwgLwPolyline) dwgObject).getElevation();
                double[][] lwPolylinePoints3D = new double[vertices.length][3];
                for( int j = 0; j < vertices.length; j++ ) {
                    lwPolylinePoints3D[j][0] = vertices[j].getX();
                    lwPolylinePoints3D[j][1] = vertices[j].getY();
                    lwPolylinePoints3D[j][2] = elev;
                    lwPolylinePoints3D[j] = AcadExtrusionCalculator.CalculateAcadExtrusion(
                            lwPolylinePoints3D[j], lwPolylineExt);
                }
                ((DwgLwPolyline) dwgObject).setElevation(elev);
                for( int j = 0; j < vertices.length; j++ ) {
                    vertices[j] = new Point2D.Double(lwPolylinePoints3D[j][0],
                            lwPolylinePoints3D[j][1]);
                }
                ((DwgLwPolyline) dwgObject).setVertices(vertices);
            } else if (dwgObject instanceof DwgMText) {
                double[] mtextPoint = ((DwgMText) dwgObject).getInsertionPoint();
                double[] mtextExt = ((DwgMText) dwgObject).getExtrusion();
                mtextPoint = AcadExtrusionCalculator.CalculateAcadExtrusion(mtextPoint, mtextExt);
                ((DwgMText) dwgObject).setInsertionPoint(mtextPoint);
            } else if (dwgObject instanceof DwgPoint) {
                double[] point = ((DwgPoint) dwgObject).getPoint();
                double[] pointExt = ((DwgPoint) dwgObject).getExtrusion();
                point = AcadExtrusionCalculator.CalculateAcadExtrusion(point, pointExt);
                ((DwgPoint) dwgObject).setPoint(point);
            } else if (dwgObject instanceof DwgSolid) {
                double[] corner1 = ((DwgSolid) dwgObject).getCorner1();
                double[] corner2 = ((DwgSolid) dwgObject).getCorner2();
                double[] corner3 = ((DwgSolid) dwgObject).getCorner3();
                double[] corner4 = ((DwgSolid) dwgObject).getCorner4();
                double[] solidExt = ((DwgSolid) dwgObject).getExtrusion();
                corner1 = AcadExtrusionCalculator.CalculateAcadExtrusion(corner1, solidExt);
                ((DwgSolid) dwgObject).setCorner1(corner1);
                ((DwgSolid) dwgObject).setCorner2(corner2);
                ((DwgSolid) dwgObject).setCorner3(corner3);
                ((DwgSolid) dwgObject).setCorner4(corner4);
            } else if (dwgObject instanceof DwgSpline) {
                // DwgSpline hasn't Extrusion
            } else if (dwgObject instanceof DwgText) {
                Point2D tpoint = ((DwgText) dwgObject).getInsertionPoint();
                double elev = ((DwgText) dwgObject).getElevation();
                double[] textPoint = new double[]{tpoint.getX(), tpoint.getY(), elev};
                double[] textExt = ((DwgText) dwgObject).getExtrusion();
                textPoint = AcadExtrusionCalculator.CalculateAcadExtrusion(textPoint, textExt);
                ((DwgText) dwgObject).setInsertionPoint(new Point2D.Double(textPoint[0],
                        textPoint[1]));
                ((DwgText) dwgObject).setElevation(elev);
            } else if (dwgObject instanceof DwgPolyline2D
                    && ((DwgPolyline2D) dwgObject).getPts() != null) {
                Point2D[] vertices = ((DwgPolyline2D) dwgObject).getPts();
                double[] polyline2DExt = ((DwgPolyline2D) dwgObject).getExtrusion();
                double elev = ((DwgPolyline2D) dwgObject).getElevation();
                double[][] polylinePoints3D = new double[vertices.length][3];
                for( int j = 0; j < vertices.length; j++ ) {
                    polylinePoints3D[j][0] = vertices[j].getX();
                    polylinePoints3D[j][1] = vertices[j].getY();
                    polylinePoints3D[j][2] = elev;
                    polylinePoints3D[j] = AcadExtrusionCalculator.CalculateAcadExtrusion(
                            polylinePoints3D[j], polyline2DExt);
                }
                ((DwgPolyline2D) dwgObject).setElevation(elev);
                for( int j = 0; j < vertices.length; j++ ) {
                    vertices[j] = new Point2D.Double(polylinePoints3D[j][0], polylinePoints3D[j][1]);
                }
                ((DwgPolyline2D) dwgObject).setPts(vertices);
            } else if (dwgObject instanceof DwgPolyline3D) {
                // DwgPolyline3D hasn't Extrusion
            } else if (dwgObject instanceof DwgVertex2D) {
                // DwgVertex2D hasn't Extrusion
            } else if (dwgObject instanceof DwgVertex3D) {
                // DwgVertex3D hasn't Extrusion
            } else {
                //
            }
        }
    }
934898
public void onSaveInstanceState(Bundle outState) {
    int bottomSheetBehaviorState = summaryBehavior == null ? INVALID_STATE : summaryBehavior.getState();
    boolean isWayNameVisible = wayNameView.getVisibility() == VISIBLE;
    NavigationViewInstanceState navigationViewInstanceState = new NavigationViewInstanceState(
      bottomSheetBehaviorState, recenterBtn.getVisibility(), instructionView.isShowingInstructionList(),
      isWayNameVisible, wayNameView.retrieveWayNameText(), navigationViewModel.isMuted());
    String instanceKey = getContext().getString(R.string.navigation_view_instance_state);
    outState.putParcelable(instanceKey, navigationViewInstanceState);
    outState.putBoolean(getContext().getString(R.string.navigation_running), navigationViewModel.isRunning());
    mapView.onSaveInstanceState(outState);
    saveNavigationMapInstanceState(outState);
  }