Search in sources :

Example 1 with CanvasContext

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);
}
Also used : CanvasContext(com.instructure.canvasapi2.models.CanvasContext)

Example 2 with CanvasContext

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;
}
Also used : CanvasContext(com.instructure.canvasapi2.models.CanvasContext)

Example 3 with CanvasContext

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;
    }
}
Also used : Call(retrofit2.Call) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) FragmentActivity(android.support.v4.app.FragmentActivity) NavigationActivity(com.instructure.candroid.activity.NavigationActivity) Activity(android.app.Activity) StatusCallback(com.instructure.canvasapi2.StatusCallback) Fragment(android.support.v4.app.Fragment) InternalWebviewFragment(com.instructure.candroid.fragment.InternalWebviewFragment) QuizStartFragment(com.instructure.candroid.fragment.QuizStartFragment) QuizStartFragment(com.instructure.candroid.fragment.QuizStartFragment) QuizSubmissionResponse(com.instructure.canvasapi2.models.QuizSubmissionResponse) Response(retrofit2.Response) QuizSubmissionQuestionResponse(com.instructure.canvasapi2.models.QuizSubmissionQuestionResponse) QuizSubmit(com.instructure.candroid.interfaces.QuizSubmit) NonNull(android.support.annotation.NonNull) ApiType(com.instructure.canvasapi2.utils.ApiType) NavigationActivity(com.instructure.candroid.activity.NavigationActivity) Nullable(android.support.annotation.Nullable)

Example 4 with CanvasContext

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;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) FragmentActivity(android.support.v4.app.FragmentActivity) DialogInterface(android.content.DialogInterface) SuppressLint(android.annotation.SuppressLint) CanvasContext(com.instructure.canvasapi2.models.CanvasContext) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ExpandableListView(android.widget.ExpandableListView) NonNull(android.support.annotation.NonNull)

Example 5 with CanvasContext

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;
}
Also used : CanvasContext(com.instructure.canvasapi2.models.CanvasContext)

Aggregations

RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)60 RestParams (com.instructure.canvasapi2.builders.RestParams)55 CanvasContext (com.instructure.canvasapi2.models.CanvasContext)19 StatusCallback (com.instructure.canvasapi2.StatusCallback)8 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)7 List (java.util.List)7 ApiType (com.instructure.canvasapi2.utils.ApiType)6 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)6 DiscussionTopicHeader (com.instructure.canvasapi2.models.DiscussionTopicHeader)5 FileFolder (com.instructure.canvasapi2.models.FileFolder)5 ArrayList (java.util.ArrayList)5 NotNull (org.jetbrains.annotations.NotNull)5 NonNull (android.support.annotation.NonNull)4 View (android.view.View)4 TextView (android.widget.TextView)4 UpdateFileFolder (com.instructure.canvasapi2.models.UpdateFileFolder)4 Bundle (android.os.Bundle)3 ImageView (android.widget.ImageView)3 BindView (butterknife.BindView)3 Course (com.instructure.canvasapi2.models.Course)3