package com.heinrichreimersoftware.materialintro.view.parallax.util;

import android.support.annotation.FloatRange;
import android.view.View;
import android.view.ViewGroup;

import com.heinrichreimersoftware.materialintro.view.parallax.Parallaxable;

import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

/**
 * Created by meier on 13.06.17.
 */

public class ParallaxUtil {
    private ParallaxUtil() {
        //no instance
    }

    public static List<Parallaxable> findParallaxableChildren(View root) {
        List<Parallaxable> parallaxableChildrenFound = new LinkedList<>();
        Queue<View> queue = new LinkedList<>();
        queue.add(root);
        while (!queue.isEmpty()) {
            View child = queue.remove();
            if (child instanceof Parallaxable) {
                parallaxableChildrenFound.add((Parallaxable) child);
            } else if (child instanceof ViewGroup) {
                ViewGroup viewGroup = (ViewGroup) child;
                for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) {
                    queue.add(viewGroup.getChildAt(i));
                }
            }
        }
        return parallaxableChildrenFound;
    }

    /**
     * sets the provided offset to all items in the parallaxableChildren list
     *
     * @param parallaxableChildren list of items to set offset to
     * @param offset               the offset to assign
     */
    public static void setOffsetToParallaxableList(
            final List<Parallaxable> parallaxableChildren,
            @FloatRange(from = -1.0, to = 1.0) float offset
    ) {
        if (!parallaxableChildren.isEmpty()) {
            for (Parallaxable parallaxable : parallaxableChildren) {
                parallaxable.setOffset(offset);
            }
        }
    }

}

@@ -325,50 +325,8 @@
 e;%0A%0A
-/**%0A * Created by meier on 13.06.17.%0A */%0A%0A
 publ
@@ -381,35 +381,8 @@
 () %7B
-%0A        //no instance%0A    
 %7D%0A%0A 
@@ -1148,12 +1148,11 @@
   * 
-s
+S
 et
-s
  the
@@ -1176,49 +1176,36 @@
 to a
-ll items in the parallaxableChildren list
+ list of parallaxable items.
 %0A   
@@ -1243,24 +1243,28 @@
 hildren 
+The 
 list of 
 items to
@@ -1255,16 +1255,29 @@
 list of 
+parallaxable 
 items to
@@ -1281,16 +1281,20 @@
  to set 
+the 
 offset t
@@ -1294,16 +1294,17 @@
 ffset to
+.
 %0A     * 
@@ -1321,23 +1321,9 @@
 set 
-              t
+T
 he o
@@ -1337,16 +1337,17 @@
 o assign
+.
 %0A     */

Fix typos, reformat code