Преглед изворни кода

增加学生端直播间分享逻辑

Pq пре 2 година
родитељ
комит
fcda0382ad
23 измењених фајлова са 747 додато и 12 уклоњено
  1. 2 0
      BaseLibrary/src/main/java/com/cooleshow/base/common/WebConstants.java
  2. 1 0
      BaseLibrary/src/main/java/com/cooleshow/base/constanst/RouteConstants.java
  3. 14 0
      BaseLibrary/src/main/java/com/cooleshow/base/utils/JumpUtils.java
  4. 5 0
      BaseLibrary/src/main/res/drawable/shape_24dp_white.xml
  5. 2 0
      BaseLibrary/src/main/res/values/colors.xml
  6. 165 7
      student/src/main/java/com/cooleshow/student/helper/ShareHelper.java
  7. 143 4
      student/src/main/java/com/cooleshow/student/ui/live/LiveRoomActivity.java
  8. 181 0
      student/src/main/java/com/cooleshow/student/widgets/dialog/LiveRoomShareDialog.java
  9. BIN
      student/src/main/res/drawable-xhdpi/bg_share_live_bottom.png
  10. BIN
      student/src/main/res/drawable-xhdpi/bg_share_live_top.png
  11. BIN
      student/src/main/res/drawable-xhdpi/icon_klx_logo2.png
  12. BIN
      student/src/main/res/drawable-xhdpi/icon_share_live_room.png
  13. BIN
      student/src/main/res/drawable-xhdpi/icon_share_live_tag.png
  14. BIN
      student/src/main/res/drawable-xxhdpi/bg_share_live_bottom.png
  15. BIN
      student/src/main/res/drawable-xxhdpi/bg_share_live_top.png
  16. BIN
      student/src/main/res/drawable-xxhdpi/icon_klx_logo2.png
  17. BIN
      student/src/main/res/drawable-xxhdpi/icon_share_live_room.png
  18. BIN
      student/src/main/res/drawable-xxhdpi/icon_share_live_tag.png
  19. 8 0
      student/src/main/res/drawable/shape_share_live_info_bg.xml
  20. 7 0
      student/src/main/res/drawable/shape_share_live_tip_bg.xml
  21. 10 1
      student/src/main/res/layout/activity_liveroom_layout.xml
  22. 207 0
      student/src/main/res/layout/dialog_live_share_layout.xml
  23. 2 0
      student/src/main/res/values/strings.xml

+ 2 - 0
BaseLibrary/src/main/java/com/cooleshow/base/common/WebConstants.java

@@ -145,6 +145,8 @@ public abstract class WebConstants {
     public static final String CONTACT_US_PAGE = getBaseUrlH5() + "/#/contactus";
     //我的乐谱
     public static final String MINE_MUSIC_SHEET = getBaseUrlH5() + "/#/mySheetMusic";
+    //分享直播间落地页地址
+    public static final String SHARE_LIVE_URL = getBaseUrlH5() + "/#/transfer?action=app&pageTag=liveRoom&liveRoomId=%s";
 
 
 }

+ 1 - 0
BaseLibrary/src/main/java/com/cooleshow/base/constanst/RouteConstants.java

@@ -11,4 +11,5 @@ public class RouteConstants {
     public static final String PAGE_TAG_EVALUATE="evaluate";//评价页面
     public static final String PAGE_TAG_MESSAGE="message";//消息页面
     public static final String PAGE_TAG_MUSIC_SHEET="musicSheet";//我的乐谱
+    public static final String PAGE_TAG_LIVE_ROOM="liveRoom";//直播间
 }

+ 14 - 0
BaseLibrary/src/main/java/com/cooleshow/base/utils/JumpUtils.java

@@ -93,6 +93,20 @@ public class JumpUtils {
                             return true;
                         }
                     }
+
+                    if (TextUtils.equals(routeBean.pageTag, RouteConstants.PAGE_TAG_LIVE_ROOM)) {
+                        //跳转直播间
+                        if (!BaseApplication.Companion.isTeacherClient()) {
+                            String liveRoomId = getParams(routeBean.params, "liveRoomId");
+                            if (TextUtils.isEmpty(liveRoomId)) {
+                                return false;
+                            }
+                            ARouter.getInstance().build(RouterPath.LiveCenter.ACTIVITY_LIVE_ROOM)
+                                    .withString("roomid_key", liveRoomId)
+                                    .navigation();
+                            return true;
+                        }
+                    }
                 }
             } else {
                 //跳转H5页面

+ 5 - 0
BaseLibrary/src/main/res/drawable/shape_24dp_white.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="@color/white" />
+    <corners android:radius="24dp" />
+</shape>

+ 2 - 0
BaseLibrary/src/main/res/values/colors.xml

@@ -145,6 +145,8 @@
     <color name="color_10a0a0a0">#10A0A0A0</color>
     <color name="color_102dc7aa">#102dc7aa</color>
     <color name="color_502dc7aa">#502dc7aa</color>
+    <color name="color_ff598e">#FF598E</color>
+    <color name="color_fd2d55">#FD2D55</color>
 
     <color name="color_25292e">#25292E</color>
     <color name="color_F8F8F8">#F8F8F8</color>

+ 165 - 7
student/src/main/java/com/cooleshow/student/helper/ShareHelper.java

@@ -9,10 +9,12 @@ import android.provider.MediaStore;
 import android.text.TextUtils;
 import android.util.Base64;
 import android.util.Log;
+import android.view.View;
 
 import com.cooleshow.base.utils.FileUtils;
 import com.cooleshow.base.utils.ToastUtil;
 import com.cooleshow.base.utils.Utils;
+import com.luck.picture.lib.tools.BitmapUtils;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -28,6 +30,7 @@ import io.reactivex.rxjava3.core.Observer;
 import io.reactivex.rxjava3.disposables.Disposable;
 import io.reactivex.rxjava3.schedulers.Schedulers;
 import io.rong.imkit.IMCenter;
+import io.rong.imkit.picture.tools.PictureFileUtils;
 import io.rong.imkit.utils.helper.OpenChatHelper;
 import io.rong.imlib.IRongCallback;
 import io.rong.imlib.RongIMClient;
@@ -88,6 +91,54 @@ public class ShareHelper {
                 });
     }
 
