use of com.instructure.interactions.Navigation in project instructure-android by instructure.
the class NotificationListFragment method applyTheme.
@Override
public void applyTheme() {
CanvasContext canvasContext = getCanvasContext();
if (canvasContext instanceof Course || canvasContext instanceof Group) {
PandaViewUtils.setupToolbarBackButton(mToolbar, this);
ViewStyler.themeToolbar(getActivity(), mToolbar, canvasContext);
} else {
Navigation navigation = getNavigation();
if (navigation != null)
navigation.attachNavigationDrawer(this, mToolbar);
// Styling done in attachNavigationDrawer
}
}
use of com.instructure.interactions.Navigation in project instructure-android by instructure.
the class NotificationListFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRootView = getLayoutInflater().inflate(R.layout.fragment_list_notification, container, false);
mToolbar = mRootView.findViewById(R.id.toolbar);
mAdapterToFragmentCallback = new NotificationAdapterToFragmentCallback<StreamItem>() {
@Override
public void onRowClicked(StreamItem streamItem, int position, boolean isOpenDetail) {
mRecyclerAdapter.setSelectedPosition(position);
Navigation navigation = getNavigation();
if (navigation != null) {
onRowClick(streamItem, isOpenDetail);
}
}
@Override
public void onRefreshFinished() {
setRefreshing(false);
mEditOptions.setVisibility(View.GONE);
}
@Override
public void onShowEditView(boolean isVisible) {
mEditOptions.setVisibility(isVisible ? View.VISIBLE : View.GONE);
}
@Override
public void onShowErrorCrouton(int message) {
showToast(message);
}
};
mRecyclerAdapter = new NotificationListRecyclerAdapter(getContext(), getCanvasContext(), onNotificationCountInvalidated, mAdapterToFragmentCallback);
configureRecyclerView(mRootView, getContext(), mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
PandaRecyclerView pandaRecyclerView = mRootView.findViewById(R.id.listView);
pandaRecyclerView.setSelectionEnabled(false);
configureViews(mRootView);
return mRootView;
}
use of com.instructure.interactions.Navigation in project instructure-android by instructure.
the class NotificationListFragment method addFragmentForStreamItem.
public static DialogFragment addFragmentForStreamItem(StreamItem streamItem, FragmentActivity activity, boolean fromWidget) {
ParentFragment fragment = null;
if (streamItem == null || activity == null) {
return null;
}
String unsupportedLabel = null;
switch(streamItem.getType()) {
case SUBMISSION:
if (streamItem.getAssignment() == null && streamItem.getCanvasContext() instanceof Course) {
fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle(streamItem.getCanvasContext(), streamItem.getAssignmentId()));
} else if (streamItem.getAssignment() != null && streamItem.getCanvasContext() instanceof Course) {
// add an empty submission with the grade to the assignment so that we can see the score.
Submission emptySubmission = new Submission();
emptySubmission.setGrade(streamItem.getGrade());
streamItem.getAssignment().setSubmission(emptySubmission);
fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle((Course) streamItem.getCanvasContext(), streamItem.getAssignment()));
}
break;
case ANNOUNCEMENT:
if (streamItem.getCanvasContext() != null) {
fragment = FragUtils.getFrag(DiscussionDetailsFragment.class, DiscussionDetailsFragment.makeBundle(streamItem.getCanvasContext(), streamItem.getDiscussionTopicId(), true));
}
break;
case CONVERSATION:
Conversation conversation = streamItem.getConversation();
if (conversation != null) {
// Check to see if the conversation has been deleted.
if (conversation.isDeleted()) {
Toast.makeText(activity, R.string.deleteConversation, Toast.LENGTH_SHORT).show();
return null;
}
Bundle extras = InboxConversationFragment.createBundle(conversation, 0, null);
fragment = FragUtils.getFrag(InboxConversationFragment.class, extras);
}
break;
case DISCUSSION_TOPIC:
if (streamItem.getCanvasContext() != null) {
fragment = FragUtils.getFrag(DiscussionDetailsFragment.class, DiscussionDetailsFragment.makeBundle(streamItem.getCanvasContext(), streamItem.getDiscussionTopicId(), false));
}
break;
case MESSAGE:
if (streamItem.getAssignmentId() > 0) {
if (streamItem.getCanvasContext() != null) {
fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle(activity, streamItem.getCanvasContext(), streamItem.getAssignmentId(), streamItem));
}
} else {
fragment = FragUtils.getFrag(UnknownItemFragment.class, UnknownItemFragment.createBundle(streamItem.getCanvasContext(), streamItem));
}
break;
case COLLABORATION:
if (streamItem.getCanvasContext() != null) {
unsupportedLabel = activity.getString(R.string.collaborations);
fragment = UnSupportedTabFragment.createFragment(UnSupportedTabFragment.class, UnSupportedTabFragment.createBundle(streamItem.getCanvasContext(), Tab.COLLABORATIONS_ID, R.string.collaborations));
}
break;
case CONFERENCE:
if (streamItem.getCanvasContext() != null) {
unsupportedLabel = activity.getString(R.string.conferences);
fragment = UnSupportedTabFragment.createFragment(UnSupportedTabFragment.class, UnSupportedTabFragment.createBundle(streamItem.getCanvasContext(), Tab.CONFERENCES_ID, R.string.conferences));
}
break;
default:
if (streamItem.getCanvasContext() != null) {
unsupportedLabel = streamItem.getType().toString();
fragment = FragUtils.getFrag(UnSupportedFeatureFragment.class, UnSupportedFeatureFragment.createBundle(streamItem.getCanvasContext(), unsupportedLabel, streamItem.getUrl()));
}
break;
}
if (unsupportedLabel != null) {
if (activity instanceof Navigation) {
((Navigation) activity).addFragment(fragment);
}
} else {
if (activity instanceof Navigation && fragment != null) {
((Navigation) activity).addFragment(fragment);
}
if (fromWidget) {
if (streamItem.getUrl() != null) {
RouterUtils.routeUrl(activity, streamItem.getUrl(), false);
} else {
RouterUtils.routeUrl(activity, streamItem.getHtmlUrl(), false);
}
}
}
return null;
}
use of com.instructure.interactions.Navigation in project instructure-android by instructure.
the class QuizListFragment method rowClick.
private void rowClick(Quiz quiz, boolean closeSlidingPane) {
Navigation navigation = getNavigation();
if (navigation != null) {
// to a webview. Also, we currently don't support one quiz question at a time quizzes.
if (!isNativeQuiz(getCanvasContext(), quiz)) {
// Log to GA, track if they're a teacher (because teachers currently always get the non native quiz)
Bundle bundle = BasicQuizViewFragment.Companion.createBundle(getCanvasContext(), quiz.getUrl(), quiz);
navigation.addFragment(FragUtils.getFrag(BasicQuizViewFragment.class, bundle));
} else {
Bundle bundle = QuizStartFragment.createBundle(getCanvasContext(), quiz);
navigation.addFragment(FragUtils.getFrag(QuizStartFragment.class, bundle));
}
}
}
use of com.instructure.interactions.Navigation in project instructure-android by instructure.
the class ScheduleListFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRootView = getLayoutInflater().inflate(R.layout.fragment_list_syllabus, container, false);
mToolbar = mRootView.findViewById(R.id.toolbar);
mAdapterToFragmentCallback = new AdapterToFragmentCallback<ScheduleItem>() {
@Override
public void onRowClicked(ScheduleItem scheduleItem, int position, boolean isOpenDetail) {
Navigation navigation = getNavigation();
if (navigation != null) {
ParentFragment fragment;
if (scheduleItem.getAssignment() != null) {
fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle((Course) getCanvasContext(), scheduleItem.getAssignment()));
} else if (scheduleItem.getItemType() == ScheduleItem.Type.TYPE_SYLLABUS) {
fragment = FragUtils.getFrag(SyllabusFragment.class, SyllabusFragment.Companion.createBundle((Course) getCanvasContext(), scheduleItem));
} else {
fragment = FragUtils.getFrag(CalendarEventFragment.class, CalendarEventFragment.createBundle(getCanvasContext(), scheduleItem));
}
navigation.addFragment(fragment);
}
}
@Override
public void onRefreshFinished() {
setRefreshing(false);
}
};
mRecyclerAdapter = new SyllabusRecyclerAdapter(getContext(), getCanvasContext(), mAdapterToFragmentCallback);
configureRecyclerView(mRootView, getContext(), mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
return mRootView;
}
Aggregations