use of org.edx.mobile.profiles.UserProfileActivity in project edx-app-android by edx.
the class NavigationFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
drawerNavigationBinding = DataBindingUtil.inflate(inflater, R.layout.drawer_navigation, container, false);
if (config.isUserProfilesEnabled()) {
if (null != profileImage) {
loadProfileImage(profileImage, drawerNavigationBinding.profileImage);
}
if (profile != null && profile.username != null) {
drawerNavigationBinding.profileImage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final BaseFragmentActivity act = (BaseFragmentActivity) getActivity();
act.closeDrawer();
if (!(act instanceof UserProfileActivity)) {
environment.getRouter().showUserProfileWithNavigationDrawer(getActivity(), profile.username);
if (!(act instanceof MyCoursesListActivity)) {
act.finish();
}
}
}
});
}
} else {
drawerNavigationBinding.profileImage.setVisibility(View.GONE);
drawerNavigationBinding.navigationHeaderLayout.setClickable(false);
drawerNavigationBinding.navigationHeaderLayout.setForeground(null);
}
drawerNavigationBinding.drawerOptionMyCourses.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Activity act = getActivity();
((BaseFragmentActivity) act).closeDrawer();
if (!(act instanceof MyCoursesListActivity)) {
environment.getRouter().showMyCourses(act);
act.finish();
}
}
});
if (environment.getConfig().getCourseDiscoveryConfig().isCourseDiscoveryEnabled()) {
drawerNavigationBinding.drawerOptionFindCourses.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AnalyticsRegistry analyticsRegistry = environment.getAnalyticsRegistry();
analyticsRegistry.trackUserFindsCourses();
FragmentActivity act = getActivity();
((BaseFragmentActivity) act).closeDrawer();
if (!(act instanceof WebViewFindCoursesActivity || act instanceof NativeFindCoursesActivity)) {
environment.getRouter().showFindCourses(act);
// the student should be returned to the MyCourses screen
if (!(act instanceof MyCoursesListActivity)) {
act.finish();
}
}
}
});
if (config.getCourseDiscoveryConfig().isWebviewCourseDiscoveryEnabled()) {
drawerNavigationBinding.drawerOptionFindCourses.setText(R.string.label_discover);
} else {
drawerNavigationBinding.drawerOptionFindCourses.setText(R.string.label_find_courses);
}
} else {
drawerNavigationBinding.drawerOptionFindCourses.setVisibility(View.GONE);
}
drawerNavigationBinding.drawerOptionAccount.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Activity act = getActivity();
((BaseFragmentActivity) act).closeDrawer();
if (!(act instanceof AccountActivity)) {
environment.getRouter().showAccountActivity(act);
if (!(act instanceof MyCoursesListActivity)) {
act.finish();
}
}
}
});
if (profile != null) {
if (profile.name != null) {
drawerNavigationBinding.nameTv.setText(profile.name);
drawerNavigationBinding.nameTv.setContentDescription(ResourceUtil.getFormattedString(getResources(), R.string.navigation_header, "username", profile.name));
}
}
return drawerNavigationBinding.getRoot();
}
Aggregations