+    public static void saveImg(Context context, Bitmap bitmap, ResultCallBack resultCallBack) {
+        Observable.create(new ObservableOnSubscribe<File>() {
+            @Override
+            public void subscribe(ObservableEmitter<File> emitter) throws Exception {
+                File file = saveImageToGallery(bitmap);
+                emitter.onNext(file);
+            }
+        }).subscribeOn(Schedulers.newThread())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new Observer<File>() {
+                    @Override
+                    public void onSubscribe(Disposable d) {
+
+                    }
+
+                    @Override
+                    public void onNext(File file) {
+                        if (context != null) {
+                            try {
+                                MediaStore.Images.Media.insertImage(context.getContentResolver(),
+                                        file.getAbsolutePath(), file.getName(), null);
+                                // 最后通知图库更新
+                                context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
+                                        Uri.fromFile(new File(file.getPath()))));
+                                if (resultCallBack != null) {
+                                    resultCallBack.onResult(true);
+                                }
+                            } catch (FileNotFoundException e) {
+                                ToastUtil.getInstance().show(context, "保存失败");
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+
+                    @Override
+                    public void onError(Throwable e) {
+                        if (resultCallBack != null) {
+                            resultCallBack.onResult(false);
+                        }
+                    }
+
+                    @Override
+                    public void onComplete() {
+
+                    }
+                });
+    }
+
     public static void shareImgToChatGroup(String base64, String targetId, Conversation.ConversationType conversationType, ResultCallBack resultCallBack) {
         Observable.create(new ObservableOnSubscribe<String>() {
             @Override
@@ -158,6 +209,81 @@ public class ShareHelper {
                 });
     }
 
+    public static void shareImgToChatGroup(File file, String targetId, Conversation.ConversationType conversationType, ResultCallBack resultCallBack) {
+        if (file == null || !file.exists()) {
+            if (resultCallBack != null) {
+                resultCallBack.onResult(false);
+            }
+            return;
+        }
+        Observable.create(new ObservableOnSubscribe<String>() {
+            @Override
+            public void subscribe(ObservableEmitter<String> emitter) throws Exception {
+                Message imageMessage = createImageMessage(file, targetId, conversationType);
+                IMCenter.getInstance().sendMediaMessage(imageMessage, null, null, new IRongCallback.ISendMediaMessageCallback() {
+                    @Override
+                    public void onProgress(Message message, int progress) {
+
+                    }
+
+                    @Override
+                    public void onCanceled(Message message) {
+
+                    }
+
+                    @Override
+                    public void onAttached(Message message) {
+
+                    }
+
+                    @Override
+                    public void onSuccess(Message message) {
+                        Log.i("pq", "message send success");
+                        if (resultCallBack != null) {
+                            resultCallBack.onResult(true);
+                        }
+                    }
+
+                    @Override
+                    public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+                        Log.i("pq", "message send onError:" + errorCode);
+                        if (resultCallBack != null) {
+                            resultCallBack.onResult(false);
+                        }
+                    }
+                });
+                emitter.onNext("");
+            }
+        }).subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new Observer<String>() {
+                    @Override
+                    public void onSubscribe(Disposable d) {
+
+                    }
+
+                    @Override
+                    public void onNext(String s) {
+                        if (resultCallBack != null) {
+                            resultCallBack.onResult(true);
+                        }
+                    }
+
+                    @Override
+                    public void onError(Throwable e) {
+                        e.printStackTrace();
+                        if (resultCallBack != null) {
+                            resultCallBack.onResult(false);
+                        }
+                    }
+
+                    @Override
+                    public void onComplete() {
+
+                    }
+                });
+    }
+
     private static Message createImageMessage(String base64, Conversation conversation) {
         ImageMessage imageMessage = ImageMessage.obtain();
         imageMessage.setBase64(base64);
@@ -177,13 +303,7 @@ public class ShareHelper {
             bytes = Base64.decode(base64, Base64.DEFAULT);
         }
         Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
-        File parentFile = new File(FileUtils.getCacheDir(Utils.getApp()) + File.separator + "share");
-        if (!parentFile.exists()) {
-            parentFile.mkdirs();
-        }
-        String targetFileName = "IMG_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + ".png";
-        File file = new File(parentFile, targetFileName);
-        FileUtils.saveImageToGallery(bitmap, file.getAbsolutePath());
+        File file = saveImageToGallery(bitmap);
         return new File(file.getAbsolutePath());
     }
 
