package Ġcom . tun jid . android x . recyclerview . diff Ċ Ċ import Ġandroidx . recyclerview . widget . Diff Util Ċ Ċ internal Ġclass ĠDiff Callback < T >( ĊĠĠĠ Ġprivate Ġval Ġstale : ĠList < T >, ĊĠĠĠ Ġprivate Ġval Ġupdated : ĠList < T >, ĊĠĠĠ Ġprivate Ġval Ġdiff Function : Ġ( T ) Ġ-> ĠDiff able Ċ ) Ġ: ĠDiff Util . Callback () Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġget Old List Size (): ĠInt Ġ= Ġstale . size ĊĊĠĠĠ Ġoverride Ġfun Ġget New List Size (): ĠInt Ġ= Ġupdated . size ĊĊĠĠĠ Ġoverride Ġfun Ġare Items The Same ( old Item Position : ĠInt , Ġnew Item Position : ĠInt ): ĠBoolean Ġ= ĊĠĠĠĠĠĠĠ Ġusing ( old Item Position , Ġnew Item Position ) Ġ{ Ġstale , Ġcurrent Ġ-> Ġstale . diff Id Ġ== Ġcurrent . diff Id Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġare Contents The Same ( old Item Position : ĠInt , Ġnew Item Position : ĠInt ): ĠBoolean Ġ= ĊĠĠĠĠĠĠĠ Ġusing ( old Item Position , Ġnew Item Position , ĠDiff able :: are Contents The Same ) ĊĊĠĠĠ Ġoverride Ġfun Ġget Change Payload ( old Item Position : ĠInt , Ġnew Item Position : ĠInt ): ĠAny ? Ġ= ĊĠĠĠĠĠĠĠ Ġusing ( old Item Position , Ġnew Item Position , ĠDiff able :: get Change Payload ) ĊĊĠĠĠ Ġprivate Ġfun Ġ< S > Ġusing ( old Position : ĠInt , Ġnew Position : ĠInt , Ġfunction : Ġ( Diff able , ĠDiff able ) Ġ-> ĠS ): ĠS Ġ= ĊĠĠĠĠĠĠĠ Ġfunction ( diff Function ( st ale [ old Position ]), Ġdiff Function ( updated [ new Position ])) Ċ } Ċ