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