Search in sources :

Example 6 with PollSession

use of com.instructure.canvasapi2.models.PollSession in project instructure-android by instructure.

the class ClosedPollListFragment method getRowViewForItem.

@Override
public View getRowViewForItem(PollSession item, View convertView, int childPosition) {
    Poll poll = pollMap.get(item.getPoll_id());
    String pollName = "";
    if (poll != null) {
        pollName = poll.getQuestion();
    }
    String courseName = "";
    if (courseMap.containsKey(item.getCourse_id())) {
        courseName = courseMap.get(item.getCourse_id()).getName();
    }
    return PollRowFactory.buildRowView(layoutInflater(), courseName, pollName, convertView, getActivity(), item.getCreated_at());
}
Also used : Poll(com.instructure.canvasapi2.models.Poll)

Example 7 with PollSession

use of com.instructure.canvasapi2.models.PollSession in project instructure-android by instructure.

the class OpenPollExpandableListFragment method getRowViewForItem.

@Override
public View getRowViewForItem(PollSession item, View convertView, int groupPosition, int childPosition, boolean isLastRowInGroup, boolean isLastRow) {
    Poll poll = pollMap.get(item.getPoll_id());
    String pollName = "";
    if (poll != null) {
        pollName = poll.getQuestion();
    }
    String courseName = "";
    if (courseMap.containsKey(item.getCourse_id())) {
        courseName = courseMap.get(item.getCourse_id()).getName();
    }
    return PollRowFactory.buildRowView(layoutInflater(), courseName, pollName, convertView, getActivity(), item.getCreated_at());
}
Also used : Poll(com.instructure.canvasapi2.models.Poll)

Example 8 with PollSession

use of com.instructure.canvasapi2.models.PollSession 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 9 with PollSession

use of com.instructure.canvasapi2.models.PollSession in project instructure-android by instructure.

the class PollSessionListFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Constants.PUBLISH_POLL_SUCCESS || resultCode == Constants.PUBLISH_POLL_SUCCESS_MULTIPLE) {
        if (data != null) {
            PollSession session = data.getExtras().getParcelable(Constants.POLL_SESSION);
            PollResultsFragment pollResultsFragment = new PollResultsFragment();
            Bundle bundle = new Bundle();
            bundle.putParcelable(Constants.POLL_DATA, poll);
            bundle.putParcelable(Constants.POLL_SESSION, session);
            pollResultsFragment.setArguments(bundle);
            ((FragmentManagerActivity) getActivity()).removeFragment(this);
            ((FragmentManagerActivity) getActivity()).swapFragments(pollResultsFragment, PollResultsFragment.class.getSimpleName());
            return;
        }
        reloadData();
    }
}
Also used : PollSession(com.instructure.canvasapi2.models.PollSession) Bundle(android.os.Bundle) FragmentManagerActivity(com.instructure.androidpolling.app.activities.FragmentManagerActivity)

Aggregations

PollSession (com.instructure.canvasapi2.models.PollSession)7 Bundle (android.os.Bundle)4 Poll (com.instructure.canvasapi2.models.Poll)3 FragmentManagerActivity (com.instructure.androidpolling.app.activities.FragmentManagerActivity)2 PollChoiceResponse (com.instructure.canvasapi2.models.PollChoiceResponse)2 PollSessionResponse (com.instructure.canvasapi2.models.PollSessionResponse)2 ApiType (com.instructure.canvasapi2.utils.ApiType)2 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ResponseBody (okhttp3.ResponseBody)2 Response (retrofit2.Response)2 Intent (android.content.Intent)1 Time (android.text.format.Time)1 LayoutAnimationController (android.view.animation.LayoutAnimationController)1 ListView (android.widget.ListView)1 SwipeDismissListViewTouchListener (com.instructure.androidpolling.app.util.SwipeDismissListViewTouchListener)1 PollChoice (com.instructure.canvasapi2.models.PollChoice)1 PollResponse (com.instructure.canvasapi2.models.PollResponse)1 PollSubmission (com.instructure.canvasapi2.models.PollSubmission)1