友盟第三方 登录与分享功能实现

xiaoxiao2021-02-28  12

友盟第三方登录与分享功能实现

——微信登录;微信朋友圈,微信好友,QQ好友分享

——程序媛:安鱼儿

 

步骤 、

1.引入友盟包: http://dev.umeng.com/social/android/quick-integration

 

 

 

 

 

2.app下的gridle中配置好属于您的签名。

 

3.申请小主项目的微信AppID和AppSectret,申请小主的友盟appkey,申请小主的腾讯QQ的QQ_KEY,QQ_APPKEY

1.微信:

微信开发平台链接:https://open.weixin.qq.com/

申请小主的项目AppID和AppSectret.

 

应用签名:md5,去掉冒号,大写全改成小写,去掉空格。

应用签名:清单文件的包名。

 

申请审核通过小主会得到微信的AppID和AppSectret.

 

 

 

2.友盟:http://mobile.umeng.com/social。

 

添加应用,获取友盟AppKey

 

 

 

 

 

 

 

 

 

 

3.腾讯QQhttp://open.qq.com/reg  

申请个人或者企业为开发者

 

获取到APP IDAPP KEY

 

 

4.清单文件配置

1.配置权限

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> 

2.添加友盟appkey

 

3.微信:

<activity android:name=".apshare.ShareEntryActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:exported="true" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent.NoTitleBar" />

QQ:

   <activity

            android:name="com.umeng.qq.tencent.AuthActivity"

            android:launchMode="singleTask"

            android:noHistory="true">

            <intent-filter>

                <action android:name="android.intent.action.VIEW"/>

                <category android:name="android.intent.category.DEFAULT"/>

                <category android:name="android.intent.category.BROWSABLE"/>

                <data android:scheme="tencent1105703772"/>

            </intent-filter>

        </activity>

        <activity

            android:name="com.umeng.qq.tencent.AssistActivity"

            android:configChanges="orientation|keyboardHidden|screenSize"

            android:screenOrientation="portrait"

            android:theme="@android:style/Theme.Translucent.NoTitleBar"/>

5.初始化友盟配置  微信,QQ平台配置示例

    public void initUMSharePlatform() {

        com.umeng.socialize.Config.isUmengSina = false;

        MobclickAgent.setDebugMode(Config.DEBUG);

        MobclickAgent.setCatchUncaughtExceptions(true);

        UMShareAPI.get(mContext);

        //微信 appid appsecret

        PlatformConfig.setWeixin(mContext.getString(R.string.WECHAT_APPID), mContext.getString(R.string.WECHAT_APPSECRECT));

// QQ和Qzone appid appkey

        PlatformConfig.setQQZone(mContext.getString(R.string.QQ_APPID), mContext.getString(R.string.QQ_KEY));

        Log.LOG = Config.DEBUG;

        com.umeng.socialize.Config.isJumptoAppStore = true;

}

 

 

6.友盟第三方登录

1.第三方登录广播监听 编写 登录管理类

public class UMThirdLoginManager {

    private Activity mActivity;

    private UMThirdLoginListener mUMThirdLoginListener;

    private UMShareAPI mShareAPI;

    public void setUMThirdLoginListener(UMThirdLoginListener umThirdLoginListener) {

        mUMThirdLoginListener = umThirdLoginListener;

    }

    public UMThirdLoginManager(Context context) {

        mActivity = (Activity) context;

        if (mShareAPI == null)

            mShareAPI = UMShareAPI.get(mActivity);

    }

    public void thirdLogin(SHARE_MEDIA platform) {

        mShareAPI.doOauthVerify(mActivity, platform, umAuthListener);

    }

    public void deleteOauth(SHARE_MEDIA platform) {

        mShareAPI.deleteOauth(mActivity, platform, new UMAuthListener() {

            @Override

            public void onStart(SHARE_MEDIA share_media) {

            }

            @Override

            public void onComplete(SHARE_MEDIA share_media, int i, Map<String, String> map) {

                if (mUMThirdLoginListener != null) {

                    mUMThirdLoginListener.deleteOauth(share_media, map);

                }

            }

 

            @Override

            public void onError(SHARE_MEDIA share_media, int i, Throwable throwable) {

            }

 

            @Override

            public void onCancel(SHARE_MEDIA share_media, int i) {

            }

        });

    }

 

