WassimBenltaief/FlowLayout

Will this lib work within SwipeRefreshLayout?

Closed this issue · 10 comments

Will this lib work within SwipeRefreshLayout?

It should be yes. Simply do not call FlowLayout.setMode(FlowLayout.MODE.PROGRESS)
but instead something like this :

<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipe_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <com.beltaief.flowlayout.FlowLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:tools="http://schemas.android.com/tools"
         android:id="@+id/flow_layout"
         android:layout_width="match_parent"
         android:layout_height="match_parent">

             // content goes here

        </com.beltaief.flowlayout.FlowLayout>

</android.support.v4.widget.SwipeRefreshLayout>
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
    swipeLayout.setOnRefreshListener(this);
    flowLayout = (FlowLayout) findViewById(R.id.flow_layout);
}


@Override 
public void onRefresh() {
           // getData
          ...
          // hide progress
          swipeLayout.setRefreshing(false);
           // assign result to the view
           if (data.isEmpty()) {
                    flowLayout.setMode(FlowLayout.MODE.EMPTY);
            } else {
                    flowLayout.setMode(FlowLayout.MODE.CONTENT);
           // show the data in the view
           ...
    }
}

Why the extra ScrollView around FlowLayout?

That was just an example I had.
If you don't need a scrollview then don't put it.

The point is that the content inside FlowLayout is a RecyclerView (or ListView or NestedScrollView) and is already scrollable. Why would you ever need a ScrollView around the FlowLayout?

This was just an example and not exclusive. It depends on what you put inside FlowLayout. If it's a scrollable component like a RecyclerView then you don't need to wrap it with a ScrollView.

My point exactly. Why is the ScrollView around the FlowLayout?

In other news: ScrollView does not support nested scrolling below API 21 which may interfere with other function.

You now manage a public open source library and have a responsibility to other developers using it. Keep your examples complete but minimal. (It will also save you form nitpicking assholes like myself. :D )

alright @consp1racy , I edited my example to not to confuse the reader with nested scroll content issue inside a ScrollView :)

@WassimBenltaief But initial it's possible to use FlowLayout.setMode(FlowLayout.MODE.PROGRESS)? Only later when the user uses SwipeToRefresh, then I shouldn't use MODE_PROGRESS anymore. Is this right?

@Rainer-Lang That't right. You can make that.

@WassimBenltaief Thanks for this lib! It's working.
I'm waiting for the error view. ;)