MagicMashRoom / SuperCalendar

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

Calendar v2 = calendars.get((currentPosition - 1) % 3) 越界 #122

Open ZaneSummer opened 6 years ago

ZaneSummer commented 6 years ago

java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1 at java.util.ArrayList.get(ArrayList.java:310) at com.ldf.calendar.component.CalendarViewAdapter.refreshCalendar(CalendarViewAdapter.java:258) at com.ldf.calendar.component.CalendarViewAdapter.notifyDataChanged(CalendarViewAdapter.java:219) at com.hqyxjy.ldf.supercalendar.JyCalendar.refreshMonthPager(JyCalendar.java:277) at com.hqyxjy.ldf.supercalendar.JyCalendar.onWindowFocusChanged(JyCalendar.java:93) at android.view.View.dispatchWindowFocusChanged(View.java:7589) at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:985) at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:989) at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:989) at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:989) at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:989) at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:989) at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:989) at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:989) at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3171) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5162) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:756) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:572) at miui.dexspy.DexspyInstaller.main(DexspyInstaller.java:171) at dalvik.system.NativeStart.main(Native Method)

ZaneSummer commented 6 years ago

系统android 4.3 1GBRAM 红米1s

avp90 commented 6 years ago

I have the same issue (in CalendarViewAdapter.java:258), when i call notifyDataChanged() after init. this.currentPosition has the value 0 and (this.currentPosition - 1) % 3 results -1

avp90 commented 6 years ago

My solution was to create a Adapter that inherits from CalendarViewAdapter and overrides finishUpdate(container: ViewGroup) to delegate the information to the Fragment or Presenter. When the finishUpdate(container: ViewGroup) is called, you can "safety" call notifyDataChanged().