Search in sources :

Example 1 with SwipeOnScrollListener

use of it.gmariotti.cardslib.library.view.listener.SwipeOnScrollListener in project cardslib by gabrielemariotti.

the class CardArrayAdapter method setupSwipeableAnimation.

/**
     * Sets SwipeAnimation on List
     *
     * @param card {@link Card}
     * @param cardView {@link it.gmariotti.cardslib.library.view.base.CardViewWrapper}
     */
protected void setupSwipeableAnimation(final Card card, CardViewWrapper cardView) {
    if (card.isSwipeable()) {
        if (mOnTouchListener == null) {
            mOnTouchListener = new SwipeDismissListViewTouchListener(mCardListView, mCallback);
            //Configure the default DismissableManager
            if (mDismissable == null)
                mDismissable = new DefaultDismissableManager();
            mDismissable.setAdapter(this);
            mOnTouchListener.setDismissable(mDismissable);
            // ListView scrolling, we don't look for swipes.
            if (mCardListView.getOnScrollListener() == null) {
                SwipeOnScrollListener scrollListener = new SwipeOnScrollListener();
                scrollListener.setTouchListener(mOnTouchListener);
                mCardListView.setOnScrollListener(scrollListener);
            } else {
                AbsListView.OnScrollListener onScrollListener = mCardListView.getOnScrollListener();
                if (onScrollListener instanceof SwipeOnScrollListener)
                    ((SwipeOnScrollListener) onScrollListener).setTouchListener(mOnTouchListener);
            }
            mCardListView.setOnTouchListener(mOnTouchListener);
        }
        cardView.setOnTouchListener(mOnTouchListener);
    } else {
        //prevent issue with recycle view
        cardView.setOnTouchListener(null);
    }
}
Also used : SwipeDismissListViewTouchListener(it.gmariotti.cardslib.library.view.listener.SwipeDismissListViewTouchListener) DefaultDismissableManager(it.gmariotti.cardslib.library.view.listener.dismiss.DefaultDismissableManager) AbsListView(android.widget.AbsListView) SwipeOnScrollListener(it.gmariotti.cardslib.library.view.listener.SwipeOnScrollListener)

Example 2 with SwipeOnScrollListener

use of it.gmariotti.cardslib.library.view.listener.SwipeOnScrollListener in project Weather by Sparker0i.

the class AboutActivity method initCards.

public void initCards() {
    cards = new ArrayList<>();
    cards.add(new AboutCard(this, R.layout.about_card_layout_1, 1));
    cards.add(new AboutCard(this, R.layout.about_card_layout_2, 2));
    cards.add(new AboutCard(this, R.layout.about_card_layout_3, 3));
    cards.add(new AboutCard(this, R.layout.about_card_layout_4, 4));
    cards.add(new AboutCard(this, R.layout.about_card_layout_5, 5));
    cardArrayAdapter = new CardArrayAdapter(this, cards);
    if (aboutList != null) {
        aboutList.setAdapter(cardArrayAdapter);
        aboutList.setOnScrollListener(new SwipeOnScrollListener() {

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                if (firstVisibleItem > previousVisibleItem)
                    fab.hide();
                else if (firstVisibleItem < previousVisibleItem)
                    fab.show();
                previousVisibleItem = firstVisibleItem;
            }
        });
    }
}
Also used : AbsListView(android.widget.AbsListView) SwipeOnScrollListener(it.gmariotti.cardslib.library.view.listener.SwipeOnScrollListener) AboutCard(com.a5corp.weather.cards.AboutCard) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter)

Aggregations

AbsListView (android.widget.AbsListView)2 SwipeOnScrollListener (it.gmariotti.cardslib.library.view.listener.SwipeOnScrollListener)2 AboutCard (com.a5corp.weather.cards.AboutCard)1 CardArrayAdapter (it.gmariotti.cardslib.library.internal.CardArrayAdapter)1 SwipeDismissListViewTouchListener (it.gmariotti.cardslib.library.view.listener.SwipeDismissListViewTouchListener)1 DefaultDismissableManager (it.gmariotti.cardslib.library.view.listener.dismiss.DefaultDismissableManager)1