WassimBenltaief / FlowLayout

A custom Layout packed with a content view, an empty view, a progress bar and network connectivity status
MIT License
228 stars 24 forks source link

Will this lib work within SwipeRefreshLayout? #4

Closed Rainer-Lang closed 8 years ago

WassimBenltaief commented 8 years ago

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
           ...
    }
}
consp1racy commented 8 years ago

Why the extra ScrollView around FlowLayout?

WassimBenltaief commented 8 years ago

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

consp1racy commented 8 years ago

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?

WassimBenltaief commented 8 years ago

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.

consp1racy commented 8 years ago

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 )

WassimBenltaief commented 8 years ago

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

Rainer-Lang commented 8 years ago

@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?

WassimBenltaief commented 8 years ago

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

Rainer-Lang commented 8 years ago

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