public static int getChildIndex(ViewParent parent, View child) {
        try {
            if (!(parent instanceof ViewGroup)) {
                return -1;
            }
            ViewGroup viewParent = (ViewGroup) parent;
            final String childIdName = SAViewUtils.getViewId(child);

            String childClassName = SnapCache.getInstance().getCanonicalName(child.getClass());
            int index = 0;
            for (int i = 0; i < viewParent.getChildCount(); i++) {
                View brother = viewParent.getChildAt(i);
                if (!Pathfinder.hasClassName(brother, childClassName)) {
                    continue;
                }
                String brotherIdName = SAViewUtils.getViewId(brother);
                if (null != childIdName && !childIdName.equals(brotherIdName)) {
                    index++;
                    continue;
                }
                if (brother == child) {
                    return index;
                }
                index++;
            }
            return -1;
        } catch (Exception e) {
            SALog.printStackTrace(e);
            return -1;
        }
    }
@Test
    public void getChildIndex() {
        LinearLayout linearLayout = new LinearLayout(mApplication);
        TextView textView1 = new TextView(mApplication);
        textView1.setText("child1");
        TextView textView2 = new TextView(mApplication);
        textView2.setText("child2");
        linearLayout.addView(textView1);
        linearLayout.addView(textView2);
        Assert.assertEquals(0, SAViewUtils.getChildIndex(linearLayout, textView1));
        Assert.assertEquals(1, SAViewUtils.getChildIndex(linearLayout, textView2));
    }