Search in sources :

Example 1 with UMWeb

use of com.umeng.socialize.media.UMWeb in project AnkiChinaAndroid by ankichinateam.

the class WebViewActivity method shareUrl.

public void shareUrl(String url, String title, String desc, String thumb, SHARE_MEDIA share_media) {
    UMWeb web = new UMWeb(url);
    web.setTitle(title);
    web.setThumb(new UMImage(this, thumb));
    web.setDescription(desc);
    new ShareAction(this).withMedia(web).setPlatform(share_media).setCallback(new UMShareListener() {

        @Override
        public void onStart(SHARE_MEDIA share_media) {
        }

        @Override
        public void onResult(SHARE_MEDIA share_media) {
        }

        @Override
        public void onError(SHARE_MEDIA share_media, Throwable throwable) {
        }

        @Override
        public void onCancel(SHARE_MEDIA share_media) {
        }
    }).share();
}
Also used : UMShareListener(com.umeng.socialize.UMShareListener) SHARE_MEDIA(com.umeng.socialize.bean.SHARE_MEDIA) ShareAction(com.umeng.socialize.ShareAction) UMImage(com.umeng.socialize.media.UMImage) UMWeb(com.umeng.socialize.media.UMWeb)

Example 2 with UMWeb

use of com.umeng.socialize.media.UMWeb in project SunnyBeach by anjiemo.

the class DialogActivity method onClick.

