1:修改所有接口返回提示,只是添加了返回错误的提示,不涉及功能
2:给所有网络请求添加网络判断,添加拦截器 3:启动页添加启动视频,添加跳过功能 4:去掉抱麦弹框,直接跳转到用户列表 5:修改拍卖房,当抱人上麦后,没有选择关系,然后退出房间再次进来后,显示立即竞拍的按钮 6:修改我的歌单,添加和修改的时候,选择了不能使用的礼物,让dialog不关闭 7:修改点唱房,点一个人同一首歌,右侧下一首歌的作者不显示的问题 8:修改互娱房,选择关系的时候,会出现两次选择关系的问题 9:修改在送背包礼物的时候,最后一个送出,页面没有刷新 10:修改房间设置里面,点击了抽盘,设置页面不关闭的问题 11:修改个性装扮中,购买的装扮展示的时候,出现图片裁剪
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package com.xscm.moduleutil.http;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.http.NetworkException;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Response;
|
||||
|
||||
/**
|
||||
* 项目名称:羽声语音
|
||||
* 时间:2025/12/23 16:58
|
||||
* 用途:网络状态检查拦截器,会在每次请求前检查网络状态。
|
||||
*/
|
||||
public class NetworkCheckInterceptor implements Interceptor {
|
||||
|
||||
private final Context context;
|
||||
|
||||
public NetworkCheckInterceptor(Context context) {
|
||||
this.context = context.getApplicationContext(); // 使用 Application Context 避免内存泄漏
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
// 检查网络连接状态
|
||||
if (!isNetworkAvailable()) {
|
||||
// 如果没有网络,抛出我们自定义的异常
|
||||
ToastUtils.showLong("网络连接不可用,请检查您的网络设置");
|
||||
}
|
||||
|
||||
// 如果有网络,继续执行请求
|
||||
return chain.proceed(chain.request());
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查网络是否可用
|
||||
* @return true if network is available, false otherwise.
|
||||
*/
|
||||
private boolean isNetworkAvailable() {
|
||||
ConnectivityManager connectivityManager =
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
if (connectivityManager != null) {
|
||||
// 获取所有网络信息
|
||||
NetworkInfo[] networkInfos = connectivityManager.getAllNetworkInfo();
|
||||
if (networkInfos != null) {
|
||||
for (NetworkInfo info : networkInfos) {
|
||||
if (info.getState() == NetworkInfo.State.CONNECTED) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -208,9 +208,6 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
if (giftPackBeans == null) {
|
||||
return;
|
||||
}
|
||||
MvpRef.get().giftPack(giftPackBeans);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1815,6 +1815,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
LogUtils.e("handleMsgType1004", "mRoomInfoResp = $mRoomInfoResp")
|
||||
roomFragment!!.upRoomInfoData(mRoomInfoResp)
|
||||
roomFragment?.handleRoomMessage(messageEvent)
|
||||
roomBtnShowIsHide(fromUserInfo.user_id)
|
||||
|
||||
@@ -100,14 +100,14 @@ public class FriendshipRoomFragment extends BaseRoomFragment<FriendshipRoomPrese
|
||||
|
||||
@Override
|
||||
public void endFriend(FriendUserBean friendUserBean) {
|
||||
if (friendUserBean != null) {
|
||||
dialogFragment = (RoomConcernDialogFragment) getChildFragmentManager().findFragmentByTag("RoomConcernDialogFragment");
|
||||
if (dialogFragment != null && dialogFragment.isAdded()) {
|
||||
return;
|
||||
}
|
||||
RoomConcernDialogFragment.newInstance(friendUserBean, this).show(getChildFragmentManager(), "RoomConcernDialogFragment");
|
||||
|
||||
}
|
||||
// if (friendUserBean != null) {
|
||||
// dialogFragment = (RoomConcernDialogFragment) getChildFragmentManager().findFragmentByTag("RoomConcernDialogFragment");
|
||||
// if (dialogFragment != null && dialogFragment.isAdded()) {
|
||||
// return;
|
||||
// }
|
||||
// RoomConcernDialogFragment.newInstance(friendUserBean, this).show(getChildFragmentManager(), "RoomConcernDialogFragment");
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -238,7 +238,7 @@ public class FriendshipRoomFragment extends BaseRoomFragment<FriendshipRoomPrese
|
||||
initFriendshipViews();
|
||||
// 设置默认状态
|
||||
updateFriendshipState(FriendshipPartType.WAIT);
|
||||
initPopupWindow();
|
||||
// initPopupWindow(); 2025年12月24日11:21:56 去掉抱麦弹框
|
||||
|
||||
roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
|
||||
@@ -359,7 +359,10 @@ public class FriendshipRoomFragment extends BaseRoomFragment<FriendshipRoomPrese
|
||||
// 3. 锁定/解锁麦位等
|
||||
pitNumber = pitBean.getPit_number();
|
||||
if (checkWeather(pitBean.getPit_number())) {
|
||||
showPopupMenu(wheatView); // v 是点击的按钮视图
|
||||
// showPopupMenu(wheatView); // v 是点击的按钮视图
|
||||
if (getActivity() != null && getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).showUserListDialog(roomId, pitNumber, roomInfoResp.getUser_info(), roomInfoResp, getChildFragmentManager());
|
||||
}
|
||||
} else if (pitBean.getPit_number().equals("10")) {
|
||||
if (getActivity() != null && getActivity() instanceof RoomActivity) {
|
||||
if (((RoomActivity) getActivity()).getHostUser() < 4) {
|
||||
|
||||
@@ -148,16 +148,6 @@ public class RoomAuctionFragment extends BaseMvpFragment<RoomAuctionPresenterTow
|
||||
mBinding.tvPB.setText(StringUtil.toWan2(auctionUserBean.getCharm(), 1));
|
||||
countDownTime(auctionUserBean.getDuration());
|
||||
|
||||
if (auctionUserBean.getAuction_id() != null) {
|
||||
mBinding.ivJp.setVisibility(VISIBLE);
|
||||
gengv();
|
||||
auctionId = auctionUserBean.getAuction_id();
|
||||
SpUtil.setAuctionId(auctionId);
|
||||
} else {
|
||||
SpUtil.setAuctionId("");
|
||||
mBinding.ivJp.setVisibility(INVISIBLE);
|
||||
}
|
||||
|
||||
if (auctionUserBean.getUser_id() != null && auctionUserBean.getUser_id().equals(SpUtil.getUserId() + "")) {
|
||||
mBinding.ivJp.setVisibility(INVISIBLE);
|
||||
} else {
|
||||
@@ -179,7 +169,15 @@ public class RoomAuctionFragment extends BaseMvpFragment<RoomAuctionPresenterTow
|
||||
mBinding.ivJp.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
if (auctionUserBean.getAuction_id() != null && !auctionUserBean.getAuction_id().isEmpty()) {
|
||||
mBinding.ivJp.setVisibility(VISIBLE);
|
||||
gengv();
|
||||
auctionId = auctionUserBean.getAuction_id();
|
||||
SpUtil.setAuctionId(auctionId);
|
||||
} else {
|
||||
SpUtil.setAuctionId("");
|
||||
mBinding.ivJp.setVisibility(INVISIBLE);
|
||||
}
|
||||
}
|
||||
if (roomAuction.getAuction_list() != null && !roomAuction.getAuction_list().isEmpty()) {
|
||||
auctionList = roomAuction.getAuction_list();
|
||||
@@ -615,10 +613,13 @@ public class RoomAuctionFragment extends BaseMvpFragment<RoomAuctionPresenterTow
|
||||
mBinding.pB.setImageResource(com.xscm.moduleutil.R.mipmap.qm_b);
|
||||
mBinding.btnRelation.setImageResource(com.xscm.moduleutil.R.mipmap.guanx);
|
||||
mBinding.tvRelation.setTextColor(ContextCompat.getColor(requireContext(), com.xscm.moduleutil.R.color.color_FF999999));
|
||||
mBinding.tvRelation.setBackgroundResource(0);
|
||||
mBinding.btnGift.setImageResource(com.xscm.moduleutil.R.mipmap.liwu);
|
||||
mBinding.tvGift.setTextColor(ContextCompat.getColor(requireContext(), com.xscm.moduleutil.R.color.color_FF999999));
|
||||
mBinding.tvGift.setBackgroundResource(0);
|
||||
mBinding.btnTime.setImageResource(com.xscm.moduleutil.R.mipmap.shij);
|
||||
mBinding.tvTimetg.setTextColor(ContextCompat.getColor(requireContext(), com.xscm.moduleutil.R.color.color_FF999999));
|
||||
mBinding.tvTimetg.setBackgroundResource(0);
|
||||
mBinding.ivJp.setImageResource(com.xscm.moduleutil.R.mipmap.room_auction_jp);
|
||||
mBinding.avatar4.setImageResource(com.xscm.moduleutil.R.mipmap.room_ic_wheat_default);
|
||||
mBinding.avatar5.setImageResource(com.xscm.moduleutil.R.mipmap.room_ic_wheat_default);
|
||||
|
||||
@@ -103,7 +103,7 @@ public class RoomJukeboxFragment extends BaseMvpFragment<JukeboxPresenter, Fragm
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
initPopupWindow();
|
||||
// initPopupWindow(); 2025年12月24日11:25:00 去掉抱麦弹框
|
||||
mBinding.guestContainer.setVisibility(GONE);
|
||||
|
||||
viewList.clear();
|
||||
@@ -135,7 +135,10 @@ public class RoomJukeboxFragment extends BaseMvpFragment<JukeboxPresenter, Fragm
|
||||
if (cheackWether(pitBean.getPit_number())) {
|
||||
pitNumber = pitBean.getPit_number();
|
||||
roomPitBean = pitBean;
|
||||
showPopupMenu(roomJukeboxWheatView); // v 是点击的按钮视图
|
||||
// showPopupMenu(roomJukeboxWheatView); // v 是点击的按钮视图
|
||||
if (getActivity() != null && getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).showUserListDialog(roomId, pitNumber, roomInfoResp.getUser_info(), roomInfoResp, getChildFragmentManager());
|
||||
}
|
||||
} else if ((finalI + 1) == 10) {
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
if (((RoomActivity) ActivityUtils.getTopActivity()).getHostUser() < 4) {
|
||||
@@ -647,6 +650,7 @@ public class RoomJukeboxFragment extends BaseMvpFragment<JukeboxPresenter, Fragm
|
||||
roomInfoResp.getSinger_info().setNext_song_info(messageEvent.getText().getNext_song_info());
|
||||
} else {
|
||||
mBinding.guestContainer.setVisibility(View.GONE);
|
||||
roomInfoResp.getSinger_info().setNext_song_info(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class RoomMentorShipFragment(var mRoomInfoResp: RoomInfoResp?) :
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
initPopupWindow()
|
||||
// initPopupWindow() 2025年12月24日11:27:57,去掉抱麦弹框
|
||||
viewList.clear()
|
||||
|
||||
viewList.add(mBinding.rmsw1)
|
||||
|
||||
@@ -147,7 +147,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
initPopupWindow();
|
||||
// initPopupWindow(); 2025年12月24日11:18:58,去掉弹框,直接进行抱麦
|
||||
flexboxLayout = mBinding.flexboxLayout;
|
||||
var wheatContainer = WheatLayoutSingManager.Companion.getInstance().getRootContainer();
|
||||
flexboxLayout.addView(wheatContainer);
|
||||
@@ -185,7 +185,10 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
if (cheackWether(pitBean.getPit_number())) {
|
||||
pitNumber = pitBean.getPit_number();
|
||||
roomPitBean = pitBean;
|
||||
showPopupMenu(view); // v 是点击的按钮视图
|
||||
// showPopupMenu(view); // v 是点击的按钮视图
|
||||
if(getActivity() != null && getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).showUserListDialog(roomId, pitNumber, roomInfoResp.getUser_info(), roomInfoResp, getChildFragmentManager());
|
||||
}
|
||||
} else if (pitNumber1 == 10) {
|
||||
if (getActivity() != null && getActivity() instanceof RoomActivity){
|
||||
if (getActivity() != null && ((RoomActivity) getActivity()).getHostUser() < 4){
|
||||
@@ -714,7 +717,10 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
pitNumber = pitBean.getPit_number();
|
||||
roomPitBean = pitBean;
|
||||
showPopupMenu(view); // v 是点击的按钮视图
|
||||
// showPopupMenu(view); // v 是点击的按钮视图
|
||||
if(getActivity() != null && getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).showUserListDialog(roomId, pitNumber, roomInfoResp.getUser_info(), roomInfoResp, getChildFragmentManager());
|
||||
}
|
||||
} else if (pitNumber1 == 10) {
|
||||
// 添加防重复点击检查
|
||||
if (!isFastDoubleClick("online_dialog", pitNumber1 + "")) {
|
||||
@@ -785,7 +791,10 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
pitNumber = pitBean.getPit_number();
|
||||
roomPitBean = pitBean;
|
||||
showPopupMenu(view); // v 是点击的按钮视图
|
||||
// showPopupMenu(view); // v 是点击的按钮视图
|
||||
if(getActivity() != null && getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).showUserListDialog(roomId, pitNumber, roomInfoResp.getUser_info(), roomInfoResp, getChildFragmentManager());
|
||||
}
|
||||
} else if (pitNumber1 == 10) {
|
||||
// 添加防重复点击检查
|
||||
if (!isFastDoubleClick("online_dialog", pitNumber1 + "")) {
|
||||
|
||||
@@ -60,6 +60,13 @@ public class HotListPresenter extends BasePresenter<HotListContacts.View> implem
|
||||
view.finishRefreshLoadMore();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().finishRefreshLoadMore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -185,6 +185,10 @@ public class VocalRangeFragment extends BaseMvpFragment<MePresenter, FragmentVoc
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
if (userInfo==null ){
|
||||
ToastUtils.show("用户数据错误");
|
||||
return;
|
||||
}
|
||||
int id = view.getId();
|
||||
if (id == R.id.ll_visit) {
|
||||
// ARouter.getInstance().build(ARouteConstants.ME_VISIT).navigation();
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ZhuangBanShangChengAdapter extends BaseQuickAdapter<ZhuangBanShangC
|
||||
if (item.getBase_image().equals("")) {
|
||||
helper.getView(R.id.integral).setVisibility(View.GONE);
|
||||
} else {
|
||||
ImageUtils.loadHeadCC(item.getBase_image(), helper.getView(R.id.iv_img));
|
||||
ImageUtils.loadHead(item.getBase_image(), helper.getView(R.id.iv_img));
|
||||
}
|
||||
|
||||
TextView tv_integral = helper.getView(R.id.integral);
|
||||
|
||||
@@ -442,6 +442,7 @@ public class RoomSettingFragment extends BaseMvpDialogFragment<RoomSettingPresen
|
||||
GiftLotteryDialog newDialog = GiftLotteryDialog.newInstance(
|
||||
"11", roomId, "", "", "");
|
||||
newDialog.show(fm, "GiftLotteryDialog");
|
||||
dismiss();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("RoomGiftDialogFragment", "Error in showGiftLotteryDialog", e);
|
||||
@@ -458,6 +459,7 @@ public class RoomSettingFragment extends BaseMvpDialogFragment<RoomSettingPresen
|
||||
GiftLotteryDialog newDialog = GiftLotteryDialog.newInstance(
|
||||
"12", roomId, "", "", "");
|
||||
newDialog.show(fm, "GiftLotteryDialog");
|
||||
dismiss();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("RoomGiftDialogFragment", "Error in showGiftLotteryDialog", e);
|
||||
|
||||
@@ -71,9 +71,9 @@ android {
|
||||
beta {
|
||||
dimension "environment"
|
||||
// // 测试版包名:基础包名 + .beta(com.example.myapp.beta)
|
||||
applicationIdSuffix ".beta"
|
||||
// applicationIdSuffix ".beta"
|
||||
// // 测试版版本名:1.0-beta
|
||||
versionNameSuffix "-beta"
|
||||
// versionNameSuffix "-beta"
|
||||
//
|
||||
// // 【测试版应用名称】动态生成带标识的名称
|
||||
resValue "string", "app_name", "羽声-测试版"
|
||||
|
||||
@@ -181,86 +181,132 @@ public class LaunchPageActivity extends BaseMvpActivity<IPresenter,ActivityLaunc
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
// 创建VideoView并添加到布局中
|
||||
videoView = new VideoView(this);
|
||||
// 创建LayoutParams并设置MATCH_PARENT
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
);
|
||||
// 设置gravity来填充整个布局
|
||||
params.gravity = Gravity.FILL;
|
||||
mBinding.container.addView(videoView, params);
|
||||
|
||||
setEnter();
|
||||
// 设置视频缩放模式为拉伸填充
|
||||
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
||||
@Override
|
||||
public void onPrepared(MediaPlayer mp) {
|
||||
// 获取视频的宽高
|
||||
int videoWidth = mp.getVideoWidth();
|
||||
int videoHeight = mp.getVideoHeight();
|
||||
// 获取屏幕的宽高
|
||||
int screenWidth = getResources().getDisplayMetrics().widthPixels;
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
|
||||
// if (AppContext.isKilled()) {
|
||||
// videoView = new VideoView(this);
|
||||
// // 创建LayoutParams并设置MATCH_PARENT
|
||||
// FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT
|
||||
// );
|
||||
//// 设置gravity来填充整个布局
|
||||
// params.gravity = Gravity.FILL;
|
||||
// mBinding.root.addView(videoView, params);
|
||||
//
|
||||
//// 设置视频缩放模式为拉伸填充
|
||||
// videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
||||
// @Override
|
||||
// public void onPrepared(MediaPlayer mp) {
|
||||
// // 获取视频的宽高
|
||||
// int videoWidth = mp.getVideoWidth();
|
||||
// int videoHeight = mp.getVideoHeight();
|
||||
// // 获取屏幕的宽高
|
||||
// int screenWidth = getResources().getDisplayMetrics().widthPixels;
|
||||
// int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
//
|
||||
// // 计算缩放比例
|
||||
// float scaleX = (float) screenWidth / videoWidth;
|
||||
// float scaleY = (float) screenHeight / videoHeight;
|
||||
//
|
||||
// // 选择较大的缩放比例,确保视频填满屏幕
|
||||
// float scale = Math.max(scaleX, scaleY);
|
||||
//
|
||||
// // 计算实际显示的宽高
|
||||
// int scaledWidth = (int) (videoWidth * scale);
|
||||
// int scaledHeight = (int) (videoHeight * scale);
|
||||
//
|
||||
// // 设置VideoView的布局参数
|
||||
// FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(scaledWidth, scaledHeight);
|
||||
// layoutParams.gravity = Gravity.CENTER;
|
||||
// videoView.setLayoutParams(layoutParams);
|
||||
// }
|
||||
// });
|
||||
// // 设置视频路径,从raw资源中
|
||||
// String videoPath = "android.resource://" + getPackageName() + "/" + R.raw.app_start;
|
||||
//
|
||||
// // 设置播放完成监听器
|
||||
// videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||
// @Override
|
||||
// public void onCompletion(MediaPlayer mp) {
|
||||
// // 播放完成后执行后续操作
|
||||
// setEnter();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// // 设置错误监听器
|
||||
// videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
|
||||
// @Override
|
||||
// public boolean onError(MediaPlayer mp, int what, int extra) {
|
||||
// // 发生错误时也执行后续操作
|
||||
// setEnter();
|
||||
// return true; // 返回true表示已处理错误
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// // 设置视频路径并开始播放
|
||||
// try {
|
||||
// videoView.setVideoURI(Uri.parse(videoPath));
|
||||
// videoView.requestFocus(); // 请求焦点以确保视频能够播放
|
||||
// videoView.start();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// // 如果设置视频路径时出错,直接执行后续操作
|
||||
// setEnter();
|
||||
// }
|
||||
// AppContext.setKilled(false);
|
||||
// } else {
|
||||
// setEnter();
|
||||
// }
|
||||
// 计算缩放比例
|
||||
float scaleX = (float) screenWidth / videoWidth;
|
||||
float scaleY = (float) screenHeight / videoHeight;
|
||||
|
||||
// 选择较大的缩放比例,确保视频填满屏幕
|
||||
float scale = Math.max(scaleX, scaleY);
|
||||
|
||||
// 计算实际显示的宽高
|
||||
int scaledWidth = (int) (videoWidth * scale);
|
||||
int scaledHeight = (int) (videoHeight * scale);
|
||||
|
||||
// 设置VideoView的布局参数
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(scaledWidth, scaledHeight);
|
||||
layoutParams.gravity = Gravity.CENTER;
|
||||
videoView.setLayoutParams(layoutParams);
|
||||
|
||||
// 获取视频总时长并设置进度条最大值
|
||||
int duration = mp.getDuration();
|
||||
mBinding.progress.setMaxProgress(duration);
|
||||
|
||||
// 显示跳过按钮
|
||||
mBinding.btnSkipImg.setVisibility(android.view.View.VISIBLE);
|
||||
|
||||
// 启动进度更新
|
||||
startProgressUpdate(mp, duration);
|
||||
}
|
||||
});
|
||||
|
||||
// 设置视频路径,从raw资源中
|
||||
String videoPath = "android.resource://" + getPackageName() + "/" + R.raw.app_start;
|
||||
|
||||
// 设置播放完成监听器
|
||||
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
// 播放完成后执行后续操作
|
||||
setEnter();
|
||||
}
|
||||
});
|
||||
|
||||
// 设置错误监听器
|
||||
videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
|
||||
@Override
|
||||
public boolean onError(MediaPlayer mp, int what, int extra) {
|
||||
// 发生错误时也执行后续操作
|
||||
setEnter();
|
||||
return true; // 返回true表示已处理错误
|
||||
}
|
||||
});
|
||||
|
||||
// 设置视频路径并开始播放
|
||||
try {
|
||||
videoView.setVideoURI(Uri.parse(videoPath));
|
||||
videoView.requestFocus(); // 请求焦点以确保视频能够播放
|
||||
videoView.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// 如果设置视频路径时出错,直接执行后续操作
|
||||
setEnter();
|
||||
}
|
||||
|
||||
// 设置跳过按钮点击事件
|
||||
mBinding.btnSkipImg.setOnClickListener(v -> {
|
||||
// 点击跳过按钮时,停止视频并跳转到登录页
|
||||
if (videoView != null) {
|
||||
videoView.stopPlayback();
|
||||
}
|
||||
setEnter();
|
||||
});
|
||||
|
||||
// 设置文本跳过按钮点击事件
|
||||
mBinding.btnSkipVideo.setOnClickListener(v -> {
|
||||
// 点击跳过按钮时,停止视频并跳转到登录页
|
||||
if (videoView != null) {
|
||||
videoView.stopPlayback();
|
||||
}
|
||||
setEnter();
|
||||
});
|
||||
}
|
||||
|
||||
// 用于更新进度条的方法
|
||||
private void startProgressUpdate(MediaPlayer mediaPlayer, int duration) {
|
||||
// 使用MediaPlayer实例的引用,避免在回调中直接使用可能导致异常的MediaPlayer对象
|
||||
final MediaPlayer mp = mediaPlayer;
|
||||
handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// 检查videoView是否还在播放状态,而不是直接检查mediaPlayer
|
||||
if (videoView != null && videoView.isPlaying()) {
|
||||
// 使用videoView获取当前播放位置,而不是mediaPlayer
|
||||
int currentPosition = videoView.getCurrentPosition();
|
||||
mBinding.progress.setCurProgress(currentPosition);
|
||||
|
||||
// 继续更新进度
|
||||
handler.postDelayed(this, 100); // 每100毫秒更新一次
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 捕获任何可能的异常,防止应用崩溃
|
||||
LogUtils.e("LaunchPageActivity", "更新进度时出错: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}, 100); // 延迟100毫秒开始更新
|
||||
}
|
||||
|
||||
private void initLogin() {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
android:layout_marginTop="37dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:background="@drawable/bg_launcher_skip"
|
||||
android:visibility="invisible">
|
||||
android:visibility="visible">
|
||||
|
||||
<com.xscm.moduleutil.custon.CircleProgress
|
||||
android:id="@+id/progress"
|
||||
@@ -89,14 +89,14 @@
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:src="@mipmap/screen"
|
||||
android:scaleType="centerCrop"
|
||||
android:visibility="visible" />
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/cover"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
<!-- android:clickable="true"-->
|
||||
<!-- android:src="@mipmap/screen"-->
|
||||
<!-- android:scaleType="centerCrop"-->
|
||||
<!-- android:visibility="visible" />-->
|
||||
|
||||
</FrameLayout>
|
||||
</layout>
|
||||
Binary file not shown.
Reference in New Issue
Block a user