From b0ba5b7d573af6c4215dfcb1609dfbc35ad3c0e8 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Tue, 25 Oct 2022 16:10:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/dialog/HintDialog.java | 38 +++++++++---------- .../yunbao/common/manager/IMLoginManager.java | 2 +- .../yunbao/main/activity/MainActivity.java | 12 +++++- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/dialog/HintDialog.java b/common/src/main/java/com/yunbao/common/dialog/HintDialog.java index 4df56490e..a4ec14280 100644 --- a/common/src/main/java/com/yunbao/common/dialog/HintDialog.java +++ b/common/src/main/java/com/yunbao/common/dialog/HintDialog.java @@ -7,8 +7,6 @@ import android.view.Window; import android.view.WindowManager; import android.widget.TextView; -import com.lzf.easyfloat.interfaces.OnPermissionResult; -import com.lzf.easyfloat.permission.PermissionUtils; import com.yunbao.common.R; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.DpUtil; @@ -48,9 +46,10 @@ public class HintDialog extends AbsDialogFragment { TextView hint = (TextView) findViewById(R.id.hint); TextView toSetUp = (TextView) findViewById(R.id.to_set_up); TextView knowThe = (TextView) findViewById(R.id.know_the); - IMLoginManager.get(mContext).initISHint(); + Bundle args = getArguments(); if (args != null && !TextUtils.isEmpty(args.getString("close")) && TextUtils.equals(args.getString("close"), "1")) { + IMLoginManager.get(mContext).initISHint2(); hint.setText(getString(R.string.do_you_like)); toSetUp.setText(getString(R.string.to_set_up)); knowThe.setText(getString(R.string.know_the)); @@ -63,28 +62,29 @@ public class HintDialog extends AbsDialogFragment { }); ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.know_the), () -> dismiss()); } else { + IMLoginManager.get(mContext).initISHint(); hint.setText(getString(R.string.want_pre)); toSetUp.setText(getString(R.string.know_the)); knowThe.setText(getString(R.string.to_set_up)); - ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.to_set_up), new ViewClicksAntiShake.ViewClicksCallBack() { - @Override - public void onViewClicks() { - PermissionUtils.requestPermission(getActivity(), new OnPermissionResult() { - @Override - public void permissionResult(boolean b) { - - } - }); - dismiss(); - } - }); - ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.to_set_up), new ViewClicksAntiShake.ViewClicksCallBack() { - @Override - public void onViewClicks() { - dismiss(); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.know_the), () -> { + if (listener != null) { + listener.requestPermission(); } + dismiss(); }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.to_set_up), () -> dismiss()); } } + + private HintListener listener; + + public HintDialog setListener(HintListener listener) { + this.listener = listener; + return this; + } + + public interface HintListener { + void requestPermission(); + } } diff --git a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java index f3b00750f..02bc9b767 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java @@ -52,7 +52,7 @@ public class IMLoginManager extends BaseCacheManager { } public void initISHint2() { - put(IS_HINT, false); + put(IS_HINT2, false); } diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index eb04cdd73..83ff904ad 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -41,6 +41,8 @@ import com.google.firebase.messaging.FirebaseMessaging; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.jakewharton.rxbinding3.view.RxView; +import com.lzf.easyfloat.interfaces.OnPermissionResult; +import com.lzf.easyfloat.permission.PermissionUtils; import com.tencent.imsdk.v2.V2TIMCallback; import com.tencent.imsdk.v2.V2TIMManager; import com.tencent.imsdk.v2.V2TIMSDKConfig; @@ -483,6 +485,14 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene if (IMLoginManager.get(mContext).isHint()) { HintDialog fragment = new HintDialog(); fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "HintDialog"); + fragment.setListener(new HintDialog.HintListener() { + @Override + public void requestPermission() { + PermissionUtils.requestPermission(mContext, b -> { + + }); + } + }); } } @@ -1265,7 +1275,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene @Subscribe(threadMode = ThreadMode.MAIN) public void onLiveFloatEvent(LiveFloatEvent event) { - if (event != null && event.getmLiveBean() != null && !TextUtils.isEmpty(event.getmLiveBean().getPull())){ + if (event != null && event.getmLiveBean() != null && !TextUtils.isEmpty(event.getmLiveBean().getPull())) { new Handler().post(() -> LiveFloatView.getInstance() .cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK(), event.getmLiveTypeVal()) .builderFloat(mContext, event.getmLiveBean().getPull(), LiveAudienceActivity.class));