@@ -219,4 +339,42 @@ public class ShareHelper {
             });
         }
     }
+
+    public static void parseShareContactData(File file, Intent data) {
+        String targetId = data.getStringExtra("targetId");
+        int conversationValue = data.getIntExtra("conversation", -1);
+        if (file != null) {
+            Conversation.ConversationType conversationType = OpenChatHelper.getConversationType(conversationValue);
+            shareImgToChatGroup(file, targetId, conversationType, new ShareHelper.ResultCallBack() {
+                @Override
+                public void onResult(boolean isSuccess) {
+                    if (isSuccess) {
+                        ToastUtil.getInstance().showShort("分享成功");
+                    } else {
+                        ToastUtil.getInstance().showShort("分享失败");
+                    }
+//                    sendCallBack("shareAchievements", "", true);
+                }
+            });
+        }
+    }
+
+
+    public static Bitmap createBitmapByView(View view) {
+        view.buildDrawingCache();
+        Bitmap bitmap = view.getDrawingCache();
+        return bitmap;
+    }
+
+
+    public static File saveImageToGallery(Bitmap bitmap) {
+        File parentFile = new File(FileUtils.getCacheDir(Utils.getApp()) + File.separator + "share");
+        if (!parentFile.exists()) {
+            parentFile.mkdirs();
+        }
+        String targetFileName = "IMG_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + ".png";
+        File file = new File(parentFile, targetFileName);
+        FileUtils.saveImageToGallery(bitmap, file.getAbsolutePath());
+        return file;
+    }
 }

+ 143 - 4
student/src/main/java/com/cooleshow/student/ui/live/LiveRoomActivity.java

@@ -19,7 +19,6 @@ import android.provider.Settings;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
-import android.view.ViewGroup;
 import android.view.WindowManager;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
@@ -48,10 +47,12 @@ import com.cooleshow.base.widgets.InputBar;
 import com.cooleshow.base.widgets.dialog.CommonConfirmDialog;
 import com.cooleshow.student.bean.FriendInfoBean;
 import com.cooleshow.student.helper.EventHelper;
+import com.cooleshow.student.helper.ShareHelper;
 import com.cooleshow.student.ui.live.floatPop.FloatWindowHelper;
 import com.cooleshow.student.ui.live.floatPop.FloatingWindowService;
 import com.cooleshow.student.widgets.dialog.LiveRoomCloseTipDialog;
 import com.cooleshow.student.widgets.dialog.LiveRoomMicManagerDialog;
+import com.cooleshow.student.widgets.dialog.LiveRoomShareDialog;
 import com.cooleshow.student.widgets.dialog.OpenOverlayPermissionTipDialog;
 import com.cooleshow.student.widgets.helper.LiveRoomAddLikeHelper;
 import com.cooleshow.base.widgets.dialog.InputBarDialog;
@@ -61,7 +62,6 @@ import com.cooleshow.student.bean.LiveRoomInfoBean;
 import com.cooleshow.student.contract.LiveRoomContract;
 import com.cooleshow.student.databinding.ActivityLiveroomLayoutBinding;
 import com.cooleshow.student.presenter.live.LiveRoomPresenter;
-import com.rong.io.live.bean.User;
 import com.rong.io.live.helper.LiveMemberHelper;
 import com.rong.io.live.helper.LiveMessageHelper;
 import com.rong.io.live.helper.LiveRTCEngineInitHelper;
@@ -86,6 +86,7 @@ import com.rong.io.live.widget.LiveRoomMicIconView;
 import org.json.JSONException;
 import org.json.JSONObject;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -109,7 +110,6 @@ import cn.rongcloud.rtc.api.stream.RCRTCVideoView;
 import cn.rongcloud.rtc.base.RCRTCLiveRole;
 import cn.rongcloud.rtc.base.RCRTCMediaType;
 import cn.rongcloud.rtc.base.RCRTCResourceState;
-import cn.rongcloud.rtc.core.RendererCommon;
 import de.hdodenhof.circleimageview.CircleImageView;
 import io.reactivex.rxjava3.disposables.Disposable;
 import io.rong.imkit.IMCenter;
@@ -124,13 +124,20 @@ import io.rong.message.TextMessage;
 
 import com.cooleshow.student.widgets.helper.VideoViewManager;
 import com.tbruyelle.rxpermissions3.RxPermissions;
+import com.umeng.socialize.ShareAction;
+import com.umeng.socialize.UMShareAPI;
+import com.umeng.socialize.UMShareListener;
+import com.umeng.socialize.bean.SHARE_MEDIA;
+import com.umeng.socialize.media.UMImage;
+import com.umeng.socialize.shareboard.SnsPlatform;
+import com.umeng.socialize.utils.ShareBoardlistener;
 
 /**
  * Author by pq, Date on 2022/3/29.
  */
 
 @Route(path = RouterPath.LiveCenter.ACTIVITY_LIVE_ROOM)
