本文整理汇总了Java中android.support.v4.view.BetterViewPager类的典型用法代码示例。如果您正苦于以下问题:Java BetterViewPager类的具体用法?Java BetterViewPager怎么用?Java BetterViewPager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BetterViewPager类属于android.support.v4.view包,在下文中一共展示了BetterViewPager类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWeekCountBasedOnMode
import android.support.v4.view.BetterViewPager; //导入依赖的package包/类
/**
* This is abhorrent...
*
* @return
* @throws NoSuchFieldException
* @throws IllegalAccessException
* @throws NoSuchMethodException
* @throws InvocationTargetException
*/
@Deprecated
private int getWeekCountBasedOnMode() throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
Field calendarModeField = MaterialCalendarView.class.getDeclaredField("calendarMode");
calendarModeField.setAccessible(true);
CalendarMode calendarMode = (CalendarMode) calendarModeField.get(this);
Field mDynamicHeightEnabledField = MaterialCalendarView.class.getDeclaredField("mDynamicHeightEnabled");
mDynamicHeightEnabledField.setAccessible(true);
boolean mDynamicHeightEnabled = (boolean) mDynamicHeightEnabledField.get(this);
Field adapterField = MaterialCalendarView.class.getDeclaredField("adapter");
adapterField.setAccessible(true);
Object adapter = adapterField.get(this);
Field pagerField = MaterialCalendarView.class.getDeclaredField("pager");
pagerField.setAccessible(true);
BetterViewPager pager = (BetterViewPager) pagerField.get(this);
Field weekCountField = CalendarMode.class.getDeclaredField("visibleWeeksCount");
weekCountField.setAccessible(true);
int weekCount = (int) weekCountField.get(calendarMode);
boolean isInMonthsMode = calendarMode.equals(CalendarMode.MONTHS);
if (isInMonthsMode && mDynamicHeightEnabled && adapter != null && pager != null) {
Method getItemMethod = adapter.getClass().getDeclaredMethod("getItem", CalendarDay.class);
Object currentItem = getItemMethod.invoke(adapter, pager.getClass().getMethod("getCurrentItem").invoke(pager));
Calendar cal = (Calendar) currentItem.getClass().getMethod("getCalendar").invoke(currentItem);
cal = (Calendar) cal.clone();
//(Calendar) adapter.getItem(pager.getCurrentItem()).getCalendar().clone();
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
//noinspection ResourceType
cal.setFirstDayOfWeek(getFirstDayOfWeek());
weekCount = cal.get(Calendar.WEEK_OF_MONTH);
}
return weekCount + DAY_NAMES_ROW;
}