MagicMashRoom / SuperCalendar

@Deprecated android 自定义日历控件 支持左右无限滑动 周月切换 标记日期显示 自定义显示效果跳转到指定日期
2.76k stars 484 forks source link

请问如何单纯使用周模式? #12

Closed StephenCMZ closed 7 years ago

StephenCMZ commented 7 years ago
  1. 如何初始化便直接是周模式?在CalendarViewAdapter设置为WEEK不起作用
  2. 如何禁止RecyclerView下拉月模式的切换?
MagicMashRoom commented 7 years ago

首先你找到SyllabusActivity中 97 98 行 在确保你的View绘制出来之后调用这两句话 最后一个参数 时间 改为0 然后你在你的recyclerView的实例对象使用setNestedScrollingEnabled(false)这个方法 禁止掉嵌套滑动就可以了

StephenCMZ commented 7 years ago

感谢!

JYPJSY commented 7 years ago

额,ST同学解决了吗?

StephenCMZ commented 7 years ago

@JYPJSY 根据楼上作者的回复,已经解决了

hqAnd commented 7 years ago

@StephenCMZ 老哥 Utils.scrollTo(content, recyclerView, monthPager.getCellHeight(), 200); calendarAdapter.switchToWeek(0); 这两句代码你些在哪里了。我放在initMonthPager();这个方法后面了。但是变为周的时候显示空白。滑动一下就好了。

JYPJSY commented 7 years ago

@StephenCMZ 请问,初始化就是周历的话。你的周历滑动操作,周历数据不会异常吗??我的周历数据异常了。求教,除了作者回复的修改,你还修改了哪里,谢谢。

StephenCMZ commented 7 years ago

@hqAnd 根据作者的回答是“在确保你的View绘制出来之后调用”,放在initMonthPager();后面出现异常,估计是 View 还没绘制完成吧。我是如下调用的:

@Override
    public void onStart() {
        super.onStart();
        if (calendarAdapter.getCalendarType() != CalendarAttr.CalendayType.WEEK){
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    scrollSwitchAction();
                }
            },500);
        }
    }
StephenCMZ commented 7 years ago

@JYPJSY 确实有出现过周历数据异常,我的做法是延迟切换到周模式:

@Override
    public void onStart() {
        super.onStart();
        if (calendarAdapter.getCalendarType() != CalendarAttr.CalendayType.WEEK){
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    scrollSwitchAction();
                }
            },500);
        }
    }
MagicMashRoom commented 7 years ago

Utils.scrollTo(content, recyclerView, monthPager.getCellHeight(), 0);//时间改为0 calendarAdapter.switchToWeek(monthPager.getRowIndex());//滑动到当前日所在行 这两句方法可以在 @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (hasFocus && !initiated) { refreshMonthPager(); initiated = true; } } 这句生命周期的回调中添加 添加完后可以提pull request ,将这个操作作为日历的一个特性封装起来

sxf-Ignite commented 6 years ago

@MagicMashRoom 我布局外层没有像你demo那样嵌套,怎么设置,在初始日历的时候只显示week模式?

2628286752 commented 6 years ago

@MagicMashRoom 只想要你的周日历效果,不需要下面的RecycleView,可以设置吗

TheBloodElf commented 6 years ago

问题太多了,基本的需求没办法满足;希望做成通用一点的

wardenlzr commented 6 years ago

@MagicMashRoom 老哥,如何单纯使用月模式呢?