-public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBinding, LiveRoomPresenter> implements View.OnClickListener, LiveRoomContract.view, SoftKeyboardUtil.OnSoftInputChangedListener {
+public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBinding, LiveRoomPresenter> implements View.OnClickListener, LiveRoomContract.view, SoftKeyboardUtil.OnSoftInputChangedListener, UMShareListener {
     public static final int SEND_SHOW_FLOAT_WINDOW_TIME = 1000;//退到后台以后检查是否显示悬浮窗等待时长
     public static final int SEND_APP_BACKGROUND_MSG = 1001;//退到后台消息
     public static final int SEND_JUMP_OTHER_PAGE_MSG = 1002;//页面切换消息(购物车详情页等等)
@@ -138,6 +145,8 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
     public static final int LIVE_STATUS_IS_REST = 1;//休息一下,马上回来
     public static final int LIVE_STATUS_IS_CLOSE_VIDEO = 2;//主持人关闭画面
     public static final int LIVE_STATUS_IS_OFFLINE = 3;//直播已结束
+    public static final int SHARE_CHAT_REQUEST_CODE = 500;//分享群聊requestcode
+    private File targetShareImgFile = null;
     ConstraintLayout content_view;
     RelativeLayout mFlLiveView;
     LinearLayout ll_like;
@@ -250,6 +259,7 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
     private VideoViewManager mVideoViewManager;
     private LiveRoomShopCarDialog mShopCarDialog;
     private LiveRoomMicManagerDialog mMicManagerDialog;
+    private LiveRoomShareDialog mLiveRoomShareDialog;
 
     public static void startLiveRoomActivity(Context context, String roomid) {
         Intent intent = new Intent(context, LiveRoomActivity.class);
@@ -310,6 +320,7 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
         viewBinding.tvVideoCourse.setOnClickListener(this);
         viewBinding.tvMusicSheet.setOnClickListener(this);
         viewBinding.ivAvatar.setOnClickListener(this);
+        viewBinding.ivShare.setOnClickListener(this);
 
         mRecyclerMsg.addOnScrollListener(new RecyclerView.OnScrollListener() {
             @Override
@@ -524,6 +535,31 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
             sendShowFloatWindowAction(SEND_JUMP_OTHER_PAGE_MSG);
             return;
         }
+
+        if (id == R.id.iv_share) {
+            //分享直播间
+            showShareDialog();
+            return;
+        }
+    }
+
+    private void showShareDialog() {
+        if (mRoomInfoBean == null) {
+            return;
+        }
+        if (mLiveRoomShareDialog == null) {
+            mLiveRoomShareDialog = new LiveRoomShareDialog(this);
+            mLiveRoomShareDialog.setOnEventListener(new LiveRoomShareDialog.OnEventListener() {
+                @Override
+                public void onShare(File file) {
+                    shareLive(file);
+                }
+            });
+        }
+        if (!mLiveRoomShareDialog.isShowing()) {
+            mLiveRoomShareDialog.show();
+        }pq
+        mLiveRoomShareDialog.setData(mRoomInfoBean.speakerPic, mRoomInfoBean.speakerName, mRoomInfoBean.roomUid);
     }
 
     private void showMicManagerDialog() {
@@ -1914,9 +1950,21 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
         }
     }
 
+
     @Override
     protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
+        if (resultCode == RESULT_OK) {
+            if (requestCode == SHARE_CHAT_REQUEST_CODE) {
+                //选择群聊
+                if (targetShareImgFile == null) {
+                    ToastUtil.getInstance().showShort("分享失败");
+                    return;
+                }
+                ShareHelper.parseShareContactData(targetShareImgFile, data);
+                return;
+            }
+        }
     }
 
 
@@ -2082,6 +2130,42 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
         return mFlJoinBarrage.getVisibility() != View.VISIBLE && mFlSnapUpBarrage.getVisibility() != View.VISIBLE;
     }
 
+    private void shareLive(File imagfile) {
+        if (mLiveRoomShareDialog != null && mLiveRoomShareDialog.isShowing()) {
+            mLiveRoomShareDialog.dismiss();
+        }
+        this.targetShareImgFile = imagfile;
+        ShareAction ShareAction = new ShareAction(this).setDisplayList(
+                SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.SINA)
+                .setShareboardclickCallback(new ShareBoardlistener() {
+                    @Override
+                    public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
+
+                        if (share_media == null) {
+                            if (TextUtils.equals(snsPlatform.mKeyword, "chat")) {
+                                //分享群聊
+                                ARouter.getInstance().build(RouterPath.ChatCenter.CHAT_SELECT_CONTACT)
+                                        .navigation(LiveRoomActivity.this, SHARE_CHAT_REQUEST_CODE);
+                            }
+                        } else {
+                            if (!UMShareAPI.get(getApplicationContext()).isInstall(LiveRoomActivity.this, share_media)) {
+                                ToastUtil.getInstance().show(getApplicationContext(), "应用未安装,分享失败");
+                                return;
+                            }
+                            UMImage image = new UMImage(LiveRoomActivity.this, file);//bitmap文件
+                            image.setThumb(image);
+                            image.compressStyle = UMImage.CompressStyle.SCALE;
+                            new ShareAction(LiveRoomActivity.this).withMedia(image)
+                                    .setPlatform(share_media)
+                                    .setCallback(LiveRoomActivity.this)
+                                    .share();
+                        }
+                    }
+                });
+        ShareAction.addButton("群聊", "chat", "icon_share_chat_group", "icon_share_chat_group");
+        ShareAction.open();
+    }
+
     @Override
     public void onDestroy() {
         if (presenter != null) {
@@ -2129,4 +2213,59 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
             Log.i("pq", "SoftInput show");
         }
     }
