Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
9e69e5db
Commit
9e69e5db
authored
Aug 25, 2022
by
霍志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:分享添加
parent
0af98d7e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1028 additions
and
852 deletions
+1028
-852
config.gradle
config.gradle
+5
-5
build.gradle
ydl-platform/build.gradle
+4
-4
ShareUtils.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/actions/share/ShareUtils.kt
+325
-284
CustomShareDialog.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/view/dialog/CustomShareDialog.kt
+179
-144
YDLShareDialog.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/view/dialog/YDLShareDialog.kt
+515
-415
No files found.
config.gradle
View file @
9e69e5db
ext
{
ext
{
kotlin_version
=
"1.3.21"
kotlin_version
=
"1.3.21"
dev_mode
=
fals
e
dev_mode
=
tru
e
ydlPublishVersion
=
[
ydlPublishVersion
=
[
// -------------- 业务模块 --------------
// -------------- 业务模块 --------------
...
@@ -234,13 +234,13 @@ ext {
...
@@ -234,13 +234,13 @@ ext {
"umeng-common"
:
"com.umeng.umsdk:common:9.5.1"
,
"umeng-common"
:
"com.umeng.umsdk:common:9.5.1"
,
"umeng-asms"
:
"com.umeng.umsdk:asms:1.4.1"
,
"umeng-asms"
:
"com.umeng.umsdk:asms:1.4.1"
,
// //友盟社会化分享
// //友盟社会化分享
//
"umeng-share-core" : "com.umeng.umsdk:share-core:7.1.4",
"umeng-share-core"
:
"com.umeng.umsdk:share-core:7.1.4"
,
//
"umeng-share-qq" : "com.umeng.umsdk:share-qq:7.1.4",
"umeng-share-qq"
:
"com.umeng.umsdk:share-qq:7.1.4"
,
"umeng-share-wechat"
:
"com.umeng.umsdk:share-wx:7.1.4"
,
"umeng-share-wechat"
:
"com.umeng.umsdk:share-wx:7.1.4"
,
// //分享面板
// //分享面板
//
"umeng-shareboard" : "com.umeng.umsdk:share-board:7.1.4",
"umeng-shareboard"
:
"com.umeng.umsdk:share-board:7.1.4"
,
"umeng-wx-guanfang"
:
"com.tencent.mm.opensdk:wechat-sdk-android-without-mta:6.6.5"
,
"umeng-wx-guanfang"
:
"com.tencent.mm.opensdk:wechat-sdk-android-without-mta:6.6.5"
,
//
"umeng-qq-guanfang" : "com.tencent.tauth:qqopensdk:3.51.2",
"umeng-qq-guanfang"
:
"com.tencent.tauth:qqopensdk:3.51.2"
,
"tablayout"
:
"com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar"
,
"tablayout"
:
"com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar"
,
"stetho"
:
"com.facebook.stetho:stetho:1.5.0"
,
"stetho"
:
"com.facebook.stetho:stetho:1.5.0"
,
"stetho-okhttp3"
:
"com.facebook.stetho:stetho-okhttp3:1.4.1"
,
"stetho-okhttp3"
:
"com.facebook.stetho:stetho-okhttp3:1.4.1"
,
...
...
ydl-platform/build.gradle
View file @
9e69e5db
...
@@ -143,12 +143,12 @@ dependencies {
...
@@ -143,12 +143,12 @@ dependencies {
api
rootProject
.
ext
.
dependencies
[
"eventbus"
]
api
rootProject
.
ext
.
dependencies
[
"eventbus"
]
api
rootProject
.
ext
.
dependencies
[
"umeng-common"
]
api
rootProject
.
ext
.
dependencies
[
"umeng-common"
]
api
rootProject
.
ext
.
dependencies
[
"umeng-asms"
]
api
rootProject
.
ext
.
dependencies
[
"umeng-asms"
]
//
api rootProject.ext.dependencies["umeng-share-core"]
api
rootProject
.
ext
.
dependencies
[
"umeng-share-core"
]
//
api rootProject.ext.dependencies["umeng-share-qq"]
api
rootProject
.
ext
.
dependencies
[
"umeng-share-qq"
]
api
rootProject
.
ext
.
dependencies
[
"umeng-share-wechat"
]
api
rootProject
.
ext
.
dependencies
[
"umeng-share-wechat"
]
//
api rootProject.ext.dependencies["umeng-shareboard"]
api
rootProject
.
ext
.
dependencies
[
"umeng-shareboard"
]
api
rootProject
.
ext
.
dependencies
[
"umeng-wx-guanfang"
]
api
rootProject
.
ext
.
dependencies
[
"umeng-wx-guanfang"
]
//
api rootProject.ext.dependencies["umeng-qq-guanfang"]
api
rootProject
.
ext
.
dependencies
[
"umeng-qq-guanfang"
]
api
rootProject
.
ext
.
dependencies
[
"stetho"
]
api
rootProject
.
ext
.
dependencies
[
"stetho"
]
api
rootProject
.
ext
.
dependencies
[
"stetho-okhttp3"
]
api
rootProject
.
ext
.
dependencies
[
"stetho-okhttp3"
]
api
rootProject
.
ext
.
dependencies
[
"bugly-crashreport"
]
api
rootProject
.
ext
.
dependencies
[
"bugly-crashreport"
]
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/actions/share/ShareUtils.kt
View file @
9e69e5db
//package com.ydl.ydlcommon.actions.share
package
com.ydl.ydlcommon.actions.share
import
android.app.Activity
import
android.graphics.Bitmap
import
android.text.TextUtils
import
com.umeng.socialize.ShareAction
import
com.umeng.socialize.UMShareListener
import
com.umeng.socialize.bean.SHARE_MEDIA
import
com.umeng.socialize.media.UMImage
import
com.umeng.socialize.media.UMMin
import
com.umeng.socialize.media.UMWeb
import
com.umeng.socialize.shareboard.ShareBoardConfig
import
com.ydl.ydlcommon.utils.remind.ToastHelper
import
com.ydl.ydlcommon.view.dialog.CustomShareDialog
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.ToastUtil
/**
* 分享工具类
*/
object
ShareUtils
{
var
platform
:
SHARE_MEDIA
?
=
null
var
callBack
:
ShareActionCallBack
?
=
null
/**
* 直接分享到指定平台
* @param platform
*/
fun
shareTo
(
platform
:
SHARE_MEDIA
?,
context
:
Activity
,
share_title
:
String
,
share_url
:
String
,
share_context
:
String
?,
share_head
:
String
?
)
{
LogUtil
.
d
(
"shareTo"
)
val
web
=
UMWeb
(
share_url
)
web
.
title
=
share_title
//标题
if
(
platform
==
SHARE_MEDIA
.
WEIXIN_CIRCLE
)
{
web
.
title
=
"$share_title\n$share_context"
}
web
.
setThumb
(
UMImage
(
context
,
share_head
?:
"http://static.ydlcdn.com/v1/images/logo320.png"
)
)
//缩略图
web
.
description
=
share_context
//描述
ShareAction
(
context
)
.
setPlatform
(
platform
)
.
setCallback
(
object
:
UMShareListener
{
override
fun
onStart
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"开始分享------"
)
}
override
fun
onResult
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"分享结束------"
)
callBack
?.
onShareSuccessed
(
share_media
)
callBack
=
null
}
override
fun
onError
(
share_media
:
SHARE_MEDIA
,
throwable
:
Throwable
)
{
LogUtil
.
e
(
"ydl"
,
"分享出错------"
+
throwable
.
message
)
try
{
var
message
=
handleMessage
(
throwable
.
message
!!
)
ToastUtil
.
toastShort
(
"分享失败,"
+
message
)
}
catch
(
e
:
Exception
)
{
ToastUtil
.
toastShort
(
"分享错误"
)
}
callBack
?.
onShareFailed
(
share_media
,
throwable
)
callBack
=
null
}
override
fun
onCancel
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"分享取消------"
)
}
})
.
withMedia
(
web
)
.
share
()
}
/**
* 分享纯图片到微信
*/
fun
sharePicToWeiXin
(
context
:
Activity
,
bitmap
:
Bitmap
?)
{
if
(
bitmap
==
null
)
{
ToastUtil
.
toastShort
(
"数据异常,请重试"
)
return
}
if
(
platform
==
null
)
{
ToastUtil
.
toastShort
(
"分享异常,请重试"
)
return
}
val
image
=
UMImage
(
context
,
bitmap
)
//bitmap文件
val
thumb
=
UMImage
(
context
,
bitmap
)
image
.
setThumb
(
thumb
)
image
.
compressStyle
=
UMImage
.
CompressStyle
.
SCALE
//大小压缩,默认为大小压缩,适合普通很大的图
image
.
compressStyle
=
UMImage
.
CompressStyle
.
QUALITY
//质量压缩,适合长图的分享
ShareAction
(
context
)
.
setPlatform
(
platform
)
.
setCallback
(
object
:
UMShareListener
{
override
fun
onStart
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"开始分享------"
)
}
override
fun
onResult
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"分享结束------"
)
callBack
?.
onShareSuccessed
(
share_media
)
callBack
=
null
}
override
fun
onError
(
share_media
:
SHARE_MEDIA
,
throwable
:
Throwable
)
{
LogUtil
.
e
(
"ydl"
,
"分享出错------"
+
throwable
.
message
)
try
{
var
message
=
handleMessage
(
throwable
.
message
!!
)
ToastUtil
.
toastShort
(
"分享失败,"
+
message
)
}
catch
(
e
:
Exception
)
{
ToastUtil
.
toastShort
(
"分享错误"
)
}
callBack
?.
onShareFailed
(
share_media
,
throwable
)
callBack
=
null
}
override
fun
onCancel
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"分享取消------"
)
}
})
.
withMedia
(
image
)
.
share
()
}
/**
* 分享小程序类型
*/
fun
shareSmailWeixin
(
context
:
Activity
,
share_title
:
String
,
share_url
:
String
,
share_context
:
String
?,
image
:
String
?,
path
:
String
?,
id
:
String
?,
shareListener
:
UMShareListener
?
)
{
val
umMin
=
UMMin
(
share_url
)
//兼容低版本的网页链接
val
img
=
UMImage
(
context
,
image
)
img
.
compressStyle
=
UMImage
.
CompressStyle
.
SCALE
umMin
.
setThumb
(
img
)
// 小程序消息封面图片
umMin
.
title
=
share_title
// 小程序消息title
umMin
.
description
=
share_context
// 小程序消息描述
umMin
.
path
=
path
//小程序页面路径
umMin
.
userName
=
id
// 小程序原始id,在微信平台查询
ShareAction
(
context
)
.
withMedia
(
umMin
)
.
setPlatform
(
SHARE_MEDIA
.
WEIXIN
)
.
setCallback
(
shareListener
)
.
share
()
}
/**
* 自定义分享弹出框
* author harvie
* @param activity
* @param actions 扩展按钮
* @param share_title
* @param share_url
* @param share_context
* @param share_head
*/
fun
share
(
activity
:
Activity
,
share_title
:
String
?,
share_url
:
String
?,
share_context
:
String
?,
share_head
:
String
?,
actions
:
List
<
ShareMoreBean
>
)
{
var
content
=
share_context
var
image
=
share_head
if
(
share_title
==
null
||
share_url
==
null
)
{
ToastHelper
.
show
(
"缺少分享参数"
)
return
}
if
(
TextUtils
.
isEmpty
(
share_head
))
{
image
=
"http://static.ydlcdn.com/v1/images/logo320.png"
}
if
(
TextUtils
.
isEmpty
(
content
))
content
=
share_title
val
dialog
=
CustomShareDialog
(
activity
)
dialog
.
setShareBody
(
share_title
,
share_url
,
content
?:
""
,
image
!!
)
dialog
.
addActions
(
actions
)
dialog
.
show
()
}
/**
* 友盟自带分享弹框
*/
fun
share
(
activity
:
Activity
,
share_title
:
String
?,
share_url
:
String
?,
share_context
:
String
?,
share_head
:
String
?
)
{
LogUtil
.
d
(
"share"
)
var
content
=
share_context
var
image
=
share_head
if
(
share_title
==
null
||
share_url
==
null
)
{
ToastHelper
.
show
(
"缺少分享参数"
)
return
}
if
(
share_head
==
null
||
share_head
==
""
)
{
image
=
"http://static.ydlcdn.com/v1/images/logo320.png"
}
if
(
TextUtils
.
isEmpty
(
content
))
content
=
share_title
val
web
=
UMWeb
(
share_url
)
web
.
title
=
share_title
//标题
web
.
setThumb
(
UMImage
(
activity
,
image
))
//缩略图
web
.
description
=
content
//描述
val
config
=
ShareBoardConfig
()
config
.
setIndicatorVisibility
(
false
)
if
(
activity
.
packageName
.
endsWith
(
"yidianling_atk9"
))
{
ShareAction
(
activity
).
withMedia
(
web
)
.
setDisplayList
(
SHARE_MEDIA
.
QQ
,
SHARE_MEDIA
.
QZONE
)
.
setCallback
(
object
:
UMShareListener
{
override
fun
onStart
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"开始分享------"
)
}
override
fun
onResult
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"分享结束------"
)
}
override
fun
onError
(
share_media
:
SHARE_MEDIA
,
throwable
:
Throwable
)
{
LogUtil
.
e
(
"ydl"
,
"分享出错------"
+
throwable
.
message
)
try
{
var
message
=
handleMessage
(
throwable
.
message
!!
)
ToastUtil
.
toastShort
(
"分享失败,"
+
message
)
}
catch
(
e
:
Exception
)
{
ToastUtil
.
toastShort
(
"分享错误"
)
}
}
override
fun
onCancel
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"分享取消------"
)
}
})
.
open
(
config
)
}
else
{
ShareAction
(
activity
).
withMedia
(
web
)
.
setDisplayList
(
SHARE_MEDIA
.
WEIXIN
,
SHARE_MEDIA
.
WEIXIN_CIRCLE
,
SHARE_MEDIA
.
QQ
,
SHARE_MEDIA
.
QZONE
)
.
setCallback
(
object
:
UMShareListener
{
override
fun
onStart
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"开始分享------"
)
}
override
fun
onResult
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"分享结束------"
)
callBack
?.
onShareSuccessed
(
share_media
)
callBack
=
null
}
override
fun
onError
(
share_media
:
SHARE_MEDIA
,
throwable
:
Throwable
)
{
LogUtil
.
e
(
"ydl"
,
"分享出错------"
+
throwable
.
message
)
try
{
var
message
=
handleMessage
(
throwable
.
message
!!
)
ToastUtil
.
toastShort
(
"分享失败,"
+
message
)
}
catch
(
e
:
Exception
)
{
ToastUtil
.
toastShort
(
"分享错误"
)
}
callBack
?.
onShareFailed
(
share_media
,
throwable
)
callBack
=
null
}
override
fun
onCancel
(
share_media
:
SHARE_MEDIA
)
{
LogUtil
.
e
(
"ydl"
,
"分享取消------"
)
}
})
.
open
(
config
)
}
}
/**
* 强制处理分享失败消息
*/
fun
handleMessage
(
msg
:
String
):
String
{
var
index
=
msg
.
indexOf
(
"错误信息"
)
var
message
=
msg
.
substring
(
index
,
msg
!!
.
length
)
var
lastIndex
=
message
.
indexOf
(
" "
)
message
=
message
.
substring
(
0
,
lastIndex
)
return
message
}
}
//
//
//import android.app.Activity
/**
//import android.graphics.Bitmap
*
//import android.text.TextUtils
*/
//import com.umeng.socialize.ShareAction
class
ShareMoreBean
(
//import com.umeng.socialize.UMShareListener
var
imageResId
:
Int
,
var
actionName
:
String
,
//扩展按钮动作
//import com.umeng.socialize.bean.SHARE_MEDIA
var
shareMoreAction
:
ShareMoreAction
?
//import com.umeng.socialize.media.UMImage
)
//import com.umeng.socialize.media.UMMin
//import com.umeng.socialize.media.UMWeb
//分享动作
//import com.umeng.socialize.shareboard.ShareBoardConfig
interface
ShareMoreAction
{
//import com.ydl.ydlcommon.utils.remind.ToastHelper
fun
onClick
()
//import com.ydl.ydlcommon.view.dialog.CustomShareDialog
}
//import com.yidianling.common.tools.LogUtil
//import com.yidianling.common.tools.ToastUtil
interface
ShareActionCallBack
{
///**
fun
onShareSuccessed
(
share_media
:
SHARE_MEDIA
)
// * 分享工具类
fun
onShareFailed
(
share_media
:
SHARE_MEDIA
,
throwable
:
Throwable
)
// */
}
//
//object ShareUtils {
//
// var platform: SHARE_MEDIA? = null
//
// var callBack: ShareActionCallBack? = null
//
// /**
// * 直接分享到指定平台
// * @param platform
// */
// fun shareTo(platform: SHARE_MEDIA?, context: Activity, share_title: String, share_url: String, share_context: String?, share_head: String?) {
// LogUtil.d("shareTo")
// val web = UMWeb(share_url)
// web.title = share_title //标题
// if (platform == SHARE_MEDIA.WEIXIN_CIRCLE) {
// web.title = "$share_title\n$share_context"
// }
// web.setThumb(UMImage(context, share_head
// ?: "http://static.ydlcdn.com/v1/images/logo320.png")) //缩略图
// web.description = share_context//描述
// ShareAction(context)
// .setPlatform(platform)
// .setCallback(object : UMShareListener {
// override fun onStart(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "开始分享------")
// }
//
// override fun onResult(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "分享结束------")
// callBack?.onShareSuccessed(share_media)
// callBack = null
// }
//
// override fun onError(share_media: SHARE_MEDIA, throwable: Throwable) {
// LogUtil.e("ydl", "分享出错------" + throwable.message)
// try {
// var message = handleMessage(throwable.message!!)
// ToastUtil.toastShort("分享失败," + message)
// } catch (e: Exception) {
// ToastUtil.toastShort("分享错误")
// }
// callBack?.onShareFailed(share_media, throwable)
// callBack = null
// }
//
// override fun onCancel(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "分享取消------")
// }
// })
// .withMedia(web)
// .share()
// }
//
// /**
// * 分享纯图片到微信
// */
// fun sharePicToWeiXin(context: Activity, bitmap: Bitmap?) {
// if (bitmap == null) {
// ToastUtil.toastShort("数据异常,请重试")
// return
// }
// if (platform == null) {
// ToastUtil.toastShort("分享异常,请重试")
// return
// }
// val image = UMImage(context, bitmap)//bitmap文件
//
// val thumb = UMImage(context, bitmap)
// image.setThumb(thumb)
//
// image.compressStyle = UMImage.CompressStyle.SCALE//大小压缩,默认为大小压缩,适合普通很大的图
// image.compressStyle = UMImage.CompressStyle.QUALITY//质量压缩,适合长图的分享
// ShareAction(context)
// .setPlatform(platform)
// .setCallback(object : UMShareListener {
// override fun onStart(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "开始分享------")
// }
//
// override fun onResult(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "分享结束------")
// callBack?.onShareSuccessed(share_media)
// callBack = null
// }
//
// override fun onError(share_media: SHARE_MEDIA, throwable: Throwable) {
// LogUtil.e("ydl", "分享出错------" + throwable.message)
// try {
// var message = handleMessage(throwable.message!!)
// ToastUtil.toastShort("分享失败," + message)
// } catch (e: Exception) {
// ToastUtil.toastShort("分享错误")
// }
// callBack?.onShareFailed(share_media, throwable)
// callBack = null
// }
//
// override fun onCancel(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "分享取消------")
// }
// })
// .withMedia(image)
// .share()
// }
//
// /**
// * 分享小程序类型
// */
// fun shareSmailWeixin(context: Activity, share_title: String, share_url: String, share_context: String?, image: String?, path: String?, id: String?, shareListener: UMShareListener?) {
// val umMin = UMMin(share_url) //兼容低版本的网页链接
// val img = UMImage(context, image)
// img.compressStyle = UMImage.CompressStyle.SCALE
// umMin.setThumb(img) // 小程序消息封面图片
// umMin.title = share_title // 小程序消息title
// umMin.description = share_context // 小程序消息描述
// umMin.path = path //小程序页面路径
// umMin.userName = id // 小程序原始id,在微信平台查询
// ShareAction(context)
// .withMedia(umMin)
// .setPlatform(SHARE_MEDIA.WEIXIN)
// .setCallback(shareListener)
// .share()
// }
//
// /**
// * 自定义分享弹出框
// * author harvie
// * @param activity
// * @param actions 扩展按钮
// * @param share_title
// * @param share_url
// * @param share_context
// * @param share_head
// */
// fun share(activity: Activity, share_title: String?, share_url: String?, share_context: String?, share_head: String?, actions: List<ShareMoreBean>) {
// var content = share_context
// var image = share_head
// if (share_title == null || share_url == null) {
// ToastHelper.show("缺少分享参数")
// return
// }
// if (TextUtils.isEmpty(share_head)) {
// image = "http://static.ydlcdn.com/v1/images/logo320.png"
// }
// if (TextUtils.isEmpty(content)) content = share_title
// val dialog = CustomShareDialog(activity)
// dialog.setShareBody(share_title, share_url, content ?: "", image!!)
// dialog.addActions(actions)
// dialog.show()
//
// }
//
// /**
// * 友盟自带分享弹框
// */
// fun share(activity: Activity, share_title: String?, share_url: String?, share_context: String?, share_head: String?) {
// LogUtil.d("share")
// var content = share_context
// var image = share_head
// if (share_title == null || share_url == null) {
// ToastHelper.show("缺少分享参数")
// return
// }
// if (share_head == null || share_head == "") {
// image = "http://static.ydlcdn.com/v1/images/logo320.png"
// }
// if (TextUtils.isEmpty(content)) content = share_title
//
// val web = UMWeb(share_url)
// web.title = share_title//标题
// web.setThumb(UMImage(activity, image)) //缩略图
// web.description = content//描述
// val config = ShareBoardConfig()
// config.setIndicatorVisibility(false)
// if (activity.packageName.endsWith("yidianling_atk9")) {
// ShareAction(activity).withMedia(web)
// .setDisplayList(SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE)
// .setCallback(object : UMShareListener {
// override fun onStart(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "开始分享------")
// }
//
// override fun onResult(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "分享结束------")
// }
//
// override fun onError(share_media: SHARE_MEDIA, throwable: Throwable) {
// LogUtil.e("ydl", "分享出错------" + throwable.message)
// try {
// var message = handleMessage(throwable.message!!)
// ToastUtil.toastShort("分享失败," + message)
// } catch (e: Exception) {
// ToastUtil.toastShort("分享错误")
// }
// }
//
// override fun onCancel(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "分享取消------")
// }
// })
// .open(config)
// } else {
// ShareAction(activity).withMedia(web)
// .setDisplayList(SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE)
// .setCallback(object : UMShareListener {
// override fun onStart(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "开始分享------")
// }
//
// override fun onResult(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "分享结束------")
// callBack?.onShareSuccessed(share_media)
// callBack = null
// }
//
// override fun onError(share_media: SHARE_MEDIA, throwable: Throwable) {
// LogUtil.e("ydl", "分享出错------" + throwable.message)
// try {
// var message = handleMessage(throwable.message!!)
// ToastUtil.toastShort("分享失败," + message)
// } catch (e: Exception) {
// ToastUtil.toastShort("分享错误")
// }
// callBack?.onShareFailed(share_media, throwable)
// callBack = null
// }
//
// override fun onCancel(share_media: SHARE_MEDIA) {
// LogUtil.e("ydl", "分享取消------")
// }
// })
// .open(config)
// }
//
// }
//
//
// /**
// * 强制处理分享失败消息
// */
// fun handleMessage(msg: String): String {
// var index = msg.indexOf("错误信息")
// var message = msg.substring(index, msg!!.length)
// var lastIndex = message.indexOf(" ")
// message = message.substring(0, lastIndex)
// return message
// }
//}
//
////
///**
// *
// */
//class ShareMoreBean(var imageResId: Int, var actionName: String, //扩展按钮动作
// var shareMoreAction: ShareMoreAction?)
//
////分享动作
//interface ShareMoreAction {
// fun onClick()
//}
//
//interface ShareActionCallBack {
// fun onShareSuccessed(share_media: SHARE_MEDIA)
// fun onShareFailed(share_media: SHARE_MEDIA, throwable: Throwable)
//}
ydl-platform/src/main/java/com/ydl/ydlcommon/view/dialog/CustomShareDialog.kt
View file @
9e69e5db
//package com.ydl.ydlcommon.view.dialog
package
com.ydl.ydlcommon.view.dialog
//
//import android.app.Activity
import
android.app.Activity
//import android.app.Dialog
import
android.app.Dialog
//import android.os.Bundle
import
android.os.Bundle
//import android.view.View
import
android.view.View
//import android.view.ViewGroup
import
android.view.ViewGroup
//import android.widget.AdapterView
import
android.widget.AdapterView
//import android.widget.ImageView
import
android.widget.ImageView
//import com.umeng.socialize.bean.SHARE_MEDIA
import
com.umeng.socialize.bean.SHARE_MEDIA
//import com.ydl.ydlcommon.R
import
com.ydl.ydlcommon.R
//import com.ydl.ydlcommon.actions.share.ShareMoreBean
import
com.ydl.ydlcommon.actions.share.ShareMoreBean
//import com.ydl.ydlcommon.actions.share.ShareUtils
import
com.ydl.ydlcommon.actions.share.ShareUtils
//import com.ydl.ydlcommon.adapter.CommonAdapter
import
com.ydl.ydlcommon.adapter.CommonAdapter
//import com.ydl.ydlcommon.view.BaseViewHolder
import
com.ydl.ydlcommon.view.BaseViewHolder
//import kotlinx.android.synthetic.main.platform_share_custom_ui.*
import
kotlinx.android.synthetic.main.platform_share_custom_ui.*
//
///**
/**
// * 自定义分享Dialog
* 自定义分享Dialog
// * Created by hgw on 2017/3/22.
* Created by hgw on 2017/3/22.
// */
*/
//
//class CustomShareDialog(private val context: Activity) : Dialog(context, R.style.platform_transparentFrameWindowStyle), View.OnClickListener {
class
CustomShareDialog
(
private
val
context
:
Activity
)
:
//
Dialog
(
context
,
R
.
style
.
platform_transparentFrameWindowStyle
),
View
.
OnClickListener
{
//
// private var share_title: String? = null
// private var share_url: String? = null
private
var
share_title
:
String
?
=
null
// private var share_context: String? = null
private
var
share_url
:
String
?
=
null
// private var share_head: String? = null
private
var
share_context
:
String
?
=
null
// private var list: List<ShareMoreBean>? = null
private
var
share_head
:
String
?
=
null
//
private
var
list
:
List
<
ShareMoreBean
>?
=
null
// private var adapter: CommonAdapter<ShareMoreBean>? = null
//
private
var
adapter
:
CommonAdapter
<
ShareMoreBean
>?
=
null
// override fun onCreate(savedInstanceState: Bundle?) {
// super.onCreate(savedInstanceState)
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
// setContentView(R.layout.platform_share_custom_ui)
super
.
onCreate
(
savedInstanceState
)
//
setContentView
(
R
.
layout
.
platform_share_custom_ui
)
// initView()
//
initView
()
// val window = window
// // 设置显示动画
val
window
=
window
// window!!.setWindowAnimations(R.style.platform_main_menu_animstyle)
// 设置显示动画
// val wl = window.attributes
window
!!
.
setWindowAnimations
(
R
.
style
.
platform_main_menu_animstyle
)
// wl.x = 0
val
wl
=
window
.
attributes
// wl.y = context.windowManager.defaultDisplay.height
wl
.
x
=
0
// // 以下这两句是为了保证按钮可以水平满屏
wl
.
y
=
context
.
windowManager
.
defaultDisplay
.
height
// wl.width = ViewGroup.LayoutParams.MATCH_PARENT
// 以下这两句是为了保证按钮可以水平满屏
// wl.height = ViewGroup.LayoutParams.WRAP_CONTENT
wl
.
width
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
//
wl
.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
// // 设置显示位置
// onWindowAttributesChanged(wl)
// 设置显示位置
// // 设置点击外围解散
onWindowAttributesChanged
(
wl
)
// setCanceledOnTouchOutside(true)
// 设置点击外围解散
// }
setCanceledOnTouchOutside
(
true
)
//
}
// private fun initView() {
//
private
fun
initView
()
{
// share_weichat.setOnClickListener(this)
// share_pyq.setOnClickListener(this)
share_weichat
.
setOnClickListener
(
this
)
// share_qqzone.setOnClickListener(this)
share_pyq
.
setOnClickListener
(
this
)
// share_qq.setOnClickListener(this)
share_qqzone
.
setOnClickListener
(
this
)
//
share_qq
.
setOnClickListener
(
this
)
//
// if (list == null || list!!.isEmpty()) {
// grid_view!!.visibility = View.GONE
if
(
list
==
null
||
list
!!
.
isEmpty
())
{
// return
grid_view
!!
.
visibility
=
View
.
GONE
// } else {
return
// grid_view!!.visibility = View.VISIBLE
}
else
{
// }
grid_view
!!
.
visibility
=
View
.
VISIBLE
// adapter = object : CommonAdapter<ShareMoreBean>() {
}
// override fun getView(position: Int, convertView1: View?, parent: ViewGroup): View {
adapter
=
object
:
CommonAdapter
<
ShareMoreBean
>()
{
// var convertView = convertView1
override
fun
getView
(
position
:
Int
,
convertView1
:
View
?,
parent
:
ViewGroup
):
View
{
// val holder: BaseViewHolder
var
convertView
=
convertView1
// if (convertView == null) {
val
holder
:
BaseViewHolder
// convertView = layoutInflater.inflate(R.layout.platform_item_custom_share_ui, null)
if
(
convertView
==
null
)
{
// holder = BaseViewHolder(convertView)
convertView
=
// convertView!!.tag = holder
layoutInflater
.
inflate
(
R
.
layout
.
platform_item_custom_share_ui
,
null
)
// } else {
holder
=
BaseViewHolder
(
convertView
)
// holder = convertView.tag as BaseViewHolder
convertView
!!
.
tag
=
holder
// }
}
else
{
// val imageView = holder.getView<ImageView>(R.id.share_img)
holder
=
convertView
.
tag
as
BaseViewHolder
// //加载图标
}
// imageView.setImageResource(mDataList[position].imageResId)
val
imageView
=
holder
.
getView
<
ImageView
>(
R
.
id
.
share_img
)
// //设置title
//加载图标
// holder.setText(R.id.text_title, mDataList[position].actionName)
imageView
.
setImageResource
(
mDataList
[
position
].
imageResId
)
// return convertView
//设置title
// }
holder
.
setText
(
R
.
id
.
text_title
,
mDataList
[
position
].
actionName
)
// }
return
convertView
// grid_view!!.adapter = adapter
}
// grid_view!!.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ ->
}
// val action = adapter!!.dataList[position].shareMoreAction
grid_view
!!
.
adapter
=
adapter
// action?.onClick()
grid_view
!!
.
onItemClickListener
=
AdapterView
.
OnItemClickListener
{
_
,
_
,
position
,
_
->
// dismiss()
val
action
=
adapter
!!
.
dataList
[
position
].
shareMoreAction
// }
action
?.
onClick
()
// adapter!!.update(list)
dismiss
()
// }
}
//
adapter
!!
.
update
(
list
)
// //设置分享内容
}
// fun setShareBody(share_title: String, share_url: String, share_context: String, share_head: String) {
// this.share_title = share_title
//设置分享内容
// this.share_url = share_url
fun
setShareBody
(
// this.share_context = share_context
share_title
:
String
,
// this.share_head = share_head
share_url
:
String
,
// }
share_context
:
String
,
//
share_head
:
String
// //添加扩展按钮
)
{
// fun addActions(list1: List<ShareMoreBean>) {
this
.
share_title
=
share_title
// this.list = list1
this
.
share_url
=
share_url
// }
this
.
share_context
=
share_context
//
this
.
share_head
=
share_head
// override fun onClick(v: View) {
}
// when (v.id) {
// R.id.share_weichat -> {
//添加扩展按钮
// ShareUtils.shareTo(SHARE_MEDIA.WEIXIN, context, share_title!!, share_url!!, share_context!!, share_head)
fun
addActions
(
list1
:
List
<
ShareMoreBean
>)
{
// dismiss()
this
.
list
=
list1
// }
}
// R.id.share_pyq -> {
// ShareUtils.shareTo(SHARE_MEDIA.WEIXIN_CIRCLE, context, share_title!!, share_url!!, share_context!!, share_head)
override
fun
onClick
(
v
:
View
)
{
// dismiss()
when
(
v
.
id
)
{
// }
R
.
id
.
share_weichat
->
{
// R.id.share_qq -> {
ShareUtils
.
shareTo
(
// ShareUtils.shareTo(SHARE_MEDIA.QQ, context, share_title!!, share_url!!, share_context!!, share_head)
SHARE_MEDIA
.
WEIXIN
,
// dismiss()
context
,
// }
share_title
!!
,
// R.id.share_qqzone -> {
share_url
!!
,
// ShareUtils.shareTo(SHARE_MEDIA.QZONE, context, share_title!!, share_url!!, share_context!!, share_head)
share_context
!!
,
// dismiss()
share_head
// }
)
// }
dismiss
()
// }
}
//
R
.
id
.
share_pyq
->
{
// override fun show() {
ShareUtils
.
shareTo
(
// if (null == context) {
SHARE_MEDIA
.
WEIXIN_CIRCLE
,
// return
context
,
// }
share_title
!!
,
// if (context is Activity) {
share_url
!!
,
// if (context.isFinishing) {
share_context
!!
,
// return
share_head
// }
)
// }
dismiss
()
// super.show()
}
// }
R
.
id
.
share_qq
->
{
//}
ShareUtils
.
shareTo
(
//
SHARE_MEDIA
.
QQ
,
context
,
share_title
!!
,
share_url
!!
,
share_context
!!
,
share_head
)
dismiss
()
}
R
.
id
.
share_qqzone
->
{
ShareUtils
.
shareTo
(
SHARE_MEDIA
.
QZONE
,
context
,
share_title
!!
,
share_url
!!
,
share_context
!!
,
share_head
)
dismiss
()
}
}
}
override
fun
show
()
{
if
(
null
==
context
)
{
return
}
if
(
context
is
Activity
)
{
if
(
context
.
isFinishing
)
{
return
}
}
super
.
show
()
}
}
ydl-platform/src/main/java/com/ydl/ydlcommon/view/dialog/YDLShareDialog.kt
View file @
9e69e5db
//package com.ydl.ydlcommon.view.dialog
package
com.ydl.ydlcommon.view.dialog
//
//import android.annotation.SuppressLint
import
android.annotation.SuppressLint
//import android.app.Activity
import
android.app.Activity
//import android.app.DialogFragment
import
android.app.DialogFragment
//import android.graphics.drawable.ColorDrawable
import
android.graphics.drawable.ColorDrawable
//import android.os.Bundle
import
android.os.Bundle
//import android.text.TextUtils
import
android.text.TextUtils
//import android.util.Base64
import
android.util.Base64
//import android.view.*
import
android.view.*
//import android.widget.LinearLayout
import
android.widget.LinearLayout
//import com.bumptech.glide.load.engine.DiskCacheStrategy
import
com.bumptech.glide.load.engine.DiskCacheStrategy
//import com.umeng.socialize.bean.SHARE_MEDIA
import
com.umeng.socialize.bean.SHARE_MEDIA
//import com.ydl.ydl_image.module.GlideApp
import
com.ydl.ydl_image.module.GlideApp
//import com.ydl.ydlcommon.R
import
com.ydl.ydlcommon.R
//import com.ydl.ydlcommon.actions.share.ShareActionCallBack
import
com.ydl.ydlcommon.actions.share.ShareActionCallBack
//import com.ydl.ydlcommon.actions.share.ShareUtils
import
com.ydl.ydlcommon.actions.share.ShareUtils
//import com.ydl.ydlcommon.utils.ImageUtil
import
com.ydl.ydlcommon.utils.ImageUtil
//import com.ydl.ydlcommon.utils.ScreenUtil
import
com.ydl.ydlcommon.utils.ScreenUtil
//import com.yidianling.common.tools.RxImageTool
import
com.yidianling.common.tools.RxImageTool
//import kotlinx.android.synthetic.main.platform_dialog_share.*
import
kotlinx.android.synthetic.main.platform_dialog_share.*
//import java.util.concurrent.Executors
import
java.util.concurrent.Executors
//
//
///**
/**
// * @author yuanWai
* @author yuanWai
// * @描述:分享弹窗
* @描述:分享弹窗
// * @Copyright Copyright (c) 2018
* @Copyright Copyright (c) 2018
// * @Company 壹点灵
* @Company 壹点灵
// * @date 2019/2/19
* @date 2019/2/19
// */
*/
//class YDLShareDialog : DialogFragment {
class
YDLShareDialog
:
DialogFragment
{
//
// private var mActivity: Activity? = null
private
var
mActivity
:
Activity
?
=
null
// private var shareTitle: String? = null
private
var
shareTitle
:
String
?
=
null
// private var shareUrl: String? = null
private
var
shareUrl
:
String
?
=
null
// private var shareContent: String? = null
private
var
shareContent
:
String
?
=
null
// private var base64DataStr: String? = null
private
var
base64DataStr
:
String
?
=
null
// private var shareHead: String? = null
private
var
shareHead
:
String
?
=
null
// private var mCallback: ICallBack? = null
private
var
mCallback
:
ICallBack
?
=
null
// private var mShareCallBack: IShareCallBack? = null
private
var
mShareCallBack
:
IShareCallBack
?
=
null
//
// //小程序页面地址
//小程序页面地址
// private var path: String? = null
private
var
path
:
String
?
=
null
// //小程序id
// private var minProgramId: String? = null
//小程序id
//
private
var
minProgramId
:
String
?
=
null
// private var dp55 = 0
// private var dp7 = 0
private
var
dp55
=
0
// private var llmargin = 0
private
var
dp7
=
0
//
private
var
llmargin
=
0
// @SuppressLint("ValidFragment")
// constructor(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?) : super() {
@SuppressLint
(
"ValidFragment"
)
// this.mActivity = activity
constructor
(
// this.shareTitle = shareTitle
activity
:
Activity
,
// this.shareUrl = shareUrl
shareTitle
:
String
?,
// this.shareContent = shareContent
shareUrl
:
String
?,
// this.shareHead = shareHead
shareContent
:
String
?,
// }
shareHead
:
String
?
//
)
:
super
()
{
// //传递小程序参数
this
.
mActivity
=
activity
// @SuppressLint("ValidFragment")
this
.
shareTitle
=
shareTitle
// constructor(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?, path: String?, minProgramId: String?) : super() {
this
.
shareUrl
=
shareUrl
// this.mActivity = activity
this
.
shareContent
=
shareContent
// this.shareTitle = shareTitle
this
.
shareHead
=
shareHead
// this.shareUrl = shareUrl
}
// this.shareContent = shareContent
// this.shareHead = shareHead
//传递小程序参数
// this.path = path
@SuppressLint
(
"ValidFragment"
)
// this.minProgramId = minProgramId
constructor
(
// }
activity
:
Activity
,
//
shareTitle
:
String
?,
// constructor() : super() {}
shareUrl
:
String
?,
//
shareContent
:
String
?,
// init {
shareHead
:
String
?,
// dp55 = RxImageTool.dip2px(55f)
path
:
String
?,
// llmargin = (ScreenUtil.screenWidth - RxImageTool.dip2px(260f)) / 3
minProgramId
:
String
?
// dp7 = RxImageTool.dip2px(7.5f)
)
:
super
()
{
// }
this
.
mActivity
=
activity
//
this
.
shareTitle
=
shareTitle
// companion object {
this
.
shareUrl
=
shareUrl
// var typeStyle: Int = 0
this
.
shareContent
=
shareContent
// /**
this
.
shareHead
=
shareHead
// * 1.为显示1排(5个) 2.为显示2排(隐藏动态和举报)3.为显示2排(隐藏动态和删除) 4.为显示1排(4个)隐藏动态按钮 5:生成海报按钮、隐藏动态 6:保存海报按钮、隐藏动态 7.为显示1排(4个)隐藏动态按钮
this
.
path
=
path
// */
this
.
minProgramId
=
minProgramId
// const val TYPE1 = 1
}
// const val TYPE2 = 2
// const val TYPE3 = 3
constructor
()
:
super
()
{}
// const val TYPE4 = 4
// const val TYPE5 = 5
init
{
// const val TYPE6 = 6
dp55
=
RxImageTool
.
dip2px
(
55f
)
// const val TYPE7 = 7
llmargin
=
(
ScreenUtil
.
screenWidth
-
RxImageTool
.
dip2px
(
260f
))
/
3
// /**
dp7
=
RxImageTool
.
dip2px
(
7.5f
)
// * 点击事件类型 1.动态 2.删除 3.举报 4.返回首页 5:生成海报 6:保存本地 7:分享纯图片
}
// */
// const val CLICK_DYNAMIC = 1
companion
object
{
// const val CLICK_DELETE = 2
var
typeStyle
:
Int
=
0
// const val CLICK_REPORT = 3
// const val CLICK_BACKHOME = 4
/**
// const val CLICK_POSTER = 5
* 1.为显示1排(5个) 2.为显示2排(隐藏动态和举报)3.为显示2排(隐藏动态和删除) 4.为显示1排(4个)隐藏动态按钮 5:生成海报按钮、隐藏动态 6:保存海报按钮、隐藏动态 7.为显示1排(4个)隐藏动态按钮
// const val CLICK_SAVE = 6
*/
// const val CLICK_SHARE_IMAGE = 7
const
val
TYPE1
=
1
//
const
val
TYPE2
=
2
// fun style1(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?): YDLShareDialog {
const
val
TYPE3
=
3
// typeStyle = TYPE1
const
val
TYPE4
=
4
// return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead)
const
val
TYPE5
=
5
// }
const
val
TYPE6
=
6
//
const
val
TYPE7
=
7
// //支持分享小程序
// fun style1(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?, minProgramPath: String? = "", minProgramId: String? = ""): YDLShareDialog {
/**
// typeStyle = TYPE1
* 点击事件类型 1.动态 2.删除 3.举报 4.返回首页 5:生成海报 6:保存本地 7:分享纯图片
// return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead, minProgramPath, minProgramId)
*/
// }
const
val
CLICK_DYNAMIC
=
1
//
const
val
CLICK_DELETE
=
2
// fun style2(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?): YDLShareDialog {
const
val
CLICK_REPORT
=
3
// typeStyle = TYPE2
const
val
CLICK_BACKHOME
=
4
// return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead)
const
val
CLICK_POSTER
=
5
// }
const
val
CLICK_SAVE
=
6
//
const
val
CLICK_SHARE_IMAGE
=
7
// fun style3(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?): YDLShareDialog {
// typeStyle = TYPE3
fun
style1
(
// return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead)
activity
:
Activity
,
// }
shareTitle
:
String
?,
//
shareUrl
:
String
?,
// fun style4(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?): YDLShareDialog {
shareContent
:
String
?,
// typeStyle = TYPE4
shareHead
:
String
?
// return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead)
):
YDLShareDialog
{
// }
typeStyle
=
TYPE1
//
return
YDLShareDialog
(
activity
,
shareTitle
,
shareUrl
,
shareContent
,
shareHead
)
// fun style5(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?): YDLShareDialog {
}
// typeStyle = TYPE5
// return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead)
//支持分享小程序
// }
fun
style1
(
//
activity
:
Activity
,
// fun style6(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?): YDLShareDialog {
shareTitle
:
String
?,
// typeStyle = TYPE6
shareUrl
:
String
?,
// return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead)
shareContent
:
String
?,
// }
shareHead
:
String
?,
//
minProgramPath
:
String
?
=
""
,
// //支持分享小程序
minProgramId
:
String
?
=
""
// fun style7(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?, minProgramPath: String? = "", minProgramId: String? = ""): YDLShareDialog {
):
YDLShareDialog
{
// typeStyle = TYPE7
typeStyle
=
TYPE1
// return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead, minProgramPath, minProgramId)
return
YDLShareDialog
(
// }
activity
,
// }
shareTitle
,
//
shareUrl
,
// override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View {
shareContent
,
// //去掉dialog的标题,需要在setContentView()之前
shareHead
,
// this.dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
minProgramPath
,
// val window = this.dialog.window
minProgramId
// //去掉dialog默认的padding
)
// window!!.decorView.setPadding(0, 0, 0, 0)
}
// val lp = window.attributes
// lp.width = WindowManager.LayoutParams.MATCH_PARENT
fun
style2
(
// lp.height = WindowManager.LayoutParams.WRAP_CONTENT
activity
:
Activity
,
// //设置dialog的位置在底部
shareTitle
:
String
?,
// lp.gravity = Gravity.BOTTOM
shareUrl
:
String
?,
// //设置dialog的动画
shareContent
:
String
?,
// lp.windowAnimations = R.style.platform_BottomDialogAnimation
shareHead
:
String
?
// window.attributes = lp
):
YDLShareDialog
{
// window.setBackgroundDrawable(ColorDrawable())
typeStyle
=
TYPE2
// return inflater!!.inflate(R.layout.platform_dialog_share, null)
return
YDLShareDialog
(
activity
,
shareTitle
,
shareUrl
,
shareContent
,
shareHead
)
// }
}
//
//
fun
style3
(
// /**
activity
:
Activity
,
// * 设置咨询师海报的图片
shareTitle
:
String
?,
// * @param base64DataStr base64数据
shareUrl
:
String
?,
// */
shareContent
:
String
?,
// fun setPosterPicture(base64DataStr: String) {
shareHead
:
String
?
// this.base64DataStr = base64DataStr
):
YDLShareDialog
{
// }
typeStyle
=
TYPE3
//
return
YDLShareDialog
(
activity
,
shareTitle
,
shareUrl
,
shareContent
,
shareHead
)
// override fun onResume() {
}
// super.onResume()
// initView()
fun
style4
(
// initParams()
activity
:
Activity
,
// }
shareTitle
:
String
?,
//
shareUrl
:
String
?,
// /**
shareContent
:
String
?,
// * 初始化样式
shareHead
:
String
?
// */
):
YDLShareDialog
{
// private fun initParams() {
typeStyle
=
TYPE4
// when (typeStyle) {
return
YDLShareDialog
(
activity
,
shareTitle
,
shareUrl
,
shareContent
,
shareHead
)
// TYPE1 -> {
}
// //样式1
// ll_layout2.visibility = View.GONE
fun
style5
(
// }
activity
:
Activity
,
// TYPE2 -> {
shareTitle
:
String
?,
// //样式2
shareUrl
:
String
?,
// ll_dynamic.visibility = View.GONE
shareContent
:
String
?,
// ll_report.visibility = View.GONE
shareHead
:
String
?
// setStyle()
):
YDLShareDialog
{
// val deleteParams = LinearLayout.LayoutParams(dp55, ViewGroup.LayoutParams.WRAP_CONTENT)
typeStyle
=
TYPE5
// deleteParams.setMargins(dp7, 0, llmargin, 0)
return
YDLShareDialog
(
activity
,
shareTitle
,
shareUrl
,
shareContent
,
shareHead
)
// deleteParams.weight = 0f
}
// ll_delete.layoutParams = deleteParams
// }
fun
style6
(
// TYPE3 -> {
activity
:
Activity
,
// //样式3
shareTitle
:
String
?,
// ll_dynamic.visibility = View.GONE
shareUrl
:
String
?,
// ll_delete.visibility = View.GONE
shareContent
:
String
?,
// setStyle()
shareHead
:
String
?
// val reportParams = LinearLayout.LayoutParams(dp55, ViewGroup.LayoutParams.WRAP_CONTENT)
):
YDLShareDialog
{
// reportParams.setMargins(dp7, 0, llmargin, 0)
typeStyle
=
TYPE6
// reportParams.weight = 0f
return
YDLShareDialog
(
activity
,
shareTitle
,
shareUrl
,
shareContent
,
shareHead
)
// ll_report.layoutParams = reportParams
}
// }
// TYPE4 -> {
//支持分享小程序
// //样式4
fun
style7
(
// ll_dynamic.visibility = View.GONE
activity
:
Activity
,
// ll_layout2.visibility = View.GONE
shareTitle
:
String
?,
// setStyle()
shareUrl
:
String
?,
// }
shareContent
:
String
?,
// TYPE5 -> {
shareHead
:
String
?,
// //样式5
minProgramPath
:
String
?
=
""
,
// ll_dynamic.visibility = View.GONE
minProgramId
:
String
?
=
""
// ll_poster.visibility = View.VISIBLE
):
YDLShareDialog
{
// ll_layout2.visibility = View.GONE
typeStyle
=
TYPE7
// }
return
YDLShareDialog
(
// TYPE6 -> {
activity
,
// //样式6
shareTitle
,
// ll_dynamic.visibility = View.GONE
shareUrl
,
// ll_save.visibility = View.VISIBLE
shareContent
,
// ll_layout2.visibility = View.GONE
shareHead
,
// }
minProgramPath
,
// TYPE7 -> {
minProgramId
// //样式7
)
// ll_layout2.visibility = View.GONE
}
// ll_dynamic.visibility = View.GONE
}
// }
// }
override
fun
onCreateView
(
//
inflater
:
LayoutInflater
?,
// showPictureView()
container
:
ViewGroup
?,
// }
savedInstanceState
:
Bundle
?
//
):
View
{
//
//去掉dialog的标题,需要在setContentView()之前
// private fun showPictureView() {
this
.
dialog
.
requestWindowFeature
(
Window
.
FEATURE_NO_TITLE
)
// if (TextUtils.isEmpty(base64DataStr)) {
val
window
=
this
.
dialog
.
window
// return
//去掉dialog默认的padding
// }
window
!!
.
decorView
.
setPadding
(
0
,
0
,
0
,
0
)
// cv_pic.visibility = View.VISIBLE
val
lp
=
window
.
attributes
//
lp
.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
// Executors.newCachedThreadPool().execute {
lp
.
height
=
WindowManager
.
LayoutParams
.
WRAP_CONTENT
// var imageByte = Base64.decode(base64DataStr, Base64.DEFAULT)
//设置dialog的位置在底部
// mActivity!!.runOnUiThread {
lp
.
gravity
=
Gravity
.
BOTTOM
// GlideApp.with(this)
//设置dialog的动画
// .load(imageByte)
lp
.
windowAnimations
=
R
.
style
.
platform_BottomDialogAnimation
// .diskCacheStrategy(DiskCacheStrategy.NONE)
window
.
attributes
=
lp
// .into(img_pic)
window
.
setBackgroundDrawable
(
ColorDrawable
())
// }
return
inflater
!!
.
inflate
(
R
.
layout
.
platform_dialog_share
,
null
)
// }
}
//
// tv_save_pic.setOnClickListener {
// ImageUtil.savePicture(mActivity, base64DataStr)
/**
// }
* 设置咨询师海报的图片
// }
* @param base64DataStr base64数据
//
*/
// private fun setStyle() {
fun
setPosterPicture
(
base64DataStr
:
String
)
{
// val weixinParams = LinearLayout.LayoutParams(dp55, ViewGroup.LayoutParams.WRAP_CONTENT)
this
.
base64DataStr
=
base64DataStr
// weixinParams.setMargins(dp7, 0, 0, 0)
}
// weixinParams.weight = 0f
// ll_weixin.layoutParams = weixinParams
override
fun
onResume
()
{
//
super
.
onResume
()
// val friendsParams = LinearLayout.LayoutParams(dp55, ViewGroup.LayoutParams.WRAP_CONTENT)
initView
()
// friendsParams.setMargins(llmargin, 0, 0, 0)
initParams
()
// friendsParams.weight = 0f
}
// ll_friends.layoutParams = friendsParams
//
/**
// val qqzoneParams = LinearLayout.LayoutParams(dp55, ViewGroup.LayoutParams.WRAP_CONTENT)
* 初始化样式
// qqzoneParams.setMargins(llmargin, 0, 0, 0)
*/
// qqzoneParams.weight = 0f
private
fun
initParams
()
{
// ll_qqzone.layoutParams = qqzoneParams
when
(
typeStyle
)
{
//
TYPE1
->
{
// val qqParams = LinearLayout.LayoutParams(dp55, ViewGroup.LayoutParams.WRAP_CONTENT)
//样式1
// qqParams.setMargins(llmargin, 0, dp7, 0)
ll_layout2
.
visibility
=
View
.
GONE
// qqParams.weight = 0f
}
// ll_qq.layoutParams = qqParams
TYPE2
->
{
// ll_layout.invalidate()
//样式2
//
ll_dynamic
.
visibility
=
View
.
GONE
// val backhomeParams = LinearLayout.LayoutParams(dp55, ViewGroup.LayoutParams.WRAP_CONTENT)
ll_report
.
visibility
=
View
.
GONE
// backhomeParams.setMargins(0, 0, 0, 0)
setStyle
()
// backhomeParams.weight = 0f
val
deleteParams
=
// ll_backhome.layoutParams = backhomeParams
LinearLayout
.
LayoutParams
(
dp55
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
// }
deleteParams
.
setMargins
(
dp7
,
0
,
llmargin
,
0
)
//
deleteParams
.
weight
=
0f
// fun setCallBack(callback: ICallBack) {
ll_delete
.
layoutParams
=
deleteParams
// this.mCallback = callback
}
// }
TYPE3
->
{
//
//样式3
// fun setShareCallBack(callBack: IShareCallBack) {
ll_dynamic
.
visibility
=
View
.
GONE
// this.mShareCallBack = callBack
ll_delete
.
visibility
=
View
.
GONE
// }
setStyle
()
//
val
reportParams
=
// private fun initView() {
LinearLayout
.
LayoutParams
(
dp55
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
// ll_poster.setOnClickListener {
reportParams
.
setMargins
(
dp7
,
0
,
llmargin
,
0
)
// //生成海报
reportParams
.
weight
=
0f
// mCallback?.callBack(CLICK_POSTER)
ll_report
.
layoutParams
=
reportParams
// dismiss()
}
// }
TYPE4
->
{
//
//样式4
// ll_save.setOnClickListener {
ll_dynamic
.
visibility
=
View
.
GONE
// //保存本地
ll_layout2
.
visibility
=
View
.
GONE
// mCallback?.callBack(CLICK_SAVE)
setStyle
()
// dismiss()
}
// }
TYPE5
->
{
// ll_dynamic.setOnClickListener {
//样式5
// //动态
ll_dynamic
.
visibility
=
View
.
GONE
// mCallback?.callBack(CLICK_DYNAMIC)
ll_poster
.
visibility
=
View
.
VISIBLE
// dismiss()
ll_layout2
.
visibility
=
View
.
GONE
// }
}
// ll_weixin.setOnClickListener {
TYPE6
->
{
// //分享海报到微信:直接分享图片到微信
//样式6
// if (typeStyle == TYPE6) {
ll_dynamic
.
visibility
=
View
.
GONE
// ShareUtils.platform = SHARE_MEDIA.WEIXIN
ll_save
.
visibility
=
View
.
VISIBLE
// mCallback?.callBack(CLICK_SHARE_IMAGE)
ll_layout2
.
visibility
=
View
.
GONE
// } else {
}
// //微信
TYPE7
->
{
// if (TextUtils.isEmpty(minProgramId)) {
//样式7
// share(SHARE_MEDIA.WEIXIN)
ll_layout2
.
visibility
=
View
.
GONE
// } else {
ll_dynamic
.
visibility
=
View
.
GONE
// shareMinWeixin()
}
// }
}
// }
// }
showPictureView
()
// ll_friends.setOnClickListener {
}
// //分享海报到微信朋友圈:直接分享图片到微信朋友圈
// if (typeStyle == TYPE6) {
// ShareUtils.platform = SHARE_MEDIA.WEIXIN_CIRCLE
private
fun
showPictureView
()
{
// mCallback?.callBack(CLICK_SHARE_IMAGE)
if
(
TextUtils
.
isEmpty
(
base64DataStr
))
{
// } else {
return
// //微信朋友圈
}
// share(SHARE_MEDIA.WEIXIN_CIRCLE)
cv_pic
.
visibility
=
View
.
VISIBLE
// }
// }
Executors
.
newCachedThreadPool
().
execute
{
// ll_qqzone.setOnClickListener {
var
imageByte
=
Base64
.
decode
(
base64DataStr
,
Base64
.
DEFAULT
)
// //分享海报到qq空间:直接分享图片到qq空间
mActivity
!!
.
runOnUiThread
{
// if (typeStyle == TYPE6) {
GlideApp
.
with
(
this
)
// ShareUtils.platform = SHARE_MEDIA.QZONE
.
load
(
imageByte
)
// mCallback?.callBack(CLICK_SHARE_IMAGE)
.
diskCacheStrategy
(
DiskCacheStrategy
.
NONE
)
// } else {
.
into
(
img_pic
)
// //qq空间
}
// share(SHARE_MEDIA.QZONE)
}
// }
// }
tv_save_pic
.
setOnClickListener
{
// ll_qq.setOnClickListener {
ImageUtil
.
savePicture
(
mActivity
,
base64DataStr
)
// //分享海报到qq:直接分享图片到qq
}
// if (typeStyle == TYPE6) {
}
// ShareUtils.platform = SHARE_MEDIA.QQ
// mCallback?.callBack(CLICK_SHARE_IMAGE)
private
fun
setStyle
()
{
// } else {
val
weixinParams
=
LinearLayout
.
LayoutParams
(
dp55
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
// //qq
weixinParams
.
setMargins
(
dp7
,
0
,
0
,
0
)
// share(SHARE_MEDIA.QQ)
weixinParams
.
weight
=
0f
// }
ll_weixin
.
layoutParams
=
weixinParams
// }
// if (TYPE2 == typeStyle || TYPE3 == typeStyle) {
val
friendsParams
=
LinearLayout
.
LayoutParams
(
dp55
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
// ll_delete.setOnClickListener {
friendsParams
.
setMargins
(
llmargin
,
0
,
0
,
0
)
// //删除
friendsParams
.
weight
=
0f
// mCallback?.callBack(CLICK_DELETE)
ll_friends
.
layoutParams
=
friendsParams
// dismiss()
// }
val
qqzoneParams
=
LinearLayout
.
LayoutParams
(
dp55
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
// ll_report.setOnClickListener {
qqzoneParams
.
setMargins
(
llmargin
,
0
,
0
,
0
)
// //举报
qqzoneParams
.
weight
=
0f
// mCallback?.callBack(CLICK_REPORT)
ll_qqzone
.
layoutParams
=
qqzoneParams
// dismiss()
// }
val
qqParams
=
LinearLayout
.
LayoutParams
(
dp55
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
// ll_backhome.setOnClickListener {
qqParams
.
setMargins
(
llmargin
,
0
,
dp7
,
0
)
// //返回首页
qqParams
.
weight
=
0f
// mCallback?.callBack(CLICK_BACKHOME)
ll_qq
.
layoutParams
=
qqParams
// dismiss()
ll_layout
.
invalidate
()
// }
// }
val
backhomeParams
=
LinearLayout
.
LayoutParams
(
dp55
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
// tv_cancel.setOnClickListener {
backhomeParams
.
setMargins
(
0
,
0
,
0
,
0
)
// //取消
backhomeParams
.
weight
=
0f
// dismiss()
ll_backhome
.
layoutParams
=
backhomeParams
// }
}
// rl_root.setOnClickListener {
// //取消
fun
setCallBack
(
callback
:
ICallBack
)
{
// dismiss()
this
.
mCallback
=
callback
// }
}
// }
//
fun
setShareCallBack
(
callBack
:
IShareCallBack
)
{
// private fun share(platform: SHARE_MEDIA) {
this
.
mShareCallBack
=
callBack
// ShareUtils.shareTo(platform, mActivity!!, shareTitle!!, shareUrl!!, shareContent, shareHead)
}
// ShareUtils.callBack = object : ShareActionCallBack {
// override fun onShareSuccessed(share_media: SHARE_MEDIA) {
private
fun
initView
()
{
// mShareCallBack?.onShareSuccessed(share_media)
ll_poster
.
setOnClickListener
{
// }
//生成海报
//
mCallback
?.
callBack
(
CLICK_POSTER
)
// override fun onShareFailed(share_media: SHARE_MEDIA, throwable: Throwable) {
dismiss
()
// mShareCallBack?.onShareFailed(share_media, throwable)
}
// }
// }
ll_save
.
setOnClickListener
{
// dismiss()
//保存本地
// }
mCallback
?.
callBack
(
CLICK_SAVE
)
//
dismiss
()
// /**
}
// * 分享小程序
ll_dynamic
.
setOnClickListener
{
// */
//动态
// private fun shareMinWeixin() {
mCallback
?.
callBack
(
CLICK_DYNAMIC
)
// //分享小程序到微信
dismiss
()
// ShareUtils.shareSmailWeixin(mActivity!!, shareTitle!!, shareUrl!!, shareContent, shareHead, path, minProgramId, null)
}
// dismiss()
ll_weixin
.
setOnClickListener
{
// }
//分享海报到微信:直接分享图片到微信
//
if
(
typeStyle
==
TYPE6
)
{
// interface ICallBack {
ShareUtils
.
platform
=
SHARE_MEDIA
.
WEIXIN
// fun callBack(type: Int)
mCallback
?.
callBack
(
CLICK_SHARE_IMAGE
)
// }
}
else
{
//
//微信
// interface IShareCallBack {
if
(
TextUtils
.
isEmpty
(
minProgramId
))
{
// fun onShareSuccessed(share_media: SHARE_MEDIA)
share
(
SHARE_MEDIA
.
WEIXIN
)
// fun onShareFailed(share_media: SHARE_MEDIA, throwable: Throwable)
}
else
{
// }
shareMinWeixin
()
//}
}
\ No newline at end of file
}
}
ll_friends
.
setOnClickListener
{
//分享海报到微信朋友圈:直接分享图片到微信朋友圈
if
(
typeStyle
==
TYPE6
)
{
ShareUtils
.
platform
=
SHARE_MEDIA
.
WEIXIN_CIRCLE
mCallback
?.
callBack
(
CLICK_SHARE_IMAGE
)
}
else
{
//微信朋友圈
share
(
SHARE_MEDIA
.
WEIXIN_CIRCLE
)
}
}
ll_qqzone
.
setOnClickListener
{
//分享海报到qq空间:直接分享图片到qq空间
if
(
typeStyle
==
TYPE6
)
{
ShareUtils
.
platform
=
SHARE_MEDIA
.
QZONE
mCallback
?.
callBack
(
CLICK_SHARE_IMAGE
)
}
else
{
//qq空间
share
(
SHARE_MEDIA
.
QZONE
)
}
}
ll_qq
.
setOnClickListener
{
//分享海报到qq:直接分享图片到qq
if
(
typeStyle
==
TYPE6
)
{
ShareUtils
.
platform
=
SHARE_MEDIA
.
QQ
mCallback
?.
callBack
(
CLICK_SHARE_IMAGE
)
}
else
{
//qq
share
(
SHARE_MEDIA
.
QQ
)
}
}
if
(
TYPE2
==
typeStyle
||
TYPE3
==
typeStyle
)
{
ll_delete
.
setOnClickListener
{
//删除
mCallback
?.
callBack
(
CLICK_DELETE
)
dismiss
()
}
ll_report
.
setOnClickListener
{
//举报
mCallback
?.
callBack
(
CLICK_REPORT
)
dismiss
()
}
ll_backhome
.
setOnClickListener
{
//返回首页
mCallback
?.
callBack
(
CLICK_BACKHOME
)
dismiss
()
}
}
tv_cancel
.
setOnClickListener
{
//取消
dismiss
()
}
rl_root
.
setOnClickListener
{
//取消
dismiss
()
}
}
private
fun
share
(
platform
:
SHARE_MEDIA
)
{
ShareUtils
.
shareTo
(
platform
,
mActivity
!!
,
shareTitle
!!
,
shareUrl
!!
,
shareContent
,
shareHead
)
ShareUtils
.
callBack
=
object
:
ShareActionCallBack
{
override
fun
onShareSuccessed
(
share_media
:
SHARE_MEDIA
)
{
mShareCallBack
?.
onShareSuccessed
(
share_media
)
}
override
fun
onShareFailed
(
share_media
:
SHARE_MEDIA
,
throwable
:
Throwable
)
{
mShareCallBack
?.
onShareFailed
(
share_media
,
throwable
)
}
}
dismiss
()
}
/**
* 分享小程序
*/
private
fun
shareMinWeixin
()
{
//分享小程序到微信
ShareUtils
.
shareSmailWeixin
(
mActivity
!!
,
shareTitle
!!
,
shareUrl
!!
,
shareContent
,
shareHead
,
path
,
minProgramId
,
null
)
dismiss
()
}
interface
ICallBack
{
fun
callBack
(
type
:
Int
)
}
interface
IShareCallBack
{
fun
onShareSuccessed
(
share_media
:
SHARE_MEDIA
)
fun
onShareFailed
(
share_media
:
SHARE_MEDIA
,
throwable
:
Throwable
)
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment