new LongSparseArray<>(composition.getLayers().size()); continue; layerMap.put(layer.getLayerModel().getId(), layer); if (mattedLayer != null) { mattedLayer.setMatteLayer(layer); for (int i = 0; i < layerMap.size(); i++) { long key = layerMap.keyAt(i); BaseLayer layerView = layerMap.get(key); continue; BaseLayer parentLayer = layerMap.get(layerView.getLayerModel().getParentId()); if (parentLayer != null) { layerView.setParentLayer(parentLayer);
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; }
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; }
@RestrictTo(RestrictTo.Scope.LIBRARY) public Layer layerModelForId(long id) { return layerMap.get(id); }
checkedIdStates.clear(); for (int checkedIndex = 0; checkedIndex < checkedIdStates.size(); checkedIndex++) { final long id = checkedIdStates.keyAt(checkedIndex); final int lastPos = checkedIdStates.valueAt(checkedIndex); found = true; checkStates.put(searchPos, true); checkedIdStates.setValueAt(checkedIndex, searchPos); break; checkedIdStates.delete(id); checkedIndex--; checkedItemCount--;
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)); } }
private LottieComposition createComposition(int startFrame, int endFrame) { LottieComposition composition = new LottieComposition(); composition.init(new Rect(), startFrame, endFrame, 1000, new ArrayList<Layer>(), new LongSparseArray<Layer>(0), new HashMap<String, List<Layer>>(0), new HashMap<String, LottieImageAsset>(0), new SparseArrayCompat<FontCharacter>(0), new HashMap<String, Font>(0)); return composition; }
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(); } } } }
@Override public void run() { synchronized (scene.lock) { for (int i = 0; i < sceneObjects.size(); i++) { SceneObjectInfo sceneObjectInfo = (SceneObjectInfo) sceneObjects.valueAt(i).getTag(); if (sceneObjectInfo != null && sceneObjectInfo.fleet != null) { updateMovingFleet(sceneObjects.valueAt(i)); } } } App.i.getTaskRunner().runTask( updateMovingFleetsRunnable, Threads.UI, UPDATE_MOVING_FLEETS_TIME_MS); } };
SavedState(Parcel in) { checkedItemCount = in.readInt(); checkStates = in.readSparseBooleanArray(); final int n = in.readInt(); if (n >= 0) { checkedIdStates = new LongSparseArray<>(n); for (int i = 0; i < n; i++) { final long key = in.readLong(); final int value = in.readInt(); checkedIdStates.append(key, value); } } }
@Override public boolean hasNext() { return position < holders.size(); }
@Override public EpoxyViewHolder next() { if (!hasNext()) { throw new NoSuchElementException(); } return holders.valueAt(position++); }
public void remove(EpoxyViewHolder holder) { holders.remove(holder.getItemId()); }
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; }
@Nullable public EpoxyViewHolder getHolderForModel(EpoxyModel<?> model) { return holders.get(model.id()); }
LongSparseArray<Layer> layerMap = new LongSparseArray<>(); while (reader.hasNext()) { Layer layer = LayerParser.parse(reader, composition); layerMap.put(layer.getId(), layer); layers.add(layer);
public void put(EpoxyViewHolder holder) { holders.put(holder.getItemId(), holder); }