    public boolean isInstall(SHARE_MEDIA platform) {

        return mShareAPI.isInstall(mActivity, platform);

    }

    private UMAuthListener umAuthListener = new UMAuthListener() {

        @Override

        public void onStart(SHARE_MEDIA share_media) {

        }

        @Override

        public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {

            if (mUMThirdLoginListener != null) {

                mUMThirdLoginListener.loginResult(platform, data);

            }

        }

        @Override

        public void onError(SHARE_MEDIA platform, int action, Throwable t) {

            if (mUMThirdLoginListener != null) {

                mUMThirdLoginListener.loginResult(platform, null);

            }

        }

 

        @Override

        public void onCancel(SHARE_MEDIA platform, int action) {

            if (mUMThirdLoginListener != null) {

                mUMThirdLoginListener.loginResult(platform, null);

            }

        }

    };

 

    public void onActivityResult(int requestCode, int resultCode, Intent data) {

        mShareAPI.onActivityResult(requestCode, resultCode, data);

    }

 

 

    public interface UMThirdLoginListener {

        void loginResult(SHARE_MEDIA platform, Map<String, String> data);

 

        void deleteOauth(SHARE_MEDIA platform, Map<String, String> data);

    }

 

}

 

2.登录LoginActivity

 

初始化友盟 微信第三方登录

private void initThirdView() {

        mUmThirdLoginManager = new UMThirdLoginManager(this);

        mUmThirdLoginManager.setUMThirdLoginListener(this);

        View layout_third_login_line = findViewById(R.id.layout_third_login_line);

        if (mUmThirdLoginManager.isInstall(SHARE_MEDIA.WEIXIN)) {

             mImgWecart.setOnClickListener(new View.OnClickListener() {

                @Override

                public void onClick(View v) {

                      if (mUmThirdLoginManager != null) {

                    mUmThirdLoginManager.thirdLogin(SHARE_MEDIA.WEIXIN);

                 }

                }

            });

        }

}

//登录成功后,进行绑定手机逻辑

    @Override

    public void loginResult(SHARE_MEDIA platform, Map<String, String> data) {

                if (data != null && !data.isEmpty()) {

showShortToast("小主,您微信第三方登录成功");

            Map<String, String> params = NetApi.getParams();

            mOpenid = data.get("openid");

            mAccessToken = data.get("access_token");

            if (SHARE_MEDIA.QQ == platform) {

                mPlatform = 3;

            } else if (SHARE_MEDIA.WEIXIN == platform) {

                mPlatform = 1;

//                String unionId = data.get("unionid");

//                params.put("unionId", unionId);

            } else if (SHARE_MEDIA.SINA == platform) {

                String uid = data.get("uid");

                if (TextUtils.isEmpty(mAccessToken)) {

                    mAccessToken = data.get("accessToken");

                }

                mOpenid = uid;

                mPlatform = 2;

            }

            params.put("token", mAccessToken);

            params.put("openid", mOpenid);

            params.put("type", String.valueOf(mPlatform));

            connectionWithProgress(ACTION_THIRD_LOGIN, NetApi.getPostNetTask(NetConstants.USER_THIRDLOGIN, params, LoginBean.class));

        }

    }

 

    @Override

    public void deleteOauth(SHARE_MEDIA platform, Map<String, String> data) {

 

    }

 

}

 

 

 

 

7.友盟第三方分享微信好友,微信朋友圈,QQ

1.分享管理类

public class UMShareManager implements SharePopupWindowView.ItemClickCallBack {

    private static final int REQUEST_SHARE_WRITE_CODE = 123;

    private static final int APP_SETTING_CODE = 1002;

    private Activity mActivity;

    private ShareCallback mCallback;

    private SharePopupWindowView mSharePopupWindowView;

    private ShareMessageInfo.ShareMessageData mShareMessageData;

    private View mCurrentPlatformView;

    private Fragment mFragment;