+
+
+    //分享回调
+    @Override
+    public void onStart(SHARE_MEDIA share_media) {
+
+    }
+
+    @Override
+    public void onResult(SHARE_MEDIA platform) {
+        //分享成功
+        if (platform.name().equals("WEIXIN_FAVORITE")) {
+            ToastUtil.getInstance().showShort("收藏成功啦");
+        } else {
+            if (platform != SHARE_MEDIA.MORE && platform != SHARE_MEDIA.SMS
+                    && platform != SHARE_MEDIA.EMAIL
+                    && platform != SHARE_MEDIA.FLICKR
+                    && platform != SHARE_MEDIA.FOURSQUARE
+                    && platform != SHARE_MEDIA.TUMBLR
+                    && platform != SHARE_MEDIA.POCKET
+                    && platform != SHARE_MEDIA.PINTEREST
+
+                    && platform != SHARE_MEDIA.INSTAGRAM
+                    && platform != SHARE_MEDIA.GOOGLEPLUS
+                    && platform != SHARE_MEDIA.YNOTE
+                    && platform != SHARE_MEDIA.EVERNOTE) {
+                ToastUtil.getInstance().showShort("分享成功啦");
+            }
+
+        }
+    }
+
+    @Override
+    public void onError(SHARE_MEDIA platform, Throwable throwable) {
+        if (platform != SHARE_MEDIA.MORE && platform != SHARE_MEDIA.SMS
+                && platform != SHARE_MEDIA.EMAIL
+                && platform != SHARE_MEDIA.FLICKR
+                && platform != SHARE_MEDIA.FOURSQUARE
+                && platform != SHARE_MEDIA.TUMBLR
+                && platform != SHARE_MEDIA.POCKET
+                && platform != SHARE_MEDIA.PINTEREST
+
+                && platform != SHARE_MEDIA.INSTAGRAM
+                && platform != SHARE_MEDIA.GOOGLEPLUS
+                && platform != SHARE_MEDIA.YNOTE
+                && platform != SHARE_MEDIA.EVERNOTE) {
+            ToastUtil.getInstance().showShort("分享失败啦");
+
+        }
+    }
+
+    @Override
+    public void onCancel(SHARE_MEDIA share_media) {
+        ToastUtil.getInstance().showShort("分享取消了");
+    }
 }

+ 181 - 0
student/src/main/java/com/cooleshow/student/widgets/dialog/LiveRoomShareDialog.java

