{"id":230347,"date":"2020-12-23T16:31:10","date_gmt":"2020-12-23T08:31:10","guid":{"rendered":"http:\/\/4563.org\/?p=230347"},"modified":"2020-12-23T16:31:10","modified_gmt":"2020-12-23T08:31:10","slug":"kotlin-%e4%b8%ad%ef%bc%8c-intent-%e4%bc%a0%e9%80%92-map-%e9%81%87%e5%88%b0-unchecked-cast-%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=230347","title":{"rendered":"Kotlin \u4e2d\uff0c Intent \u4f20\u9012 Map \u9047\u5230 Unchecked cast \u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Kotlin \u4e2d\uff0c Intent \u4f20\u9012 Map \u9047\u5230 Unchecked cast \u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lixyz <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4f20\u9012\uff1a<\/p>\n<pre><code> val intent = Intent(this, ImageCategoryActivity::class.java)  intent.putExtra(\"Images\", netDiskData!!.imageMap)      startActivity(intent) <\/code><\/pre>\n<p>\u63a5\u6536\uff1a<\/p>\n<pre><code>val imageData =             intent.getSerializableExtra(\"Images\") as HashMap&lt;String, ArrayList&lt;ImageBean&gt;&gt; <\/code><\/pre>\n<p>ImageBean \u662f\u4e00\u4e2a\u5b9e\u4f53\u7c7b\uff0c\u5df2\u7ecf Serializable \u5e8f\u5217\u5316<\/p>\n<p>\u4f46\u662f AndroidStudio \u4f1a\u63d0\u793a Unchecked cast<\/p>\n<pre><code>Unchecked cast: Serializable! to kotlin.collections.HashMap&lt;String, ArrayList&lt;ImageBean&gt; \/* = ArrayList&lt;ImageBean&gt; *\/&gt; \/* = java.util.HashMap&lt;String, ArrayList&lt;ImageBean&gt;&gt; *\/ <\/code><\/pre>\n<p>\u4ee3\u7801\u6d01\u7656\u770b\u7740\u5b9e\u5728\u662f\u70e6\u4eba\uff0c\u641c\u4e86\u4e00\u5708\uff0c\u90fd\u662f\u8ba9 <code>@SuppressWarnings(\"unchecked\")<\/code> \u6765\u89e3\u51b3\u7f16\u8bd1\u5668\u8b66\u544a\uff0c\u4f46\u662f\u5e76\u6ca1\u6709\u5b9e\u9645\u89e3\u51b3\u95ee\u9898<\/p>\n<p>\u4f60\u4eec\u6709\u4eba\u9047\u5230\u8fd9\u79cd\u60c5\u51b5\u5417\uff1f\u662f\u600e\u4e48\u89e3\u51b3\u7684\u5462\uff1f\u8c22\u8c22\u8c22\u8c22<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>7<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4726834\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ZSeptember <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4e0d\u5c31\u662f\u4e00\u4e2a\u7f16\u8bd1\u5668\u8b66\u544a\u5417\uff1f<br \/>\u4f60\u628a\u4e00\u4e2a Object \u5f3a\u5236\u8f6c\u4e3a \u4e00\u4e2a Map\uff0c\u4e0d\u5f97\u544a\u8b66\u5417\u3002<br \/>\u8fd8\u60f3\u600e\u4e48\u89e3\u51b3\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4726835\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mxalbert1996 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u79cd\u7f16\u8bd1\u5668\u4e0d\u786e\u5b9a\u4f46\u4f60\u53ef\u4ee5\u786e\u5b9a\u6ca1\u95ee\u9898\u7684\u60c5\u51b5\u6b63\u662f Suppress \u7684\u7528\u9014\uff08\u4f60\u5e94\u8be5\u7528 Kotlin \u7684 @Suppress \uff09\uff0cKotlin \u7684\u6807\u51c6\u5e93\u4e5f\u662f\u8fd9\u4e48\u505a\u7684\u3002<br \/>https:\/\/github.com\/JetBrains\/kotlin\/blob\/532124d9a17e6939046bd0ff9ef5699d21d2ed2d\/libraries\/stdlib\/src\/kotlin\/util\/Lazy.kt#L84                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4726836\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : lixyz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @mxalbert1996 \u660e\u767d\u4e86\uff0c\u591a\u8c22\u591a\u8c22\uff0c\u4ed4\u7ec6\u60f3\u60f3\uff0c\u786e\u5b9e\u50cf\u4f60\u8bf4\u7684\u4e00\u6837\uff0c\u8981\u4e0d\u7136\u4eba\u5bb6\u4e5f\u4e0d\u4f1a\u5e73\u767d\u65e0\u6545\u641e\u4e2a Suppress \u51fa\u6765\u3002\u3002\u3002\u662f\u6211\u94bb\u725b\u89d2\u5c16\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4726837\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fromzero <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u662f\u6211\u7684\u8bdd\u6211\u4e0d\u4f1a\u628a map \u4f20\u5230 intent \u3002\u6700\u597d\u628a\u6570\u636e\u62cd\u5e73\uff0c\u5b58\u5230\u4e00\u4e2a\u5bf9\u8c61\u91cc\u3002\u5982\u679c\u662f\u62cd\u4e0d\u5e73\u975e\u8981\u7528 map \u5c31\u7528 eventbus \u4e4b\u7c7b\u7684\u53d1\u9001\u7c98\u6027\u4e8b\u4ef6\u6765\u63a5\u6536                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4726838\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : lixyz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @fromzero \u8bf7\u6559\u4e00\u4e0b\uff0c\u4e3a\u4ec0\u4e48\u8981\u8fd9\u4e48\u505a\u5462\uff1f\u8fd9\u6837\u505a\u6709\u4ec0\u4e48\u597d\u5904\u554a\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4726839\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fromzero <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lixyz intent \u5b9a\u4f4d\u8f7b\u91cf\u6570\u636e\uff0cmap \u91cc\u5982\u679c\u53ea\u662f\u51e0\u4e2a\u6570\u636e\u90a3\u5b8c\u5168\u53ef\u4ee5\u62cd\u5e73\u3002\u5982\u679c\u5927\u91cf\u6570\u636e\uff0c\u6bd4\u5982\u4f60\u4e0a\u9762\u8fd9\u79cd map \u91cc\u9762\u8fd8\u6709 list list \u91cc\u9762\u53ef\u80fd\u53c8\u6709\u5d4c\u5957\u7684\u5bf9\u8c61\uff0c\u53ef\u80fd\u51e0\u767e\u4e2a\u6570\u636e\uff0c\u4f60 debug \u4e0d\u51fa\u95ee\u9898\uff0c\u4e0d\u80fd\u4fdd\u8bc1\u6240\u6709\u624b\u673a\u6ca1\u95ee\u9898\uff0c\u6bcf\u4e2a\u624b\u673a intent size<br \/>\u4e0d\u4e00\u6837\u3002\u8fd9\u5e8f\u5217\u5316\u4f20\u8d77\u6765\u5c31\u633a\u6162\u7684\uff0c\u800c\u4e14\u4f1a\u51fa\u73b0\u4f60\u63d0\u51fa\u7684\u8fd9\u4e2a\u7c7b\u578b\u95ee\u9898\u3002\u4f60\u5f97\u81ea\u5df1\u8f6c\u7c7b\u578b\u3002\u5e8f\u5217\u5316\u4e4b\u540e\u7f16\u8bd1\u5668\u662f\u65e0\u6cd5\u77e5\u9053\u7c7b\u578b\u7684\u3002\u5f3a\u8f6c\u8fd9\u79cd\u590d\u6742\u7684\u7ed3\u6784\u5c31\u5bb9\u6613\u51fa\u9519\uff0c\u6240\u4ee5\u6700\u4f73\u5efa\u8bae\u662f\u53ea\u4f20\u8f93\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5e76\u4e14\u91cc\u9762\u5c3d\u91cf\u662f\u57fa\u672c\u6570\u636e\u7c7b\u578b\u5b57\u6bb5\u3002\u7b26\u5408 intent \u8f7b\u91cf\u6570\u636e\u5b9a\u4f4d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4726840\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : lixyz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @fromzero \u6709\u9053\u7406\uff0c\u591a\u8c22\u591a\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Kotlin \u4e2d\uff0c Intent &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/230347"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=230347"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/230347\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=230347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=230347"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=230347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}