// Path: indicator/src/main/java/com/fuzz/indicator/cell/CutoutCell.java
// public interface CutoutCell {
// 
//     /**
//      * Perform some arbitrary action to represent the provided OffsetEvent.
//      *
//      * @param offsetEvent    whatever just happened
//      * @see OffSetters
//      */
//     void offsetContentBy(@NonNull IndicatorOffsetEvent offsetEvent);
// 
//     /**
//      * @return the actual view represented by this object
//      */
//     @NonNull
//     View getItemView();
// }
// 
// Path: indicator/src/main/java/com/fuzz/indicator/proxy/ProxyReference.java
// public interface ProxyReference {
//     /**
//      * Modifies the passed-in value to represent a valid child position in this
//      * {@link CutoutViewIndicator}.
//      * @param proposed    a proposed position index
//      * @return the corrected value
//      */
//     int fixPosition(int proposed);
// 
// }
// 
// Path: indicator/src/main/java/com/fuzz/indicator/proxy/ViewProvidingStateProxy.java
// public interface ViewProvidingStateProxy extends StateProxy {
//     /**
//      * In some use cases, it may be handy to have a reference to the original
//      * View when binding a representation thereof. See
//      * {@link CutoutCellGenerator#onBindChild(View, CutoutViewLayoutParams, View)}
//      * for details.
//      *
//      * @param cviPosition    position of a child within the CutoutViewIndicator
//      * @return the view which directly inspired the indicator's child
//      */
//     @Nullable
//     View getOriginalViewFor(int cviPosition);
// }


import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.os.Build;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.fuzz.indicator.cell.CutoutCell;
import com.fuzz.indicator.cell.CutoutTextCell;
import com.fuzz.indicator.proxy.IndicatorOffsetEvent;
import com.fuzz.indicator.proxy.ProxyReference;
import com.fuzz.indicator.proxy.StateProxy;
import com.fuzz.indicator.proxy.UnavailableProxy;
import com.fuzz.indicator.proxy.ViewProvidingStateProxy;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
/*
 * Copyright 2016 Philip Cohn-Cort
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.fuzz.indicator;




/**
 * A RecyclerView-inspired ViewGroup for showing an indicator traversing multiple child Views ('cells').
 * <p>
 * There's a nice monospace line drawing in the javadoc for {@link #showOffsetIndicator(int, float)} that basically sums up
 * its appearance when operating under an {@link ImageCellGenerator}.
 * </p>
 *
 * @author Philip Cohn-Cort (Fuzz)
 */
public class CutoutViewIndicator extends LinearLayout implements ProxyReference {

    private static final String TAG = CutoutViewIndicator.class.getSimpleName();

    /**
     * Specialised implementation of {@link UnavailableProxy} for use with
     * {@linkplain #isInEditMode() the preview tools}.
     */
    protected static final UnavailableProxy EDIT_MODE_PROXY = new UnavailableProxy() {
        @Override
        public IndicatorOffsetEvent resendPositionInfo(ProxyReference cvi, float pos) {
            return IndicatorOffsetEvent.from(cvi, pos);
        }
    };

    /**
     * This holds onto the views that may be attached to this ViewGroup. It's initialised
     * with space for 5 values because practical experience says that space for 10 would
     * be excessive.
     * <p>
     *     This is kinda micro-optimising since it can expand automatically later.
     * </p>
     */
    @NonNull
// Path: indicator/src/main/java/com/fuzz/indicator/cell/CutoutCell.java
// public interface CutoutCell {
// 
//     /**
//      * Perform some arbitrary action to represent the provided OffsetEvent.
//      *
//      * @param offsetEvent    whatever just happened
//      * @see OffSetters
//      */
//     void offsetContentBy(@NonNull IndicatorOffsetEvent offsetEvent);
// 
//     /**
//      * @return the actual view represented by this object
//      */
//     @NonNull
//     View getItemView();
// }
// 
// Path: indicator/src/main/java/com/fuzz/indicator/proxy/ProxyReference.java
// public interface ProxyReference {
//     /**
//      * Modifies the passed-in value to represent a valid child position in this
//      * {@link CutoutViewIndicator}.
//      * @param proposed    a proposed position index
//      * @return the corrected value
//      */
//     int fixPosition(int proposed);
// 
// }
// 
// Path: indicator/src/main/java/com/fuzz/indicator/proxy/ViewProvidingStateProxy.java
// public interface ViewProvidingStateProxy extends StateProxy {
//     /**
//      * In some use cases, it may be handy to have a reference to the original
//      * View when binding a representation thereof. See
//      * {@link CutoutCellGenerator#onBindChild(View, CutoutViewLayoutParams, View)}
//      * for details.
//      *
//      * @param cviPosition    position of a child within the CutoutViewIndicator
//      * @return the view which directly inspired the indicator's child
//      */
//     @Nullable
//     View getOriginalViewFor(int cviPosition);
// }


// Path: indicator/src/main/java/com/fuzz/indicator/CutoutViewIndicator.java
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.os.Build;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.fuzz.indicator.cell.CutoutCell;
import com.fuzz.indicator.cell.CutoutTextCell;
import com.fuzz.indicator.proxy.IndicatorOffsetEvent;
import com.fuzz.indicator.proxy.ProxyReference;
import com.fuzz.indicator.proxy.StateProxy;
import com.fuzz.indicator.proxy.UnavailableProxy;
import com.fuzz.indicator.proxy.ViewProvidingStateProxy;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

/*
 * Copyright 2016 Philip Cohn-Cort
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.fuzz.indicator;




/**
 * A RecyclerView-inspired ViewGroup for showing an indicator traversing multiple child Views ('cells').
 * <p>
 * There's a nice monospace line drawing in the javadoc for {@link #showOffsetIndicator(int, float)} that basically sums up
 * its appearance when operating under an {@link ImageCellGenerator}.
 * </p>
 *
 * @author Philip Cohn-Cort (Fuzz)
 */
public class CutoutViewIndicator extends LinearLayout implements ProxyReference {

    private static final String TAG = CutoutViewIndicator.class.getSimpleName();

    /**
     * Specialised implementation of {@link UnavailableProxy} for use with
     * {@linkplain #isInEditMode() the preview tools}.
     */
    protected static final UnavailableProxy EDIT_MODE_PROXY = new UnavailableProxy() {
        @Override
        public IndicatorOffsetEvent resendPositionInfo(ProxyReference cvi, float pos) {
            return IndicatorOffsetEvent.from(cvi, pos);
        }
    };

    /**
     * This holds onto the views that may be attached to this ViewGroup. It's initialised
     * with space for 5 values because practical experience says that space for 10 would
     * be excessive.
     * <p>
     *     This is kinda micro-optimising since it can expand automatically later.
     * </p>
     */
    @NonNull
    protected SparseArray<CutoutCell> cells = new SparseArray<>(5);