use of com.instructure.canvasapi2.models.Tab in project instructure-android by instructure.
the class StudentViewActivity method setupViews.
private void setupViews() {
if (statusBarHeightId > 0) {
// else it uses the default dimens in XML
// Configure views to slide under status bar, will only effect > API 21
int statusBarHeight = getResources().getDimensionPixelSize(statusBarHeightId);
RelativeLayout root = (RelativeLayout) findViewById(R.id.rootView);
RelativeLayout navigationWrapper = (RelativeLayout) findViewById(R.id.navigationWrapper);
FrameLayout.LayoutParams rootParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
rootParams.setMargins(0, -statusBarHeight, 0, 0);
root.setLayoutParams(rootParams);
navigationWrapper.setPadding(0, statusBarHeight, 0, 0);
} else {
RelativeLayout root = (RelativeLayout) findViewById(R.id.rootView);
RelativeLayout navigationWrapper = (RelativeLayout) findViewById(R.id.navigationWrapper);
FrameLayout.LayoutParams rootParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
rootParams.setMargins(0, 0, 0, 0);
root.setLayoutParams(rootParams);
navigationWrapper.setPadding(0, 0, 0, 0);
}
mSettingsButton = (ImageButton) findViewById(R.id.settings);
mStudentName = (TextView) findViewById(R.id.studentName);
// Get the ViewPager and set it's PagerAdapter so that it can display items
final ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
if (mPagerAdapter == null) {
mPagerAdapter = new StudentActivityFragmentPagerAdapter(getSupportFragmentManager(), StudentViewActivity.this);
}
viewPager.setAdapter(mPagerAdapter);
// When loading course page, alert page will need to be updated so we need to be sure to
// keep all fragments in memory
viewPager.setOffscreenPageLimit(2);
// Give the TabLayout the ViewPager
mTabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
mTabLayout.setupWithViewPager(viewPager);
mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
if (tab.getCustomView() != null) {
tab.getCustomView().setAlpha(1f);
}
viewPager.setCurrentItem(tab.getPosition());
// set the tab content description to the title of the tab, for a11y/testing
tab.setContentDescription(tab.getText());
onPageScrolled(mCarouselViewPager.getCurrentItem(), 0, 0);
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
if (tab.getCustomView() != null) {
tab.getCustomView().setAlpha(.30f);
}
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
// Iterate over all tabs and set the custom view
for (int i = 0; i < mTabLayout.getTabCount(); i++) {
TabLayout.Tab tab = mTabLayout.getTabAt(i);
tab.setCustomView(mPagerAdapter.getTabView(i));
if (i != viewPager.getCurrentItem()) {
tab.getCustomView().setAlpha(.30f);
}
}
configureUserCarousel();
Prefs prefs = new Prefs(StudentViewActivity.this, com.instructure.parentapp.util.Const.CANVAS_PARENT_SP);
int pos = prefs.load(Const.TAB, 0);
if (pos != 0) {
viewPager.setCurrentItem(pos);
}
// update unread count
mPagerAdapter.setAlertFragmentUnreadCount(mUnreadAlertCount);
}
use of com.instructure.canvasapi2.models.Tab in project instructure-android by instructure.
the class CourseNavigationAdapter method getDropDownView.
@Override
public View getDropDownView(int position, View view, ViewGroup parent) {
Tab tab = getItem(position);
view = inflater.inflate(R.layout.viewholder_course_navigation, parent, false);
TextView text = (TextView) view.findViewById(R.id.title);
ImageView image = (ImageView) view.findViewById(R.id.icon);
text.setText(tab.getLabel());
image.setImageDrawable(ColorKeeper.getColoredDrawable(mContext, getIconResIdForTab(tab), color));
return view;
}
use of com.instructure.canvasapi2.models.Tab in project instructure-android by instructure.
the class CourseNavigationAdapter method getView.
@Override
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
view = inflater.inflate(R.layout.actionbar_course_spinner, parent, false);
}
final TextView mTitle = (TextView) view.findViewById(R.id.text1);
final TextView mSubTitle = (TextView) view.findViewById(R.id.text2);
Tab tab = getItem(position);
if (tab != null) {
final String title = tab.getLabel();
final String subTitle = getSubTitle();
if (mTitle != null) {
if (!TextUtils.isEmpty(title)) {
mTitle.setText(title);
}
}
if (mSubTitle != null) {
if (!TextUtils.isEmpty(subTitle)) {
mSubTitle.setText(subTitle);
mSubTitle.setVisibility(View.VISIBLE);
} else {
mSubTitle.setVisibility(View.GONE);
}
}
}
return view;
}
use of com.instructure.canvasapi2.models.Tab in project instructure-android by instructure.
the class CourseNavigationAdapter method formatAvailableTabs.
private void formatAvailableTabs(Context context, List<Tab> result) {
// result might be null if the API returns null
if (result == null) {
return;
}
ArrayList<Tab> tabs = new ArrayList<>();
for (Tab tab : result) {
// Excludes tabs that are hidden, see api for a huge lack of detail on what that means.
if (!tab.isHidden()) {
tabs.add(tab);
}
}
// add course navigation in, which is not returned by the server
tabs.add(Tab.newInstance(Tab.NOTIFICATIONS_ID, context.getString(R.string.Notifications)));
addItems(tabs);
}
use of com.instructure.canvasapi2.models.Tab in project instructure-android by instructure.
the class TabTest method equals_TestDifferentValues.
@Test
public void equals_TestDifferentValues() {
Tab tabby2 = Tab.newInstance("id", "label_extra");
assertFalse(tabby1.equals(tabby2));
}
Aggregations