diff --git a/Share/src/main/java/com/yunbao/share/AbsShareInterface.java b/Share/src/main/java/com/yunbao/share/AbsShareInterface.java index fed5ddee8..dbae5135a 100644 --- a/Share/src/main/java/com/yunbao/share/AbsShareInterface.java +++ b/Share/src/main/java/com/yunbao/share/AbsShareInterface.java @@ -7,7 +7,7 @@ import android.net.Uri; import androidx.core.content.FileProvider; import com.twitter.sdk.android.tweetcomposer.TweetUploadService; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; import com.yunbao.share.receiver.TwitterResultReceiver; import java.io.File; @@ -23,7 +23,7 @@ public abstract class AbsShareInterface { context.registerReceiver(new TwitterResultReceiver(), filter); } - public abstract void share(ShareBuilder builder, ICallback callback); + public abstract void share(ShareBean builder, ICallback callback); public Uri fileToUri(File file){ return FileProvider.getUriForFile(mContext, diff --git a/Share/src/main/java/com/yunbao/share/adapters/InternalShareAdapter.java b/Share/src/main/java/com/yunbao/share/adapters/InternalShareAdapter.java index d245fc17d..8944dfc9d 100644 --- a/Share/src/main/java/com/yunbao/share/adapters/InternalShareAdapter.java +++ b/Share/src/main/java/com/yunbao/share/adapters/InternalShareAdapter.java @@ -3,6 +3,7 @@ package com.yunbao.share.adapters; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.CompoundButton; import android.widget.RadioButton; import android.widget.TextView; @@ -75,6 +76,10 @@ public class InternalShareAdapter extends RecyclerView.Adapter { + selectPosition = position; + notifyDataSetChanged(); + }); itemView.setOnClickListener(view -> { selectPosition = position; notifyDataSetChanged(); diff --git a/Share/src/main/java/com/yunbao/share/adapters/ShareAppAdapter.java b/Share/src/main/java/com/yunbao/share/adapters/ShareAppAdapter.java index 977367b96..2ec55c811 100644 --- a/Share/src/main/java/com/yunbao/share/adapters/ShareAppAdapter.java +++ b/Share/src/main/java/com/yunbao/share/adapters/ShareAppAdapter.java @@ -1,7 +1,6 @@ package com.yunbao.share.adapters; import android.content.Context; -import android.os.Environment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -15,7 +14,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.pdlive.shayu.R; import com.yunbao.share.ICallback; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; import com.yunbao.share.platform.FacebookShare; import com.yunbao.share.platform.Instagram; import com.yunbao.share.platform.Internal; @@ -24,13 +23,12 @@ import com.yunbao.share.platform.MessengerShare; import com.yunbao.share.platform.TwitterShare; import com.yunbao.share.platform.WhatsApp; -import java.io.File; import java.util.ArrayList; import java.util.List; public class ShareAppAdapter extends RecyclerView.Adapter { private Context mContext; - private List list; + private List list; ShareCallback shareCallback; public ShareAppAdapter(Context mContext) { @@ -38,7 +36,7 @@ public class ShareAppAdapter extends RecyclerView.Adapter list) { + public void setList(List list) { this.list = list; notifyDataSetChanged(); } @@ -51,27 +49,28 @@ public class ShareAppAdapter extends RecyclerView.Adapter"+builder.getType()); switch (builder.getType()) { - case ShareBuilder.APP_FACEBOOK: + case ShareBean.APP_FACEBOOK: holder.setData(builder, R.mipmap.icon_share_facebook, R.string.dialog_share_app_facebook); break; - case ShareBuilder.APP_LINE: + case ShareBean.APP_LINE: holder.setData(builder, R.mipmap.icon_share_line, R.string.dialog_share_app_line); break; - case ShareBuilder.APP_TWITTER: + case ShareBean.APP_TWITTER: holder.setData(builder, R.mipmap.icon_share_twitter, R.string.dialog_share_app_twitter); break; - case ShareBuilder.APP_WHATSAPP: + case ShareBean.APP_WHATSAPP: holder.setData(builder, R.mipmap.icon_share_whatsapp, R.string.dialog_share_app_whatsapp); break; - case ShareBuilder.APP_MESSENGER: + case ShareBean.APP_MESSENGER: holder.setData(builder, R.mipmap.icon_share_messenger, R.string.dialog_share_app_messenger); break; - case ShareBuilder.APP_INSTAGRAM: + case ShareBean.APP_INSTAGRAM: holder.setData(builder, R.mipmap.icon_share_instagram, R.string.dialog_share_app_instagram); break; - case ShareBuilder.APP_INTERNAL: + case ShareBean.APP_INTERNAL: holder.setData(builder, R.mipmap.ic_share_friend, R.string.dialog_share_app_internal); break; } @@ -99,30 +98,30 @@ public class ShareAppAdapter extends RecyclerView.Adapter { switch (bean.getType()) { - case ShareBuilder.APP_FACEBOOK: + case ShareBean.APP_FACEBOOK: new FacebookShare(itemView.getContext()).share(bean, new ShareCallback()); break; - case ShareBuilder.APP_LINE: + case ShareBean.APP_LINE: new Line(itemView.getContext()).share(bean, new ShareCallback()); break; - case ShareBuilder.APP_TWITTER: + case ShareBean.APP_TWITTER: new TwitterShare(itemView.getContext()).share(bean, new ShareCallback()); break; - case ShareBuilder.APP_WHATSAPP: + case ShareBean.APP_WHATSAPP: new WhatsApp(itemView.getContext()).share(bean, new ShareCallback()); break; - case ShareBuilder.APP_MESSENGER: + case ShareBean.APP_MESSENGER: new MessengerShare(itemView.getContext()).share(bean, new ShareCallback()); break; - case ShareBuilder.APP_INSTAGRAM: + case ShareBean.APP_INSTAGRAM: new Instagram(itemView.getContext()).share(bean, new ShareCallback()); break; - case ShareBuilder.APP_INTERNAL: + case ShareBean.APP_INTERNAL: new Internal(itemView.getContext()).share(bean, shareCallback); break; } diff --git a/Share/src/main/java/com/yunbao/share/bean/ShareBean.java b/Share/src/main/java/com/yunbao/share/bean/ShareBean.java new file mode 100644 index 000000000..d6a65daa8 --- /dev/null +++ b/Share/src/main/java/com/yunbao/share/bean/ShareBean.java @@ -0,0 +1,260 @@ +package com.yunbao.share.bean; + +import androidx.annotation.NonNull; + +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.WordUtil; +import com.yunbao.share.ui.SharePopDialog; + +import java.io.File; + +public class ShareBean { + public static final int APP_FACEBOOK = 0; + public static final int APP_LINE = 1; + public static final int APP_TWITTER = 2; + public static final int APP_WHATSAPP = 3; + public static final int APP_MESSENGER = 4; + public static final int APP_INSTAGRAM = 5; + public static final int APP_INTERNAL = 6; + + private String text; + private String link; + private File file; + private int type; + private String uid; + private String anchorId; + private String anchorName; + private String anchorAvatar; + private int shareType; + private String cover; + private String title; + + + public static String createLiveShareLink(String shareUid, String anchorId, String anchorName, String anchorAvatar) { + return String.format(CommonAppConfig.HOST + + "/index.php?g=Appapi&m=home&a=share&uid=%s&user_id=%s&isGoogle=%s", + anchorId, + shareUid, + CommonAppConfig.IS_GOOGLE_PLAY + ); + } + + public static String createInviteLink(String shareUid) { + return String.format("https://www.pdlive.com/public/app/download/index.html?user_id=%s&isGoogle=%s", + shareUid, + CommonAppConfig.IS_GOOGLE_PLAY + ); + } + + public static ShareBean builder(int type) { + return new ShareBean(type); + } + + private ShareBean(int type) { + this.type = type; + } + + public int getShareType() { + return shareType; + } + + public void setShareType(int shareType) { + this.shareType = shareType; + } + + public void setType(int type) { + this.type = type; + } + + public String getCover() { + return cover; + } + + public void setCover(String cover) { + this.cover = cover; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public int getType() { + return type; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getAnchorId() { + return anchorId; + } + + public void setAnchorId(String anchorId) { + this.anchorId = anchorId; + } + + public String getAnchorName() { + return anchorName; + } + + public void setAnchorName(String anchorName) { + this.anchorName = anchorName; + } + + public String getAnchorAvatar() { + return anchorAvatar; + } + + public void setAnchorAvatar(String anchorAvatar) { + this.anchorAvatar = anchorAvatar; + } + + public ShareBean setText(String text) { + this.text = text; + return this; + } + + public ShareBean setLink(String link) { + this.link = link; + return this; + } + + public ShareBean setFile(File file) { + this.file = file; + return this; + } + + public String getText() { + if (StringUtil.isEmpty(text)) { + return getLink(); + } + return text + "\n" + getLink(); + } + + public String getLink() { + if (StringUtil.isEmpty(link)) { + link = createLiveShareLink(uid, anchorId, anchorName, anchorAvatar); + } + return link; + } + + public File getFile() { + return file; + } + + @NonNull + @Override + public String toString() { + return "ShareBuilder{" + + "text='" + text + '\'' + + ", link='" + link + '\'' + + ", file=" + file + + '}'; + } + + /** + * private String text; + * private String link; + * private File file; + * private int type; + * private String uid; + * private String anchorId; + * private String anchorName; + * private String anchorAvatar; + * private int shareType; + * private String cover; + * private String title; + */ + @NonNull + @Override + public ShareBean clone(){ + ShareBean bean=new ShareBean(type); + bean.anchorId=anchorId; + bean.anchorName=anchorName; + bean.anchorAvatar=anchorAvatar; + bean.text=text; + bean.link=link; + bean.file=file; + bean.uid=uid; + bean.shareType=shareType; + bean.cover=cover; + bean.title=title; + return bean; + } + + public static class ShareBuilder { + ShareBean bean; + + public ShareBuilder() { + bean = new ShareBean(APP_FACEBOOK); + } + + public ShareBuilder setShareType(int shareType) { + bean.setShareType(shareType); + return this; + } + + public ShareBuilder setCover(String cover) { + bean.setCover(cover); + return this; + } + + public ShareBuilder setTitle(String title) { + bean.setTitle(title); + return this; + } + + public ShareBuilder setUid(String uid) { + bean.setUid(uid); + return this; + } + + public ShareBuilder setAnchorId(String anchorId) { + bean.setAnchorId(anchorId); + return this; + } + + public ShareBuilder setAnchorName(String anchorName) { + bean.setAnchorName(anchorName); + return this; + } + + public ShareBuilder setAnchorAvatar(String anchorAvatar) { + bean.setAnchorAvatar(anchorAvatar); + return this; + } + + public ShareBuilder setText(String text) { + bean.setText(text); + return this; + } + + public ShareBuilder setLink(String link) { + bean.setLink(link); + return this; + } + + public ShareBuilder setFile(File file) { + bean.setFile(file); + return this; + } + public ShareBean build() { + return bean; + } + + + public static ShareBuilder create() { + return new ShareBuilder(); + } + } +} diff --git a/Share/src/main/java/com/yunbao/share/bean/ShareBuilder.java b/Share/src/main/java/com/yunbao/share/bean/ShareBuilder.java deleted file mode 100644 index 903386a68..000000000 --- a/Share/src/main/java/com/yunbao/share/bean/ShareBuilder.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.yunbao.share.bean; - -import androidx.annotation.NonNull; - -import com.yunbao.common.CommonAppConfig; -import com.yunbao.common.CommonAppContext; -import com.yunbao.common.manager.IMLoginManager; -import com.yunbao.common.utils.StringUtil; - -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.Locale; - -public class ShareBuilder { - public static final int APP_FACEBOOK = 0; - public static final int APP_LINE = 1; - public static final int APP_TWITTER = 2; - public static final int APP_WHATSAPP = 3; - public static final int APP_MESSENGER = 4; - public static final int APP_INSTAGRAM = 5; - public static final int APP_INTERNAL = 6; - - private String text; - private String link; - private File file; - private int type; - private String uid; - private String anchorId; - private String anchorName; - private String anchorAvatar; - - public static String createLiveShareLink(String shareUid, String anchorId, String anchorName, String anchorAvatar) { - return String.format(CommonAppConfig.HOST + - "/index.php?g=Appapi&m=home&a=share&uid=%s&user_id=%s&isGoogle=%s", - anchorId, - shareUid, - CommonAppConfig.IS_GOOGLE_PLAY - ); - } - - public static String createInviteLink(String shareUid) { - return String.format("https://www.pdlive.com/public/app/download/index.html?user_id=%s&isGoogle=%s", - shareUid, - CommonAppConfig.IS_GOOGLE_PLAY - ); - } - - public static ShareBuilder builder(int type) { - return new ShareBuilder(type); - } - - private ShareBuilder(int type) { - this.type = type; - } - - public int getType() { - return type; - } - - public String getUid() { - return uid; - } - - public void setUid(String uid) { - this.uid = uid; - } - - public String getAnchorId() { - return anchorId; - } - - public void setAnchorId(String anchorId) { - this.anchorId = anchorId; - } - - public String getAnchorName() { - return anchorName; - } - - public void setAnchorName(String anchorName) { - this.anchorName = anchorName; - } - - public String getAnchorAvatar() { - return anchorAvatar; - } - - public void setAnchorAvatar(String anchorAvatar) { - this.anchorAvatar = anchorAvatar; - } - - public ShareBuilder setText(String text) { - this.text = text; - return this; - } - - public ShareBuilder setLink(String link) { - this.link = link; - return this; - } - - public ShareBuilder setFile(File file) { - this.file = file; - return this; - } - - public String getText() { - if (StringUtil.isEmpty(text)) { - return getLink(); - } - return text + "\n" + getLink(); - } - - public String getLink() { - if (StringUtil.isEmpty(link)) { - link = createLiveShareLink(uid, anchorId, anchorName, anchorAvatar); - } - return link; - } - - public File getFile() { - return file; - } - - @NonNull - @Override - public String toString() { - return "ShareBuilder{" + - "text='" + text + '\'' + - ", link='" + link + '\'' + - ", file=" + file + - '}'; - } -} diff --git a/Share/src/main/java/com/yunbao/share/platform/FacebookShare.java b/Share/src/main/java/com/yunbao/share/platform/FacebookShare.java index c34739e1f..d899895b2 100644 --- a/Share/src/main/java/com/yunbao/share/platform/FacebookShare.java +++ b/Share/src/main/java/com/yunbao/share/platform/FacebookShare.java @@ -12,10 +12,9 @@ import com.facebook.FacebookException; import com.facebook.share.Sharer; import com.facebook.share.model.ShareLinkContent; import com.facebook.share.widget.ShareDialog; -import com.yunbao.common.utils.ToastUtil; import com.yunbao.share.AbsShareInterface; import com.yunbao.share.ICallback; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; public class FacebookShare extends AbsShareInterface { public static CallbackManager callbackManager; @@ -24,7 +23,7 @@ public class FacebookShare extends AbsShareInterface { } @Override - public void share(ShareBuilder builder, ICallback callback) { + public void share(ShareBean builder, ICallback callback) { callbackManager= CallbackManager.Factory.create(); ShareLinkContent content = new ShareLinkContent.Builder() .setContentUrl(Uri.parse(builder.getLink())) diff --git a/Share/src/main/java/com/yunbao/share/platform/Instagram.java b/Share/src/main/java/com/yunbao/share/platform/Instagram.java index da876e6fb..d77fe5685 100644 --- a/Share/src/main/java/com/yunbao/share/platform/Instagram.java +++ b/Share/src/main/java/com/yunbao/share/platform/Instagram.java @@ -6,7 +6,7 @@ import android.net.Uri; import com.yunbao.share.AbsShareInterface; import com.yunbao.share.ICallback; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; public class Instagram extends AbsShareInterface { public Instagram(Context context) { @@ -14,7 +14,7 @@ public class Instagram extends AbsShareInterface { } @Override - public void share(ShareBuilder builder, ICallback callback) { + public void share(ShareBean builder, ICallback callback) { String type = "image/*"; Intent share = new Intent(Intent.ACTION_SEND); Uri uri = fileToUri(builder.getFile()); diff --git a/Share/src/main/java/com/yunbao/share/platform/Internal.java b/Share/src/main/java/com/yunbao/share/platform/Internal.java index 67b76cdb0..56cb0ec55 100644 --- a/Share/src/main/java/com/yunbao/share/platform/Internal.java +++ b/Share/src/main/java/com/yunbao/share/platform/Internal.java @@ -3,20 +3,23 @@ package com.yunbao.share.platform; import android.content.Context; import com.yunbao.common.interfaces.OnItemClickListener; -import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.interfaces.OnSendMessageListener; +import com.yunbao.common.message.content.MessageChatCardContent; import com.yunbao.share.AbsShareInterface; import com.yunbao.share.ICallback; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; import com.yunbao.share.ui.AppInternalShareDialog; import com.yunbao.share.ui.ShareSuccessNotifyDialog; +import io.rong.imlib.model.Conversation; + public class Internal extends AbsShareInterface { public Internal(Context context) { super(context); } @Override - public void share(ShareBuilder builder, ICallback callback) { + public void share(ShareBean builder, ICallback callback) { new AppInternalShareDialog(mContext) .setOnItemClickListener(new OnItemClickListener() { @Override @@ -26,10 +29,36 @@ public class Internal extends AbsShareInterface { return; } builder.setUid(toUid); + sendMessage(builder); new ShareSuccessNotifyDialog(mContext, builder) .showDialog(); callback.onSuccess(); } }).showDialog(); } + + void sendMessage(ShareBean builder) { + MessageChatCardContent.sendMessage(Conversation.ConversationType.PRIVATE, builder.getUid(), + MessageChatCardContent.obtain( + builder.getCover(), + builder.getTitle(), + builder.getAnchorAvatar(), + builder.getAnchorName(), + builder.getAnchorId(), + builder.getShareType() + "", + builder.getAnchorId() + ), + new OnSendMessageListener() { + @Override + public void onSuccess(String token, Object bean) { + super.onSuccess(token, bean); + } + + @Override + public void onError(int status, String msg) { + super.onError(status, msg); + } + } + ); + } } diff --git a/Share/src/main/java/com/yunbao/share/platform/Line.java b/Share/src/main/java/com/yunbao/share/platform/Line.java index bbad5c934..5b88e69a6 100644 --- a/Share/src/main/java/com/yunbao/share/platform/Line.java +++ b/Share/src/main/java/com/yunbao/share/platform/Line.java @@ -6,7 +6,7 @@ import android.net.Uri; import com.yunbao.share.AbsShareInterface; import com.yunbao.share.ICallback; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; import java.net.URLEncoder; @@ -17,7 +17,7 @@ public class Line extends AbsShareInterface { } @Override - public void share(ShareBuilder builder, ICallback callback) { + public void share(ShareBean builder, ICallback callback) { try { Intent share = new Intent(Intent.ACTION_VIEW, Uri.parse("https://line.me/R/share?text=" + URLEncoder.encode(builder.getText(), "UTF-8"))); mContext.startActivity(share); diff --git a/Share/src/main/java/com/yunbao/share/platform/MessengerShare.java b/Share/src/main/java/com/yunbao/share/platform/MessengerShare.java index e9b312646..3c3db1906 100644 --- a/Share/src/main/java/com/yunbao/share/platform/MessengerShare.java +++ b/Share/src/main/java/com/yunbao/share/platform/MessengerShare.java @@ -13,10 +13,9 @@ import com.facebook.FacebookSdk; import com.facebook.share.Sharer; import com.facebook.share.model.ShareLinkContent; import com.facebook.share.widget.MessageDialog; -import com.yunbao.common.utils.ToastUtil; import com.yunbao.share.AbsShareInterface; import com.yunbao.share.ICallback; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; public class MessengerShare extends AbsShareInterface { public static CallbackManager callbackManager; @@ -27,7 +26,7 @@ public class MessengerShare extends AbsShareInterface { } @Override - public void share(ShareBuilder builder, ICallback callback) { + public void share(ShareBean builder, ICallback callback) { callbackManager = CallbackManager.Factory.create(); ShareLinkContent content = new ShareLinkContent.Builder() .setContentUrl(Uri.parse(builder.getLink())) diff --git a/Share/src/main/java/com/yunbao/share/platform/TwitterShare.java b/Share/src/main/java/com/yunbao/share/platform/TwitterShare.java index 399cc758c..05adb5aa2 100644 --- a/Share/src/main/java/com/yunbao/share/platform/TwitterShare.java +++ b/Share/src/main/java/com/yunbao/share/platform/TwitterShare.java @@ -7,7 +7,7 @@ import android.net.Uri; import com.twitter.sdk.android.core.Twitter; import com.yunbao.share.AbsShareInterface; import com.yunbao.share.ICallback; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; import java.net.URLEncoder; @@ -19,7 +19,7 @@ public class TwitterShare extends AbsShareInterface { } @Override - public void share(ShareBuilder date, ICallback callback) { + public void share(ShareBean date, ICallback callback) { /* new TwitterAuthClient().authorize((Activity) mContext, new Callback() { diff --git a/Share/src/main/java/com/yunbao/share/platform/WhatsApp.java b/Share/src/main/java/com/yunbao/share/platform/WhatsApp.java index 51485e6fb..6d982ffe2 100644 --- a/Share/src/main/java/com/yunbao/share/platform/WhatsApp.java +++ b/Share/src/main/java/com/yunbao/share/platform/WhatsApp.java @@ -5,7 +5,7 @@ import android.content.Intent; import com.yunbao.share.AbsShareInterface; import com.yunbao.share.ICallback; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; public class WhatsApp extends AbsShareInterface { public WhatsApp(Context context) { @@ -13,7 +13,7 @@ public class WhatsApp extends AbsShareInterface { } @Override - public void share(ShareBuilder builder, ICallback callback) { + public void share(ShareBean builder, ICallback callback) { try { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); diff --git a/Share/src/main/java/com/yunbao/share/ui/AppInternalShareDialog.java b/Share/src/main/java/com/yunbao/share/ui/AppInternalShareDialog.java index 3bf8e3545..6ee31a9c2 100644 --- a/Share/src/main/java/com/yunbao/share/ui/AppInternalShareDialog.java +++ b/Share/src/main/java/com/yunbao/share/ui/AppInternalShareDialog.java @@ -2,27 +2,21 @@ package com.yunbao.share.ui; import android.content.Context; import android.widget.EditText; -import android.widget.ImageView; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.lxj.xpopup.XPopup; import com.pdlive.shayu.R; -import com.yunbao.common.bean.MessageChatUserBean; import com.yunbao.common.dialog.AbsDialogFullScreenPopupWindow; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.ViewUtils; import com.yunbao.share.adapters.InternalShareAdapter; -import com.yunbao.share.bean.ShareBuilder; import java.util.ArrayList; import java.util.List; import io.rong.imkit.conversationlist.model.SingleConversation; -import io.rong.imkit.userinfo.RongUserInfoManager; import io.rong.imkit.widget.refresh.SmartRefreshLayout; import io.rong.imkit.widget.refresh.api.RefreshLayout; import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener; @@ -31,7 +25,6 @@ import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader; import io.rong.imlib.IRongCoreCallback; import io.rong.imlib.IRongCoreEnum; import io.rong.imlib.RongCoreClient; -import io.rong.imlib.RongIMClient; import io.rong.imlib.model.Conversation; public class AppInternalShareDialog extends AbsDialogFullScreenPopupWindow { @@ -72,6 +65,10 @@ public class AppInternalShareDialog extends AbsDialogFullScreenPopupWindow { dismiss(); }); findViewById(R.id.btn_share).setOnClickListener(view -> { + if(adapter.getSelectPosition()==-1){ + ToastUtil.show(R.string.dialog_share_failure_not_select); + return; + } if (onItemClickListener != null) { onItemClickListener.onItemClick(listData.get(adapter.getSelectPosition()).mCore.getTargetId(), adapter.getSelectPosition()); } diff --git a/Share/src/main/java/com/yunbao/share/ui/InvitePopDialog.java b/Share/src/main/java/com/yunbao/share/ui/InvitePopDialog.java index fbfeeb53e..8d0782712 100644 --- a/Share/src/main/java/com/yunbao/share/ui/InvitePopDialog.java +++ b/Share/src/main/java/com/yunbao/share/ui/InvitePopDialog.java @@ -2,14 +2,12 @@ package com.yunbao.share.ui; import static android.content.Context.CLIPBOARD_SERVICE; -import android.app.Dialog; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.graphics.Color; import android.graphics.LinearGradient; import android.graphics.Shader; -import android.view.ViewTreeObserver; import android.widget.ImageView; import android.widget.TextView; @@ -22,10 +20,8 @@ import com.makeramen.roundedimageview.RoundedImageView; import com.pdlive.shayu.R; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.dialog.AbsDialogPopupWindow; -import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; import com.yunbao.share.adapters.ShareAppAdapter; import java.util.ArrayList; @@ -38,7 +34,7 @@ public class InvitePopDialog extends AbsDialogPopupWindow { private TextView info; private TextView link; private TextView title; - private List data; + private List data; private String uid; private String anchorId; @@ -123,18 +119,18 @@ public class InvitePopDialog extends AbsDialogPopupWindow { private void initData() { data = new ArrayList<>(); - data.add(builder(ShareBuilder.APP_FACEBOOK)); - data.add(builder(ShareBuilder.APP_LINE)); - data.add(builder(ShareBuilder.APP_TWITTER)); - data.add(builder(ShareBuilder.APP_WHATSAPP)); - data.add(builder(ShareBuilder.APP_MESSENGER)); + data.add(builder(ShareBean.APP_FACEBOOK)); + data.add(builder(ShareBean.APP_LINE)); + data.add(builder(ShareBean.APP_TWITTER)); + data.add(builder(ShareBean.APP_WHATSAPP)); + data.add(builder(ShareBean.APP_MESSENGER)); // data.add(builder(ShareBuilder.APP_INSTAGRAM)); adapter.setList(data); } - private ShareBuilder builder(int type) { - ShareBuilder builder = ShareBuilder.builder(type); + private ShareBean builder(int type) { + ShareBean builder = ShareBean.builder(type); builder.setText(getContext().getString(R.string.dialog_invite_info)); builder.setLink(url); builder.setUid(uid); diff --git a/Share/src/main/java/com/yunbao/share/ui/SharePopDialog.java b/Share/src/main/java/com/yunbao/share/ui/SharePopDialog.java index 66832548b..81fd55240 100644 --- a/Share/src/main/java/com/yunbao/share/ui/SharePopDialog.java +++ b/Share/src/main/java/com/yunbao/share/ui/SharePopDialog.java @@ -12,58 +12,48 @@ import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.lxj.xpopup.XPopup; -import com.lxj.xpopup.util.XPopupUtils; import com.makeramen.roundedimageview.RoundedImageView; import com.pdlive.shayu.R; +import com.yunbao.common.dialog.AbsDialogCenterPopupWindow; import com.yunbao.common.dialog.AbsDialogPopupWindow; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.share.adapters.ShareAppAdapter; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; import java.util.ArrayList; import java.util.List; public class SharePopDialog extends AbsDialogPopupWindow { + public static final int TYPE_LIVE = 1; + public static final int TYPE_DYNAMIC = 0; private ShareAppAdapter adapter; private RecyclerView list; private RoundedImageView avatar; private TextView info; private TextView link; - private List data; + private List data; - private String uid; - private String anchorId; - private String anchorName; - private String anchorAvatar; private String shareLink; + private int type; + private ShareBean bean; public SharePopDialog(@NonNull Context context) { super(context); } - public SharePopDialog setUid(String uid) { - this.uid = uid; + + public SharePopDialog setShareType(int type) { + this.type = type; return this; } - public SharePopDialog setAnchorId(String anchorId) { - this.anchorId = anchorId; + public SharePopDialog setShareData(ShareBean build) { + this.bean=build; return this; } - - public SharePopDialog setAnchorName(String anchorName) { - this.anchorName = anchorName; - return this; - } - - public SharePopDialog setAnchorAvatar(String anchorAvatar) { - this.anchorAvatar = anchorAvatar; - return this; - } - public SharePopDialog setShareLink(String link) { this.shareLink = link + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0); return this; @@ -89,7 +79,7 @@ public class SharePopDialog extends AbsDialogPopupWindow { info = findViewById(R.id.share_info); link = findViewById(R.id.share_link); adapter = new ShareAppAdapter(getContext()); - adapter.setOnShareStatusListener(new ShareAppAdapter.ShareCallback(){ + adapter.setOnShareStatusListener(new ShareAppAdapter.ShareCallback() { @Override public void onSuccess() { super.onSuccess(); @@ -103,16 +93,16 @@ public class SharePopDialog extends AbsDialogPopupWindow { private void initData() { data = new ArrayList<>(); - data.add(builder(ShareBuilder.APP_FACEBOOK)); - data.add(builder(ShareBuilder.APP_LINE)); - data.add(builder(ShareBuilder.APP_TWITTER)); - data.add(builder(ShareBuilder.APP_WHATSAPP)); - data.add(builder(ShareBuilder.APP_MESSENGER)); - data.add(builder(ShareBuilder.APP_INTERNAL)); + data.add(builder(ShareBean.APP_FACEBOOK)); + data.add(builder(ShareBean.APP_LINE)); + data.add(builder(ShareBean.APP_TWITTER)); + data.add(builder(ShareBean.APP_WHATSAPP)); + data.add(builder(ShareBean.APP_MESSENGER)); + data.add(builder(ShareBean.APP_INTERNAL)); adapter.setList(data); String url; if (shareLink == null) { - url = ShareBuilder.createLiveShareLink(uid, anchorId, anchorName, anchorAvatar).substring(0, 40) + "..."; + url = ShareBean.createLiveShareLink(bean.getUid(), bean.getAnchorId(), bean.getAnchorName(), bean.getAnchorAvatar()).substring(0, 40) + "..."; } else { if (shareLink.length() > 40) { url = shareLink.substring(0, 40) + "..."; @@ -122,20 +112,14 @@ public class SharePopDialog extends AbsDialogPopupWindow { } url = url + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0); link.setText(url); - info.setText(String.format(getContext().getString(R.string.dialog_share_info), StringUtil.isEmpty(anchorName) ? "" : anchorName)); - ImgLoader.display(getContext(), anchorAvatar, avatar); + info.setText(String.format(getContext().getString(R.string.dialog_share_info), StringUtil.isEmpty(bean.getAnchorName()) ? "" : bean.getAnchorName())); + ImgLoader.display(getContext(), bean.getAnchorAvatar(), avatar); } - private ShareBuilder builder(int type) { - ShareBuilder builder = ShareBuilder.builder(type); - builder.setText(String.format(getContext().getString(R.string.dialog_share_info), StringUtil.isEmpty(anchorName) ? "" : anchorName)); - builder.setUid(uid); - builder.setAnchorId(anchorId); - builder.setAnchorName(anchorName); - builder.setAnchorAvatar(anchorAvatar); - if (shareLink != null) { - builder.setLink(shareLink); - } + private ShareBean builder(int type) { + ShareBean builder = bean.clone(); + builder.setType(type); + builder.setText(String.format(getContext().getString(R.string.dialog_share_info), StringUtil.isEmpty(bean.getAnchorName()) ? "" : bean.getAnchorName())); return builder; } @@ -144,11 +128,12 @@ public class SharePopDialog extends AbsDialogPopupWindow { if (shareLink != null) { url = shareLink; } else { - url = ShareBuilder.createLiveShareLink(uid, anchorId, anchorName, anchorAvatar); + url = ShareBean.createLiveShareLink(bean.getUid(), bean.getAnchorId(), bean.getAnchorName(), bean.getAnchorAvatar()); } ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE); ClipData clipData = ClipData.newPlainText("text", info.getText().toString() + "\n" + url + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0)); cm.setPrimaryClip(clipData); ToastUtil.show(getContext().getString(com.yunbao.common.R.string.copy_success)); } + } diff --git a/Share/src/main/java/com/yunbao/share/ui/ShareSuccessNotifyDialog.java b/Share/src/main/java/com/yunbao/share/ui/ShareSuccessNotifyDialog.java index bb9c2c030..391286b17 100644 --- a/Share/src/main/java/com/yunbao/share/ui/ShareSuccessNotifyDialog.java +++ b/Share/src/main/java/com/yunbao/share/ui/ShareSuccessNotifyDialog.java @@ -11,19 +11,16 @@ import androidx.annotation.NonNull; import com.lxj.xpopup.XPopup; import com.lxj.xpopup.enums.PopupAnimation; import com.pdlive.shayu.R; -import com.yunbao.common.bean.MessageUserInfoBean; import com.yunbao.common.custom.RatioRoundImageView; import com.yunbao.common.dialog.AbsDialogPositionPopupWindow; -import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.utils.DpUtil; -import com.yunbao.common.utils.StringUtil; -import com.yunbao.share.bean.ShareBuilder; +import com.yunbao.share.bean.ShareBean; import io.rong.imkit.utils.RouteUtils; import io.rong.imlib.model.Conversation; public class ShareSuccessNotifyDialog extends AbsDialogPositionPopupWindow { - private ShareBuilder bean; + private ShareBean bean; private DialogInterface.OnDismissListener onDismissListener; private TextView anchorName; @@ -34,7 +31,7 @@ public class ShareSuccessNotifyDialog extends AbsDialogPositionPopupWindow { super(context); } - public ShareSuccessNotifyDialog(@NonNull Context context, ShareBuilder bean) { + public ShareSuccessNotifyDialog(@NonNull Context context, ShareBean bean) { super(context); this.bean = bean; } diff --git a/Share/src/main/res/values-en/strings.xml b/Share/src/main/res/values-en/strings.xml index a45ce7e82..bb68d289c 100644 --- a/Share/src/main/res/values-en/strings.xml +++ b/Share/src/main/res/values-en/strings.xml @@ -12,4 +12,5 @@ Share Success Chat + Please select friends \ No newline at end of file diff --git a/Share/src/main/res/values/strings.xml b/Share/src/main/res/values/strings.xml index 4c2e01402..9cc433273 100644 --- a/Share/src/main/res/values/strings.xml +++ b/Share/src/main/res/values/strings.xml @@ -21,4 +21,5 @@ 發送 分享成功 去聊聊 + 请选择好友 \ No newline at end of file diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index 2685dcde5..bed092f91 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -44,7 +44,9 @@ import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider; import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.manager.imrongcloud.RecommendLiveRoom; import com.yunbao.common.manager.imrongcloud.RongcloudIMManager; +import com.yunbao.common.message.content.MessageChatCardContent; import com.yunbao.common.message.content.MessageChatTipsContent; +import com.yunbao.common.provider.MessageChatCardItemProvider; import com.yunbao.common.provider.MessageChatTipsItemProvider; import com.yunbao.common.utils.AppManager; import com.yunbao.common.utils.Bus; @@ -60,6 +62,7 @@ import com.yunbao.live.socket.SocketRyClient; import com.yunbao.live.utils.LiveImDeletUtil; import com.yunbao.live.views.PortraitLiveManager; import com.yunbao.live.views.RecommendLiveRoomProvider; +import com.yunbao.main.activity.CompleteUserInfoActivity; import com.yunbao.main.activity.MainActivity; import com.yunbao.main.activity.MainHomeCommunityActivity; import com.yunbao.main.activity.MsgSettActivity; @@ -108,17 +111,21 @@ public class AppContext extends CommonAppContext { MessageSayHiNotifyManager.getInstance().stop(); return; } - if(activity instanceof MainHomeCommunityActivity){ + if (activity instanceof MainHomeCommunityActivity) { MessageSayHiNotifyManager.getInstance().stop(); return; } - if(activity instanceof SudGameActivity){ + if (activity instanceof SudGameActivity) { MessageSayHiNotifyManager.getInstance().stop(); return; } if (activity instanceof MainActivity && !MessageSayHiNotifyManager.getInstance().isInit()) { return; } + if (activity instanceof CompleteUserInfoActivity) { + MessageSayHiNotifyManager.getInstance().stop(); + return; + } MessageSayHiNotifyManager.getInstance().reload(); } @@ -220,12 +227,14 @@ public class AppContext extends CommonAppContext { myMessages.add(RecommendLiveRoom.class); myMessages.add(InstructorSendReward.class); myMessages.add(MessageChatTipsContent.class); + myMessages.add(MessageChatCardContent.class); RongIMClient.registerMessageType(myMessages); // 注册自定义消息模板 RongConfigCenter.conversationConfig().addMessageProvider(new InstructorSendRewardProvider(getApplicationContext())); RongConfigCenter.conversationConfig().addMessageProvider(new RecommendLiveRoomProvider(getApplicationContext())); RongConfigCenter.conversationConfig().addMessageProvider(new MessageChatTipsItemProvider(getApplicationContext())); + RongConfigCenter.conversationConfig().addMessageProvider(new MessageChatCardItemProvider(getApplicationContext())); RongcloudIMManager.addRongcloudIMOnReceiveMessageListener(new RongIMClient.OnReceiveMessageWrapperListener() { @Override @@ -260,6 +269,10 @@ public class AppContext extends CommonAppContext { } else if (message.getConversationType() == Conversation.ConversationType.PRIVATE) {//私聊信息 EventBus.getDefault().post(message); + if (AppManager.getInstance().getLastActivity() instanceof CompleteUserInfoActivity) { + return false; + } + MessageChatNotifyManager.getInstance().setShieldClass(CompleteUserInfoActivity.class); MessageChatNotifyManager.getInstance().push(AppManager.getInstance().getLastActivity() , message.getTargetId(), content.getContent() @@ -358,9 +371,9 @@ public class AppContext extends CommonAppContext { activity.get().finish(); } } + setFirebaseCrashData(); Process.killProcess(Process.myPid()); System.exit(0); - setFirebaseCrashData(); new Handler(Looper.getMainLooper()).postDelayed(() -> { throw new RuntimeException(e); }, 100); diff --git a/common/src/main/java/com/yunbao/common/bean/CareerBean.java b/common/src/main/java/com/yunbao/common/bean/CareerBean.java new file mode 100644 index 000000000..405785447 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/CareerBean.java @@ -0,0 +1,76 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class CareerBean extends BaseModel { + int id; + int pid; + @SerializedName("cn_title") + String titleCn; + @SerializedName("en_title") + String titleEn; + @SerializedName("create_time") + long createTime; + @SerializedName("uplong_time") + long uplongTime; + @SerializedName("children") + List children; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getPid() { + return pid; + } + + public void setPid(int pid) { + this.pid = pid; + } + + public String getTitleCn() { + return titleCn; + } + + public void setTitleCn(String titleCn) { + this.titleCn = titleCn; + } + + public String getTitleEn() { + return titleEn; + } + + public void setTitleEn(String titleEn) { + this.titleEn = titleEn; + } + + public long getCreateTime() { + return createTime; + } + + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + public long getUplongTime() { + return uplongTime; + } + + public void setUplongTime(long uplongTime) { + this.uplongTime = uplongTime; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/FirstLoginBean.java b/common/src/main/java/com/yunbao/common/bean/FirstLoginBean.java new file mode 100644 index 000000000..cb70f4911 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/FirstLoginBean.java @@ -0,0 +1,16 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +public class FirstLoginBean extends BaseModel{ + @SerializedName("status") + int status;//0是第一次登陸,1是已經登錄過的 + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/MessageUserInfoBean.java b/common/src/main/java/com/yunbao/common/bean/MessageUserInfoBean.java index d85da7fda..760011933 100644 --- a/common/src/main/java/com/yunbao/common/bean/MessageUserInfoBean.java +++ b/common/src/main/java/com/yunbao/common/bean/MessageUserInfoBean.java @@ -8,7 +8,7 @@ import java.util.List; public class MessageUserInfoBean extends BaseModel{ IMLoginModel user; UserInfo info; - UserLevel level; + //UserLevel level; @SerializedName("gift_num") int giftNum; @SerializedName("msg") @@ -60,13 +60,13 @@ public class MessageUserInfoBean extends BaseModel{ this.info = info; } - public UserLevel getLevel() { + /*public UserLevel getLevel() { return level; } public void setLevel(UserLevel level) { this.level = level; - } + }*/ public int getGiftNum() { return giftNum; @@ -107,6 +107,20 @@ public class MessageUserInfoBean extends BaseModel{ private String age; @SerializedName("open_off") private int openOff;//接单设置 1开启 2关闭 + @SerializedName("rong_online") + private int rongOnline; + + public void setOpenOff(int openOff) { + this.openOff = openOff; + } + + public int getRongOnline() { + return rongOnline; + } + + public void setRongOnline(int rongOnline) { + this.rongOnline = rongOnline; + } public int getOpenOff() { return openOff; diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index b9e53bc9c..61c5339bf 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -11,6 +11,7 @@ import com.yunbao.common.bean.BattlePassPoints; import com.yunbao.common.bean.BattlePassTask; import com.yunbao.common.bean.BattlePassUserInfoBean; import com.yunbao.common.bean.BlindBoxInfoModel; +import com.yunbao.common.bean.CareerBean; import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.ContributeModel; @@ -23,6 +24,7 @@ import com.yunbao.common.bean.FaceBookUpModel; import com.yunbao.common.bean.FansCheckRed; import com.yunbao.common.bean.FansGroupGiftPack; import com.yunbao.common.bean.FansGroupGiftPackInfo; +import com.yunbao.common.bean.FirstLoginBean; import com.yunbao.common.bean.GiftAlreadyWallModel; import com.yunbao.common.bean.GiftGuideModel; import com.yunbao.common.bean.GiftNamingInfoModel; @@ -1196,7 +1198,6 @@ public interface PDLiveApi { @GET("/api/public/?service=Userhome.getUserHomeBanner") Observable>> getUserHomeBanner(@Query("select_uid") String tuid); - @GET("/api/public/?service=Pdlinfos.getIsAnchor") Observable> getIsAnchor(); @@ -1273,4 +1274,27 @@ public interface PDLiveApi { @GET("/api/public/?service=Pdlcommunity.getDynamicInfo") Observable> getDynamicInfo(@Query("dynamic_id") String dynamic_id); + @GET("/api/public/?service=Pdlinfos.getCareer") + Observable>> getCareer(); + + @GET("/api/public/?service=Pdlinfos.setCareer") + Observable>> setCareer( + @Query("career") String career, + @Query("en_career") String en + ); + + @GET("/api/public/?service=Pdlinfos.setHeight") + Observable>> setUserHeight( + @Query("height") String height + ); + + @GET("/api/public/?service=Pdllable.get") + Observable>> getHobby(); + @GET("/api/public/?service=Pdlinfos.setLabel") + Observable>> setHobby( + @Query("labels") String labelsId + ); + @GET("/api/public/?service=Pdlinfos.getIsSet") + Observable> isFirstLogin( + ); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 183fb71f8..ea8f6d1f4 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -16,6 +16,7 @@ import com.yunbao.common.bean.BattlePassPoints; import com.yunbao.common.bean.BattlePassTask; import com.yunbao.common.bean.BattlePassUserInfoBean; import com.yunbao.common.bean.BlindBoxInfoModel; +import com.yunbao.common.bean.CareerBean; import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.CoolConfig; @@ -26,6 +27,7 @@ import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.bean.FansCheckRed; import com.yunbao.common.bean.FansGroupGiftPack; import com.yunbao.common.bean.FansGroupGiftPackInfo; +import com.yunbao.common.bean.FirstLoginBean; import com.yunbao.common.bean.GiftAlreadyWallModel; import com.yunbao.common.bean.GiftGuideModel; import com.yunbao.common.bean.GiftNamingInfoModel; @@ -3406,6 +3408,120 @@ public class LiveNetManager { }).isDisposed(); } + public void getCareer(HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getCareer() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(roomMicStatusModelResponseModel -> { + if (callback != null) { + callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo()); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + public void setCareer(String career,String careerEn, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .setCareer(career,careerEn) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(listResponseModel -> { + if (callback != null) { + callback.onSuccess(new HttpCallbackModel(listResponseModel.getData().getCode(), listResponseModel.getData().getMsg())); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + public void setUserHeight(String height, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .setUserHeight(height) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(listResponseModel -> { + if (callback != null) { + callback.onSuccess(new HttpCallbackModel(listResponseModel.getData().getCode(), listResponseModel.getData().getMsg())); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + public void getHobby(HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getHobby() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(roomMicStatusModelResponseModel -> { + if (callback != null) { + callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo()); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + public void setHobby(String ids, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .setHobby(ids) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(listResponseModel -> { + if (callback != null) { + callback.onSuccess(new HttpCallbackModel(listResponseModel.getData().getCode(), listResponseModel.getData().getMsg())); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + public void isFirstLogin(HttpCallback callback) { + API.get().pdLiveApi(mContext) + .isFirstLogin() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(roomMicStatusModelResponseModel -> { + if (callback != null) { + callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo()); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } private MultipartBody.Part createUploadFile(File file) { RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); return MultipartBody.Part.createFormData("file", file.getName(), requestBody); diff --git a/common/src/main/java/com/yunbao/common/message/content/MessageChatCardContent.java b/common/src/main/java/com/yunbao/common/message/content/MessageChatCardContent.java index 138313281..1137d1d3d 100644 --- a/common/src/main/java/com/yunbao/common/message/content/MessageChatCardContent.java +++ b/common/src/main/java/com/yunbao/common/message/content/MessageChatCardContent.java @@ -6,6 +6,7 @@ import android.os.Parcelable; import androidx.annotation.NonNull; import com.yunbao.common.interfaces.OnSendMessageListener; +import com.yunbao.common.utils.ToastUtil; import org.json.JSONException; import org.json.JSONObject; @@ -14,6 +15,7 @@ import java.io.UnsupportedEncodingException; import io.rong.common.ParcelUtils; import io.rong.imkit.IMCenter; +import io.rong.imlib.IRongCallback; import io.rong.imlib.MessageTag; import io.rong.imlib.RongIMClient; import io.rong.imlib.model.Conversation; @@ -31,20 +33,29 @@ public class MessageChatCardContent extends MessageContent implements Parcelable private String extraData; public static void sendMessage(Conversation.ConversationType type, String targetId, MessageChatCardContent tipsContent, OnSendMessageListener listener) { - IMCenter.getInstance().insertOutgoingMessage(type, targetId, Message.SentStatus.SENT, tipsContent, System.currentTimeMillis(), new RongIMClient.ResultCallback() { + ToastUtil.show("发送给:"+targetId); + Message message=Message.obtain(targetId, type,tipsContent); + IMCenter.getInstance().sendMessage(message,null,null,new IRongCallback.ISendMessageCallback(){ + + @Override + public void onAttached(Message message) { + + } + @Override public void onSuccess(Message message) { + ToastUtil.show("发送成功"); if (listener != null) { listener.onSuccess(null, null); } } @Override - public void onError(RongIMClient.ErrorCode e) { + public void onError(Message message, RongIMClient.ErrorCode e) { + ToastUtil.show("发送失败:"+e.getMessage()); if (listener != null) { listener.onError(e.code, e.msg); } - } }); } diff --git a/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java b/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java index ea8cc52ca..83abc14de 100644 --- a/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java +++ b/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java @@ -4,9 +4,19 @@ import android.content.Context; import android.text.Spannable; import android.view.ViewGroup; +import com.alibaba.fastjson.JSON; import com.yunbao.common.R; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.message.content.MessageChatCardContent; -import com.yunbao.common.message.content.MessageChatTipsContent; +import com.yunbao.common.utils.LiveRoomCheckLivePresenter; +import com.yunbao.common.utils.MicStatusManager; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.StringUtil; + +import org.greenrobot.eventbus.EventBus; import java.util.List; @@ -21,34 +31,74 @@ public class MessageChatCardItemProvider extends BaseMessageItemProvider list, IViewProviderListener listener) { - holder.setText(R.id.tips, content.getAvatar()); + holder.setText(R.id.user_name, content.getUserName()); + holder.setText(R.id.titleView, content.getTitle()); + ImgLoader.display(mContext, content.getAvatar(), holder.getView(R.id.avatar)); + if (!StringUtil.isEmpty()) { + ImgLoader.display(mContext, content.getCover(), holder.getView(R.id.cover)); + } } @Override - protected boolean onItemClick(ViewHolder holder, MessageChatCardContent messageChatTipsContent, UiMessage uiMessage, int position, List list, IViewProviderListener listener) { + protected boolean onItemClick(ViewHolder holder, MessageChatCardContent content, UiMessage uiMessage, int position, List list, IViewProviderListener listener) { + if ("1".equals(content.getType())) { + gotoLive(content.getExtraData()); + } return false; } @Override protected boolean isMessageViewType(MessageContent messageContent) { - return messageContent instanceof MessageChatTipsContent; + return messageContent instanceof MessageChatCardContent; } @Override public Spannable getSummarySpannable(Context context, MessageChatCardContent content) { return null; } + + private void gotoLive(final String live_id) { + LiveHttpUtil.getLiveInfo(live_id + "", new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); + new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { + @Override + public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { + if (liveBean == null) { + return; + } + if (MicStatusManager.getInstance().isMic(liveUid)) { + MicStatusManager.getInstance().showDownMicDialog(mContext); + return; + } + RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk)); + } + + @Override + public void onCheckError(String contextError) { + + } + }); + } else { + RouteUtil.forwardUserHome(mContext, String.valueOf(live_id), 0); + } + } + + }); + } } diff --git a/common/src/main/java/com/yunbao/common/utils/MessageChatNotifyManager.java b/common/src/main/java/com/yunbao/common/utils/MessageChatNotifyManager.java index 797aac2f5..733feea7e 100644 --- a/common/src/main/java/com/yunbao/common/utils/MessageChatNotifyManager.java +++ b/common/src/main/java/com/yunbao/common/utils/MessageChatNotifyManager.java @@ -13,6 +13,7 @@ import java.util.List; public class MessageChatNotifyManager { private static MessageChatNotifyManager instance; private List startListNotifyList = new ArrayList<>(); + Class clazz; public static MessageChatNotifyManager getInstance() { if (instance == null) { @@ -21,6 +22,10 @@ public class MessageChatNotifyManager { return instance; } + public void setShieldClass(Class clazz) { + this.clazz = clazz; + } + public void push(Context mContext, MessageUserInfoBean userInfo) { if (startListNotifyList.isEmpty()) { startListNotifyList.add(userInfo); @@ -31,6 +36,10 @@ public class MessageChatNotifyManager { } private void notifyLiveFlot(Context mContext) { + if (AppManager.getInstance().getLastActivity().getClass().getSimpleName().equals(clazz.getSimpleName())) { + ToastUtil.showDebug("屏蔽类,不展示"); + return; + } if (startListNotifyList.iterator().hasNext()) { MessageUserInfoBean bean = startListNotifyList.iterator().next(); new MessageChatNotifyDialog(AppManager.getInstance().getLastActivity(), bean).setOnDismissListener(dialog -> { diff --git a/common/src/main/res/layout/view_message_chat_card.xml b/common/src/main/res/layout/view_message_chat_card.xml new file mode 100644 index 000000000..d9373d3df --- /dev/null +++ b/common/src/main/res/layout/view_message_chat_card.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_title_not_color.xml b/common/src/main/res/layout/view_title_not_color.xml new file mode 100644 index 000000000..82f5bf9a9 --- /dev/null +++ b/common/src/main/res/layout/view_title_not_color.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + diff --git a/common/src/main/res/mipmap-xxhdpi/ic_chat_black.png b/common/src/main/res/mipmap-xxhdpi/ic_chat_black.png new file mode 100644 index 000000000..21180bbbf Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/ic_chat_black.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/ic_chat_remarks.png b/common/src/main/res/mipmap-xxhdpi/ic_chat_remarks.png new file mode 100644 index 000000000..37508c5d3 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/ic_chat_remarks.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/ic_chat_report.png b/common/src/main/res/mipmap-xxhdpi/ic_chat_report.png new file mode 100644 index 000000000..6569f87c4 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/ic_chat_report.png differ diff --git a/common/src/main/res/values-en-rUS/string.xml b/common/src/main/res/values-en-rUS/string.xml index f5606a71a..cb4cb260c 100644 --- a/common/src/main/res/values-en-rUS/string.xml +++ b/common/src/main/res/values-en-rUS/string.xml @@ -26,6 +26,7 @@ Pull black Relieving blackout Remarks + Report Sign in immediately Continuously signed in day diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml index 83071f619..b22937da0 100644 --- a/common/src/main/res/values-zh-rHK/strings.xml +++ b/common/src/main/res/values-zh-rHK/strings.xml @@ -16,7 +16,8 @@ 沒有更多數據了 拉黑 解除拉黑 - 備註 + 修改備註 + 舉報 立即簽到 已連續簽到 diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index 0b3c17129..813230c49 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -16,7 +16,8 @@ 沒有更多數據了 拉黑 解除拉黑 - 備註 + 修改備註 + 舉報 立即簽到 已連續簽到 diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index 5e6be0fa4..fe1e5b20f 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -16,7 +16,8 @@ 沒有更多數據了 拉黑 解除拉黑 - 備註 + 修改備註 + 舉報 立即簽到 已連續簽到 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 571e9d67c..7a8983b7e 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -26,6 +26,7 @@ Pull black Relieving blackout Remarks + Report Sign in immediately Continuously signed in day diff --git a/common/src/main/res/values/style.xml b/common/src/main/res/values/style.xml index c444de78d..0511f2543 100644 --- a/common/src/main/res/values/style.xml +++ b/common/src/main/res/values/style.xml @@ -98,6 +98,13 @@ 15dp @color/white +