Search in sources :

Example 6 with Poll

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

the class AddQuestionFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Constants.PUBLISH_POLL_SUCCESS) {
        // try to go to the poll result
        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;
        }
        // if there are multiple poll sessions, go to the list
        getActivity().onBackPressed();
    } else if (resultCode == Constants.PUBLISH_POLL_SUCCESS_MULTIPLE) {
        PollSessionListFragment pollSessionListFragment = new PollSessionListFragment();
        Bundle bundle = new Bundle();
        bundle.putParcelable(Constants.POLL_DATA, poll);
        pollSessionListFragment.setArguments(bundle);
        ((FragmentManagerActivity) getActivity()).removeFragment(this);
        ((FragmentManagerActivity) getActivity()).swapFragments(pollSessionListFragment, PollResultsFragment.class.getSimpleName());
    }
}
Also used : PollSession(com.instructure.canvasapi2.models.PollSession) Bundle(android.os.Bundle) FragmentManagerActivity(com.instructure.androidpolling.app.activities.FragmentManagerActivity)

Example 7 with Poll

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

the class AddQuestionFragment method checkBundle.

private void checkBundle(Bundle bundle) {
    if (bundle != null) {
        poll = bundle.getParcelable(Constants.POLL_BUNDLE);
        if (poll != null) {
            editPoll = true;
            // we're editing a poll that has already been created
            scrollView.setVisibility(View.VISIBLE);
            editQuestion.setText(poll.getQuestion());
            ArrayList<PollChoice> pollChoices = bundle.getParcelableArrayList(Constants.POLL_CHOICES);
            if (pollChoices != null) {
                for (PollChoice pollChoice : pollChoices) {
                    addAnswer(pollChoice.getText(), pollChoice.is_correct(), pollChoice.getId());
                }
            }
            // update the actionbar
            getActivity().invalidateOptionsMenu();
        }
    }
}
Also used : PollChoice(com.instructure.canvasapi2.models.PollChoice)

Example 8 with Poll

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

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

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

the class PollResultsFragment method setupViews.

private void setupViews(Poll poll, ArrayList<PollChoice> pollChoices) {
    clearAdapter();
    question.setText(poll.getQuestion());
    if (pollChoices != null) {
        for (PollChoice choice : pollChoices) {
            addItem(choice);
        }
    }
}
Also used : PollChoice(com.instructure.canvasapi2.models.PollChoice)

Aggregations

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