@@ -0,0 +1,181 @@
+package com.cooleshow.student.widgets.dialog;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.cooleshow.base.common.WebConstants;
+import com.cooleshow.base.router.RouterPath;
+import com.cooleshow.base.utils.GlideUtils;
+import com.cooleshow.base.utils.MyFileUtils;
+import com.cooleshow.base.utils.SizeUtils;
+import com.cooleshow.base.utils.ToastUtil;
+import com.cooleshow.student.R;
+import com.cooleshow.student.helper.ShareHelper;
+import com.cooleshow.student.ui.web.HtmlActivity;
+import com.cooleshow.usercenter.helper.UserHelper;
+import com.umeng.socialize.ShareAction;
+import com.umeng.socialize.UMShareAPI;
+import com.umeng.socialize.bean.SHARE_MEDIA;
+import com.umeng.socialize.media.UMImage;
+import com.umeng.socialize.shareboard.SnsPlatform;
+import com.umeng.socialize.utils.ShareBoardlistener;
+import com.uuzuche.lib_zxing.activity.CodeUtils;
+
+import java.io.File;
+
+import androidx.annotation.NonNull;
+import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
+import io.reactivex.rxjava3.core.Observable;
+import io.reactivex.rxjava3.core.ObservableEmitter;
+import io.reactivex.rxjava3.core.ObservableOnSubscribe;
+import io.reactivex.rxjava3.core.Observer;
+import io.reactivex.rxjava3.core.Scheduler;
+import io.reactivex.rxjava3.disposables.Disposable;
+import io.reactivex.rxjava3.schedulers.Schedulers;
+
+/**
+ * Author by pq, Date on 2022/9/21.
+ */
+public class LiveRoomShareDialog extends Dialog {
+
+    private ImageView mIvAvatarAnchor;
+    private ImageView mIvAvatarOwner;
+    private TextView mTvShareTitle;
+    private TextView mTvSharerName;
+    private ImageView mIvCode;
+    private TextView mTvSave;
+    private TextView mTvShare;
+    private boolean isNeedCreateQRCode = true;
+    private View mShareView;
+    private OnEventListener mOnEventListener;
+    private View mCsRoot;
+
+    public LiveRoomShareDialog(@NonNull Context context) {
+        super(context, R.style.DialogStyle);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.dialog_live_share_layout);
+        mShareView = findViewById(R.id.cs_share_view);
+        mCsRoot = findViewById(R.id.cs_root);
+        mIvAvatarAnchor = findViewById(R.id.iv_avatar_anchor);
+        mIvAvatarOwner = findViewById(R.id.iv_avatar_owner);
+        mTvShareTitle = findViewById(R.id.tv_share_title);
+        mTvSharerName = findViewById(R.id.tv_sharer_name);
+        mIvCode = findViewById(R.id.iv_code);
+        mTvSave = findViewById(R.id.tv_save);
+        mTvShare = findViewById(R.id.tv_share);
+
+        mTvSave.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Bitmap bitmapByView = ShareHelper.createBitmapByView(mShareView);
+                if (bitmapByView != null) {
+                    ShareHelper.saveImg(getContext(), bitmapByView, new ShareHelper.ResultCallBack() {
+                        @Override
+                        public void onResult(boolean isSuccess) {
+                            if (isSuccess) {
+                                ToastUtil.getInstance().showShort("保存成功");
+                                dismiss();
+                            } else {
+                                ToastUtil.getInstance().showShort("保存失败");
+                            }
+                        }
+                    });
+                }
+            }
+        });
+
+        mTvShare.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Bitmap bitmapByView = ShareHelper.createBitmapByView(mShareView);
+                //此处待优化,最好子线程去保存
+                File file = ShareHelper.saveImageToGallery(bitmapByView);
+                if (bitmapByView != null) {
+                    if (mOnEventListener != null) {
+                        mOnEventListener.onShare(file);
+                    }
+                }
+            }
+        });
+
+        String userName = UserHelper.getUserName();
+        String userAvatar = UserHelper.getUserAvatar();
+        GlideUtils.INSTANCE.loadImage(getContext(), userAvatar, mIvAvatarOwner, R.drawable.icon_student_default_head);
+        mTvSharerName.setText(String.format("%s 为您推荐", userName));
+    }
+
+    private void share() {
+
+    }
+
+    public void setData(String liveAnchorAvatar, String liveAnchorName, String liveRoomId) {
+        //直播老师头像
+        GlideUtils.INSTANCE.loadImage(getContext(), liveAnchorAvatar, mIvAvatarAnchor, R.drawable.icon_student_default_head);
+        mTvShareTitle.setText(String.format("%s正在直播中!去围观吧~", liveAnchorName));
+        createQRCode(liveRoomId);
+    }
+
+    private void createQRCode(String roomId) {
+        if (!isNeedCreateQRCode) {
+            return;
+        }
+        String url = String.format(WebConstants.SHARE_LIVE_URL, roomId);
+        Observable.create(new ObservableOnSubscribe<Bitmap>() {
+            @Override
+            public void subscribe(@io.reactivex.rxjava3.annotations.NonNull ObservableEmitter<Bitmap> emitter) throws Throwable {
+                Bitmap bitmap = CodeUtils.createImage(url, SizeUtils.dp2px(89), SizeUtils.dp2px(89), null);
+                emitter.onNext(bitmap);
+            }
+        }).subscribeOn(Schedulers.newThread())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new Observer<Bitmap>() {
+                    @Override
+                    public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
+
+                    }
+
+                    @Override
+                    public void onNext(@io.reactivex.rxjava3.annotations.NonNull Bitmap bitmap) {
+                        if (bitmap != null && mIvCode != null) {
+                            isNeedCreateQRCode = false;
+                            mIvCode.setImageBitmap(bitmap);
+                        }
+                    }
+
+                    @Override
+                    public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
+
+                    }
+
+                    @Override
+                    public void onComplete() {
+
+                    }
+                });
+    }
+
+    public View getRootView() {
+        return getWindow().getDecorView();
+    }
+
+    public void setOnEventListener(OnEventListener onEventListener) {
+        this.mOnEventListener = onEventListener;
+    }
+
+    public interface OnEventListener {
+        void onShare(File file);
+    }
+
+}

BIN
student/src/main/res/drawable-xhdpi/bg_share_live_bottom.png


BIN
student/src/main/res/drawable-xhdpi/bg_share_live_top.png


BIN
student/src/main/res/drawable-xhdpi/icon_klx_logo2.png


BIN
student/src/main/res/drawable-xhdpi/icon_share_live_room.png


BIN
student/src/main/res/drawable-xhdpi/icon_share_live_tag.png


BIN
student/src/main/res/drawable-xxhdpi/bg_share_live_bottom.png


BIN
student/src/main/res/drawable-xxhdpi/bg_share_live_top.png


BIN
student/src/main/res/drawable-xxhdpi/icon_klx_logo2.png


BIN
student/src/main/res/drawable-xxhdpi/icon_share_live_room.png


BIN
student/src/main/res/drawable-xxhdpi/icon_share_live_tag.png


