use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.
the class CalendarListRecyclerAdapter method onBindChildHolder.
// region ViewHolder Configuration
@Override
public void onBindChildHolder(RecyclerView.ViewHolder holder, Date date, ScheduleItem item) {
final CanvasContext canvasContext = getCanvasContextForItem(item);
final int courseColor = ColorKeeper.getOrGenerateColor(canvasContext);
ScheduleItemBinder.bind((ScheduleItemViewHolder) holder, item, getContext(), courseColor, getContextName(item), mAdapterToFragmentCallback);
}
use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.
the class CanvasContextSpinnerAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final CanvasContextViewHolder viewHolder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.canvas_context_spinner_adapter_item, parent, false);
viewHolder = new CanvasContextViewHolder();
viewHolder.title = (TextView) convertView.findViewById(R.id.title);
viewHolder.indicator = (ImageView) convertView.findViewById(R.id.icon);
convertView.setTag(viewHolder);
} else {
viewHolder = (CanvasContextViewHolder) convertView.getTag();
}
CanvasContext item = mData.get(position);
if (item != null) {
viewHolder.title.setText(item.getName());
viewHolder.indicator.setVisibility(View.VISIBLE);
viewHolder.indicator.setBackground(BaseBinder.createIndicatorBackground(ColorKeeper.getOrGenerateColor(item)));
} else {
viewHolder.indicator.setVisibility(View.GONE);
viewHolder.title.setText("");
}
return convertView;
}
use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.
the class QuizSubmissionQuestionListRecyclerAdapter method bindTheHolder.
public void bindTheHolder(final QuizSubmissionQuestion baseItem, RecyclerView.ViewHolder holder, int position) {
int courseColor = ColorKeeper.getOrGenerateColor(canvasContext);
if (position == super.getItemCount()) {
// submit button
SubmitButtonBinder.bind((SubmitButtonViewHolder) holder, getContext(), canvasContext, QuizSubmissionQuestionListRecyclerAdapter.this, new QuizSubmit() {
@Override
public void submitQuiz() {
QuizManager.postQuizSubmit(canvasContext, quizSubmission, true, new StatusCallback<QuizSubmissionResponse>() {
@Override
public void onResponse(@NonNull Response<QuizSubmissionResponse> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
if (type == ApiType.CACHE)
return;
// Submitted!
Toast.makeText(getContext(), R.string.quizSubmittedSuccessfully, Toast.LENGTH_SHORT).show();
// Go back to the startQuizFragment
((Activity) getContext()).onBackPressed();
Fragment fragment = ((NavigationActivity) getContext()).getTopFragment();
if (fragment instanceof QuizStartFragment) {
((QuizStartFragment) fragment).updateQuizInfo();
}
}
@Override
public void onFail(@Nullable Call<QuizSubmissionResponse> call, @NonNull Throwable error, @Nullable Response response) {
Toast.makeText(getContext(), R.string.quizSubmittedFailure, Toast.LENGTH_SHORT).show();
}
});
}
});
return;
}
switch(baseItem.getQuestionType()) {
case ESSAY:
case SHORT_ANSWER:
addEssayQuestion(baseItem, (QuizEssayViewHolder) holder, position, courseColor);
break;
case MUTIPLE_CHOICE:
case TRUE_FALSE:
addMultipleChoiceQuestion(baseItem, (QuizMultiChoiceViewHolder) holder, position, courseColor);
break;
case TEXT_ONLY:
QuizTextOnlyBinder.bind((QuizTextOnlyViewHolder) holder, baseItem);
break;
case MULTIPLE_ANSWERS:
addMultipleAnswerQuestion((QuizMultiChoiceViewHolder) holder, position, courseColor);
break;
case MATCHING:
addMatchingQuestion(baseItem, (QuizMatchingViewHolder) holder, position, courseColor);
break;
case FILE_UPLOAD:
addFileUploadQuestion(baseItem, (QuizFileUploadViewHolder) holder, position, courseColor);
break;
case NUMERICAL:
addNumericalQuestion(baseItem, (QuizNumericalViewHolder) holder, position, courseColor);
break;
case MULTIPLE_DROPDOWNS:
addMultipleDropdown(baseItem, (QuizMultipleDropdownViewHolder) holder, position, courseColor);
break;
}
}
use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.
the class QuizQuestionDialog method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final FragmentActivity activity = getActivity();
AlertDialog.Builder builder = new AlertDialog.Builder(activity).setTitle(activity.getString(R.string.viewQuestions)).setPositiveButton(activity.getString(R.string.okay), null);
// Suppress lint warning about null parent when inflating layout
@SuppressLint("InflateParams") View view = LayoutInflater.from(getActivity()).inflate(R.layout.quiz_question_dialog, null);
listView = view.findViewById(R.id.listview);
builder.setView(view);
final AlertDialog dialog = builder.create();
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface useless) {
CanvasContext course = getArguments().getParcelable(Const.COURSE);
if (course != null) {
int courseColor = ColorKeeper.getOrGenerateColor(course);
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(courseColor);
}
}
});
return dialog;
}
use of com.instructure.canvasapi2.models.CanvasContext in project instructure-android by instructure.
the class CanvasContextSpinnerAdapter method getDropDownView.
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
final CanvasContextViewHolder viewHolder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.canvas_context_spinner_adapter_item, parent, false);
viewHolder = new CanvasContextViewHolder();
viewHolder.title = (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (CanvasContextViewHolder) convertView.getTag();
}
CanvasContext item = mData.get(position);
if (item != null) {
viewHolder.title.setText(item.getName());
if (item.getId() == GROUP_SEPARATOR || item.getId() == COURSE_SEPARATOR) {
viewHolder.title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
viewHolder.title.setTextColor(mInflater.getContext().getResources().getColor(R.color.defaultTextGray));
} else {
viewHolder.title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
viewHolder.title.setTextColor(mInflater.getContext().getResources().getColor(R.color.defaultTextDark));
}
}
return convertView;
}
Aggregations