{"id":396,"date":"2023-02-25T08:50:16","date_gmt":"2023-02-25T00:50:16","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=396"},"modified":"2023-04-30T14:36:54","modified_gmt":"2023-04-30T06:36:54","slug":"rxjava2-learning-8-preventing-repeated-continuous-clicking-of-button","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/25\/rxjava2-learning-8-preventing-repeated-continuous-clicking-of-button\/","title":{"rendered":"RxJava2\u5b66\u4e60\u4e4b\u516b\uff1a\u9632\u6b62\u6309\u94ae\u91cd\u590d\uff08\u8fde\u7eed\uff09\u70b9\u51fb"},"content":{"rendered":"<h3>RxBinding<\/h3>\n<p>RxJava\u5b9e\u73b0\u6570\u636e\u4e0e\u89c6\u56fe\u7684\u7ed1\u5b9a\u4f7f\u7528\u5230\u4e86RxBinding\u3002RxBinding\u662f\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\uff0c\u53ef\u4ee5\u5b9e\u73b0\u6570\u636e\u5c42\u4e0eView\u5c42\u7684\u7ed1\u5b9a\uff0c\u5f53\u6570\u636e\u53d1\u751f\u53d8\u5316\uff0cView\u4f1a\u81ea\u52a8\u66f4\u65b0UI\u3002<\/p>\n<p>RxBinding\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/JakeWharton\/RxBinding\">https:\/\/github.com\/JakeWharton\/RxBinding<\/a><\/p>\n<p><!-- more --><\/p>\n<blockquote>\n<p>\u6ce8\u610f\uff1aRxBinding\u76ee\u524d\u53ea\u652f\u6301RxJava1<\/p>\n<\/blockquote>\n<h3>RxJava\u64cd\u4f5c\u7b26<\/h3>\n<p>\u672c\u4f8b\u6d89\u53ca\u7684RxJava\u64cd\u4f5c\u7b26\uff1a<\/p>\n<ul>\n<li><strong>ThrottleFirst<\/strong> \u2014 <em>\u5141\u8bb8\u8bbe\u7f6e\u4e00\u4e2a\u65f6\u95f4\u957f\u5ea6\uff0c\u4e4b\u540e\u5b83\u4f1a\u53d1\u9001\u56fa\u5b9a\u65f6\u95f4\u957f\u5ea6\u5185\u7684\u7b2c\u4e00\u4e2a\u4e8b\u4ef6\uff0c\u800c\u5c4f\u853d\u5176\u5b83\u4e8b\u4ef6\uff0c\u5728\u95f4\u9694\u8fbe\u5230\u8bbe\u7f6e\u7684\u65f6\u95f4\u540e\uff0c\u53ef\u4ee5\u518d\u53d1\u9001\u4e0b\u4e00\u4e2a\u4e8b\u4ef6<\/em><\/li>\n<\/ul>\n<h3>\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<h4>\u6dfb\u52a0\u4f9d\u8d56<\/h4>\n<pre><code>compile &#039;com.squareup.retrofit2:retrofit:2.1.0&#039;\ncompile &#039;com.squareup.retrofit2:converter-gson:2.1.0&#039;\ncompile &#039;com.jakewharton.rxbinding:rxbinding:1.0.0&#039;<\/code><\/pre>\n<h4>RxJava\u5b9e\u73b0<\/h4>\n<pre><code class=\"language-java\">Button button = (Button) this.findViewById(R.id.prevent_duplicate_click);\nRxView.clicks(button).throttleFirst(1, TimeUnit.SECONDS)\n    .subscribe(new Observer&lt;Void&gt;() {\n        @Override\n        public void onCompleted() {\n\n        }\n\n        @Override\n        public void onError(Throwable e) {\n\n        }\n\n        @Override\n        public void onNext(Void aVoid) {\n            Log.i(TAG, &quot;onNext: \u6309\u94ae\u70b9\u51fb&quot;);\n        }\n    });<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>RxBinding RxJava\u5b9e\u73b0\u6570\u636e\u4e0e\u89c6\u56fe\u7684\u7ed1\u5b9a\u4f7f\u7528\u5230\u4e86RxBinding\u3002RxBinding\u662f\u4e00\u4e2a\u5f00\u6e90\u9879 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[131],"tags":[132],"class_list":["post-396","post","type-post","status-publish","format-standard","hentry","category-rxjava","tag-rxjava"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=396"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/396\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}