1:只是启动页动画

2:修改房间消息,插入动画
This commit is contained in:
2025-12-22 23:06:17 +08:00
parent 9bf2de01d4
commit 8b24ac310e
4 changed files with 86 additions and 81 deletions

View File

@@ -18,6 +18,7 @@ import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.GsonUtils; import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.LogUtils; import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils; import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.tencent.imsdk.v2.V2TIMManager; import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMMessage; import com.tencent.imsdk.v2.V2TIMMessage;
import com.tencent.imsdk.v2.V2TIMSendCallback; import com.tencent.imsdk.v2.V2TIMSendCallback;
@@ -254,6 +255,7 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
private void initChatAdapter() { private void initChatAdapter() {
if (easeChatAdapter == null) { if (easeChatAdapter == null) {
easeChatAdapter = new EaseChatAdapter(); easeChatAdapter = new EaseChatAdapter();
easeChatAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_LEFT);
// 添加空值检查确保mBinding和recycleViewPublic都不为null // 添加空值检查确保mBinding和recycleViewPublic都不为null
if (mBinding != null) { if (mBinding != null) {
mBinding.recycleViewPublic.setAdapter(easeChatAdapter); mBinding.recycleViewPublic.setAdapter(easeChatAdapter);

View File

@@ -181,81 +181,84 @@ public class LaunchPageActivity extends BaseMvpActivity<IPresenter,ActivityLaunc
@Override @Override
protected void initView() { protected void initView() {
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(); setEnter();
}
});
// 设置错误监听器 // if (AppContext.isKilled()) {
videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { // videoView = new VideoView(this);
@Override // // 创建LayoutParams并设置MATCH_PARENT
public boolean onError(MediaPlayer mp, int what, int extra) { // FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
// 发生错误时也执行后续操作 // ViewGroup.LayoutParams.MATCH_PARENT,
setEnter(); // ViewGroup.LayoutParams.MATCH_PARENT
return true; // 返回true表示已处理错误 // );
} //// 设置gravity来填充整个布局
}); // params.gravity = Gravity.FILL;
// mBinding.root.addView(videoView, params);
// 设置视频路径并开始播放 //
try { //// 设置视频缩放模式为拉伸填充
videoView.setVideoURI(Uri.parse(videoPath)); // videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
videoView.requestFocus(); // 请求焦点以确保视频能够播放 // @Override
videoView.start(); // public void onPrepared(MediaPlayer mp) {
} catch (Exception e) { // // 获取视频的宽高
e.printStackTrace(); // int videoWidth = mp.getVideoWidth();
// 如果设置视频路径时出错,直接执行后续操作 // int videoHeight = mp.getVideoHeight();
setEnter(); // // 获取屏幕的宽高
} // int screenWidth = getResources().getDisplayMetrics().widthPixels;
AppContext.setKilled(false); // int screenHeight = getResources().getDisplayMetrics().heightPixels;
} 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);
// }
// });
// // 设置视频路径从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();
// }
} }

View File

@@ -89,14 +89,14 @@
</LinearLayout> </LinearLayout>
<!-- <ImageView--> <ImageView
<!-- android:id="@+id/cover"--> android:id="@+id/cover"
<!-- android:layout_width="match_parent"--> android:layout_width="match_parent"
<!-- android:layout_height="match_parent"--> android:layout_height="match_parent"
<!-- android:clickable="true"--> android:clickable="true"
<!-- android:src="@mipmap/screen"--> android:src="@mipmap/screen"
<!-- android:scaleType="centerCrop"--> android:scaleType="centerCrop"
<!-- android:visibility="visible" />--> android:visibility="visible" />
</FrameLayout> </FrameLayout>
</layout> </layout>

Binary file not shown.