@RestrictTo(RestrictTo.Scope.LIBRARY) public Layer layerModelForId(long id) { return layerMap.get(id); }
@Nullable public EpoxyViewHolder get(EpoxyViewHolder holder) { return holders.get(holder.getItemId()); }
@Nullable public EpoxyViewHolder getHolderForModel(EpoxyModel<?> model) { return holders.get(model.id()); }
/** * Looks through the payloads list and returns the first model found with the given model id. This * assumes that the payloads list will only contain objects of type {@link DiffPayload}, and will * throw if an unexpected type is found. */ @Nullable public static EpoxyModel<?> getModelFromPayload(List<Object> payloads, long modelId) { if (payloads.isEmpty()) { return null; } for (Object payload : payloads) { DiffPayload diffPayload = (DiffPayload) payload; if (diffPayload.singleModel != null) { if (diffPayload.singleModel.id() == modelId) { return diffPayload.singleModel; } } else { EpoxyModel<?> modelForId = diffPayload.modelsById.get(modelId); if (modelForId != null) { return modelForId; } } } return null; }
private Drawable getCachedDrawable(LongSparseArray<WeakReference<Drawable.ConstantState>> cache, long key) { synchronized (mAccessLock) { WeakReference<Drawable.ConstantState> wr = cache.get(key); if (wr != null) { Drawable.ConstantState entry = wr.get(); if (entry != null) { return entry.newDrawable(this); } else { cache.delete(key); } } } return null; }
private static Drawable getCachedDrawable(LongSparseArray<WeakReference<Drawable.ConstantState>> cache, long key, Resources res) { synchronized (mAccessLock) { WeakReference<Drawable.ConstantState> wr = cache.get(key); if (wr != null) { Drawable.ConstantState entry = wr.get(); if (entry != null) { return entry.newDrawable(res); } else { cache.delete(key); } } } return null; }
private LinearGradient getLinearGradient() { int gradientHash = getGradientHash(); LinearGradient gradient = linearGradientCache.get(gradientHash); if (gradient != null) { return gradient; } PointF startPoint = startPointAnimation.getValue(); PointF endPoint = endPointAnimation.getValue(); GradientColor gradientColor = colorAnimation.getValue(); int[] colors = gradientColor.getColors(); float[] positions = gradientColor.getPositions(); int x0 = (int) (boundsRect.left + boundsRect.width() / 2 + startPoint.x); int y0 = (int) (boundsRect.top + boundsRect.height() / 2 + startPoint.y); int x1 = (int) (boundsRect.left + boundsRect.width() / 2 + endPoint.x); int y1 = (int) (boundsRect.top + boundsRect.height() / 2 + endPoint.y); gradient = new LinearGradient(x0, y0, x1, y1, colors, positions, Shader.TileMode.CLAMP); linearGradientCache.put(gradientHash, gradient); return gradient; }
private RadialGradient getRadialGradient() { int gradientHash = getGradientHash(); RadialGradient gradient = radialGradientCache.get(gradientHash); if (gradient != null) { return gradient; } PointF startPoint = startPointAnimation.getValue(); PointF endPoint = endPointAnimation.getValue(); GradientColor gradientColor = colorAnimation.getValue(); int[] colors = gradientColor.getColors(); float[] positions = gradientColor.getPositions(); int x0 = (int) (boundsRect.left + boundsRect.width() / 2 + startPoint.x); int y0 = (int) (boundsRect.top + boundsRect.height() / 2 + startPoint.y); int x1 = (int) (boundsRect.left + boundsRect.width() / 2 + endPoint.x); int y1 = (int) (boundsRect.top + boundsRect.height() / 2 + endPoint.y); float r = (float) Math.hypot(x1 - x0, y1 - y0); gradient = new RadialGradient(x0, y0, r, colors, positions, Shader.TileMode.CLAMP); radialGradientCache.put(gradientHash, gradient); return gradient; }
private LinearGradient getLinearGradient() { int gradientHash = getGradientHash(); LinearGradient gradient = linearGradientCache.get(gradientHash); if (gradient != null) { return gradient; } PointF startPoint = startPointAnimation.getValue(); PointF endPoint = endPointAnimation.getValue(); GradientColor gradientColor = colorAnimation.getValue(); int[] colors = gradientColor.getColors(); float[] positions = gradientColor.getPositions(); gradient = new LinearGradient(startPoint.x, startPoint.y, endPoint.x, endPoint.y, colors, positions, Shader.TileMode.CLAMP); linearGradientCache.put(gradientHash, gradient); return gradient; }
private RadialGradient getRadialGradient() { int gradientHash = getGradientHash(); RadialGradient gradient = radialGradientCache.get(gradientHash); if (gradient != null) { return gradient; } PointF startPoint = startPointAnimation.getValue(); PointF endPoint = endPointAnimation.getValue(); GradientColor gradientColor = colorAnimation.getValue(); int[] colors = gradientColor.getColors(); float[] positions = gradientColor.getPositions(); float x0 = startPoint.x; float y0 = startPoint.y; float x1 = endPoint.x; float y1 = endPoint.y; float r = (float) Math.hypot(x1 - x0, y1 - y0); if (r <= 0) { r = 0.001f; } gradient = new RadialGradient(x0, y0, r, colors, positions, Shader.TileMode.CLAMP); radialGradientCache.put(gradientHash, gradient); return gradient; }
/** * Gets the {@link SceneObject} that's being used to render the star with the given ID, or if * the given star isn't being rendered by us, returns null. */ @Nullable public SceneObject getStarSceneObject(long starId) { return sceneObjects.get(starId); }
private boolean isLoaded(Calendar start) { return loadedEvents.get(start.getTimeInMillis()) != null; }
@Override public List<WeekViewDisplayable<WidgetCalendarItem>> onMonthChange(Calendar startDate, Calendar endDate) { if (!isLoaded(startDate)) { loadEventsInBackground(startDate, endDate); return new ArrayList<>(); } return loadedEvents.get(startDate.getTimeInMillis()); }
/** Sets the star we have selected to the given value (or unselects if star is null). */ public void setSelectedStar(@Nullable Star star) { if (star != null) { selectionIndicatorSceneObject.setSize(60, 60); SceneObject sceneObject = sceneObjects.get(star.id); sceneObject.addChild(selectionIndicatorSceneObject); } else if (selectionIndicatorSceneObject.getParent() != null) { selectionIndicatorSceneObject.getParent().removeChild(selectionIndicatorSceneObject); } selectedFleet = null; selectedStar = star; for (TapListener tapListener : tapListeners) { tapListener.onStarTapped(star); } }
if (fleet != null) { selectionIndicatorSceneObject.setSize(60, 60); SceneObject sceneObject = sceneObjects.get(fleet.id); if (sceneObject != null) { sceneObject.addChild(selectionIndicatorSceneObject);
SceneObject container = sceneObjects.get(fleet.id); if (container == null) { container = new SceneObject(scene.getDimensionResolver());
SceneObject container = sceneObjects.get(star.id); if (container == null) { container = new SceneObject(scene.getDimensionResolver());