vlonjat-gashi / progress-activity

Easily add loading, empty and error states in your app.
1.02k stars 171 forks source link

contentViews is not Incomplete #5

Open xingag opened 9 years ago

xingag commented 9 years ago

If I want to show empty or error layout ,and want to show a part of widget ,And The layout is a child in other widget . and it take no effect. i think the contentViews is incomplete, it must be include the all child view

xingag commented 9 years ago

<com.vlonjatg.progressactivity.ProgressActivity xmlns:android="http://schemas.android.com/apk/res/android" xmlns:progressActivity="http://schemas.android.com/apk/res-auto" android:id="@+id/progress" android:layout_width="match_parent" android:layout_height="match_parent" progressActivity:loadingBackgroundColor="#FFFFFF" progressActivity:emptyBackgroundColor="#fbc02d" progressActivity:emptyContentTextColor="#FFFFFF" progressActivity:emptyTitleTextColor="#FFFFFF" progressActivity:errorBackgroundColor="#42a5f5" progressActivity:errorButtonTextColor="#FFFFFF" progressActivity:errorContentTextColor="#FFFFFF" progressActivity:errorTitleTextColor="#FFFFFF">

<android.support.v7.widget.Toolbar
    android:id="@+id/activityToolbar"
    android:layout_width="fill_parent"
    android:layout_height="56dp"
    android:elevation="2dp"
    android:theme="@style/Toolbar" />

<LinearLayout
    android:id="@+id/container"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<TextView
    android:id="@+id/one"
    android:gravity="center"
    android:layout_width="fill_parent"
    android:layout_height="100dip"
    android:layout_marginTop="56dp"
    android:text="1111" />
    <TextView
        android:id="@+id/two"
        android:gravity="center"
        android:layout_width="fill_parent"
        android:layout_height="100dip"
        android:layout_marginTop="56dp"
        android:text="2222" />

</LinearLayout>

</com.vlonjatg.progressactivity.ProgressActivity>

then :

@Override public void addView(@NonNull View child, int index, ViewGroup.LayoutParams params) { super.addView(child, index, params);

    if (child.getTag() == null || (!child.getTag().equals(TAG_LOADING) &&
            !child.getTag().equals(TAG_EMPTY) && !child.getTag().equals(TAG_ERROR)))
    {
        if (child instanceof LinearLayout)
        {
            LinearLayout ll = (LinearLayout) child;
            for(int i=0;i<ll.getChildCount();i++)
            {
                contentViews.add(ll.getChildAt(i));
            }
        } else
        {
            contentViews.add(child);
        }
    }
}