+ 8 - 0
student/src/main/res/drawable/shape_share_live_info_bg.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <corners android:radius="9dp"/>
+
+    <gradient android:startColor="#C0DCFF"
+        android:endColor="#BAFFE7"/>
+
+</shape>

+ 7 - 0
student/src/main/res/drawable/shape_share_live_tip_bg.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <corners android:radius="22dp"/>
+    <gradient android:startColor="@color/color_ff598e"
+        android:angle="1"
+        android:endColor="@color/color_fd2d55"/>
+</shape>

+ 10 - 1
student/src/main/res/layout/activity_liveroom_layout.xml

@@ -216,7 +216,7 @@
         android:textSize="@dimen/sp_14"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toLeftOf="@+id/iv_mic" />
+        app:layout_constraintRight_toLeftOf="@+id/iv_share" />
 
     <ImageView
         android:id="@+id/iv_chat_speak"
@@ -264,6 +264,15 @@
         app:layout_constraintRight_toRightOf="parent" />
 
     <ImageView
+        android:id="@+id/iv_share"
+        android:layout_marginEnd="11dp"
+        app:layout_constraintRight_toLeftOf="@+id/iv_mic"
+        app:layout_constraintTop_toTopOf="@+id/icon_add_like"
+        android:src="@drawable/icon_share_live_room"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+    <ImageView
         android:visibility="visible"
         android:id="@+id/iv_mic"
         android:layout_width="wrap_content"

+ 207 - 0
student/src/main/res/layout/dialog_live_share_layout.xml