    private final String[] mPermissionList = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};

    private SHARE_MEDIA[] mHidePlatform;

    public UMShareManager(Context context) {

        mActivity = (Activity) context;

    }

    public void setFragment(Fragment fragment) {

        mFragment = fragment;

    }

 

    public void sharePlatform(SHARE_MEDIA platform, ShareMessageInfo.ShareMessageData shareMessageData) {

        ShareAction shareAction = new ShareAction(mActivity);

        checkMsgLength(platform, shareMessageData);

        UMWeb web = new UMWeb(shareMessageData.link);

        web.setTitle(TextUtils.isEmpty(shareMessageData.title) ? shareMessageData.message : shareMessageData.title);//标题

        web.setDescription(shareMessageData.message);//描述

        UMImage image = shareMessageData.resId == 0 ? new UMImage(mActivity, shareMessageData.image) :

                new UMImage(mActivity, shareMessageData.resId);

        if (platform != SHARE_MEDIA.SINA) {

            UMImage thumb = shareMessageData.resId == 0 ? new UMImage(mActivity, shareMessageData.image) :

                    new UMImage(mActivity, shareMessageData.resId);

            image.setThumb(thumb);

        }

        web.setThumb(image);

        shareAction.setPlatform(platform)

                .setCallback(umShareListener)

                .withMedia(web)

                .withExtra(image)

                .withText(shareMessageData.message)

                .share();

    }

 

    private void checkMsgLength(SHARE_MEDIA platform, ShareMessageInfo.ShareMessageData shareMessageData) {

        if (platform == SHARE_MEDIA.SINA) {

            if (!TextUtils.isEmpty(shareMessageData.link)) {

                int len = shareMessageData.link.length() / 2;

                int msgLen = shareMessageData.message.length();

                int totalLen = len + msgLen;

                if (totalLen > 140) {

                    int excrescentLen = totalLen - 140;

                    shareMessageData.message = shareMessageData.message.substring(0, msgLen - excrescentLen - 2) + "...";

                }

            }

        }

    }

 

    /**

     * 弹出分享界面

     */

    public void showSharePlatForm(ShareMessageInfo.ShareMessageData shareMessageData) {

        if (shareMessageData != null) {

            mShareMessageData = shareMessageData;

            if (mSharePopupWindowView == null) {

                mSharePopupWindowView = new SharePopupWindowView(mActivity, MyApplication.mScreenWidth, WindowManager.LayoutParams.WRAP_CONTENT, mShareMessageData.link);

                mSharePopupWindowView.setCallBack(UMShareManager.this);

                mSharePopupWindowView.setHidePlatform(mHidePlatform);

            }

            if (!mSharePopupWindowView.isShowing())

                mSharePopupWindowView.showAtLocation(mActivity.getWindow().getDecorView(), Gravity.BOTTOM, 0, 0);

        }

    }

    private UMShareListener umShareListener = new UMShareListener() {

        @Override

        public void onStart(SHARE_MEDIA share_media) {

        }

        @Override

        public void onResult(SHARE_MEDIA platform) {

            AppLog.e("lsj", "onResult==platform==" + platform.name());

            String platformText = "";

            switch (platform) {

                case SINA:

                    platformText = "新浪微博";

                    break;

                case QQ:

                    platformText = "QQ";

                    break;

                case WEIXIN:

                    platformText = "微信";

                    break;

                case WEIXIN_CIRCLE:

                    platformText = "微信朋友圈";

                    break;

            }

            Toast.makeText(mActivity, platformText + " 分享成功啦", Toast.LENGTH_SHORT)

                    .show();

            if (mCallback != null) {

                mCallback.onSuccess();

            }

        }

 

        @Override

        public void onError(SHARE_MEDIA platform, Throwable t) {

            AppLog.e("lsj", "onError==platform==" + platform.name() + ">>Throwable==" + toString());

            String platformText = "";

            switch (platform) {

                case SINA:

                    platformText = "新浪微博";

                    break;

                case QQ:

                    platformText = "QQ";

                    break;

                case WEIXIN:

                    platformText = "微信";

                    break;

                case WEIXIN_CIRCLE:

                    platformText = "微信朋友圈";

                    break;

            }

            if (mCallback != null) {

                mCallback.onError();

            }

        }

        @Override

        public void onCancel(SHARE_MEDIA platform) {

            AppLog.e("lsj", "onCancel==platform==" + platform.name());

            String platformText = "";

            switch (platform) {

                case SINA:

                    platformText = "新浪微博";

                    break;

                case QQ:

                    platformText = "QQ";

                    break;

                case WEIXIN:

                    platformText = "微信";

                    break;

                case WEIXIN_CIRCLE:

                    platformText = "微信朋友圈";

                    break;

            }

            if (mCallback != null) {

                mCallback.onCancel();

            }

        }

    };

 

    /**

     * 点击分享平台的按钮(QQ、微信、sina

     */

    @Override

    public void onItemClick(View v) {

        SHARE_MEDIA platform = null;

        switch (v.getId()) {

            case R.id.share_qq:

                if (Build.VERSION.SDK_INT >= 23 && ActivityCompat.checkSelfPermission(mActivity, mPermissionList[0]) != PackageManager.PERMISSION_GRANTED) {

                    if (ActivityCompat.shouldShowRequestPermissionRationale(mActivity, mPermissionList[0])) {

                        toSettingPermision("客官,QQ分享需要存储权限哟!请设置权限!");

                    } else {

                        if (mFragment != null) {

                            mFragment.requestPermissions(mPermissionList, REQUEST_SHARE_WRITE_CODE);

                        } else {

                            ActivityCompat.requestPermissions(mActivity, mPermissionList, REQUEST_SHARE_WRITE_CODE);

                        }

                    }

                    mCurrentPlatformView = v;

                    return;

                }

                platform = SHARE_MEDIA.QQ;

                break;

            case R.id.share_qzone:

                platform = SHARE_MEDIA.QZONE;

                break;

            case R.id.share_wechat_circle:

                platform = SHARE_MEDIA.WEIXIN_CIRCLE;

                break;

            case R.id.share_wechat_freind:

                platform = SHARE_MEDIA.WEIXIN;

                break;

            case R.id.share_sina:

                platform = SHARE_MEDIA.SINA;

                break;

        }

        UIUtil.addViewTouchScaleEffect(v);

        sharePlatform(platform, mShareMessageData);

    }

    private void toSettingPermision(String msg) {

        try {

            FashionSSFKDialog.showAlertDialog(mActivity, msg, mActivity.getString(R.string.setting), "暂不设置", new DialogInterface.OnClickListener() {

                @Override

                public void onClick(DialogInterface dialog, int which) {

                    if (mFragment != null) {

                        LinkUtils.startAppSettings(mFragment, APP_SETTING_CODE);

                    } else {

                        LinkUtils.startAppSettings(mActivity, APP_SETTING_CODE);

                    }

                }

            }, null);

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

 

    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {

        AppLog.e("lsj", "requestCode==" + requestCode + ">>>permissions==" + permissions.toString());

        switch (requestCode) {

            case REQUEST_SHARE_WRITE_CODE:

                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {

                    onItemClick(mCurrentPlatformView);

                } else {

                    toSettingPermision("客官,QQ分享需要存储权限哟!请设置权限!");

                }

                break;

        }

    }

    public interface ShareCallback {

        void onSuccess();

        void onError();

        void onCancel();

 

    }

    public void setCallback(ShareCallback callback) {

        this.mCallback = callback;

    }

}

2.分享出去的 实体类

 

public class ShareMessageInfo {

    public ShareMessageData data;

    public static class ShareMessageData {

        public String title;

        public String link;

        public String message;

        public String image;

public int resId;

    }

}

 

 

 

3.分享popuwimdow

界面:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

              android:layout_width="match_parent"

              android:layout_height="wrap_content"

              android:background="@color/white"

              android:orientation="vertical"

    >

 

    <LinearLayout

        android:layout_width="match_parent"

        android:layout_height="@dimen/dp_50"

        android:layout_marginTop="@dimen/dp_30"

        android:gravity="center"

        android:orientation="horizontal"

        >

        <ImageView

            android:id="@+id/share_qq"

            android:layout_width="match_parent"

            android:layout_height="@dimen/dp_36"

            android:layout_gravity="center"

            android:layout_weight="1"

            android:src="@drawable/icon_qq_share"

            android:visibility="visible"/>

        <ImageView

            android:id="@+id/share_wechat_freind"

            android:layout_width="match_parent"

            android:layout_height="@dimen/dp_36"

            android:layout_toRightOf="@+id/share_qq"

            android:layout_weight="1"

            android:src="@drawable/icon_wechat_freind"/>

        <ImageView

            android:id="@+id/share_wechat_circle"

            android:layout_width="match_parent"

            android:layout_height="@dimen/dp_36"

            android:layout_toRightOf="@+id/share_wechat_freind"

            android:layout_weight="1"

            android:src="@drawable/icon_wechat_circle"/>

        <ImageView

            android:id="@+id/share_sina"

            android:layout_width="@dimen/dp_36"

            android:layout_height="@dimen/dp_36"

            android:layout_marginLeft="@dimen/dp_61"

            android:src="@drawable/icon_sina_share"

            android:visibility="gone"/>

        <ImageView

            android:id="@+id/share_qzone"

            android:layout_width="@dimen/dp_36"

            android:layout_height="@dimen/dp_36"

            android:layout_marginLeft="@dimen/dp_22"

            android:src="@drawable/icon_wechat_circle"

            android:visibility="gone"/>

        <ImageView

            android:id="@+id/share_h5"

            android:layout_width="@dimen/dp_36"

            android:layout_height="@dimen/dp_36"

            android:layout_marginLeft="@dimen/dp_22"

            android:src="@drawable/icon_share_5"

            android:visibility="gone"/>

    </LinearLayout>

    <LinearLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_gravity="center"

        android:gravity="center"

        android:orientation="horizontal"

        >

        <TextView

            android:id="@+id/tv_qq"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:gravity="center"

            android:text="@string/qqfriend"/>

        <TextView

            android:id="@+id/tv_wechat"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:gravity="center"

            android:text="@string/wechatfriend"/>

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:gravity="center"

            android:text="@string/wechatfcircle"/>

    </LinearLayout>

    <TextView

        android:id="@+id/btn_cancle"

        android:layout_width="match_parent"

        android:layout_height="@dimen/dp_45"

        android:layout_gravity="center_horizontal"

        android:layout_marginTop="@dimen/dp_36"

        android:background="@color/color_e3"

        android:gravity="center"

        android:text="@string/lable_cancel"

        android:textColor="@color/color_32"

        android:textSize="@dimen/sp_17"

        android:visibility="visible"/>

</LinearLayout>

 

 

Popuwindow 代码

 

public class SharePopupWindowView implements OnClickListener {

    private UMShareAPI mShareAPI;

    private SSFKPopupWindow mPopupWindow;

    private Context mContext;

    private int mWidth, mHeight;

    private View mConvertView;

    private ItemClickCallBack mCallBack;

    private View mClickView;

    private String link;

    private ImageView share_h5;

 

    public SharePopupWindowView(Context context, int width, int height, String link) {

        // TODO Auto-generated constructor stub

        this.mContext = context;

        this.mWidth = width;

        this.mHeight = height;

        this.link = link;

        mShareAPI = UMShareAPI.get(context);

        initPopupWindow();

    }

    public void setCallBack(ItemClickCallBack callBack) {

        this.mCallBack = callBack;

    }

    private void initPopupWindow() {

        if (mPopupWindow != null && mPopupWindow.isShowing()) {

            mPopupWindow.dismiss();

        } else {

            getPop();

        }

    }

    private void getPop() {

        // TODO Auto-generated method stub

        mConvertView = View.inflate(mContext, R.layout.layout_pop_share, null);

        initView();

        mPopupWindow = new SSFKPopupWindow(mConvertView, mWidth, mHeight, true);

        mPopupWindow.setAnimationStyle(R.style.mypopwindow_anim_style);

        mPopupWindow.setBackgroundDrawable(new BitmapDrawable());

        mPopupWindow.setOnDismissListener(new OnDismissListener() {

            @Override

            public void onDismiss() {

                backgroundAlpha(1.0f);

                if (mClickView != null) {

                    mClickView.setEnabled(true);

                }

            }

        });

    }

 

    public void backgroundAlpha(float bgAlpha) {

        WindowManager.LayoutParams lp = ((Activity) mContext).getWindow().getAttributes();

        lp.alpha = bgAlpha; //0.0-1.0  

        ((Activity) mContext).getWindow().setAttributes(lp);

    }

 

    private void initView() {

        if (mConvertView != null) {

            ImageView share_wechat_freind = (ImageView) mConvertView

                    .findViewById(R.id.share_wechat_freind);

            ImageView share_qq = (ImageView) mConvertView

                    .findViewById(R.id.share_qq);

            ImageView share_qzone = (ImageView) mConvertView

                    .findViewById(R.id.share_qzone);

            ImageView share_wechat_circle = (ImageView) mConvertView

                    .findViewById(R.id.share_wechat_circle);

            ImageView share_sina = (ImageView) mConvertView

                    .findViewById(R.id.share_sina);

            share_h5 = (ImageView) mConvertView.findViewById(R.id.share_h5);

            TextView mTvCancle = (TextView) mConvertView.findViewById(R.id.btn_cancle);

 

            share_wechat_freind.setOnClickListener(this);

            share_wechat_freind.setVisibility(View.VISIBLE);

            share_wechat_circle.setOnClickListener(this);

            share_wechat_circle.setVisibility(View.VISIBLE);

            share_sina.setOnClickListener(this);

            share_sina.setVisibility(View.GONE);

            share_qq.setOnClickListener(this);

            share_qq.setVisibility(View.VISIBLE);

            mTvCancle.setOnClickListener(this);

        }

    }

 

    public void showAtLocation(View parent, int gravity, int x, int y) {

        backgroundAlpha(0.3f);

        mPopupWindow.update();

        mPopupWindow.setFocusable(true);

        mPopupWindow.setOutsideTouchable(true);

        mPopupWindow.showAtLocation(parent, gravity, x, y);

    }

    public void showAsDropDown(TextView v) {

        mPopupWindow.update();

        mPopupWindow.setFocusable(true);

        mPopupWindow.setOutsideTouchable(true);

        mPopupWindow.showAsDropDown(v);

    }

    public void showAsDropDown(View p, View v) {

        mPopupWindow.update();

        mPopupWindow.showAsDropDown(p);

        mPopupWindow.setFocusable(true);

        mPopupWindow.setOutsideTouchable(true);

    }

    public void dismiss() {

        mPopupWindow.dismiss();

    }

    public void setHidePlatform(SHARE_MEDIA[] hidePlatform) {

        if (hidePlatform != null) {

            for (int i = 0; i < hidePlatform.length; i++) {

                SHARE_MEDIA platform = hidePlatform[i];

                if (platform == SHARE_MEDIA.SINA) {

                    mConvertView.findViewById(R.id.share_sina).setVisibility(View.GONE);

                } else if (platform == SHARE_MEDIA.QQ) {

                    mConvertView.findViewById(R.id.share_qq).setVisibility(View.GONE);

                } else if (platform == SHARE_MEDIA.WEIXIN) {

                    mConvertView.findViewById(R.id.share_wechat_freind).setVisibility(View.GONE);

                } else if (platform == SHARE_MEDIA.WEIXIN_CIRCLE) {

                    mConvertView.findViewById(R.id.share_wechat_circle).setVisibility(View.GONE);

                }

            }

        }

    }

    public boolean isShowing() {

        if (mPopupWindow != null) {

            return mPopupWindow.isShowing();

        }

        return false;

    }

    public interface ItemClickCallBack {

        void onItemClick(View v);

    }

 

    @Override

    public void onClick(View v) {

        if (v.getId() != R.id.btn_cancle) {

            if (mCallBack != null) {

                mCallBack.onItemClick(v);

            }

        }

        mPopupWindow.dismiss();

    }

}

 

 

3.分享功能操作实现:

点击分享按钮执行:

 if (mUmShareManager == null) {

                    mUmShareManager = new UMShareManager(getActivity());

                    mUmShareManager.setFragment(ProductDetailFragment.this);

                }

                ShareMessageInfo.ShareMessageData shareData = new ShareMessageInfo.ShareMessageData();

                shareData.image = mLeftData.getPics().getPics().get(0) + Constants.IMAGE_COMPRESS_FEILD;

                 TODO: 2017/12/4  url等后台数据给

                shareData.link = "https://www.baidu.com/?tn=95672260_hao_pg";

                shareData.message = mLeftData.getTitle1();

                shareData.title = mLeftData.getTitle();

                mUmShareManager.showSharePlatForm(shareData);

转载请注明原文地址: https://www.6miu.com/read-1750036.html

最新回复(0)