Search in sources :

Example 1 with SwipeDismissListViewTouchListener

use of com.instructure.androidpolling.app.util.SwipeDismissListViewTouchListener in project instructure-android by instructure.

the class PollSessionListFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);
    touchListener = new SwipeDismissListViewTouchListener(getListView(), new SwipeDismissListViewTouchListener.DismissCallbacks() {

        @Override
        public boolean canDismiss(int position) {
            return true;
        }

        @Override
        public void onDismiss(ListView listView, int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                // set the poll that we want to remove after the api call returns successfully
                PollSession pollSession = getItem(position);
                // remove the item from the list
                removeItem(pollSession);
                // delete the poll from canvas
                PollsManager.deletePollSession(poll.getId(), pollSession.getId(), responseCanvasCallback, true);
            }
        }
    });
    getListView().setOnTouchListener(touchListener);
    getListView().setOnScrollListener(touchListener.makeScrollListener());
    // set an animation for adding list items
    LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.list_layout_controller);
    getListView().setLayoutAnimation(controller);
}
Also used : SwipeDismissListViewTouchListener(com.instructure.androidpolling.app.util.SwipeDismissListViewTouchListener) PollSession(com.instructure.canvasapi2.models.PollSession) ListView(android.widget.ListView) LayoutAnimationController(android.view.animation.LayoutAnimationController)

Example 2 with SwipeDismissListViewTouchListener

use of com.instructure.androidpolling.app.util.SwipeDismissListViewTouchListener in project instructure-android by instructure.

the class QuestionListFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);
    // clear the list so we don't get duplicates
    pollList.clear();
    openSessions.clear();
    closedSessions.clear();
    setupClickListeners();
    touchListener = new SwipeDismissListViewTouchListener(expandableListView, new SwipeDismissListViewTouchListener.DismissCallbacks() {

        @Override
        public boolean canDismiss(int position) {
            return true;
        }

        @Override
        public void onDismiss(ListView listView, int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                // set the poll that we want to remove after the api call returns successfully
                pollToDelete = (Poll) expandableListView.getItemAtPosition(position);
                confirmDelete();
            }
        }
    });
    expandableListView.setOnTouchListener(touchListener);
    expandableListView.setOnScrollListener(touchListener.makeScrollListener());
    // set an animation for adding list items
    LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.list_layout_controller);
    expandableListView.setLayoutAnimation(controller);
    ((BaseActivity) getActivity()).setActionBarTitle(getString(R.string.pollQuestions));
}
Also used : SwipeDismissListViewTouchListener(com.instructure.androidpolling.app.util.SwipeDismissListViewTouchListener) ListView(android.widget.ListView) ExpandableListView(android.widget.ExpandableListView) LayoutAnimationController(android.view.animation.LayoutAnimationController) BaseActivity(com.instructure.androidpolling.app.activities.BaseActivity)

Aggregations

LayoutAnimationController (android.view.animation.LayoutAnimationController)2 ListView (android.widget.ListView)2 SwipeDismissListViewTouchListener (com.instructure.androidpolling.app.util.SwipeDismissListViewTouchListener)2 ExpandableListView (android.widget.ExpandableListView)1 BaseActivity (com.instructure.androidpolling.app.activities.BaseActivity)1 PollSession (com.instructure.canvasapi2.models.PollSession)1