Skip to content

Commit

Permalink
Use notifyItemRangeChanged instead of notifyDataSetChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
kizitonwose committed Dec 25, 2020
1 parent e51bd40 commit dbc1e58
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
/build
/captures
.externalNativeBuild
.idea/markdown-navigator-enh.xml
.idea/markdown-navigator.xml
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,10 @@ open class CalendarView : RecyclerView {

/**
* Notify the CalendarView to reload all months.
* Essentially calls [RecyclerView.Adapter.notifyDataSetChanged] on the adapter.
* Just like calling [notifyMonthChanged] for all months.
*/
fun notifyCalendarChanged() {
calendarAdapter.notifyDataSetChanged()
calendarAdapter.reloadCalendar()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ internal class CalendarAdapter(
notifyItemChanged(getAdapterPosition(month))
}

fun reloadCalendar() {
notifyItemRangeChanged(0, itemCount)
}

private var visibleMonth: CalendarMonth? = null
private var calWrapsHeight: Boolean? = null
private var initialLayout = true
Expand Down

0 comments on commit dbc1e58

Please sign in to comment.