@SingleClick
@Override
public void onClick(View view) {
    int viewId = view.getId();
    if (viewId == R.id.btn_dialog_message) {
        // 消息对话框
        new MessageDialog.Builder(getActivity()).setTitle("我是标题").setMessage("我是内容").setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).setListener(new MessageDialog.OnListener() {

            @Override
            public void onConfirm(BaseDialog dialog) {
                toast("确定了");
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_input) {
        // 输入对话框
        new InputDialog.Builder(this).setTitle("我是标题").setContent("我是内容").setHint("我是提示").setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).setListener(new InputDialog.OnListener() {

            @Override
            public void onConfirm(BaseDialog dialog, String content) {
                toast("确定了:" + content);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_bottom_menu) {
        List<String> data = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            data.add("我是数据" + (i + 1));
        }
        // 底部选择框
        new MenuDialog.Builder(this).setList(data).setListener(new MenuDialog.OnListener<String>() {

            @Override
            public void onSelected(BaseDialog dialog, int position, String string) {
                toast("位置:" + position + ",文本:" + string);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_center_menu) {
        List<String> data = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            data.add("我是数据" + (i + 1));
        }
        // 居中选择框
        new MenuDialog.Builder(this).setGravity(Gravity.CENTER).setList(data).setListener(new MenuDialog.OnListener<String>() {

            @Override
            public void onSelected(BaseDialog dialog, int position, String string) {
                toast("位置:" + position + ",文本:" + string);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_single_select) {
        // 单选对话框
        new SelectDialog.Builder(this).setTitle("请选择你的性别").setList("男", "女").setSingleSelect().setSelect(0).setListener(new SelectDialog.OnListener<String>() {

            @Override
            public void onSelected(BaseDialog dialog, HashMap<Integer, String> data) {
                toast("确定了:" + data.toString());
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_more_select) {
        // 多选对话框
        new SelectDialog.Builder(this).setTitle("请选择工作日").setList("星期一", "星期二", "星期三", "星期四", "星期五").setMaxSelect(3).setSelect(2, 3, 4).setListener(new SelectDialog.OnListener<String>() {

            @Override
            public void onSelected(BaseDialog dialog, HashMap<Integer, String> data) {
                toast("确定了:" + data.toString());
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_succeed_toast) {
        // 成功对话框
        new TipsDialog.Builder(this).setIcon(TipsDialog.ICON_FINISH).setMessage("完成").show();
    } else if (viewId == R.id.btn_dialog_fail_toast) {
        // 失败对话框
        new TipsDialog.Builder(this).setIcon(TipsDialog.ICON_ERROR).setMessage("错误").show();
    } else if (viewId == R.id.btn_dialog_warn_toast) {
        // 警告对话框
        new TipsDialog.Builder(this).setIcon(TipsDialog.ICON_WARNING).setMessage("警告").show();
    } else if (viewId == R.id.btn_dialog_wait) {
        if (mWaitDialog == null) {
            mWaitDialog = new WaitDialog.Builder(this).setMessage(getString(R.string.common_loading)).create();
        }
        if (!mWaitDialog.isShowing()) {
            mWaitDialog.show();
            postDelayed(mWaitDialog::dismiss, 2000);
        }
    } else if (viewId == R.id.btn_dialog_pay) {
        // 支付密码输入对话框
        new PayPasswordDialog.Builder(this).setTitle(getString(R.string.pay_title)).setSubTitle("用于购买一个女盆友").setMoney("¥ 100.00").setListener(new PayPasswordDialog.OnListener() {

            @Override
            public void onCompleted(BaseDialog dialog, String password) {
                toast(password);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_address) {
        // 选择地区对话框
        new AddressDialog.Builder(this).setTitle(getString(R.string.address_title)).setListener(new AddressDialog.OnListener() {

            @Override
            public void onSelected(BaseDialog dialog, String province, String city, String area) {
                toast(province + city + area);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_date) {
        // 日期选择对话框
        new DateDialog.Builder(this).setTitle(getString(R.string.date_title)).setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).setListener(new DateDialog.OnListener() {

            @Override
            public void onSelected(BaseDialog dialog, int year, int month, int day) {
                toast(year + getString(R.string.common_year) + month + getString(R.string.common_month) + day + getString(R.string.common_day));
                // 如果不指定时分秒则默认为现在的时间
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.YEAR, year);
                // 月份从零开始,所以需要减 1
                calendar.set(Calendar.MONTH, month - 1);
                calendar.set(Calendar.DAY_OF_MONTH, day);
                toast("时间戳:" + calendar.getTimeInMillis());
            // toast(new SimpleDateFormat("yyyy年MM月dd日 kk:mm:ss").format(calendar.getTime()));
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_time) {
        // 时间选择对话框
        new TimeDialog.Builder(this).setTitle(getString(R.string.time_title)).setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).setListener(new TimeDialog.OnListener() {

            @Override
            public void onSelected(BaseDialog dialog, int hour, int minute, int second) {
                toast(hour + getString(R.string.common_hour) + minute + getString(R.string.common_minute) + second + getString(R.string.common_second));
                // 如果不指定年月日则默认为今天的日期
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.HOUR_OF_DAY, hour);
                calendar.set(Calendar.MINUTE, minute);
                calendar.set(Calendar.SECOND, second);
                toast("时间戳:" + calendar.getTimeInMillis());
            // toast(new SimpleDateFormat("yyyy年MM月dd日 kk:mm:ss").format(calendar.getTime()));
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_share) {
        toast("记得改好第三方 AppID 和 Secret,否则会调不起来哦");
        UMWeb content = new UMWeb("https://github.com/getActivity/AndroidProject");
        content.setTitle("Github");
        content.setThumb(new UMImage(this, R.mipmap.launcher_ic));
        content.setDescription(getString(R.string.app_name));
        // 分享对话框
        new ShareDialog.Builder(this).setShareLink(content).setListener(new UmengShare.OnShareListener() {

            @Override
            public void onSucceed(Platform platform) {
                toast("分享成功");
            }

            @Override
            public void onError(Platform platform, Throwable t) {
                toast(t.getMessage());
            }

            @Override
            public void onCancel(Platform platform) {
                toast("分享取消");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_update) {
        // 升级对话框
        new UpdateDialog.Builder(this).setVersionName("5.2.0").setForceUpdate(false).setUpdateLog("到底更新了啥\n到底更新了啥\n到底更新了啥\n到底更新了啥\n到底更新了啥\n到底更新了啥").setDownloadUrl("https://dldir1.qq.com/weixin/android/weixin807android1920_arm64.apk").setFileMd5("df2f045dfa854d8461d9cefe08b813c8").show();
    } else if (viewId == R.id.btn_dialog_safe) {
        // 身份校验对话框
        new SafeDialog.Builder(this).setListener(new SafeDialog.OnListener() {

            @Override
            public void onConfirm(BaseDialog dialog, String phone, String code) {
                toast("手机号:" + phone + "\n验证码:" + code);
            }

            @Override
            public void onCancel(BaseDialog dialog) {
                toast("取消了");
            }
        }).show();
    } else if (viewId == R.id.btn_dialog_custom) {
        // 自定义对话框
        new BaseDialog.Builder<>(this).setContentView(R.layout.custom_dialog).setAnimStyle(BaseDialog.ANIM_SCALE).setOnClickListener(R.id.btn_dialog_custom_ok, (BaseDialog.OnClickListener<Button>) (dialog, button) -> dialog.dismiss()).setOnCreateListener(dialog -> toast("Dialog 创建了")).addOnShowListener(dialog -> toast("Dialog 显示了")).addOnCancelListener(dialog -> toast("Dialog 取消了")).addOnDismissListener(dialog -> toast("Dialog 销毁了")).setOnKeyListener((dialog, event) -> {
            toast("按键代码:" + event.getKeyCode());
            return false;
        }).show();
    } else if (viewId == R.id.btn_dialog_multi) {
        BaseDialog dialog1 = new MessageDialog.Builder(getActivity()).setTitle("温馨提示").setMessage("我是第一个弹出的对话框").setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).create();
        BaseDialog dialog2 = new MessageDialog.Builder(getActivity()).setTitle("温馨提示").setMessage("我是第二个弹出的对话框").setConfirm(getString(R.string.common_confirm)).setCancel(getString(R.string.common_cancel)).create();
        DialogManager.getInstance(this).addShow(dialog1);
        DialogManager.getInstance(this).addShow(dialog2);
    }
}
Also used : UMImage(com.umeng.socialize.media.UMImage) ListPopup(cn.cqautotest.sunnybeach.ui.popup.ListPopup) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick) MenuDialog(cn.cqautotest.sunnybeach.ui.dialog.MenuDialog) PayPasswordDialog(cn.cqautotest.sunnybeach.ui.dialog.PayPasswordDialog) UMWeb(com.umeng.socialize.media.UMWeb) Intent(android.content.Intent) HashMap(java.util.HashMap) Platform(com.hjq.umeng.Platform) ArrayList(java.util.ArrayList) SafeDialog(cn.cqautotest.sunnybeach.ui.dialog.SafeDialog) Calendar(java.util.Calendar) AppActivity(cn.cqautotest.sunnybeach.app.AppActivity) AddressDialog(cn.cqautotest.sunnybeach.ui.dialog.AddressDialog) TipsDialog(cn.cqautotest.sunnybeach.ui.dialog.TipsDialog) View(android.view.View) Button(android.widget.Button) UmengClient(com.hjq.umeng.UmengClient) SelectDialog(cn.cqautotest.sunnybeach.ui.dialog.SelectDialog) DialogManager(cn.cqautotest.sunnybeach.manager.DialogManager) R(cn.cqautotest.sunnybeach.R) InputDialog(cn.cqautotest.sunnybeach.ui.dialog.InputDialog) ShareDialog(cn.cqautotest.sunnybeach.ui.dialog.ShareDialog) TimeDialog(cn.cqautotest.sunnybeach.ui.dialog.TimeDialog) UmengShare(com.hjq.umeng.UmengShare) BaseDialog(com.hjq.base.BaseDialog) MessageDialog(cn.cqautotest.sunnybeach.ui.dialog.MessageDialog) Gravity(android.view.Gravity) DateDialog(cn.cqautotest.sunnybeach.ui.dialog.DateDialog) List(java.util.List) WaitDialog(cn.cqautotest.sunnybeach.ui.dialog.WaitDialog) Nullable(androidx.annotation.Nullable) UpdateDialog(cn.cqautotest.sunnybeach.ui.dialog.UpdateDialog) BaseDialog(com.hjq.base.BaseDialog) Platform(com.hjq.umeng.Platform) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TimeDialog(cn.cqautotest.sunnybeach.ui.dialog.TimeDialog) UMWeb(com.umeng.socialize.media.UMWeb) UpdateDialog(cn.cqautotest.sunnybeach.ui.dialog.UpdateDialog) TipsDialog(cn.cqautotest.sunnybeach.ui.dialog.TipsDialog) ArrayList(java.util.ArrayList) List(java.util.List) MessageDialog(cn.cqautotest.sunnybeach.ui.dialog.MessageDialog) InputDialog(cn.cqautotest.sunnybeach.ui.dialog.InputDialog) ShareDialog(cn.cqautotest.sunnybeach.ui.dialog.ShareDialog) Calendar(java.util.Calendar) UMImage(com.umeng.socialize.media.UMImage) SelectDialog(cn.cqautotest.sunnybeach.ui.dialog.SelectDialog) MenuDialog(cn.cqautotest.sunnybeach.ui.dialog.MenuDialog) AddressDialog(cn.cqautotest.sunnybeach.ui.dialog.AddressDialog) PayPasswordDialog(cn.cqautotest.sunnybeach.ui.dialog.PayPasswordDialog) DateDialog(cn.cqautotest.sunnybeach.ui.dialog.DateDialog) SingleClick(cn.cqautotest.sunnybeach.aop.SingleClick)

Example 3 with UMWeb

use of com.umeng.socialize.media.UMWeb in project SunnyBeach by anjiemo.

the class BrowserActivity method onRightClick.

@Override
public void onRightClick(View view) {
    UMWeb content = new UMWeb(mBrowserView.getUrl());
    content.setTitle(mBrowserView.getTitle());
    content.setThumb(new UMImage(this, R.mipmap.launcher_ic));
    content.setDescription(getString(R.string.app_name));
    // 分享
    new ShareDialog.Builder(this).setShareLink(content).setListener(new UmengShare.OnShareListener() {

        @Override
        public void onSucceed(Platform platform) {
            toast("分享成功");
        }

        @Override
        public void onError(Platform platform, Throwable t) {
            toast(t.getMessage());
        }

        @Override
        public void onCancel(Platform platform) {
            toast("分享取消");
        }
    }).show();
}
Also used : ShareDialog(cn.cqautotest.sunnybeach.ui.dialog.ShareDialog) Platform(com.hjq.umeng.Platform) UMImage(com.umeng.socialize.media.UMImage) UMWeb(com.umeng.socialize.media.UMWeb)

Example 4 with UMWeb

use of com.umeng.socialize.media.UMWeb in project WeexErosFramework by bmfe.

the class DefaultShareAdapter method startUmweb.

private void startUmweb(ShareInfoBean shareInfo, SHARE_MEDIA mPlatform, UMShareListener shareListener) {
    if (!BMWXEnvironment.mPlatformConfig.getUmeng().isUmengAvailable()) {
        shareListener.onError(mPlatform, new Exception("未设置umeng三方appKey"));
        return;
    }
    mUMWeb = new UMWeb(shareInfo.getUrl());
    mUMWeb.setTitle(shareInfo.getTitle());
    mUMWeb.setDescription(shareInfo.getContent());
    String image = shareInfo.getImage();
    if (TextUtils.isEmpty(image)) {
        mUMWeb.setThumb(new UMImage(mAct, R.drawable.place_holder));
    } else {
        mUMWeb.setThumb(new UMImage(mAct, image));
    }
    new ShareAction(mAct).setPlatform(mPlatform).withMedia(mUMWeb).setCallback(shareListener).share();
}
Also used : ShareAction(com.umeng.socialize.ShareAction) UMImage(com.umeng.socialize.media.UMImage) UMWeb(com.umeng.socialize.media.UMWeb)

Example 5 with UMWeb

use of com.umeng.socialize.media.UMWeb in project SmartCampus by Vegen.

the class ShareUtils method shareWeb.

/**
 * 分享链接
 */
public static void shareWeb(final Activity activity, String WebUrl, String title, String description, String imageUrl, int imageID) {
    // 连接地址
    UMWeb web = new UMWeb(WebUrl);
    // 标题
    web.setTitle(title);
    // 描述
    web.setDescription(description);
    if (TextUtils.isEmpty(imageUrl)) {
        // 本地缩略图
        web.setThumb(new UMImage(activity, imageID));
    } else {
        // 网络缩略图
        web.setThumb(new UMImage(activity, imageUrl));
    }
    new ShareAction(activity).setDisplayList(SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE, SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.WEIXIN_FAVORITE, SHARE_MEDIA.SINA).withText(title).withMedia(web).setCallback(new UMShareListener() {

        @Override
        public void onStart(SHARE_MEDIA share_media) {
        }

        @Override
        public void onResult(final SHARE_MEDIA share_media) {
            activity.runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    if (share_media.name().equals("WEIXIN_FAVORITE")) {
                        Toast.makeText(activity, share_media + " 收藏成功", Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(activity, share_media + " 分享成功", Toast.LENGTH_SHORT).show();
                    }
                }
            });
        }

        @Override
        public void onError(final SHARE_MEDIA share_media, final Throwable throwable) {
            if (throwable != null) {
                Log.d("throw", "throw:" + throwable.getMessage());
            }
            activity.runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    Toast.makeText(activity, share_media + " 分享失败", Toast.LENGTH_SHORT).show();
                }
            });
        }

        @Override
        public void onCancel(final SHARE_MEDIA share_media) {
            activity.runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    Toast.makeText(activity, share_media + " 分享取消", Toast.LENGTH_SHORT).show();
                }
            });
        }
    }).open();
}
Also used : UMShareListener(com.umeng.socialize.UMShareListener) SHARE_MEDIA(com.umeng.socialize.bean.SHARE_MEDIA) ShareAction(com.umeng.socialize.ShareAction) UMImage(com.umeng.socialize.media.UMImage) UMWeb(com.umeng.socialize.media.UMWeb)

Aggregations

UMImage (com.umeng.socialize.media.UMImage)6 UMWeb (com.umeng.socialize.media.UMWeb)6 ShareAction (com.umeng.socialize.ShareAction)4 Intent (android.content.Intent)2 ShareDialog (cn.cqautotest.sunnybeach.ui.dialog.ShareDialog)2 Platform (com.hjq.umeng.Platform)2 UMShareListener (com.umeng.socialize.UMShareListener)2 SHARE_MEDIA (com.umeng.socialize.bean.SHARE_MEDIA)2 Gravity (android.view.Gravity)1 View (android.view.View)1 Button (android.widget.Button)1 Nullable (androidx.annotation.Nullable)1 R (cn.cqautotest.sunnybeach.R)1 SingleClick (cn.cqautotest.sunnybeach.aop.SingleClick)1 AppActivity (cn.cqautotest.sunnybeach.app.AppActivity)1 DialogManager (cn.cqautotest.sunnybeach.manager.DialogManager)1 AddressDialog (cn.cqautotest.sunnybeach.ui.dialog.AddressDialog)1 DateDialog (cn.cqautotest.sunnybeach.ui.dialog.DateDialog)1 InputDialog (cn.cqautotest.sunnybeach.ui.dialog.InputDialog)1 MenuDialog (cn.cqautotest.sunnybeach.ui.dialog.MenuDialog)1