0

I am using a SwipeRefreshLayout and an EnhancedListView to combine them like GMAIL-App. When I start to swipe horizontal I am still be able to swipe vertical. In this case the animation from EnhancedListView stuck and do not reset or swipe till the end if I do not complete the vertical (SwipeRefreshLayout) swipe.

I can see, that first pull to refresh and then swipeToDismiss does not work. Only first swipe and then refresh. So i guess it is about beeing a parent element.

Possible Solution i thought about: Check for horizontal scrolling and disable SwipeRefreshLayout with swipeL.setEnabled(false); When finished swipeL.setEnabled(true); But I can not find where to disable and enable it.

My Layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<RelativeLayout
    android:id="@+id/footer"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentBottom="true"
    android:background="#0A756E"
    android:gravity="center" >

    <LinearLayout
        android:id="@+id/ll_archiv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/greenbox" >

        <TextView
            android:id="@+id/tv_archiv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="10dp"
            android:paddingTop="10dp"
            android:text="@string/archiv"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#fff" />
    </LinearLayout>
</RelativeLayout>

<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" >

    <de.android.voucheroo.utils.EnhancedListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/footer"
        android:layout_alignParentTop="true"
        android:descendantFocusability="blocksDescendants" >
    </de.android.voucheroo.utils.EnhancedListView>
</android.support.v4.widget.SwipeRefreshLayout>

My Code:

    swipeL = (SwipeRefreshLayout) getActivity().findViewById(
            R.id.swipe_container);
    ll_archiv = (LinearLayout) getActivity().findViewById(R.id.ll_archiv);
    tv_archiv = (TextView) getActivity().findViewById(R.id.tv_archiv);
    elv = (EnhancedListView) getActivity().findViewById(android.R.id.list);
    elv.setDismissCallback(new OnDismissCallback() {

        @Override
        public Undoable onDismiss(EnhancedListView listView,
                final int position) {
            try {
                final Object vouch = voucher.get(position);
                voucher.remove(position);
                adapter.notifyDataSetChanged();
                return new EnhancedListView.Undoable() {

                    @Override
                    public void undo() {
                        voucher.add(position, vouch);
                        adapter.notifyDataSetChanged();
                    }

                    // Return a string for your item
                    @Override
                    public String getTitle() {
                        return "foo";
                    }

                    // Delete item completely from your persistent storage
                    @Override
                    public void discard() {
                        [...];
                    }
                };
            } catch (Exception e) {
                Log.w("ELV_EXCEPTION", e.getMessage());
                e.getStackTrace();
                return null;
            }
        }
    });
    swipeL.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            [...]
            swipeL.setRefreshing(false);
        }
    });

    // Handler
    elv.enableSwipeToDismiss();
    elv.setSwipingLayout(R.id.ll_parent);
    elv.setUndoStyle(UndoStyle.MULTILEVEL_POPUP);
Friedolino
  • 114
  • 8

1 Answers1

0

Nowsaday I know the answer of my own question. It is not a problem with my code, it is a problem with SwipeRefreshView.

There is a similar question with the same Problem I found here: SO-Answer

Community
  • 1
  • 1
Friedolino
  • 114
  • 8