diff --git a/app/src/main/java/com/gh/common/util/ShareUtils.java b/app/src/main/java/com/gh/common/util/ShareUtils.java index efc2f80624..90ed29f5dd 100644 --- a/app/src/main/java/com/gh/common/util/ShareUtils.java +++ b/app/src/main/java/com/gh/common/util/ShareUtils.java @@ -31,6 +31,7 @@ import com.facebook.imagepipeline.image.CloseableImage; import com.gh.common.constant.Config; import com.gh.gamecenter.R; import com.gh.gamecenter.WeiBoShareActivity; +import com.gh.gamecenter.eventbus.EBShare; import com.lightgame.utils.Utils; import com.sina.weibo.sdk.WbSdk; import com.sina.weibo.sdk.auth.AuthInfo; @@ -53,6 +54,8 @@ import java.util.List; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import org.greenrobot.eventbus.EventBus; + import static com.gh.common.util.LoginHelper.WEIBO_SCOPE; /** @@ -97,6 +100,7 @@ public class ShareUtils { private PopupWindow popupWindow; private ShareType mShareType; + public static ShareType shareType;//全局保存shareType,分享成功后判断分享的类型 private WeakReference mActivity; @@ -106,6 +110,7 @@ public class ShareUtils { @Override public void onComplete(Object o) { Utils.toast(mContext, R.string.share_success_hint); + EventBus.getDefault().post(new EBShare(ShareUtils.shareType)); } @Override @@ -156,6 +161,7 @@ public class ShareUtils { this.mSummary = shareSummary; this.mTitle = shareTitle; this.mShareType = shareType; + ShareUtils.shareType = mShareType; View contentView = View.inflate(activity, R.layout.share_popup_layout, null); contentView.setFocusable(true); @@ -181,7 +187,7 @@ public class ShareUtils { callBack.onCancel(); } else { if (!"复制链接".equals(arrLabel[position])) { - callBack.onSuccess(); + callBack.onSuccess(arrLabel[position]); } } } @@ -647,7 +653,7 @@ public class ShareUtils { } public interface ShareCallBack { - void onSuccess(); + void onSuccess(String label); void onCancel(); } diff --git a/app/src/main/java/com/gh/gamecenter/WeiBoShareActivity.java b/app/src/main/java/com/gh/gamecenter/WeiBoShareActivity.java index 3906332cbe..a940c02fc9 100644 --- a/app/src/main/java/com/gh/gamecenter/WeiBoShareActivity.java +++ b/app/src/main/java/com/gh/gamecenter/WeiBoShareActivity.java @@ -13,6 +13,7 @@ import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber; import com.facebook.imagepipeline.image.CloseableImage; import com.gh.common.util.ImageUtils; import com.gh.common.util.ShareUtils; +import com.gh.gamecenter.eventbus.EBShare; import com.lightgame.utils.Utils; import com.sina.weibo.sdk.api.ImageObject; import com.sina.weibo.sdk.api.TextObject; @@ -24,6 +25,8 @@ import com.sina.weibo.sdk.utils.Utility; import androidx.annotation.NonNull; +import org.greenrobot.eventbus.EventBus; + /** * Created by khy on 2016/11/23. *

@@ -149,6 +152,7 @@ public class WeiBoShareActivity extends Activity implements WbShareCallback { @Override public void onWbShareSuccess() { Utils.toast(this, R.string.share_success_hint); + EventBus.getDefault().post(new EBShare(ShareUtils.shareType)); finish(); } diff --git a/app/src/main/java/com/gh/gamecenter/eventbus/EBShare.java b/app/src/main/java/com/gh/gamecenter/eventbus/EBShare.java new file mode 100644 index 0000000000..de18ab986b --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/eventbus/EBShare.java @@ -0,0 +1,19 @@ +package com.gh.gamecenter.eventbus; + +import com.gh.common.util.ShareUtils; + +public class EBShare { + public ShareUtils.ShareType shareType; + + public EBShare(ShareUtils.ShareType shareType) { + this.shareType = shareType; + } + + public ShareUtils.ShareType getShareType() { + return shareType; + } + + public void setShareType(ShareUtils.ShareType shareType) { + this.shareType = shareType; + } +} diff --git a/app/src/main/java/com/gh/gamecenter/video/detail/DetailPlayerView.kt b/app/src/main/java/com/gh/gamecenter/video/detail/DetailPlayerView.kt index 045fd0e52c..99cfe1d3da 100644 --- a/app/src/main/java/com/gh/gamecenter/video/detail/DetailPlayerView.kt +++ b/app/src/main/java/com/gh/gamecenter/video/detail/DetailPlayerView.kt @@ -275,8 +275,8 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib it.title, shareSummary, ShareUtils.ShareType.video, object : ShareUtils.ShareCallBack { - override fun onSuccess() { - mViewModel?.shareVideoStatistics(mVideoEntity) + override fun onSuccess(label: String) { + if ("短信" == label) mViewModel?.shareVideoStatistics(mVideoEntity) } override fun onCancel() { diff --git a/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt b/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt index 1d08d21ce3..e7eda3232a 100644 --- a/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt @@ -15,6 +15,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.OrientationHelper import androidx.recyclerview.widget.RecyclerView import com.gh.base.fragment.BaseLazyFragment +import com.gh.common.AppExecutor import com.gh.common.constant.Constants import com.gh.common.exposure.ExposureListener import com.gh.common.util.* @@ -24,10 +25,7 @@ import com.gh.download.DownloadManager import com.gh.download.cache.ExoCacheManager import com.gh.gamecenter.R import com.gh.gamecenter.entity.VideoEntity -import com.gh.gamecenter.eventbus.EBDownloadStatus -import com.gh.gamecenter.eventbus.EBPackage -import com.gh.gamecenter.eventbus.EBReuse -import com.gh.gamecenter.eventbus.EBUserFollow +import com.gh.gamecenter.eventbus.* import com.gh.gamecenter.manager.UserManager import com.gh.gamecenter.qa.comment.CommentActivity import com.gh.gamecenter.qa.comment.NewCommentFragment @@ -600,8 +598,8 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener { it.title, shareSummary, ShareUtils.ShareType.video, object : ShareUtils.ShareCallBack { - override fun onSuccess() { - mViewModel.shareVideoStatistics(mViewModel.currentDisplayingVideo) + override fun onSuccess(label: String) { + if ("短信" == label)mViewModel.shareVideoStatistics(mViewModel.currentDisplayingVideo) } override fun onCancel() { @@ -675,9 +673,20 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener { @Subscribe(threadMode = ThreadMode.MAIN) fun onEventMainThread(follow: EBUserFollow?) { - if (follow != null && follow.userId != UserManager.getInstance().userId) { - findVisibleVideoViewByPosition()?.updateFollowStatus(follow.isFollow) - } + postDelayedRunnable({ + if (follow != null && follow.userId != UserManager.getInstance().userId && isSupportVisible) { + findVisibleVideoViewByPosition()?.updateFollowStatus(follow.isFollow) + } + }, 200) + } + + @Subscribe(threadMode = ThreadMode.MAIN) + fun onEventMainThread(share: EBShare?) { + postDelayedRunnable({ + if (share != null && share.shareType == ShareUtils.ShareType.video && isSupportVisible) { + mViewModel.shareVideoStatistics(mViewModel.currentDisplayingVideo) + } + }, 200) } override fun onHandleBackPressed(): Boolean { diff --git a/app/src/main/java/com/gh/gamecenter/wxapi/WXEntryActivity.java b/app/src/main/java/com/gh/gamecenter/wxapi/WXEntryActivity.java index 698024ebe5..c2d363ab5d 100644 --- a/app/src/main/java/com/gh/gamecenter/wxapi/WXEntryActivity.java +++ b/app/src/main/java/com/gh/gamecenter/wxapi/WXEntryActivity.java @@ -8,7 +8,9 @@ import android.widget.TextView; import com.gh.common.constant.Config; import com.gh.common.util.LoginHelper; +import com.gh.common.util.ShareUtils; import com.gh.gamecenter.R; +import com.gh.gamecenter.eventbus.EBShare; import com.lightgame.utils.Utils; import com.tencent.mm.opensdk.modelbase.BaseReq; import com.tencent.mm.opensdk.modelbase.BaseResp; @@ -17,6 +19,7 @@ import com.tencent.mm.opensdk.openapi.IWXAPI; import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler; import com.tencent.mm.opensdk.openapi.WXAPIFactory; +import org.greenrobot.eventbus.EventBus; import org.json.JSONObject; /** @@ -59,6 +62,7 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler, WeC if (RETURN_MSG_TYPE_SHARE == baseResp.getType()) { resultString = "分享成功"; Utils.toast(this, resultString); + EventBus.getDefault().post(new EBShare(ShareUtils.shareType)); } else { if (baseResp instanceof SendAuth.Resp) { SendAuth.Resp resp = (SendAuth.Resp) baseResp;