@@ -0,0 +1,3412 @@
+/*%0A * Copyright 2016 Philip Cohn-Cort%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.fuzz.indicator.clip;%0A%0Aimport android.graphics.drawable.AnimationDrawable;%0Aimport android.graphics.drawable.Drawable;%0Aimport android.support.annotation.NonNull;%0Aimport android.support.annotation.Nullable;%0Aimport android.support.v4.content.ContextCompat;%0Aimport android.widget.ImageView;%0A%0Aimport com.fuzz.indicator.CutoutImageCell;%0Aimport com.fuzz.indicator.CutoutViewLayoutParams;%0A%0A/**%0A * Extension of %7B@link CutoutImageCell%7D with support for swapping between%0A * %7B@link AnimationDrawable%7Ds and...well, any other sort of Drawable.%0A * %3Cp%3E%0A *     This takes the shape of treating individual frames of an%0A *     AnimationDrawable as different images. Each cell gets a reference%0A *     to the %7B@link #frames complete animation%7D, but only shows the nth%0A *     frame thereof (where n is the current%0A *     %7B@link CutoutViewLayoutParams#position position%7D of that cell in%0A *     the %7B@link com.fuzz.indicator.CutoutViewIndicator CutoutViewIndicator%7D).%0A *     If a cell is rebound at a different position for whatever reason,%0A *     the chosen drawable can be smoothly updated with just one call%0A *     to %7B@link #updateDrawable(CutoutViewLayoutParams)%7D.%0A * %3C/p%3E%0A *%0A * @author Philip Cohn-Cort (Fuzz)%0A */%0Apublic class ExplodingCutoutCell extends CutoutImageCell %7B%0A%0A    @Nullable%0A    protected AnimationDrawable frames;%0A%0A    /**%0A     * Check out the %7B@link ExplodingCutoutCell class javadoc%7D for details on how%0A     * this works.%0A     *%0A     * @param child    the backing view for this cell. It can be retrieved later through%0A     *                 %7B@link #getItemView()%7D%0A     */%0A    public ExplodingCutoutCell(@NonNull ImageView child) %7B%0A        super(child);%0A        if (itemView.getDrawable() instanceof AnimationDrawable) %7B%0A            frames = (AnimationDrawable) itemView.getDrawable();%0A            latestResourceId = ((CutoutViewLayoutParams) itemView.getLayoutParams()).indicatorDrawableId;%0A        %7D else %7B%0A            frames = null;%0A            latestResourceId = 0;%0A        %7D%0A    %7D%0A%0A    @Override%0A    @Nullable%0A    protected Drawable chooseDrawable(@NonNull CutoutViewLayoutParams lp) %7B%0A        Drawable chosen;%0A        if (frames == null %7C%7C lp.position %3C= -1 %7C%7C latestResourceId != lp.indicatorDrawableId) %7B%0A            latestResourceId = lp.indicatorDrawableId;%0A            chosen = ContextCompat.getDrawable(itemView.getContext(), lp.indicatorDrawableId);%0A            if (chosen instanceof AnimationDrawable) %7B%0A                frames = (AnimationDrawable) chosen;%0A            %7D else %7B%0A                frames = null;%0A            %7D%0A        %7D else %7B%0A            chosen = itemView.getDrawable();%0A        %7D%0A%0A        if (frames != null) %7B%0A            int frameIndex = lp.position %25 frames.getNumberOfFrames();%0A            chosen = frames.getFrame(frameIndex);%0A        %7D%0A%0A        return chosen;%0A    %7D%0A%7D%0A

Add new CutoutCell implementation - ExplodingCutoutCell