diff --git a/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java index 79724f229..efe2649f3 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java @@ -356,6 +356,10 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder { } else { temp = position; } + + L.eSw("PK 人数:" + temp ); + + switch (temp) { case 2: swManager.joinChannelDrEx(dr2_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid), temp); @@ -373,6 +377,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder { break; case 4: dr3_preview.setVisibility(View.VISIBLE); + dr4_preview.setVisibility(View.VISIBLE); //先退出这个主播的直播间,在进入该直播间,(视图问题暂时這樣處理) swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), drpkUid3); swManager.joinChannelDrEx(dr3_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drpkUid3, SWAuManager.getChannelName(drpkUid3), temp); diff --git a/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java index c701be428..57d774bec 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java @@ -177,7 +177,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { } }); - //结束多人PK + //发起人 多人PK 强制退出 btn_end_pk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -186,28 +186,40 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { .execute(new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { + Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.LEAVE_DR_ROOM)); PKing = false; } + + @Override + public void onError() { + super.onError(); + + } }); btn_start_dr_pk_view.setVisibility(View.GONE); yaoqing.clear(); } }); + + // 被邀请人退出多人PK btn_end_pk_dr.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - closeEndPkBt(); HttpClient.getInstance().post("tuichuduorenpkfangjian", "tuichuduorenpkfangjian") .params("roomid", drpkRoomId) .params("uid", CommonAppConfig.getInstance().getUid()) .execute(new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + closeEndPkBt(); + }else { + ToastUtil.show(msg); + } L.eSw("tuichuduorenpkfangjian" + code + " info" + new Gson().toJson(info)); - } }); } diff --git a/main/src/main/java/com/yunbao/main/FileCopier.java b/main/src/main/java/com/yunbao/main/FileCopier.java new file mode 100644 index 000000000..73cb35398 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/FileCopier.java @@ -0,0 +1,66 @@ +package com.yunbao.main; + +/** + * Author: plx + * Date: 2024/11/1 + * Description: + */ +import android.Manifest; +import android.app.Activity; +import android.content.Context; +import android.content.pm.PackageManager; +import android.os.Build; +import android.os.Environment; +import androidx.annotation.NonNull; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +public class FileCopier { + + private static final int REQUEST_WRITE_STORAGE = 112; + + public void copyLogsToExternalStorage(Context context) { + // 检查并请求写入外部存储的权限 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_STORAGE); + return; + } + } + + // 定义源目录和目标目录 + File sourceDir = new File(context.getFilesDir(), "log"); + File targetDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "app_logs"); + + // 确保目标目录存在 + if (!targetDir.exists()) { + targetDir.mkdirs(); + } + + // 复制文件 + File[] logFiles = sourceDir.listFiles((dir, name) -> name.endsWith(".log")); + if (logFiles != null) { + for (File logFile : logFiles) { + File targetFile = new File(targetDir, logFile.getName()); + try (InputStream in = new FileInputStream(logFile); + OutputStream out = new FileOutputStream(targetFile)) { + + byte[] buffer = new byte[1024]; + int read; + while ((read = in.read(buffer)) != -1) { + out.write(buffer, 0, read); + } + out.flush(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } +}