private static void cacheDrawable(TypedValue value, Resources resources, Resources.Theme theme, boolean isColorDrawable, long key, Drawable drawable, LongSparseArray<WeakReference<Drawable.ConstantState>> caches) { Drawable.ConstantState cs = drawable.getConstantState(); if (cs == null) { return; } synchronized (mAccessLock) { caches.put(key, new WeakReference<>(cs)); } }
public void put(EpoxyViewHolder holder) { holders.put(holder.getItemId(), holder); }
private void cacheDrawable(TypedValue value, Resources.Theme theme, boolean isColorDrawable, long key, Drawable drawable, LongSparseArray<WeakReference<Drawable.ConstantState>> caches) { Drawable.ConstantState cs = drawable.getConstantState(); if (cs == null) { return; } synchronized (mAccessLock) { caches.put(key, new WeakReference<>(cs)); } }
DiffPayload(List<? extends EpoxyModel<?>> models) { if (models.isEmpty()) { throw new IllegalStateException("Models must not be empty"); } int modelCount = models.size(); if (modelCount == 1) { // Optimize for the common case of only one model changed. singleModel = models.get(0); modelsById = null; } else { singleModel = null; modelsById = new LongSparseArray<>(modelCount); for (EpoxyModel<?> model : models) { modelsById.put(model.id(), model); } } }
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 static void parseLayers(JsonReader reader, LottieComposition composition, List<Layer> layers, LongSparseArray<Layer> layerMap) throws IOException { int imageCount = 0; reader.beginArray(); while (reader.hasNext()) { Layer layer = LayerParser.parse(reader, composition); if (layer.getLayerType() == Layer.LayerType.Image) { imageCount++; } layers.add(layer); layerMap.put(layer.getId(), layer); if (imageCount > 4) { L.warn("You have " + imageCount + " images. Lottie should primarily be " + "used with shapes. If you are using Adobe Illustrator, convert the Illustrator layers" + " to shape layers."); } } reader.endArray(); }
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; }
continue; layerMap.put(layer.getLayerModel().getId(), layer); if (mattedLayer != null) { mattedLayer.setMatteLayer(layer);
while (reader.hasNext()) { Layer layer = LayerParser.parse(reader, composition); layerMap.put(layer.getId(), layer); layers.add(layer);
private void loadEventsInBackground(final Calendar start, final Calendar end) { // Populate the week view with the events of the month to display new Thread(() -> { DateTimeFormatter format = DateTimeFormat.forPattern("yyyyMMdd") .withLocale(Locale.getDefault()); DateTime startTime = new DateTime(start); DateTime endTime = new DateTime(end); String formattedStartTime = format.print(startTime); String formattedEndTime = format.print(endTime); // Convert to the proper type final List<WeekViewDisplayable<WidgetCalendarItem>> events = fetchEventList(roomApiCode, formattedStartTime, formattedEndTime); requireActivity().runOnUiThread(() -> { loadedEvents.put(start.getTimeInMillis(), events); mWeekView.notifyDataSetChanged(); }); }).start(); }
public void setItemChecked(int position, boolean value) { // Start selection mode if needed. We don't need to if we're unchecking something. if (value) { startSupportActionModeIfNeeded(); } boolean oldValue = checkStates.get(position); checkStates.put(position, value); if (oldValue != value) { final long id = adapter.getItemId(position); if (checkedIdStates != null) { if (value) { checkedIdStates.put(id, position); } else { checkedIdStates.delete(id); } } if (value) { checkedItemCount++; } else { checkedItemCount--; } adapter.notifyItemChanged(position, SELECTION_PAYLOAD); if (choiceActionMode != null) { multiChoiceModeCallback.onItemCheckedStateChanged(choiceActionMode, position, id, value); if (checkedItemCount == 0) { choiceActionMode.finish(); } } } }
sceneObjects.put(fleet.id, container);
sceneObjects.put(star.id, container);