SuperCalendar icon indicating copy to clipboard operation
SuperCalendar copied to clipboard

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

Open ZaneSummer opened this issue 7 years ago • 3 comments

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 avatar Jan 16 '18 09:01 ZaneSummer

系统android 4.3 1GBRAM 红米1s

ZaneSummer avatar Jan 16 '18 09:01 ZaneSummer

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 avatar Jan 29 '18 06:01 avp90

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().

avp90 avatar Jan 29 '18 09:01 avp90