隐私协议弹窗增加5s后才能点击同意
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.yizhuan.erban.other.dialog;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
@@ -24,9 +25,18 @@ import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.yizhuan.xchat_android_core.UriProvider;
|
||||
import com.yizhuan.xchat_android_library.utils.ScreenUtils;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
|
||||
public class PrivacyAgreementDialog extends Dialog implements View.OnClickListener {
|
||||
|
||||
private final int intervalTimeCount = 5;
|
||||
private OnCallBack onCallBack;
|
||||
private Disposable disposable;
|
||||
|
||||
public PrivacyAgreementDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
@@ -36,14 +46,26 @@ public class PrivacyAgreementDialog extends Dialog implements View.OnClickListen
|
||||
this.onCallBack = onCallBack;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.dialog_privacy_agreement);
|
||||
|
||||
findViewById(R.id.tv_confirm).setOnClickListener(this);
|
||||
TextView tvConfirm = findViewById(R.id.tv_confirm);
|
||||
tvConfirm.setEnabled(false);
|
||||
tvConfirm.setOnClickListener(this);
|
||||
disposable = Observable.intervalRange(0, intervalTimeCount + 1, 0, 1, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> {
|
||||
long residueCount = intervalTimeCount - aLong;
|
||||
if (residueCount == 0) {
|
||||
tvConfirm.setEnabled(true);
|
||||
tvConfirm.setText("同意");
|
||||
} else {
|
||||
tvConfirm.setText("同意(" + residueCount + "s)");
|
||||
}
|
||||
});
|
||||
findViewById(R.id.btn_cancel).setOnClickListener(this);
|
||||
|
||||
TextView tvDesc = findViewById(R.id.tv_desc);
|
||||
String privacyAgreementTip = getContext().getString(R.string.tip_privacy_agreement);
|
||||
String userAgreementTip = getContext().getString(R.string.tip_user_agreement);
|
||||
@@ -94,6 +116,7 @@ public class PrivacyAgreementDialog extends Dialog implements View.OnClickListen
|
||||
if (onCallBack != null) {
|
||||
onCallBack.onFinish(v.getId() == R.id.tv_confirm);
|
||||
}
|
||||
if (disposable != null) disposable.dispose();
|
||||
}
|
||||
|
||||
public interface OnCallBack {
|
||||
|
Reference in New Issue
Block a user