1:只是启动页动画
2:修改房间消息,插入动画
This commit is contained in:
@@ -18,6 +18,7 @@ import com.blankj.utilcode.util.ActivityUtils;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||
import com.tencent.imsdk.v2.V2TIMSendCallback;
|
||||
@@ -254,6 +255,7 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
private void initChatAdapter() {
|
||||
if (easeChatAdapter == null) {
|
||||
easeChatAdapter = new EaseChatAdapter();
|
||||
easeChatAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_LEFT);
|
||||
// 添加空值检查,确保mBinding和recycleViewPublic都不为null
|
||||
if (mBinding != null) {
|
||||
mBinding.recycleViewPublic.setAdapter(easeChatAdapter);
|
||||
|
||||
@@ -181,81 +181,84 @@ public class LaunchPageActivity extends BaseMvpActivity<IPresenter,ActivityLaunc
|
||||
|
||||
@Override
|
||||
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;
|
||||
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();
|
||||
}
|
||||
// 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();
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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