@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="334dp"
+    android:id="@+id/cs_root"
+    android:layout_height="wrap_content"
+    xmlns:tools="http://schemas.android.com/tools">
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        android:id="@+id/cs_share_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+        <ImageView
+            android:id="@+id/iv_bg_top"
+            android:scaleType="fitXY"
+            android:adjustViewBounds="true"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:src="@drawable/bg_share_live_top"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <ImageView
+            android:id="@+id/iv_bg_bottom"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:adjustViewBounds="true"
+            android:scaleType="fitXY"
+            android:src="@drawable/bg_share_live_bottom"
+            app:layout_constraintLeft_toLeftOf="@+id/iv_bg_top"
+            app:layout_constraintRight_toRightOf="@+id/iv_bg_top"
+            app:layout_constraintTop_toBottomOf="@+id/iv_bg_top" />
+
+        <ImageView
+            android:id="@+id/iv_code"
+            android:layout_width="89dp"
+            android:layout_height="89dp"
+            android:layout_marginStart="15dp"
+            android:layout_marginBottom="10dp"
+            app:layout_constraintBottom_toBottomOf="@+id/iv_bg_top"
+            app:layout_constraintLeft_toLeftOf="@+id/iv_bg_top" />
+
+        <TextView
+            android:layout_marginTop="5dp"
+            android:id="@+id/tv_share_tip"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="25dp"
+            android:layout_marginEnd="15dp"
+            android:includeFontPadding="false"
+            android:text="温馨提示:保存图片到相册或长按识别二维码进入查看喔~"
+            android:textColor="@color/color_999999"
+            android:textSize="@dimen/sp_12"
+            app:layout_constraintLeft_toRightOf="@+id/iv_code"
+            app:layout_constraintRight_toRightOf="@+id/iv_bg_top"
+            app:layout_constraintTop_toTopOf="@+id/iv_code" />
+
+
+        <ImageView
+            android:id="@+id/iv_logo"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="6dp"
+            android:src="@drawable/icon_klx_logo2"
+            app:layout_constraintLeft_toLeftOf="@+id/tv_share_tip"
+            app:layout_constraintTop_toBottomOf="@+id/tv_share_tip" />
+
+        <TextView
+            android:id="@+id/tv_share_tip2"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="4dp"
+            android:layout_marginEnd="15dp"
+            android:text="扫码下载酷乐秀进入直播间互动"
+            android:textColor="@color/color_333333"
+            android:textSize="@dimen/sp_12"
+            android:textStyle="bold"
+            app:layout_constraintLeft_toLeftOf="@+id/iv_logo"
+            app:layout_constraintRight_toRightOf="@+id/iv_bg_top"
+            app:layout_constraintTop_toBottomOf="@+id/iv_logo" />
+
+
+        <View
+            android:id="@+id/view_info_bg"
+            android:layout_marginBottom="17dp"
+            app:layout_constraintBottom_toTopOf="@+id/iv_code"
+            android:layout_marginEnd="15dp"
+            android:layout_marginStart="15dp"
+            app:layout_constraintRight_toRightOf="@+id/iv_bg_top"
+            app:layout_constraintLeft_toLeftOf="@+id/iv_bg_top"
+            android:background="@drawable/shape_share_live_info_bg"
+            android:layout_width="0dp"
+            android:layout_height="58dp"/>
+
+        <de.hdodenhof.circleimageview.CircleImageView
+            app:civ_border_width="1dp"
+            app:civ_border_color="@color/white"
+            android:layout_width="36dp"
+            android:id="@+id/iv_avatar_owner"
+            android:layout_marginStart="12dp"
+            app:layout_constraintLeft_toLeftOf="@+id/view_info_bg"
+            app:layout_constraintBottom_toBottomOf="@+id/view_info_bg"
+            app:layout_constraintTop_toTopOf="@+id/view_info_bg"
+            android:layout_height="36dp"/>
+
+        <TextView
+            android:ellipsize="end"
+            android:maxLines="1"
+            app:layout_constraintVertical_chainStyle="packed"
+            android:id="@+id/tv_share_title"
+            android:layout_marginStart="10dp"
+            android:layout_marginEnd="12dp"
+            app:layout_constraintBottom_toTopOf="@+id/tv_sharer_name"
+            app:layout_constraintRight_toRightOf="@+id/view_info_bg"
+            app:layout_constraintLeft_toRightOf="@+id/iv_avatar_owner"
+            app:layout_constraintTop_toTopOf="@+id/iv_avatar_owner"
+            android:textColor="@color/color_333333"
+            android:textSize="@dimen/sp_16"
+            android:textStyle="bold"
+            tools:text="XXX正在直播中!去围观吧~"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"/>
+
+        <TextView
+            app:layout_constraintBottom_toBottomOf="@+id/iv_avatar_owner"
+            app:layout_constraintTop_toBottomOf="@+id/tv_share_title"
+            android:id="@+id/tv_sharer_name"
+            android:layout_marginEnd="12dp"
+            app:layout_constraintLeft_toLeftOf="@+id/tv_share_title"
+            app:layout_constraintRight_toRightOf="@+id/view_info_bg"
+            android:textColor="@color/color_333333"
+            android:textSize="@dimen/sp_12"
+            tools:text="XXX 为您推荐"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"/>
+
+
+        <de.hdodenhof.circleimageview.CircleImageView
+            android:layout_marginTop="48dp"
+            android:layout_marginStart="37dp"
+            app:layout_constraintLeft_toLeftOf="@+id/iv_bg_top"
+            app:layout_constraintTop_toTopOf="@+id/iv_bg_top"
+            app:civ_border_color="@color/white"
+            app:civ_border_width="2dp"
+            android:id="@+id/iv_avatar_anchor"
+            android:layout_width="76dp"
+            android:layout_height="76dp"/>
+
+        <View
+            android:id="@+id/view_help_line"
+            app:layout_constraintRight_toRightOf="@+id/iv_avatar_anchor"
+            app:layout_constraintLeft_toLeftOf="@+id/iv_avatar_anchor"
+            app:layout_constraintBottom_toBottomOf="@+id/iv_avatar_anchor"
+            android:layout_width="1px"
+            android:layout_height="1px"/>
+
+        <TextView
+            app:layout_constraintBottom_toBottomOf="@+id/view_help_line"
+            app:layout_constraintTop_toTopOf="@+id/view_help_line"
+            app:layout_constraintRight_toRightOf="@+id/view_help_line"
+            app:layout_constraintLeft_toLeftOf="@+id/view_help_line"
+            android:id="@+id/tv_live_tag"
+            android:drawablePadding="5dp"
+            android:paddingBottom="4dp"
+            android:paddingTop="4dp"
+            android:paddingEnd="10dp"
+            android:paddingStart="10dp"
+            android:drawableLeft="@drawable/icon_share_live_tag"
+            android:textSize="@dimen/sp_12"
+            android:textColor="@color/white"
+            android:text="直播中"
+            android:background="@drawable/shape_share_live_tip_bg"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"/>
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <TextView
+        android:id="@+id/tv_save"
+        android:layout_width="146dp"
+        android:layout_height="44dp"
+        android:layout_marginTop="50dp"
+        android:layout_marginEnd="13dp"
+        android:background="@drawable/shape_24dp_white"
+        android:gravity="center"
+        android:text="@string/save_pic_str"
+        android:textColor="@color/color_2dc7aa"
+        android:textSize="@dimen/sp_16"
+        app:layout_constraintHorizontal_chainStyle="packed"
+        app:layout_constraintLeft_toLeftOf="@+id/cs_share_view"
+        app:layout_constraintRight_toLeftOf="@+id/tv_share"
+        app:layout_constraintTop_toBottomOf="@+id/cs_share_view" />
+
+    <TextView
+        android:id="@+id/tv_share"
+        android:layout_width="146dp"
+        android:layout_height="44dp"
+        android:background="@drawable/shape_2dc7aa_24dp"
+        android:gravity="center"
+        android:text="@string/share_tip_str"
+        android:textColor="@color/white"
+        android:textSize="@dimen/sp_16"
+        app:layout_constraintLeft_toRightOf="@+id/tv_save"
+        app:layout_constraintRight_toRightOf="@+id/cs_share_view"
+        app:layout_constraintTop_toTopOf="@+id/tv_save" />
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 2 - 0
student/src/main/res/values/strings.xml

@@ -37,5 +37,7 @@
     <string name="enable_mic_mode_tip">老师已关闭连麦申请</string>
     <string name="enter_live_tip_str">%1$s 进入直播间</string>
     <string name="live_snap_up_tip_str">%1$s 正在抢购</string>
+    <string name="save_pic_str">保存图片</string>
+    <string name="share_tip_str">立即分享</string>
 
 </resources>