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);
// 设置视频缩放模式为拉伸填充 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()) {
float scaleX = (float) screenWidth / videoWidth; // videoView = new VideoView(this);
float scaleY = (float) screenHeight / videoHeight; // // 创建LayoutParams并设置MATCH_PARENT
// FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
// 选择较大的缩放比例,确保视频填满屏幕 // ViewGroup.LayoutParams.MATCH_PARENT,
float scale = Math.max(scaleX, scaleY); // ViewGroup.LayoutParams.MATCH_PARENT
// );
// 计算实际显示的宽高 //// 设置gravity来填充整个布局
int scaledWidth = (int) (videoWidth * scale); // params.gravity = Gravity.FILL;
int scaledHeight = (int) (videoHeight * scale); // mBinding.root.addView(videoView, params);
//
// 设置VideoView的布局参数 //// 设置视频缩放模式为拉伸填充
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(scaledWidth, scaledHeight); // videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
layoutParams.gravity = Gravity.CENTER; // @Override
videoView.setLayoutParams(layoutParams); // public void onPrepared(MediaPlayer mp) {
} // // 获取视频的宽高
}); // int videoWidth = mp.getVideoWidth();
// 设置视频路径从raw资源中 // int videoHeight = mp.getVideoHeight();
String videoPath = "android.resource://" + getPackageName() + "/" + R.raw.app_start; // // 获取屏幕的宽高
// int screenWidth = getResources().getDisplayMetrics().widthPixels;
// 设置播放完成监听器 // int screenHeight = getResources().getDisplayMetrics().heightPixels;
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { //
@Override // // 计算缩放比例
public void onCompletion(MediaPlayer mp) { // float scaleX = (float) screenWidth / videoWidth;
// 播放完成后执行后续操作 // float scaleY = (float) screenHeight / videoHeight;
setEnter(); //
} // // 选择较大的缩放比例,确保视频填满屏幕
}); // float scale = Math.max(scaleX, scaleY);
//
// 设置错误监听器 // // 计算实际显示的宽高
videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { // int scaledWidth = (int) (videoWidth * scale);
@Override // int scaledHeight = (int) (videoHeight * scale);
public boolean onError(MediaPlayer mp, int what, int extra) { //
// 发生错误时也执行后续操作 // // 设置VideoView的布局参数
setEnter(); // FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(scaledWidth, scaledHeight);
return true; // 返回true表示已处理错误 // layoutParams.gravity = Gravity.CENTER;
} // videoView.setLayoutParams(layoutParams);
}); // }
// });
// 设置视频路径并开始播放 // // 设置视频路径从raw资源中
try { // String videoPath = "android.resource://" + getPackageName() + "/" + R.raw.app_start;
videoView.setVideoURI(Uri.parse(videoPath)); //
videoView.requestFocus(); // 请求焦点以确保视频能够播放 // // 设置播放完成监听器
videoView.start(); // videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
} catch (Exception e) { // @Override
e.printStackTrace(); // public void onCompletion(MediaPlayer mp) {
// 如果设置视频路径时出错,直接执行后续操作 // // 播放完成后执行后续操作
setEnter(); // setEnter();
} // }
AppContext.setKilled(false); // });
} else { //
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.