From c7126e98365db4e446078e390323a22a2be0a261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=8E=89=E4=B9=85?= <1484288157@qq.com> Date: Wed, 24 Jun 2020 15:33:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E4=B8=80=E4=BA=9B=E5=86=85?= =?UTF-8?q?=E5=AD=98=E6=B3=84=E6=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gh/common/util/ShareUtils.java | 42 +++++++++---------- .../gamecenter/qa/follow/AskFollowFragment.kt | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) 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 34af0bf9fe..0ed5804265 100644 --- a/app/src/main/java/com/gh/common/util/ShareUtils.java +++ b/app/src/main/java/com/gh/common/util/ShareUtils.java @@ -97,7 +97,7 @@ public class ShareUtils { private String[] arrLabel = {"微信好友", "朋友圈", "QQ好友", "QQ空间", "新浪微博", "短信", "复制链接", "取消"}; - private PopupWindow popupWindow; + private WeakReference popupWindow; private ShareType mShareType; public static ShareType shareType;//全局保存shareType,分享成功后判断分享的类型 @@ -125,10 +125,10 @@ public class ShareUtils { }; private ShareUtils(Context context) { - mTencent = Tencent.createInstance(Config.TENCENT_APPID, context); //初始化QQ分享 - mIWXAPI = WXAPIFactory.createWXAPI(context, Config.WECHAT_APPID); //初始化微信分享 - WbSdk.install(context, new AuthInfo(context, Config.WEIBO_APPKEY, "http://www.sina.com", WEIBO_SCOPE)); mContext = context.getApplicationContext(); + mTencent = Tencent.createInstance(Config.TENCENT_APPID, mContext); //初始化QQ分享 + mIWXAPI = WXAPIFactory.createWXAPI(mContext, Config.WECHAT_APPID); //初始化微信分享 + WbSdk.install(mContext, new AuthInfo(mContext, Config.WEIBO_APPKEY, "http://www.sina.com", WEIBO_SCOPE)); } public static ShareUtils getInstance(Context context) { @@ -163,7 +163,7 @@ public class ShareUtils { this.mShareType = shareType; ShareUtils.shareType = mShareType; - View contentView = View.inflate(activity, R.layout.share_popup_layout, null); + View contentView = View.inflate(mActivity.get(), R.layout.share_popup_layout, null); contentView.setFocusable(true); contentView.setFocusableInTouchMode(true); RecyclerView shareRecyclerView = contentView.findViewById(R.id.share_rv); @@ -206,33 +206,33 @@ public class ShareUtils { arrLogo[7] = R.drawable.share_cancel_logo; } - popupWindow = new SharePopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT - , LinearLayout.LayoutParams.MATCH_PARENT, true); - popupWindow.setAnimationStyle(R.style.popwindow_exit_only_anim_style); + popupWindow = new WeakReference<>(new SharePopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT + , LinearLayout.LayoutParams.MATCH_PARENT, true)); + popupWindow.get().setAnimationStyle(R.style.popwindow_exit_only_anim_style); //解决PopupWindow无法覆盖状态栏 - popupWindow.setClippingEnabled(false); + popupWindow.get().setClippingEnabled(false); int bottomLocation = -DisplayUtils.retrieveNavigationHeight(activity); if (!DisplayUtils.isNavigationBarShow(activity)) { bottomLocation = 0; } try { - popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, 0, bottomLocation); + popupWindow.get().showAtLocation(view, Gravity.NO_GRAVITY, 0, bottomLocation); } catch (Exception e) { e.printStackTrace(); } - contentView.setOnClickListener(v -> popupWindow.dismiss()); + contentView.setOnClickListener(v -> popupWindow.get().dismiss()); contentView.setOnKeyListener((v, keyCode, event) -> { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && popupWindow != null - && popupWindow.isShowing()) { + && popupWindow.get().isShowing()) { if (callBack != null) { callBack.onCancel(); } - popupWindow.dismiss(); + popupWindow.get().dismiss(); } return false; }); @@ -272,7 +272,7 @@ public class ShareUtils { } if (mShareType != ShareType.shareGh) { - popupWindow.dismiss(); + popupWindow.get().dismiss(); } } @@ -311,7 +311,7 @@ public class ShareUtils { loadBitMap(shareIcon, msg, req); if (mShareType != ShareType.shareGh) { - popupWindow.dismiss(); + popupWindow.get().dismiss(); } } @@ -426,7 +426,7 @@ public class ShareUtils { } if (mShareType != ShareType.shareGh) { - popupWindow.dismiss(); + popupWindow.get().dismiss(); } } @@ -470,7 +470,7 @@ public class ShareUtils { loadBitMap(shareIcon, msg, req); if (mShareType != ShareType.shareGh) { - popupWindow.dismiss(); + popupWindow.get().dismiss(); } } @@ -491,7 +491,7 @@ public class ShareUtils { if (mShareType != ShareType.shareGh) { - popupWindow.dismiss(); + popupWindow.get().dismiss(); } } @@ -532,7 +532,7 @@ public class ShareUtils { } if (mShareType != ShareType.shareGh) { - popupWindow.dismiss(); + popupWindow.get().dismiss(); } } @@ -542,7 +542,7 @@ public class ShareUtils { cmb.setText(copyContent); if (mShareType != ShareType.shareGh) { Utils.toast(mContext, "复制成功"); - popupWindow.dismiss(); + popupWindow.get().dismiss(); } else { Utils.toast(mContext, "复制成功,请到微信/QQ粘贴分享"); } @@ -618,7 +618,7 @@ public class ShareUtils { break; case 7: if (mShareType != ShareType.shareGh) { - popupWindow.dismiss(); + popupWindow.get().dismiss(); } else { copyLink("推荐光环助手,绿色安全的手游加速助手:" + shareUrl); } diff --git a/app/src/main/java/com/gh/gamecenter/qa/follow/AskFollowFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/follow/AskFollowFragment.kt index ba0b0e4a2d..8d2f51fa0f 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/follow/AskFollowFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/follow/AskFollowFragment.kt @@ -160,7 +160,7 @@ class AskFollowFragment : ListFragment