package Ġcom . line cy . interest ing . ui . home Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 4 . content . Context Compat Ċ import Ġandroid . support . v 4 . widget . Swipe Refresh Layout . On Refresh Listener Ċ import Ġandroid . support . v 7 . widget . Linear LayoutManager Ċ import Ġandroid . support . v 7 . widget . helper . Item Touch Helper Ċ import Ġandroid . view . animation . Animation Ċ import Ġcom . line cy . interest ing . BR Ċ import Ġcom . line cy . interest ing . R Ċ import Ġcom . line cy . interest ing . R . color Ċ import Ġcom . line cy . interest ing . databinding . Fragment RecyclerView Binding Ċ import Ġcom . line cy . interest ing . ui . Base Fragment Ċ import Ġcom . line cy . interest ing . ui . home . adapter . RecyclerView Adapter Ċ import Ġcom . line cy . interest ing . ui . misc . Item Touch Callback Ċ import Ġcom . line cy . interest ing . ui . misc . Sticky Header Decoration Ċ import Ġcom . line cy . interest ing . ui . misc . View Container Ċ import Ġcom . line cy . interest ing . utils . Animation Utils Ċ import Ġcom . line cy . interest ing . utils . Display Utils Ċ import Ġcom . line cy . interest ing . view model . RecyclerView ViewModel Ċ import Ġkotlinx . android . synt hetic . main . fragment _ recycler _ view . re cyclerView Ċ import Ġkotlinx . android . synt hetic . main . fragment _ recycler _ view . swipe Layout Ċ import Ġkotlinx . android . synt hetic . main . fragment _ recycler _ view . view Container Ċ Ċ /** Ċ Ġ* ĠRecyclerView Ġ çĽ¸åħ³ ãĢĤ Ċ Ġ* Ċ Ġ* Ġ@ author Ġby Ġline cy . Ċ Ġ*/ Ċ Ċ class ĠRecyclerView Fragment Ġ: ĠBase Fragment < Fragment RecyclerView Binding >(), ĠOn Refresh Listener , ĊĠ ĠView Container . Empty Callback , ĠView Container . Error Callback Ġ{ ĊĊĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠRecyclerView ViewModel ĊĊĠ Ġoverride Ġfun Ġlayout Res Id (): ĠInt Ġ{ ĊĠĠĠ Ġreturn ĠR . layout . fragment _ recycler _ view ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Init View ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠ Ġswipe Layout . setOn Refresh Listener ( this ) ĊĠĠĠ Ġswipe Layout . setColor Scheme Resources ( color . color Primary ) ĊĠĠĠ Ġview Container . set Empty Callback ( this ) ĊĠĠĠ Ġview Container . setError Callback ( this ) ĊĠĠĠ ĠviewModel Ġ= ĠviewModel Provider . get ( RecyclerView ViewModel :: class . java ) ĊĠĠĠ Ġfragment Binding ?. set Variable ( BR . re cyclerView ViewModel , ĠviewModel ) ĊĠĠĠ Ġactivity ?. let Ġ{ ĊĠĠĠĠĠ Ġval Ġre cyclerView Adapter Ġ= ĠRecyclerView Adapter ( it ) ĊĠĠĠĠĠ Ġre cyclerView . run Ġ{ ĊĠĠĠĠĠĠĠ Ġadapter Ġ= Ġre cyclerView Adapter ĊĠĠĠĠĠĠĠ Ġval Ġmanager Ġ= ĠLinearLayoutManager ( context ) ĊĠĠĠĠĠĠĠ Ġlayout Manager Ġ= Ġmanager ĊĠĠĠĠĠĠĠ Ġval Ġdecoration Ġ= ĠSt icky Header Decoration . builder () ĊĠĠĠĠĠĠĠĠĠ Ġ. header View ( layout Inflater . inflate ( R . layout . layout _ stick _ header , Ġnull )) ĊĠĠĠĠĠĠĠĠĠ Ġ. draw Decoration ( true ) ĊĠĠĠĠĠĠĠĠĠ Ġ. decoration Color ( Context Compat . getColor ( context , ĠR . color . color Primary )) ĊĠĠĠĠĠĠĠĠĠ Ġ. decoration Margin Left ( Display Utils . dp 2 px ( context , Ġ 1 6 f ). toInt ()) ĊĠĠĠĠĠĠĠĠĠ Ġ. decoration Margin Right ( Display Utils . dp 2 px ( context , Ġ 1 6 f ). toInt ()) ĊĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġadd Item Decoration ( decoration ) ĊĊĠĠĠĠĠĠĠ Ġ// Item Touch Helper ä¼ļ ä¸İ view Pager åĨ² çªģ ĊĠĠĠĠĠĠĠ Ġval Ġleft Ġ= Ġlayout Inflater . inflate ( R . layout . layout _ left , Ġnull ) ĊĠĠĠĠĠĠĠ Ġval Ġright Ġ= Ġlayout Inflater . inflate ( R . layout . layout _ right , Ġnull ) ĊĠĠĠĠĠĠĠ ĠItem Touch Helper ( object Ġ: ĊĠĠĠĠĠĠĠĠĠ ĠItem Touch Callback ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġleft Option View Ġ= Ġleft , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġright Option View Ġ= Ġright , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġswipe Refresh Layout Ġ= Ġswipe Layout ĊĠĠĠĠĠĠĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Item Removed ( position : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġre cyclerView Adapter . on Item Removed ( position ) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ}). attach To RecyclerView ( this ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġon Refresh () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĊĠ Ġoverride Ġfun ĠonCreate Animation ( transit : ĠInt , Ġenter : ĠBoolean , Ġnext Anim : ĠInt ): ĠAnimation Ġ{ ĊĠĠĠ Ġreturn Ġwhen Ġ( next Anim ) Ġ{ ĊĠĠĠĠĠ ĠR . anim . rotate _ 3 d _ exit Ġ-> ĠAnimation Utils . create Exit Rotate 3 d Animation () ĊĠĠĠĠĠ Ġ// åĽłä¸º è¿Ľåħ¥ åĬ¨çĶ» ä¸ºäºĨ åĴĮ éĢĢåĩº åĬ¨çĶ» éħį åĲĪ ï¼Į è®¾ äºĨä¸Ģä¸ª å»¶ æĹ¶ ï¼Į æīĢä»¥ ç¬¬ ä¸Ģæ¬¡ è¿Ľåħ¥ çļĦæĹ¶åĢĻ ä¹Ł æľī ä¸ª å»¶ æĹ¶ ï¼Į åıªæĺ¯ åĽłä¸º å¾Ī çŁŃ ï¼Į çĽ®åīį å¿½ çķ¥ ĊĠĠĠĠĠ ĠR . anim . rotate _ 3 d _ enter Ġ-> ĠAnimation Utils . create Enter Rotate 3 d Animation () ĊĠĠĠĠĠ Ġelse Ġ-> Ġsuper . onCreate Animation ( transit , Ġenter , Ġnext Anim ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Refresh () Ġ{ ĊĠĠĠ ĠviewModel . refresh Data () ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Show Empty () Ġ{ ĊĠĠĠ Ġon Refresh () ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Show Error () Ġ{ ĊĠĠĠ Ġon Refresh () ĊĠ Ġ} Ċ Ċ }