{"id":1363,"date":"2019-06-13T10:29:52","date_gmt":"2019-06-13T01:29:52","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=1363"},"modified":"2021-07-15T15:38:06","modified_gmt":"2021-07-15T06:38:06","slug":"recyclerview-%ec%82%ac%ec%9a%a9%ec%8b%9c-diffing-callback-%ea%b5%ac%ed%98%84%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=1363","title":{"rendered":"RecyclerView \uc0ac\uc6a9\uc2dc Diffing callback  \uad6c\ud604\ud558\uae30"},"content":{"rendered":"<p>RecyclerView.Adapter\uc758 \uc131\ub2a5\uc744 \ub192\uc774\uac70\ub098 \ub610\ub294 \uac19\uc740 \uc774\uc720\uc9c0\ub9cc Paging Component\ub97c \uc4f0\ub294\uacbd\uc6b0 DiffUtil.ItemCallback\uc744 \ubc18\ub4dc\uc2dc \uad6c\ud604\ud574\uc57c \ud569\ub2c8\ub2e4.<\/p>\n<p>\ubcf4\ud1b5 Adapter\ub0b4\uc5d0\uc11c Inner class\ub85c \uad6c\ud604\ud558\uac70\ub098 Outer\ub85c \ube7c\uc11c \uc0dd\uc131\uc790 \ud30c\ub77c\ubbf8\ud130\ub85c OldItem\uacfc NewItem\uc744 \uc81c\uacf5\ud574\uc57c\ud569\ub2c8\ub2e4.<\/p>\n<p>boolean areItemsTheSame(oldItem, newItem) \ub97c \ud1b5\ud574 \uc774\uc820 \uc544\uc774\ud15c\uacfc \uc0c8\ub85c\uc6b4 \uc544\uc774\ud15c\uc758 ID\uac00 \uac19\uc740\uc9c0 \ube44\uad50\ud55c \ub4a4 \uac19\uc740 \uacbd\uc6b0 \ub0b4\ubd80\uc5d0\uc11c boolean areContentsTheSame(oldItem, newItem) \uc744 \ub2e4\uc2dc \ud638\ucd9c\ud558\uc5ec\uc11c \uac1d\uccb4\uc758 \ud544\ub4dc\uac00 \uac19\uc740\uc9c0 \ube44\uad50\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ub9cc\uc57dareItemsTheSame\uc774 false\ub97c \ubc18\ud658\ud558\uba74 areContentsTheSame\ub294 \ud638\ucd9c\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"lang:java decode:true \">private static DiffUtil.ItemCallback&lt;Concert&gt; DIFF_CALLBACK =\r\n        new DiffUtil.ItemCallback&lt;Concert&gt;() {\r\n\r\n    @Override\r\n    public boolean areItemsTheSame(Concert oldItem, Concert newItem) {\r\n        \/\/ \uc774\uac83\uc5d0\uc11c \uc774\uc804 \uc544\uc774\ud15c\uacfc \uc0c8\ub85c\uc6b4 \uc544\uc774\ud15c\uc774 \uac19\uc740\uc9c0 \ube44\uad50\ud558\uae30 \uc704\ud574 \uace0\uc720 \uc2dd\ubcc4\uc790\ub97c \ube44\uad50 \ud569\ub2c8\ub2e4.\r\n        return oldItem.getId() == newItem.getId();\r\n    }\r\n\r\n    @Override\r\n    public boolean areContentsTheSame(Concert oldItem, Concert newItem) {\r\n        \/\/ \uc774\uacf3\uc5d0\uc11c\ub294 \"==\" \uc5f0\uc0b0\uc790\ub97c \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \ub300\uc2e0 .equals()\ub97c \uc0ac\uc6a9\ud569\ub2c8\ub2e4.\r\n        \/\/ \ub610\ub294 \ub450 \uac1d\uccb4\ub97c \ube44\uad50\ud560 \uc218 \uc788\ub294 \ub85c\uc9c1\uc744 \uc774\uacf3\uc5d0 \uc791\uc131 \ud558\uc5ec \ub9ac\ud134\ud558\ub3c4\ub85d \ud569\ub2c8\ub2e4.\r\n        return oldItem.equals(newItem);\r\n    }\r\n};<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>RecyclerView.Adapter\uc758 \uc131\ub2a5\uc744 \ub192\uc774\uac70\ub098 \ub610\ub294 \uac19\uc740 \uc774\uc720\uc9c0\ub9cc Paging Component\ub97c \uc4f0\ub294\uacbd\uc6b0 DiffUtil.ItemCallback\uc744 \ubc18\ub4dc\uc2dc \uad6c\ud604\ud574\uc57c \ud569\ub2c8\ub2e4. \ubcf4\ud1b5 Adapter\ub0b4\uc5d0\uc11c Inner class\ub85c \uad6c\ud604\ud558\uac70\ub098 Outer\ub85c \ube7c\uc11c \uc0dd\uc131\uc790 \ud30c\ub77c\ubbf8\ud130\ub85c OldItem\uacfc NewItem\uc744 \uc81c\uacf5\ud574\uc57c\ud569\ub2c8\ub2e4. boolean areItemsTheSame(oldItem, newItem) \ub97c \ud1b5\ud574 \uc774\uc820 \uc544\uc774\ud15c\uacfc \uc0c8\ub85c\uc6b4 \uc544\uc774\ud15c\uc758 ID\uac00 \uac19\uc740\uc9c0 \ube44\uad50\ud55c \ub4a4 \uac19\uc740 \uacbd\uc6b0 \ub0b4\ubd80\uc5d0\uc11c boolean areContentsTheSame(oldItem, newItem) \uc744 \ub2e4\uc2dc \ud638\ucd9c\ud558\uc5ec\uc11c \uac1d\uccb4\uc758 \ud544\ub4dc\uac00 \uac19\uc740\uc9c0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[16],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/1363"}],"collection":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1363"}],"version-history":[{"count":7,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/1363\/revisions"}],"predecessor-version":[{"id":45269,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/1363\/revisions\/45269"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}