Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_goodmoney
Project
Project
Details
Activity
Releases
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
android
android_goodmoney
Commits
1c13d8ef
Commit
1c13d8ef
authored
Dec 01, 2020
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
25089161
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
30 deletions
+50
-30
FriendsFragment.kt
...n/java/com/mints/goodmoney/ui/fragment/FriendsFragment.kt
+19
-20
ShareDialog.kt
...c/main/java/com/mints/goodmoney/ui/widgets/ShareDialog.kt
+3
-5
QRCodeUtil.java
...p/src/main/java/com/mints/goodmoney/utils/QRCodeUtil.java
+26
-3
dialog_share.xml
GoodMoney/app/src/main/res/layout/dialog_share.xml
+2
-2
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/FriendsFragment.kt
View file @
1c13d8ef
...
...
@@ -10,7 +10,6 @@ import androidx.recyclerview.widget.RecyclerView
import
androidx.viewpager.widget.ViewPager
import
cn.sharesdk.framework.Platform
import
cn.sharesdk.framework.ShareSDK
import
cn.sharesdk.wechat.favorite.WechatFavorite
import
cn.sharesdk.wechat.friends.Wechat
import
com.daimajia.androidanimations.library.Techniques
import
com.daimajia.androidanimations.library.YoYo
...
...
@@ -363,25 +362,25 @@ class FriendsFragment : BaseFragment(), FriendsView, OnRefreshListener, View.OnC
R
.
id
.
btn_invite
->
{
// 邀请好友
shareImgDialog
()
//
if (!ps.getBoolean(Constant.FIRST_SHARE_INVITED, false)) {
//
// 第一次邀请提示弹框
//
firstWeChatInvite()
//
} else {
//
val wechatSp = Platform.ShareParams()
//
wechatSp.shareType = Platform.SHARE_WEBPAGE
//
wechatSp.title = Constant.SHARE_TITLE
//
wechatSp.text = Constant.SHARE_CONTENT
//
wechatSp.imageData = ImageUtil.drawableToBitmap(ContextCompat.getDrawable(requireContext(), R.mipmap.ic_launcher))
//
wechatSp.url = Constant.SHARE_URL
//
val wechat = ShareSDK.getPlatform(Wechat.NAME)
//
if (wechat.isClientValid) {
//
// 执行图文分享
//
wechat.share(wechatSp)
//
} else {
//
showToast("请先安装微信")
//
}
//
}
//
shareImgDialog()
if
(!
ps
.
getBoolean
(
Constant
.
FIRST_SHARE_INVITED
,
false
))
{
// 第一次邀请提示弹框
firstWeChatInvite
()
}
else
{
val
wechatSp
=
Platform
.
ShareParams
()
wechatSp
.
shareType
=
Platform
.
SHARE_WEBPAGE
wechatSp
.
title
=
Constant
.
SHARE_TITLE
wechatSp
.
text
=
Constant
.
SHARE_CONTENT
wechatSp
.
imageData
=
ImageUtil
.
drawableToBitmap
(
ContextCompat
.
getDrawable
(
requireContext
(),
R
.
mipmap
.
ic_launcher
))
wechatSp
.
url
=
Constant
.
SHARE_URL
val
wechat
=
ShareSDK
.
getPlatform
(
Wechat
.
NAME
)
if
(
wechat
.
isClientValid
)
{
// 执行图文分享
wechat
.
share
(
wechatSp
)
}
else
{
showToast
(
"请先安装微信"
)
}
}
}
R
.
id
.
tv_right_subtitle
->
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/widgets/ShareDialog.kt
View file @
1c13d8ef
...
...
@@ -3,7 +3,6 @@ package com.mints.goodmoney.ui.widgets
import
android.app.Dialog
import
android.content.Context
import
android.graphics.Bitmap
import
android.graphics.drawable.BitmapDrawable
import
android.view.Gravity
import
android.view.View
import
android.view.WindowManager
...
...
@@ -41,7 +40,7 @@ class ShareDialog(context: Context) :
lp
=
window
!!
.
attributes
lp
.
gravity
=
Gravity
.
BOTTOM
lp
.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
lp
.
height
=
WindowManager
.
LayoutParams
.
MATCH_PAR
ENT
lp
.
height
=
WindowManager
.
LayoutParams
.
WRAP_CONT
ENT
lp
.
windowAnimations
=
R
.
style
.
DialogAnimBottom
// lp.alpha = 1.0f;//透明效果
window
!!
.
attributes
=
lp
...
...
@@ -68,9 +67,8 @@ class ShareDialog(context: Context) :
shareWechat
()
}
val
QRCode
=
QRCodeUtil
.
createQRCode
(
Constant
.
SHARE_URL
,
50
)
// imgQrCode.setImageBitmap(QRCode)
imgQrCode
.
background
=
BitmapDrawable
(
QRCode
)
val
QRCode
=
QRCodeUtil
.
createQRCode
(
Constant
.
SHARE_URL
,
100
)
imgQrCode
.
setImageBitmap
(
QRCode
)
}
private
fun
shareWechat
()
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/utils/QRCodeUtil.java
View file @
1c13d8ef
package
com
.
mints
.
goodmoney
.
utils
;
import
android.graphics.Bitmap
;
import
android.graphics.Matrix
;
import
com.google.zxing.BarcodeFormat
;
import
com.google.zxing.EncodeHintType
;
...
...
@@ -24,7 +25,7 @@ public class QRCodeUtil {
try
{
Hashtable
<
EncodeHintType
,
Object
>
hints
=
new
Hashtable
<>();
hints
.
put
(
EncodeHintType
.
CHARACTER_SET
,
"utf-8"
);
hints
.
put
(
EncodeHintType
.
ERROR_CORRECTION
,
ErrorCorrectionLevel
.
H
);
hints
.
put
(
EncodeHintType
.
ERROR_CORRECTION
,
ErrorCorrectionLevel
.
M
);
hints
.
put
(
EncodeHintType
.
MARGIN
,
1
);
BitMatrix
bitMatrix
=
new
QRCodeWriter
().
encode
(
text
,
BarcodeFormat
.
QR_CODE
,
size
,
size
,
hints
);
...
...
@@ -39,14 +40,36 @@ public class QRCodeUtil {
}
}
Bitmap
bitmap
=
Bitmap
.
createBitmap
(
size
,
size
,
Bitmap
.
Config
.
ARGB_8888
);
Bitmap
.
Config
.
RGB_565
);
bitmap
.
setPixels
(
pixels
,
0
,
size
,
0
,
0
,
size
,
size
);
return
bitmap
;
Bitmap
zoomBitmap
=
zoomBitmap
(
bitmap
,
size
,
size
);
bitmap
.
recycle
();
return
zoomBitmap
;
}
catch
(
WriterException
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
/**
* 图片缩放
*
* @param bitmap 对象
* @param w 要缩放的宽度
* @param h 要缩放的高度
* @return newBmp 新 Bitmap对象
*/
public
static
Bitmap
zoomBitmap
(
Bitmap
bitmap
,
int
w
,
int
h
)
{
int
width
=
bitmap
.
getWidth
();
int
height
=
bitmap
.
getHeight
();
Matrix
matrix
=
new
Matrix
();
float
scaleWidth
=
((
float
)
w
/
width
);
float
scaleHeight
=
((
float
)
h
/
height
);
matrix
.
postScale
(
scaleWidth
,
scaleHeight
);
Bitmap
newBmp
=
Bitmap
.
createBitmap
(
bitmap
,
0
,
0
,
width
,
height
,
matrix
,
true
);
return
newBmp
;
}
}
GoodMoney/app/src/main/res/layout/dialog_share.xml
View file @
1c13d8ef
...
...
@@ -42,12 +42,12 @@
android:textColor=
"@color/main_mints"
/>
<ImageView
android:background=
"@color/main_mints"
android:id=
"@+id/img_qr_code"
android:layout_width=
"60dp"
android:layout_height=
"60dp"
android:layout_below=
"@id/img_share"
android:layout_alignParentEnd=
"true"
android:scaleType=
"fitXY"
/>
android:layout_alignParentEnd=
"true"
/>
</RelativeLayout>
...
...
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