update 分享支持社区分享按钮
This commit is contained in:
parent
26cb58463a
commit
ef757a8adc
@ -90,10 +90,6 @@ public class ShareAppAdapter extends RecyclerView.Adapter<ShareAppAdapter.AppVie
|
|||||||
public void setData(ShareBuilder bean, @DrawableRes int iconId, @StringRes int appName) {
|
public void setData(ShareBuilder bean, @DrawableRes int iconId, @StringRes int appName) {
|
||||||
icon.setImageResource(iconId);
|
icon.setImageResource(iconId);
|
||||||
title.setText(appName);
|
title.setText(appName);
|
||||||
String filename = "/ztest/myPhoto.jpg";
|
|
||||||
String mediaPath = Environment.getExternalStorageDirectory() + filename;
|
|
||||||
File media = new File(mediaPath);
|
|
||||||
bean.setFile(media);
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
switch (bean.getType()) {
|
switch (bean.getType()) {
|
||||||
case ShareBuilder.APP_FACEBOOK:
|
case ShareBuilder.APP_FACEBOOK:
|
||||||
|
@ -16,6 +16,7 @@ import com.makeramen.roundedimageview.RoundedImageView;
|
|||||||
import com.pdlive.shayu.R;
|
import com.pdlive.shayu.R;
|
||||||
import com.yunbao.common.dialog.AbsDialogPopupWindow;
|
import com.yunbao.common.dialog.AbsDialogPopupWindow;
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
|
import com.yunbao.common.utils.StringUtil;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
import com.yunbao.share.bean.ShareBuilder;
|
import com.yunbao.share.bean.ShareBuilder;
|
||||||
@ -36,6 +37,7 @@ public class SharePopDialog extends AbsDialogPopupWindow {
|
|||||||
private String anchorId;
|
private String anchorId;
|
||||||
private String anchorName;
|
private String anchorName;
|
||||||
private String anchorAvatar;
|
private String anchorAvatar;
|
||||||
|
private String shareLink;
|
||||||
|
|
||||||
public SharePopDialog(@NonNull Context context) {
|
public SharePopDialog(@NonNull Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -61,6 +63,11 @@ public class SharePopDialog extends AbsDialogPopupWindow {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SharePopDialog setShareLink(String link) {
|
||||||
|
this.shareLink = link;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildDialog(XPopup.Builder builder) {
|
public void buildDialog(XPopup.Builder builder) {
|
||||||
|
|
||||||
@ -96,23 +103,43 @@ public class SharePopDialog extends AbsDialogPopupWindow {
|
|||||||
data.add(builder(ShareBuilder.APP_MESSENGER));
|
data.add(builder(ShareBuilder.APP_MESSENGER));
|
||||||
//data.add(builder(ShareBuilder.APP_INSTAGRAM));
|
//data.add(builder(ShareBuilder.APP_INSTAGRAM));
|
||||||
adapter.setList(data);
|
adapter.setList(data);
|
||||||
String url=ShareBuilder.createLiveShareLink(uid,anchorId,anchorName,anchorAvatar).substring(0,40)+"...";
|
String url;
|
||||||
|
if (shareLink == null) {
|
||||||
|
url = ShareBuilder.createLiveShareLink(uid, anchorId, anchorName, anchorAvatar).substring(0, 40) + "...";
|
||||||
|
} else {
|
||||||
|
if (shareLink.length() > 40) {
|
||||||
|
url = shareLink.substring(0, 40) + "...";
|
||||||
|
} else {
|
||||||
|
url = shareLink;
|
||||||
|
}
|
||||||
|
}
|
||||||
link.setText(url);
|
link.setText(url);
|
||||||
ImgLoader.display(getContext(),anchorAvatar,avatar);
|
info.setText(String.format(WordUtil.getString(R.string.dialog_share_info), StringUtil.isEmpty(anchorName) ? "" : anchorName));
|
||||||
|
ImgLoader.display(getContext(), anchorAvatar, avatar);
|
||||||
}
|
}
|
||||||
private ShareBuilder builder(int type){
|
|
||||||
ShareBuilder builder=ShareBuilder.builder(type);
|
private ShareBuilder builder(int type) {
|
||||||
builder.setText(WordUtil.getString(R.string.dialog_share_info));
|
ShareBuilder builder = ShareBuilder.builder(type);
|
||||||
|
builder.setText(String.format(WordUtil.getString(R.string.dialog_share_info), StringUtil.isEmpty(anchorName) ? "" : anchorName));
|
||||||
builder.setUid(uid);
|
builder.setUid(uid);
|
||||||
builder.setAnchorId(anchorId);
|
builder.setAnchorId(anchorId);
|
||||||
builder.setAnchorName(anchorName);
|
builder.setAnchorName(anchorName);
|
||||||
builder.setAnchorAvatar(anchorAvatar);
|
builder.setAnchorAvatar(anchorAvatar);
|
||||||
|
if (shareLink != null) {
|
||||||
|
builder.setLink(shareLink);
|
||||||
|
}
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyLink() {
|
private void copyLink() {
|
||||||
|
String url;
|
||||||
|
if (shareLink != null) {
|
||||||
|
url = shareLink;
|
||||||
|
} else {
|
||||||
|
url = ShareBuilder.createLiveShareLink(uid, anchorId, anchorName, anchorAvatar);
|
||||||
|
}
|
||||||
ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE);
|
ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE);
|
||||||
ClipData clipData = ClipData.newPlainText("text", ShareBuilder.createLiveShareLink(uid,anchorId,anchorName,anchorAvatar));
|
ClipData clipData = ClipData.newPlainText("text", url);
|
||||||
cm.setPrimaryClip(clipData);
|
cm.setPrimaryClip(clipData);
|
||||||
ToastUtil.show(WordUtil.getString(com.yunbao.common.R.string.copy_success));
|
ToastUtil.show(WordUtil.getString(com.yunbao.common.R.string.copy_success));
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<string name="com.twitter.sdk.android.CONSUMER_SECRET" translatable="false">aq0eV4R1pqMK_AAeKRWnjPr7ErGMGgTPGgZJdm73WeRY-Kluws</string>
|
<string name="com.twitter.sdk.android.CONSUMER_SECRET" translatable="false">aq0eV4R1pqMK_AAeKRWnjPr7ErGMGgTPGgZJdm73WeRY-Kluws</string>
|
||||||
|
|
||||||
<string name="dialog_share_title">分享</string>
|
<string name="dialog_share_title">分享</string>
|
||||||
<string name="dialog_share_info">快來 PDLIVE觀看主播名稱直播,認識更多有趣的朋友吧!</string>
|
<string name="dialog_share_info">快來 PDLIVE觀看%s直播,認識更多有趣的朋友吧!</string>
|
||||||
<string name="dialog_share_app_facebook" translatable="false">Facebook</string>
|
<string name="dialog_share_app_facebook" translatable="false">Facebook</string>
|
||||||
<string name="dialog_share_app_line" translatable="false">Line</string>
|
<string name="dialog_share_app_line" translatable="false">Line</string>
|
||||||
<string name="dialog_share_app_twitter" translatable="false">Twitter</string>
|
<string name="dialog_share_app_twitter" translatable="false">Twitter</string>
|
||||||
|
@ -497,4 +497,13 @@ public class JavascriptInterfaceUtils {
|
|||||||
mWebView.setVisibility(View.VISIBLE);
|
mWebView.setVisibility(View.VISIBLE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@JavascriptInterface
|
||||||
|
public void androidCommunityShare(String avatar,String link){
|
||||||
|
JSONObject json=new JSONObject();
|
||||||
|
json.put("avatar",avatar);
|
||||||
|
json.put("link",link);
|
||||||
|
Bus.get().post(new JavascriptInterfaceEvent()
|
||||||
|
.setMethod("androidCommunityShare")
|
||||||
|
.setData(json.toJSONString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.yunbao.common.CommonAppConfig;
|
import com.yunbao.common.CommonAppConfig;
|
||||||
import com.yunbao.common.Constants;
|
import com.yunbao.common.Constants;
|
||||||
import com.yunbao.common.HtmlConfig;
|
import com.yunbao.common.HtmlConfig;
|
||||||
@ -50,6 +51,7 @@ import com.yunbao.main.R;
|
|||||||
import com.yunbao.main.activity.MainActivity;
|
import com.yunbao.main.activity.MainActivity;
|
||||||
import com.yunbao.main.dialog.EncourageDialog;
|
import com.yunbao.main.dialog.EncourageDialog;
|
||||||
import com.yunbao.main.utils.BottomBarUtil;
|
import com.yunbao.main.utils.BottomBarUtil;
|
||||||
|
import com.yunbao.share.ui.SharePopDialog;
|
||||||
import com.yunbao.video.activity.VideoPlayActivity;
|
import com.yunbao.video.activity.VideoPlayActivity;
|
||||||
import com.yunbao.video.utils.VideoStorge;
|
import com.yunbao.video.utils.VideoStorge;
|
||||||
|
|
||||||
@ -238,7 +240,7 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
|
|||||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -248,9 +250,9 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
RouteUtil.forwardUserHome(mContext, String.valueOf(live_id), 0);
|
RouteUtil.forwardUserHome(mContext, String.valueOf(live_id), 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -345,10 +347,16 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
|
|||||||
} else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) {
|
} else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) {
|
||||||
//看直播
|
//看直播
|
||||||
gotoLive(event.getLiveId());
|
gotoLive(event.getLiveId());
|
||||||
}else if (TextUtils.equals(event.getMethod(), "isCloseNavigation")){
|
} else if (TextUtils.equals(event.getMethod(), "isCloseNavigation")) {
|
||||||
if(nowMainActivity!=null) {
|
if (nowMainActivity != null) {
|
||||||
nowMainActivity.isClose(event.getIsClose());
|
nowMainActivity.isClose(event.getIsClose());
|
||||||
}
|
}
|
||||||
|
} else if (TextUtils.equals(event.getMethod(), "androidCommunityShare")) {
|
||||||
|
JSONObject json = JSONObject.parseObject(event.getData());
|
||||||
|
new SharePopDialog(mContext)
|
||||||
|
.setShareLink(CommonAppConfig.HOST+json.getString("link"))
|
||||||
|
.setAnchorAvatar(json.getString("avatar"))
|
||||||
|
.showDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user