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);
}
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));
}
Aggregations