语音转文字
This commit is contained in:
parent
172b37ece2
commit
7e00a5e71e
@ -1,16 +1,15 @@
|
|||||||
package com.yunbao.main.dialog;
|
package com.yunbao.common.dialog;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
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.manager.IMLoginManager;
|
||||||
import com.yunbao.common.utils.DpUtil;
|
import com.yunbao.common.utils.DpUtil;
|
||||||
import com.yunbao.common.utils.RouteUtil;
|
import com.yunbao.common.utils.RouteUtil;
|
||||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||||
import com.yunbao.main.R;
|
|
||||||
|
|
||||||
public class HintDialog extends AbsDialogFragment {
|
public class HintDialog extends AbsDialogFragment {
|
||||||
@Override
|
@Override
|
||||||
@ -31,7 +30,7 @@ public class HintDialog extends AbsDialogFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setWindowAttributes(Window window) {
|
protected void setWindowAttributes(Window window) {
|
||||||
window.setWindowAnimations(com.yunbao.live.R.style.bottomToTopAnim);
|
window.setWindowAnimations(R.style.bottomToTopAnim);
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
WindowManager.LayoutParams params = window.getAttributes();
|
||||||
params.width = DpUtil.dp2px(277);
|
params.width = DpUtil.dp2px(277);
|
||||||
params.height = DpUtil.dp2px(134);
|
params.height = DpUtil.dp2px(134);
|
@ -5,6 +5,8 @@ import android.util.Log;
|
|||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import com.lzf.easyfloat.EasyFloat;
|
import com.lzf.easyfloat.EasyFloat;
|
||||||
import com.lzf.easyfloat.enums.ShowPattern;
|
import com.lzf.easyfloat.enums.ShowPattern;
|
||||||
import com.lzf.easyfloat.interfaces.FloatCallbacks;
|
import com.lzf.easyfloat.interfaces.FloatCallbacks;
|
||||||
@ -14,6 +16,8 @@ import com.tencent.live2.impl.V2TXLivePlayerImpl;
|
|||||||
import com.tencent.rtmp.ui.TXCloudVideoView;
|
import com.tencent.rtmp.ui.TXCloudVideoView;
|
||||||
import com.yunbao.common.R;
|
import com.yunbao.common.R;
|
||||||
import com.yunbao.common.bean.LiveBean;
|
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.utils.RouteUtil;
|
||||||
import com.yunbao.common.views.floatingview.APPEasyFloat;
|
import com.yunbao.common.views.floatingview.APPEasyFloat;
|
||||||
import com.yunbao.common.views.floatingview.FloatingMagnetView;
|
import com.yunbao.common.views.floatingview.FloatingMagnetView;
|
||||||
@ -66,6 +70,10 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
|||||||
public void onViewClicks() {
|
public void onViewClicks() {
|
||||||
mPlayer.stopPlay();
|
mPlayer.stopPlay();
|
||||||
APPEasyFloat.getInstance().dismiss(mContext);
|
APPEasyFloat.getInstance().dismiss(mContext);
|
||||||
|
if (IMLoginManager.get(mContext).isHint()) {
|
||||||
|
HintDialog fragment = new HintDialog();
|
||||||
|
fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "HintDialog");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
|
ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
|
||||||
@ -155,6 +163,10 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
|||||||
public void onViewClicks() {
|
public void onViewClicks() {
|
||||||
mPlayer.stopPlay();
|
mPlayer.stopPlay();
|
||||||
EasyFloat.dismiss("LiveFloatView", true);
|
EasyFloat.dismiss("LiveFloatView", true);
|
||||||
|
if (IMLoginManager.get(mContext).isHint()) {
|
||||||
|
HintDialog fragment = new HintDialog();
|
||||||
|
fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "HintDialog");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
|
ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
|
||||||
|
@ -20,8 +20,6 @@ import com.iflytek.cloud.SpeechConstant;
|
|||||||
import com.iflytek.cloud.SpeechError;
|
import com.iflytek.cloud.SpeechError;
|
||||||
import com.iflytek.cloud.SpeechRecognizer;
|
import com.iflytek.cloud.SpeechRecognizer;
|
||||||
import com.yunbao.common.dialog.AbsDialogFragment;
|
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.R;
|
||||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||||
|
|
||||||
@ -83,7 +81,7 @@ public class VoiceDialog extends AbsDialogFragment {
|
|||||||
protected void setWindowAttributes(Window window) {
|
protected void setWindowAttributes(Window window) {
|
||||||
window.setWindowAnimations(com.yunbao.common.R.style.bottomToTopAnim);
|
window.setWindowAnimations(com.yunbao.common.R.style.bottomToTopAnim);
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
WindowManager.LayoutParams params = window.getAttributes();
|
||||||
params.width =WindowManager.LayoutParams.WRAP_CONTENT;
|
params.width = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||||
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||||
params.gravity = Gravity.CENTER;
|
params.gravity = Gravity.CENTER;
|
||||||
window.setAttributes(params);
|
window.setAttributes(params);
|
||||||
@ -107,25 +105,32 @@ public class VoiceDialog extends AbsDialogFragment {
|
|||||||
* 上划取消
|
* 上划取消
|
||||||
*/
|
*/
|
||||||
public void withdraw() {
|
public void withdraw() {
|
||||||
voiceFluctuations.setVisibility(View.GONE);
|
if (!isDetached()) {
|
||||||
gifView.setVisibility(View.GONE);
|
voiceFluctuations.setVisibility(View.GONE);
|
||||||
iconWithdraw.setVisibility(View.VISIBLE);
|
gifView.setVisibility(View.GONE);
|
||||||
fingersSlide.setText(getString(R.string.release_cancel_send));
|
iconWithdraw.setVisibility(View.VISIBLE);
|
||||||
isSend = false;
|
fingersSlide.setText(getString(R.string.release_cancel_send));
|
||||||
|
isSend = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上划取消
|
* 上划取消
|
||||||
*/
|
*/
|
||||||
public void notWithdraw() {
|
public void notWithdraw() {
|
||||||
if (TextUtils.isEmpty(sendMessage())){
|
if (!isDetached()) {
|
||||||
voiceFluctuations.setVisibility(View.VISIBLE);
|
if (TextUtils.isEmpty(sendMessage())) {
|
||||||
}else {
|
if (gifView.getVisibility() != View.VISIBLE)
|
||||||
gifView.setVisibility(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() {
|
RecognizerListener recognizerListener = new RecognizerListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVolumeChanged(int volume, byte[] bytes) {
|
public void onVolumeChanged(int volume, byte[] bytes) {
|
||||||
if (volume > 10) {
|
if (volume > 10) {
|
||||||
gifView.setVisibility(View.VISIBLE);
|
gifView.setVisibility(View.VISIBLE);
|
||||||
voiceFluctuations.setVisibility(View.GONE);
|
voiceFluctuations.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -290,11 +290,11 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
|||||||
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||||
float moveY = event.getY();
|
float moveY = event.getY();
|
||||||
if (downY - moveY > 120) {
|
if (downY - moveY > 120) {
|
||||||
if (voiceDialog != null)
|
if (voiceDialog != null && voiceDialog.isAdded())
|
||||||
voiceDialog.withdraw();
|
voiceDialog.withdraw();
|
||||||
}
|
}
|
||||||
if ((downY - moveY < 100) && (downY - moveY > 30)) {
|
if ((downY - moveY < 100) && (downY - moveY > 30)) {
|
||||||
if (voiceDialog != null)
|
if (voiceDialog != null&& voiceDialog.isAdded())
|
||||||
voiceDialog.notWithdraw();
|
voiceDialog.notWithdraw();
|
||||||
}
|
}
|
||||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||||
@ -326,7 +326,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
|||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
|
Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
vibrator.vibrate(30);//震动时间(ms)
|
vibrator.vibrate(100);//震动时间(ms)
|
||||||
if (voiceDialog == null) {
|
if (voiceDialog == null) {
|
||||||
voiceDialog = new VoiceDialog();
|
voiceDialog = new VoiceDialog();
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,6 @@ import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
|
|||||||
import com.yunbao.live.utils.LiveStorge;
|
import com.yunbao.live.utils.LiveStorge;
|
||||||
import com.yunbao.live.views.ChatListViewHolder;
|
import com.yunbao.live.views.ChatListViewHolder;
|
||||||
import com.yunbao.main.R;
|
import com.yunbao.main.R;
|
||||||
import com.yunbao.main.dialog.HintDialog;
|
|
||||||
import com.yunbao.main.dialog.MainStartDialogFragment;
|
import com.yunbao.main.dialog.MainStartDialogFragment;
|
||||||
import com.yunbao.main.dialog.ReturnUserDialog;
|
import com.yunbao.main.dialog.ReturnUserDialog;
|
||||||
import com.yunbao.main.dialog.SigninDialog;
|
import com.yunbao.main.dialog.SigninDialog;
|
||||||
@ -476,16 +475,13 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
@Override
|
@Override
|
||||||
protected void onRestart() {
|
protected void onRestart() {
|
||||||
super.onRestart();
|
super.onRestart();
|
||||||
new Handler().postDelayed(new Runnable() {
|
// new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
if (IMLoginManager.get(mContext).isHint()) {
|
//
|
||||||
HintDialog fragment = new HintDialog();
|
//
|
||||||
fragment.show(getSupportFragmentManager(), "HintDialog");
|
// }
|
||||||
}
|
// }, 1000);
|
||||||
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user