From 7e00a5e71e65c48a3989d58b7d2b0c10399c8e8e Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Tue, 25 Oct 2022 14:41:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E8=BD=AC=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common}/dialog/HintDialog.java | 7 ++-- .../common/views/weight/LiveFloatView.java | 12 ++++++ .../src/main/res/layout/view_hint.xml | 0 .../com/yunbao/live/dialog/VoiceDialog.java | 37 +++++++++++-------- .../live/views/LiveAudienceViewHolder.java | 6 +-- .../yunbao/main/activity/MainActivity.java | 18 ++++----- 6 files changed, 46 insertions(+), 34 deletions(-) rename {main/src/main/java/com/yunbao/main => common/src/main/java/com/yunbao/common}/dialog/HintDialog.java (88%) rename {main => common}/src/main/res/layout/view_hint.xml (100%) diff --git a/main/src/main/java/com/yunbao/main/dialog/HintDialog.java b/common/src/main/java/com/yunbao/common/dialog/HintDialog.java similarity index 88% rename from main/src/main/java/com/yunbao/main/dialog/HintDialog.java rename to common/src/main/java/com/yunbao/common/dialog/HintDialog.java index db59a3b37..23b06f659 100644 --- a/main/src/main/java/com/yunbao/main/dialog/HintDialog.java +++ b/common/src/main/java/com/yunbao/common/dialog/HintDialog.java @@ -1,16 +1,15 @@ -package com.yunbao.main.dialog; +package com.yunbao.common.dialog; import android.os.Bundle; import android.view.Gravity; import android.view.Window; import android.view.WindowManager; -import com.yunbao.common.dialog.AbsDialogFragment; +import com.yunbao.common.R; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; -import com.yunbao.main.R; public class HintDialog extends AbsDialogFragment { @Override @@ -31,7 +30,7 @@ public class HintDialog extends AbsDialogFragment { @Override protected void setWindowAttributes(Window window) { - window.setWindowAnimations(com.yunbao.live.R.style.bottomToTopAnim); + window.setWindowAnimations(R.style.bottomToTopAnim); WindowManager.LayoutParams params = window.getAttributes(); params.width = DpUtil.dp2px(277); params.height = DpUtil.dp2px(134); diff --git a/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java b/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java index 213b8cc2e..d687228bb 100644 --- a/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java +++ b/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java @@ -5,6 +5,8 @@ import android.util.Log; import android.view.Gravity; import android.view.View; +import androidx.fragment.app.FragmentActivity; + import com.lzf.easyfloat.EasyFloat; import com.lzf.easyfloat.enums.ShowPattern; import com.lzf.easyfloat.interfaces.FloatCallbacks; @@ -14,6 +16,8 @@ import com.tencent.live2.impl.V2TXLivePlayerImpl; import com.tencent.rtmp.ui.TXCloudVideoView; import com.yunbao.common.R; import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.dialog.HintDialog; +import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.views.floatingview.APPEasyFloat; import com.yunbao.common.views.floatingview.FloatingMagnetView; @@ -66,6 +70,10 @@ public class LiveFloatView implements Function1 { public void onViewClicks() { mPlayer.stopPlay(); APPEasyFloat.getInstance().dismiss(mContext); + if (IMLoginManager.get(mContext).isHint()) { + HintDialog fragment = new HintDialog(); + fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "HintDialog"); + } } }); ViewClicksAntiShake.clicksAntiShake(videoView, () -> { @@ -155,6 +163,10 @@ public class LiveFloatView implements Function1 { public void onViewClicks() { mPlayer.stopPlay(); EasyFloat.dismiss("LiveFloatView", true); + if (IMLoginManager.get(mContext).isHint()) { + HintDialog fragment = new HintDialog(); + fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "HintDialog"); + } } }); ViewClicksAntiShake.clicksAntiShake(videoView, () -> { diff --git a/main/src/main/res/layout/view_hint.xml b/common/src/main/res/layout/view_hint.xml similarity index 100% rename from main/src/main/res/layout/view_hint.xml rename to common/src/main/res/layout/view_hint.xml diff --git a/live/src/main/java/com/yunbao/live/dialog/VoiceDialog.java b/live/src/main/java/com/yunbao/live/dialog/VoiceDialog.java index 6b1148eed..f50a3bc5e 100644 --- a/live/src/main/java/com/yunbao/live/dialog/VoiceDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/VoiceDialog.java @@ -20,8 +20,6 @@ import com.iflytek.cloud.SpeechConstant; import com.iflytek.cloud.SpeechError; import com.iflytek.cloud.SpeechRecognizer; import com.yunbao.common.dialog.AbsDialogFragment; -import com.yunbao.common.glide.ImgLoader; -import com.yunbao.common.utils.DpUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveAudienceActivity; @@ -83,7 +81,7 @@ public class VoiceDialog extends AbsDialogFragment { protected void setWindowAttributes(Window window) { window.setWindowAnimations(com.yunbao.common.R.style.bottomToTopAnim); WindowManager.LayoutParams params = window.getAttributes(); - params.width =WindowManager.LayoutParams.WRAP_CONTENT; + params.width = WindowManager.LayoutParams.WRAP_CONTENT; params.height = WindowManager.LayoutParams.WRAP_CONTENT; params.gravity = Gravity.CENTER; window.setAttributes(params); @@ -107,25 +105,32 @@ public class VoiceDialog extends AbsDialogFragment { * 上划取消 */ public void withdraw() { - voiceFluctuations.setVisibility(View.GONE); - gifView.setVisibility(View.GONE); - iconWithdraw.setVisibility(View.VISIBLE); - fingersSlide.setText(getString(R.string.release_cancel_send)); - isSend = false; + if (!isDetached()) { + voiceFluctuations.setVisibility(View.GONE); + gifView.setVisibility(View.GONE); + iconWithdraw.setVisibility(View.VISIBLE); + fingersSlide.setText(getString(R.string.release_cancel_send)); + isSend = false; + } } /** * 上划取消 */ public void notWithdraw() { - if (TextUtils.isEmpty(sendMessage())){ - voiceFluctuations.setVisibility(View.VISIBLE); - }else { - gifView.setVisibility(View.VISIBLE); + if (!isDetached()) { + if (TextUtils.isEmpty(sendMessage())) { + if (gifView.getVisibility() != View.VISIBLE) + voiceFluctuations.setVisibility(View.VISIBLE); + } else { + if (voiceFluctuations.getVisibility() != View.VISIBLE) + gifView.setVisibility(View.VISIBLE); + } + iconWithdraw.setVisibility(View.GONE); + fingersSlide.setText(getString(R.string.fingers_slide)); + isSend = true; } - iconWithdraw.setVisibility(View.GONE); - fingersSlide.setText(getString(R.string.fingers_slide)); - isSend = true; + } /** @@ -134,7 +139,7 @@ public class VoiceDialog extends AbsDialogFragment { RecognizerListener recognizerListener = new RecognizerListener() { @Override public void onVolumeChanged(int volume, byte[] bytes) { - if (volume > 10) { + if (volume > 10) { gifView.setVisibility(View.VISIBLE); voiceFluctuations.setVisibility(View.GONE); } diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index a50d3cf22..5039ea535 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -290,11 +290,11 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { } else if (event.getAction() == MotionEvent.ACTION_MOVE) { float moveY = event.getY(); if (downY - moveY > 120) { - if (voiceDialog != null) + if (voiceDialog != null && voiceDialog.isAdded()) voiceDialog.withdraw(); } if ((downY - moveY < 100) && (downY - moveY > 30)) { - if (voiceDialog != null) + if (voiceDialog != null&& voiceDialog.isAdded()) voiceDialog.notWithdraw(); } } else if (event.getAction() == MotionEvent.ACTION_UP) { @@ -326,7 +326,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { public void run() { Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); - vibrator.vibrate(30);//震动时间(ms) + vibrator.vibrate(100);//震动时间(ms) if (voiceDialog == null) { voiceDialog = new VoiceDialog(); } 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 ec9db6525..b9205f6ec 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -93,7 +93,6 @@ import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.utils.LiveStorge; import com.yunbao.live.views.ChatListViewHolder; import com.yunbao.main.R; -import com.yunbao.main.dialog.HintDialog; import com.yunbao.main.dialog.MainStartDialogFragment; import com.yunbao.main.dialog.ReturnUserDialog; import com.yunbao.main.dialog.SigninDialog; @@ -476,16 +475,13 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene @Override protected void onRestart() { super.onRestart(); - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - if (IMLoginManager.get(mContext).isHint()) { - HintDialog fragment = new HintDialog(); - fragment.show(getSupportFragmentManager(), "HintDialog"); - } - - } - }, 1000); +// new Handler().postDelayed(new Runnable() { +// @Override +// public void run() { +// +// +// } +// }, 1000); } /**