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
b3015b1b
Commit
b3015b1b
authored
Feb 23, 2021
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
来电秀滑动功能
parent
715ac981
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
1202 additions
and
33 deletions
+1202
-33
build.gradle
GoodMoney/app/build.gradle
+3
-0
LayoutManagerGroup.aar
GoodMoney/app/libs/LayoutManagerGroup.aar
+0
-0
AndroidManifest.xml
GoodMoney/app/src/main/AndroidManifest.xml
+3
-0
CsjDrawAdManager.kt
...main/java/com/mints/goodmoney/ad/draw/CsjDrawAdManager.kt
+94
-0
DownloadApkManager.kt
...in/java/com/mints/goodmoney/manager/DownloadApkManager.kt
+4
-2
TtCsjAdManager.java
...main/java/com/mints/goodmoney/manager/TtCsjAdManager.java
+3
-3
DrawVideoBean.java
...ain/java/com/mints/goodmoney/mvp/model/DrawVideoBean.java
+56
-0
KylVideoPresenter.kt
...a/com/mints/goodmoney/mvp/presenters/KylVideoPresenter.kt
+31
-0
KylVideoView.kt
...c/main/java/com/mints/goodmoney/mvp/views/KylVideoView.kt
+4
-1
AwardActivity.kt
...in/java/com/mints/goodmoney/ui/activitys/AwardActivity.kt
+8
-8
DrawNativeVideoActivity.kt
...m/mints/goodmoney/ui/activitys/DrawNativeVideoActivity.kt
+457
-0
KylVideoActivity.kt
...java/com/mints/goodmoney/ui/activitys/KylVideoActivity.kt
+10
-4
DrawVideoAdapter.kt
...n/java/com/mints/goodmoney/ui/adapter/DrawVideoAdapter.kt
+94
-0
KylPageAdapter.kt
...ain/java/com/mints/goodmoney/ui/adapter/KylPageAdapter.kt
+9
-8
KuYinYuePageFragment.kt
...a/com/mints/goodmoney/ui/fragment/KuYinYuePageFragment.kt
+23
-5
MyFragment.kt
...c/main/java/com/mints/goodmoney/ui/fragment/MyFragment.kt
+2
-1
FullScreenVideoView.java
...a/com/mints/goodmoney/ui/widgets/FullScreenVideoView.java
+26
-0
DownloadProgressDialog.kt
...nts/goodmoney/ui/widgets/dialog/DownloadProgressDialog.kt
+0
-1
UIUtils.java
.../app/src/main/java/com/mints/goodmoney/utils/UIUtils.java
+281
-0
Utils.java
...ey/app/src/main/java/com/mints/goodmoney/utils/Utils.java
+2
-0
play_arrow.xml
GoodMoney/app/src/main/res/drawable/play_arrow.xml
+5
-0
activity_draw_native_video.xml
...ey/app/src/main/res/layout/activity_draw_native_video.xml
+54
-0
item_view_pager.xml
GoodMoney/app/src/main/res/layout/item_view_pager.xml
+33
-0
No files found.
GoodMoney/app/build.gradle
View file @
b3015b1b
...
...
@@ -268,6 +268,9 @@ dependencies {
// 快手
implementation
(
name:
'kssdk-ad-3.3.6-publishRelease'
,
ext:
'aar'
)
// draw视频
implementation
(
name:
'LayoutManagerGroup'
,
ext:
'aar'
)
// testImplementation 'junit:junit:4.13'
// androidTestImplementation 'androidx.test.ext:junit:1.1.2'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
...
...
GoodMoney/app/libs/LayoutManagerGroup.aar
0 → 100644
View file @
b3015b1b
File added
GoodMoney/app/src/main/AndroidManifest.xml
View file @
b3015b1b
...
...
@@ -222,6 +222,9 @@
<activity
android:name=
".ui.activitys.TaskCpdActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.DrawNativeVideoActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.KylVideoActivity"
android:configChanges=
"orientation|screenSize|keyboardHidden"
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ad/draw/CsjDrawAdManager.kt
0 → 100644
View file @
b3015b1b
package
com.mints.goodmoney.ad.draw
import
android.app.Activity
import
com.bytedance.sdk.openadsdk.AdSlot
import
com.bytedance.sdk.openadsdk.TTAdNative
import
com.bytedance.sdk.openadsdk.TTNativeExpressAd
import
com.bytedance.sdk.openadsdk.TTRewardVideoAd
import
com.mints.goodmoney.ad.video.BaseVideoAd
import
com.mints.goodmoney.manager.TTNativeExpressManager
import
com.mints.goodmoney.manager.TtCsjAdManager
import
com.mints.goodmoney.utils.LogUtil
import
com.mints.goodmoney.utils.ToastUtil
import
com.mints.goodmoney.utils.UIUtils
import
com.mints.goodmoney.utils.Utils
class
CsjDrawAdManager
private
constructor
(
activity
:
Activity
)
:
BaseVideoAd
(
activity
)
{
companion
object
{
private
var
_inst
:
CsjDrawAdManager
?
=
null
fun
getInstance
(
activity
:
Activity
):
CsjDrawAdManager
?
{
return
if
(
_inst
!=
null
)
{
_inst
}
else
{
_inst
=
CsjDrawAdManager
(
activity
)
_inst
}
}
}
private
var
ttAdNative
:
TTAdNative
?
=
null
private
var
mttRewardVideoAd
:
TTRewardVideoAd
?
=
null
private
var
csjDrawAdListener
:
CsjDrawAdListener
?
=
null
init
{
val
ttNativeExpressManager
=
TTNativeExpressManager
()
ttAdNative
=
ttNativeExpressManager
.
initTTAd
(
false
)
}
fun
loadDrawNativeAd
()
{
//step3:创建广告请求参数AdSlot,具体参数含义参考文档
//step3:创建广告请求参数AdSlot,具体参数含义参考文档
val
expressViewWidth
:
Float
=
UIUtils
.
getScreenWidthDp
(
activity
)
val
expressViewHeight
:
Float
=
UIUtils
.
getHeight
(
activity
)
val
adSlot
=
AdSlot
.
Builder
()
.
setCodeId
(
TtCsjAdManager
.
TT_AD_EXPRESS_DRAW
)
.
setExpressViewAcceptedSize
(
expressViewWidth
,
expressViewHeight
)
.
setAdCount
(
1
)
//请求广告数量为1到3条
.
build
()
mttRewardVideoAd
?.
setRewardAdInteractionListener
(
null
)
//step4:请求广告,对请求回调的广告作渲染处理
ttAdNative
?.
loadExpressDrawFeedAd
(
adSlot
,
object
:
TTAdNative
.
NativeExpressAdListener
{
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
ToastUtil
.
show
(
activity
,
p1
)
LogUtil
.
d
(
p1
)
this
@CsjDrawAdManager
.
csjDrawAdListener
?.
csjDrawAdFail
()
}
override
fun
onNativeExpressAdLoad
(
p0
:
MutableList
<
TTNativeExpressAd
>?)
{
if
(
p0
==
null
||
p0
.
isEmpty
())
{
ToastUtil
.
show
(
activity
,
"未请求到广告"
)
LogUtil
.
d
(
"未请求到广告"
)
return
}
this
@CsjDrawAdManager
.
csjDrawAdListener
?.
csjDrawAdSuccess
(
p0
)
}
})
}
fun
setCsjDrawAdListener
(
csjDrawAdListener
:
CsjDrawAdListener
)
{
this
.
csjDrawAdListener
=
csjDrawAdListener
}
interface
CsjDrawAdListener
{
fun
csjDrawAdFail
()
fun
csjDrawAdSuccess
(
data
:
MutableList
<
TTNativeExpressAd
>?)
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
mttRewardVideoAd
?.
setRewardAdInteractionListener
(
null
)
activity
=
null
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/manager/DownloadApkManager.kt
View file @
b3015b1b
...
...
@@ -108,7 +108,9 @@ object DownloadApkManager {
.
build
()
.
setOnProgressListener
{
progress
->
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
)
{
downloadProgressDialog
?.
setProgress
(
progress
)
activity
!!
.
runOnUiThread
{
downloadProgressDialog
?.
setProgress
(
progress
)
}
}
}
.
start
(
object
:
OnDownloadListener
{
...
...
@@ -126,7 +128,7 @@ object DownloadApkManager {
}
override
fun
onError
(
error
:
Error
)
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
()
)
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
)
{
downloadProgressDialog
?.
dismiss
()
CacheUtil
.
clearAllCache
()
}
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/manager/TtCsjAdManager.java
View file @
b3015b1b
package
com
.
mints
.
goodmoney
.
manager
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
com.bytedance.sdk.openadsdk.TTAdConfig
;
import
com.bytedance.sdk.openadsdk.TTAdConstant
;
import
com.bytedance.sdk.openadsdk.TTAdSdk
;
import
com.mints.goodmoney.BuildConfig
;
import
com.mints.goodmoney.MintsApplication
;
import
com.mints.goodmoney.common.AppConfig
;
import
com.mints.goodmoney.common.Constant
;
import
com.mints.goodmoney.mvp.model.AdcodeBean
;
import
com.mints.goodmoney.mvp.model.UserMsgBean
;
import
com.mints.library.utils.CommonUtils
;
/**
...
...
@@ -59,6 +56,9 @@ public class TtCsjAdManager {
public
static
String
TT_AD_INSERT_LOADING_ID_LIEBAO
=
"945608874"
;
//猎豹游戏加载时
public
static
String
TT_AD_INSERT_LOADING_ID_JULEYUN
=
"945675533"
;
//聚乐云
/*全屏Draw信息流*/
public
static
String
TT_AD_EXPRESS_DRAW
=
"945858858"
;
//讯飞信息流
private
static
boolean
sInit
;
public
static
com
.
bytedance
.
sdk
.
openadsdk
.
TTAdManager
get
()
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/mvp/model/DrawVideoBean.java
0 → 100644
View file @
b3015b1b
package
com
.
mints
.
goodmoney
.
mvp
.
model
;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
com.bytedance.sdk.openadsdk.TTNativeExpressAd
;
public
class
DrawVideoBean
implements
Parcelable
{
public
int
type
=
0
;
public
TTNativeExpressAd
ad
;
public
String
videoId
;
public
String
videoUrl
;
public
String
ImgId
;
public
DrawVideoBean
(
int
type
,
TTNativeExpressAd
ad
,
String
videoId
,
String
videoUrl
,
String
imgId
)
{
this
.
type
=
type
;
this
.
ad
=
ad
;
this
.
videoId
=
videoId
;
this
.
videoUrl
=
videoUrl
;
ImgId
=
imgId
;
}
protected
DrawVideoBean
(
Parcel
in
)
{
type
=
in
.
readInt
();
videoId
=
in
.
readString
();
videoUrl
=
in
.
readString
();
ImgId
=
in
.
readString
();
}
@Override
public
void
writeToParcel
(
Parcel
dest
,
int
flags
)
{
dest
.
writeInt
(
type
);
dest
.
writeString
(
videoId
);
dest
.
writeString
(
videoUrl
);
dest
.
writeString
(
ImgId
);
}
@Override
public
int
describeContents
()
{
return
0
;
}
public
static
final
Creator
<
DrawVideoBean
>
CREATOR
=
new
Creator
<
DrawVideoBean
>()
{
@Override
public
DrawVideoBean
createFromParcel
(
Parcel
in
)
{
return
new
DrawVideoBean
(
in
);
}
@Override
public
DrawVideoBean
[]
newArray
(
int
size
)
{
return
new
DrawVideoBean
[
size
];
}
};
}
GoodMoney/app/src/main/java/com/mints/goodmoney/mvp/presenters/KylVideoPresenter.kt
View file @
b3015b1b
...
...
@@ -3,6 +3,7 @@ package com.mints.goodmoney.mvp.presenters
import
com.google.gson.JsonObject
import
com.mints.goodmoney.manager.AppHttpManager
import
com.mints.goodmoney.mvp.model.BaseResponse
import
com.mints.goodmoney.mvp.model.KylBean
import
com.mints.goodmoney.mvp.views.KylVideoView
import
com.mints.library.net.neterror.BaseSubscriber
import
com.mints.library.net.neterror.Throwable
...
...
@@ -10,6 +11,36 @@ import java.util.*
class
KylVideoPresenter
:
BasePresenter
<
KylVideoView
>()
{
fun
getXfPageMsg
(
targetid
:
String
,
page
:
Int
,
pageCount
:
Int
)
{
val
vo
=
HashMap
<
String
,
Any
>()
vo
[
"targetid"
]
=
targetid
vo
[
"page"
]
=
page
vo
[
"size"
]
=
pageCount
AppHttpManager
.
getInstance
(
loanApplication
)
.
call
(
loanService
.
getXfPageMsg
(
vo
),
object
:
BaseSubscriber
<
BaseResponse
<
KylBean
>>()
{
override
fun
onCompleted
()
{
}
override
fun
onError
(
e
:
Throwable
)
{
if
(
isLinkView
)
return
view
.
getXfPageMsgFail
()
}
override
fun
onNext
(
baseResponse
:
BaseResponse
<
KylBean
>)
{
if
(
isLinkView
)
return
val
code
=
baseResponse
.
getStatus
()
when
(
code
)
{
200
->
{
view
.
getXfPageMsgSuc
(
baseResponse
.
data
)
}
else
->
view
.
showToast
(
baseResponse
.
getMessage
())
}
}
})
}
fun
addReadSeconds
(
seconds
:
Int
)
{
val
vo
=
HashMap
<
String
,
Any
>()
vo
[
"seconds"
]
=
seconds
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/mvp/views/KylVideoView.kt
View file @
b3015b1b
package
com.mints.goodmoney.mvp.views
import
com.mints.goodmoney.mvp.model.KylBean
interface
KylVideoView
:
BaseView
{
interface
KylVideoView
:
BaseView
{
fun
getXfPageMsgSuc
(
data
:
KylBean
)
fun
getXfPageMsgFail
()
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/AwardActivity.kt
View file @
b3015b1b
...
...
@@ -365,9 +365,14 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
AppConfig
.
isSuperTask
=
false
if
(
mReceiverBroadcastReceiver
!=
null
)
{
mContext
.
stopService
(
Intent
(
context
,
AppInstallService
::
class
.
java
))
mContext
.
unregisterReceiver
(
mReceiverBroadcastReceiver
)
mReceiverBroadcastReceiver
=
null
}
awardPresenter
.
setHighTaskType
(
"0"
)
mTimer
?.
stop
()
...
...
@@ -386,14 +391,9 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
videoAdingManager
.
setVideoAdingListener
(
null
)
videoAdingManager
.
onDestory
()
if
(
mReceiverBroadcastReceiver
!=
null
)
{
mContext
.
stopService
(
Intent
(
context
,
AppInstallService
::
class
.
java
))
mContext
.
unregisterReceiver
(
mReceiverBroadcastReceiver
)
mReceiverBroadcastReceiver
=
null
}
awardPresenter
.
detachView
()
super
.
onDestroy
()
}
override
fun
onKeyDown
(
keyCode
:
Int
,
event
:
KeyEvent
):
Boolean
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/DrawNativeVideoActivity.kt
0 → 100644
View file @
b3015b1b
package
com.mints.goodmoney.ui.activitys
import
android.Manifest
import
android.media.MediaPlayer
import
android.os.Bundle
import
android.text.TextUtils
import
android.util.Log
import
android.view.View
import
android.widget.FrameLayout
import
android.widget.ImageView
import
android.widget.VideoView
import
androidx.recyclerview.widget.OrientationHelper
import
com.bytedance.sdk.openadsdk.TTNativeExpressAd
import
com.dingmouren.layoutmanagergroup.viewpager.OnViewPagerListener
import
com.dingmouren.layoutmanagergroup.viewpager.ViewPagerLayoutManager
import
com.downloader.Error
import
com.downloader.OnDownloadListener
import
com.downloader.PRDownloader
import
com.mints.goodmoney.R
import
com.mints.goodmoney.ad.draw.CsjDrawAdManager
import
com.mints.goodmoney.ad.video.VideoAdingManager
import
com.mints.goodmoney.call.business.VideoDBHelper
import
com.mints.goodmoney.call.detail.DetailApplyActivity
import
com.mints.goodmoney.call.permission.PermissionActivity
import
com.mints.goodmoney.call.permission.PermissionManager
import
com.mints.goodmoney.common.Constant
import
com.mints.goodmoney.manager.UserManager
import
com.mints.goodmoney.mvp.model.DrawVideoBean
import
com.mints.goodmoney.mvp.model.KylBean
import
com.mints.goodmoney.mvp.model.VideoAdingBean
import
com.mints.goodmoney.mvp.presenters.KylVideoPresenter
import
com.mints.goodmoney.mvp.views.KylVideoView
import
com.mints.goodmoney.ui.activitys.base.BaseActivity
import
com.mints.goodmoney.ui.adapter.DrawVideoAdapter
import
com.mints.goodmoney.utils.LogUtil
import
com.mints.goodmoney.utils.MD5
import
com.mints.goodmoney.utils.ToastUtil
import
com.tbruyelle.rxpermissions.RxPermissions
import
kotlinx.android.synthetic.main.activity_draw_native_video.*
private
const
val
TAG
=
"DrawNativeVideoActivity"
/**
* 描述:关于我们
* 作者:孟崔广
* 时间:2020/9/23 18:39
*/
class
DrawNativeVideoActivity
:
BaseActivity
(),
View
.
OnClickListener
,
CsjDrawAdManager
.
CsjDrawAdListener
,
KylVideoView
{
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
activity_draw_native_video
override
fun
isApplyKitKatTranslucency
()
=
false
companion
object
{
const
val
TYPE_COMMON_ITEM
=
1
const
val
TYPE_AD_ITEM
=
2
const
val
CURRENT_PAGE
=
"CURRENT_PAGE"
const
val
PLAY_INDEX
=
"PLAY_INDEX"
const
val
VIDEO_DATA
=
"VIDEO_DATA"
const
val
TARGET_ID
=
"TARGET_ID"
// 来电秀跳转地址
const
val
WEB_VIDEO_URL
=
"https://vring.kuyin123.com/friend/94aa83142f7f5c98?videoId="
}
// 列表页面播放page
private
var
mCurrentPage
=
0
// 当前播放视频下标
private
var
mCurrentPlayIndex
=
0
// 当前播放视频数据源
private
val
drawDatas
:
MutableList
<
DrawVideoBean
>
=
mutableListOf
()
// targerId 视频类别
private
var
targerId
=
""
private
val
kylVideoPresenter
by
lazy
{
KylVideoPresenter
()
}
private
lateinit
var
videoAdingManager
:
VideoAdingManager
private
var
downloadVedioSucFlag
=
false
// 下载视频成功
private
var
videoPathName
=
""
// 视频下载名称
private
var
downloadId
:
Int
=
-
1
// video下载id
private
var
loadVideoFailCount
=
0
private
var
mDrawVideoAdapter
:
DrawVideoAdapter
?
=
null
private
var
mLayoutManager
:
ViewPagerLayoutManager
?
=
null
override
fun
getBundleExtras
(
extras
:
Bundle
?)
{
super
.
getBundleExtras
(
extras
)
mCurrentPage
=
extras
?.
getInt
(
CURRENT_PAGE
,
0
)
!!
mCurrentPlayIndex
=
extras
.
getInt
(
PLAY_INDEX
,
0
)
targerId
=
extras
.
getString
(
TARGET_ID
,
""
)
val
parcelableArrayList
=
extras
.
getParcelableArrayList
<
DrawVideoBean
>(
VIDEO_DATA
)
if
(
parcelableArrayList
!=
null
)
{
drawDatas
.
addAll
(
parcelableArrayList
)
}
}
override
fun
initViewsAndEvents
()
{
kylVideoPresenter
.
attachView
(
this
)
CsjDrawAdManager
.
getInstance
(
this
)
?.
loadDrawNativeAd
()
CsjDrawAdManager
.
getInstance
(
this
)
?.
setCsjDrawAdListener
(
this
)
mLayoutManager
=
ViewPagerLayoutManager
(
this
,
OrientationHelper
.
VERTICAL
)
mDrawVideoAdapter
=
DrawVideoAdapter
(
this
,
drawDatas
)
recy_draw_native
.
layoutManager
=
mLayoutManager
recy_draw_native
.
adapter
=
mDrawVideoAdapter
videoAdingManager
=
VideoAdingManager
.
getInstance
(
this
)
initListener
()
}
override
fun
onClick
(
v
:
View
?)
{
when
(
v
?.
id
)
{
R
.
id
.
ivBack
->
finish
()
R
.
id
.
ivVedio
->
{
val
bundle
=
Bundle
()
bundle
.
putString
(
WebActivity
.
WEB_TITLE
,
"视频彩铃"
)
bundle
.
putString
(
WebActivity
.
WEB_URL
,
WEB_VIDEO_URL
+
drawDatas
[
mCurrentPlayIndex
].
videoId
)
readyGo
(
WebActivity
::
class
.
java
,
bundle
)
}
R
.
id
.
ivSetting
->
{
if
(
downloadVedioSucFlag
)
{
readyGo
()
return
}
RxPermissions
(
this
)
.
request
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
.
subscribe
{
granted
:
Boolean
->
if
(
granted
)
{
downloadVedioToCacheFile
()
awardVideo
()
}
else
{
showMissingPermissionDialog
(
"存储"
)
}
}
}
}
}
private
fun
playVideo
(
position
:
Int
)
{
if
(
isFinishing
)
{
return
}
val
itemView
:
View
=
recy_draw_native
.
getChildAt
(
0
)
?:
return
val
videoLayout
=
itemView
.
findViewById
<
FrameLayout
>(
R
.
id
.
video_layout
)
val
view
=
videoLayout
.
getChildAt
(
0
)
if
(
view
!
is
VideoView
)
{
Log
.
e
(
TAG
,
"view not instanceof VideoView"
)
return
}
val
videoView
=
videoLayout
.
getChildAt
(
0
)
as
VideoView
val
imgPlay
=
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
img_play
)
val
imgThumb
=
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
img_thumb
)
val
mediaPlayer
=
arrayOfNulls
<
MediaPlayer
>(
1
)
videoView
.
start
()
videoView
.
setOnInfoListener
{
mp
,
what
,
extra
->
mediaPlayer
[
0
]
=
mp
Log
.
e
(
TAG
,
"onInfo"
)
mp
.
isLooping
=
true
imgThumb
.
animate
().
alpha
(
0f
).
setDuration
(
200
).
start
()
false
}
videoView
.
setOnPreparedListener
{
Log
.
e
(
TAG
,
"onPrepared"
)
}
imgPlay
.
setOnClickListener
(
object
:
View
.
OnClickListener
{
var
isPlaying
=
true
override
fun
onClick
(
v
:
View
)
{
isPlaying
=
if
(
videoView
.
isPlaying
)
{
Log
.
e
(
TAG
,
"isPlaying:"
+
videoView
.
isPlaying
)
imgPlay
.
animate
().
alpha
(
1f
).
start
()
videoView
.
pause
()
false
}
else
{
Log
.
e
(
TAG
,
"isPlaying:"
+
videoView
.
isPlaying
)
imgPlay
.
animate
().
alpha
(
0f
).
start
()
videoView
.
start
()
true
}
}
})
}
private
fun
downloadVedioToCacheFile
()
{
downloadVedioSucFlag
=
false
val
videoPath
:
String
=
try
{
getExternalFilesDir
(
null
)
!!
.
absolutePath
+
"/video/"
}
catch
(
e
:
java
.
lang
.
Exception
)
{
filesDir
.
absolutePath
+
"/video/"
}
val
videoName
=
MD5
.
GetMD5Code
(
System
.
currentTimeMillis
().
toString
()
+
UserManager
.
getInstance
().
userID
+
drawDatas
[
mCurrentPlayIndex
].
videoId
)
+
".mp4"
videoPathName
=
videoPath
+
videoName
downloadId
=
PRDownloader
.
download
(
drawDatas
[
mCurrentPlayIndex
].
videoUrl
,
videoPath
,
videoName
)
.
build
()
.
start
(
object
:
OnDownloadListener
{
override
fun
onDownloadComplete
()
{
downloadVedioSucFlag
=
true
}
override
fun
onError
(
error
:
Error
)
{
}
})
}
private
fun
releaseVideo
(
index
:
Int
)
{
if
(
isFinishing
)
{
return
}
val
itemView
:
View
=
recy_draw_native
.
getChildAt
(
index
)
val
videoLayout
=
itemView
.
findViewById
<
FrameLayout
>(
R
.
id
.
video_layout
)
?:
return
val
view
=
videoLayout
.
getChildAt
(
0
)
if
(
view
is
VideoView
)
{
val
videoView
=
videoLayout
.
getChildAt
(
0
)
as
VideoView
val
imgThumb
=
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
img_thumb
)
val
imgPlay
=
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
img_play
)
videoView
.
stopPlayback
()
imgThumb
.
animate
().
alpha
(
1f
).
start
()
imgPlay
.
animate
().
alpha
(
0f
).
start
()
}
}
private
fun
initListener
()
{
ivBack
.
setOnClickListener
(
this
)
ivVedio
.
setOnClickListener
(
this
)
ivSetting
.
setOnClickListener
(
this
)
mLayoutManager
?.
setOnViewPagerListener
(
object
:
OnViewPagerListener
{
override
fun
onInitComplete
()
{
onLayoutComplete
()
}
override
fun
onPageRelease
(
isNext
:
Boolean
,
position
:
Int
)
{
Log
.
e
(
TAG
,
"释放位置:$position 下一页:$isNext"
)
val
index
:
Int
=
if
(
isNext
)
{
0
}
else
{
1
}
if
(
drawDatas
[
position
].
type
==
TYPE_COMMON_ITEM
)
{
releaseVideo
(
index
)
}
}
override
fun
onPageSelected
(
position
:
Int
,
isBottom
:
Boolean
)
{
Log
.
e
(
TAG
,
"选中位置:$position 是否是滑动到底部:$isBottom"
)
mCurrentPlayIndex
=
position
if
(
drawDatas
[
position
].
type
==
TYPE_COMMON_ITEM
)
{
playVideo
(
0
)
changeBottomTopLayoutVisibility
(
true
)
}
else
{
changeBottomTopLayoutVisibility
(
false
)
}
if
(
isBottom
)
{
loadMoreData
()
}
}
private
fun
onLayoutComplete
()
{
if
(
drawDatas
[
0
].
type
==
TYPE_COMMON_ITEM
)
{
playVideo
(
0
)
changeBottomTopLayoutVisibility
(
true
)
}
else
{
changeBottomTopLayoutVisibility
(
false
)
}
}
})
}
private
fun
loadMoreData
()
{
mCurrentPage
++
kylVideoPresenter
.
getXfPageMsg
(
targerId
,
mCurrentPage
,
3
)
}
private
fun
changeBottomTopLayoutVisibility
(
visibility
:
Boolean
)
{
ivVedio
.
visibility
=
if
(
visibility
)
View
.
VISIBLE
else
View
.
GONE
ivSetting
.
visibility
=
if
(
visibility
)
View
.
VISIBLE
else
View
.
GONE
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
if
(
downloadId
!=
-
1
)
{
PRDownloader
.
cancel
(
downloadId
)
}
videoAdingManager
.
setVideoAdingListener
(
null
)
videoAdingManager
.
onDestory
()
kylVideoPresenter
.
detachView
()
if
(
mLayoutManager
!=
null
)
{
mLayoutManager
!!
.
setOnViewPagerListener
(
null
)
}
}
/**
* 获取激励视频
*/
private
fun
awardVideo
()
{
if
(
videoAdingManager
.
videoFinishFlag
)
{
showToast
(
"今日视频已看完,请明天再来吧"
)
return
}
loadVideoFailCount
=
0
showLoading
(
"加载中..."
)
val
bean
=
VideoAdingBean
()
bean
.
carrierType
=
Constant
.
CARRIER_KUYINYUE_VEDIO
loadVideo
(
videoAdingManager
,
bean
,
true
)
}
/**
* 加载激励视频
*/
private
fun
loadVideo
(
videoAdingManager
:
VideoAdingManager
,
bean
:
VideoAdingBean
,
isFirstLoad
:
Boolean
)
{
videoAdingManager
.
setVideoAdingListener
(
object
:
VideoAdingManager
.
VideoAdingListener
{
override
fun
videoAdingListenerError
(
adType
:
String
)
{
showToast
(
"加载超时,请休息一下"
)
hideLoading
()
}
override
fun
videoAdingListenerFail
(
adType
:
String
)
{
loadVideoFailCount
++
if
(
loadVideoFailCount
>=
2
)
{
hideLoading
()
showToast
(
"加载失败,请稍后重试!"
)
}
else
{
loadVideo
(
videoAdingManager
,
bean
,
false
)
}
}
override
fun
videoAdingListenerSuccess
(
adType
:
String
)
{
hideLoading
()
vedioAdingSuccess
(
adType
)
}
})
if
(
isFirstLoad
)
{
// 首页按权重加载
videoAdingManager
.
loadAding
(
this
,
bean
)
}
else
{
// 失败按优先级加载
videoAdingManager
.
loadFailAding
(
this
,
bean
)
}
}
private
fun
vedioAdingSuccess
(
adType
:
String
)
{
if
(!
downloadVedioSucFlag
||
TextUtils
.
isEmpty
(
videoPathName
))
{
showToast
(
"视频处理中,请稍候"
)
return
}
readyGo
()
}
private
fun
readyGo
()
{
if
(
PermissionManager
.
getInstance
().
checkEssential
(
this
))
{
VideoDBHelper
.
getInstance
().
setSelectVideo
(
this
,
VideoDBHelper
.
UNKNOWN_NUMBER
,
videoPathName
)
DetailApplyActivity
.
startSelf
(
this
,
videoPathName
,
true
)
}
else
{
PermissionActivity
.
startSelf
(
this
)
}
}
override
fun
csjDrawAdFail
()
{
LogUtil
.
d
(
"csjDrawAdFail"
)
showToast
(
"加载失败,请稍候再试"
)
}
override
fun
csjDrawAdSuccess
(
ads
:
MutableList
<
TTNativeExpressAd
>?)
{
if
(
ads
==
null
||
ads
.
isEmpty
())
{
ToastUtil
.
show
(
this
,
"请求广告为空"
)
return
}
// for (i in 0 until drawDatas.size) {
// val random = (Math.random() * 100).toInt()
// val index: Int = random % drawDatas.size
// drawDatas.add(DrawVideoBean(TYPE_COMMON_ITEM, null, drawDatas[index].ImgId, drawDatas[index].videoUrl, drawDatas[index].videoId))
// }
for
(
ad
in
ads
)
{
//点击监听器必须在getAdView之前调
ad
.
setVideoAdListener
(
object
:
TTNativeExpressAd
.
ExpressVideoAdListener
{
override
fun
onVideoLoad
()
{
}
override
fun
onVideoError
(
p0
:
Int
,
p1
:
Int
)
{
}
override
fun
onVideoAdStartPlay
()
{
}
override
fun
onVideoAdPaused
()
{
}
override
fun
onVideoAdContinuePlay
()
{
}
override
fun
onProgressUpdate
(
p0
:
Long
,
p1
:
Long
)
{
}
override
fun
onVideoAdComplete
()
{
}
override
fun
onClickRetry
()
{
}
})
ad
.
setCanInterruptVideoPlay
(
true
)
ad
.
setExpressInteractionListener
(
object
:
TTNativeExpressAd
.
ExpressAdInteractionListener
{
override
fun
onAdClicked
(
p0
:
View
?,
p1
:
Int
)
{
}
override
fun
onAdShow
(
p0
:
View
?,
p1
:
Int
)
{
}
override
fun
onRenderFail
(
p0
:
View
?,
p1
:
String
?,
p2
:
Int
)
{
}
override
fun
onRenderSuccess
(
p0
:
View
?,
p1
:
Float
,
p2
:
Float
)
{
// val random = (Math.random() * 100).toInt()
// var index = random % drawDatas.size
// if (index == 0) {
// index++
// }
val
index
=
drawDatas
.
size
drawDatas
.
add
(
index
,
DrawVideoBean
(
TYPE_AD_ITEM
,
ad
,
""
,
""
,
""
))
// mDrawVideoAdapter?.notifyDataSetChanged()
}
})
ad
.
render
()
}
mDrawVideoAdapter
?.
notifyItemInserted
(
mCurrentPlayIndex
+
1
)
}
override
fun
getXfPageMsgSuc
(
data
:
KylBean
)
{
for
(
data
in
data
.
data
)
{
drawDatas
.
add
(
DrawVideoBean
(
TYPE_COMMON_ITEM
,
null
,
data
.
vedioId
,
data
.
url
,
data
.
pvurl
))
}
CsjDrawAdManager
.
getInstance
(
this
)
?.
loadDrawNativeAd
()
// mDrawVideoAdapter?.notifyDataSetChanged()
}
override
fun
getXfPageMsgFail
()
{
showToast
(
"加载失败,请稍候再试"
)
}
}
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/KylVideoActivity.kt
View file @
b3015b1b
...
...
@@ -16,6 +16,7 @@ import com.mints.goodmoney.call.permission.PermissionActivity
import
com.mints.goodmoney.call.permission.PermissionManager
import
com.mints.goodmoney.common.Constant
import
com.mints.goodmoney.manager.UserManager
import
com.mints.goodmoney.mvp.model.KylBean
import
com.mints.goodmoney.mvp.model.VideoAdingBean
import
com.mints.goodmoney.mvp.presenters.KylVideoPresenter
import
com.mints.goodmoney.mvp.views.KylVideoView
...
...
@@ -133,11 +134,10 @@ class KylVideoActivity : BaseActivity(), View.OnClickListener, KylVideoView {
private
fun
downloadVedioToCacheFile
()
{
downloadVedioSucFlag
=
false
var
vedioPath
=
""
try
{
vedioPath
=
getExternalFilesDir
(
null
)
!!
.
absolutePath
+
"/video/"
var
vedioPath
:
String
=
try
{
getExternalFilesDir
(
null
)
!!
.
absolutePath
+
"/video/"
}
catch
(
e
:
java
.
lang
.
Exception
)
{
vedioPath
=
filesDir
.
absolutePath
+
"/video/"
filesDir
.
absolutePath
+
"/video/"
}
val
vedioName
=
MD5
.
GetMD5Code
(
System
.
currentTimeMillis
().
toString
()
+
UserManager
.
getInstance
().
userID
+
videoUrl
)
+
".mp4"
vedioPathName
=
vedioPath
+
vedioName
...
...
@@ -225,4 +225,10 @@ class KylVideoActivity : BaseActivity(), View.OnClickListener, KylVideoView {
PermissionActivity
.
startSelf
(
this
)
}
}
override
fun
getXfPageMsgSuc
(
data
:
KylBean
)
{
}
override
fun
getXfPageMsgFail
()
{
}
}
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/adapter/DrawVideoAdapter.kt
0 → 100644
View file @
b3015b1b
package
com.mints.goodmoney.ui.adapter
import
android.content.Context
import
android.net.Uri
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.*
import
androidx.recyclerview.widget.RecyclerView
import
com.mints.goodmoney.R
import
com.mints.goodmoney.mvp.model.DrawVideoBean
import
com.mints.goodmoney.ui.activitys.DrawNativeVideoActivity
import
com.mints.goodmoney.ui.adapter.listener.OnItemClickListener
import
com.mints.goodmoney.ui.widgets.FullScreenVideoView
import
com.mints.goodmoney.utils.LogUtil
import
com.mints.library.utils.GlideUtils
class
DrawVideoAdapter
(
context
:
Context
,
datas
:
List
<
DrawVideoBean
>)
:
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>()
{
private
var
mContext
:
Context
=
context
private
var
mDrawVideoData
:
List
<
DrawVideoBean
>
=
datas
private
var
mOnItemClickListener
:
OnItemClickListener
?
=
null
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
RecyclerView
.
ViewHolder
{
val
view
=
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
item_view_pager
,
parent
,
false
)
return
ViewHolder
(
view
)
}
override
fun
getItemViewType
(
position
:
Int
):
Int
{
return
mDrawVideoData
[
position
].
type
}
override
fun
onBindViewHolder
(
viewHolder
:
RecyclerView
.
ViewHolder
,
position
:
Int
)
{
val
holder
=
viewHolder
as
ViewHolder
var
view
:
View
?
=
View
(
mContext
)
val
item
:
DrawVideoBean
?
=
mDrawVideoData
[
position
]
if
(
item
?.
type
==
DrawNativeVideoActivity
.
TYPE_COMMON_ITEM
)
{
GlideUtils
.
loadImageView
(
mContext
,
item
.
ImgId
,
holder
.
img_thumb
)
view
=
getView
()
LogUtil
.
d
(
DrawNativeVideoActivity
.
WEB_VIDEO_URL
+
mDrawVideoData
[
position
].
videoId
)
(
view
as
VideoView
).
setVideoURI
(
Uri
.
parse
(
mDrawVideoData
[
position
].
videoUrl
))
}
else
if
(
item
?.
type
==
DrawNativeVideoActivity
.
TYPE_AD_ITEM
&&
item
.
ad
!=
null
)
{
view
=
item
.
ad
.
expressAdView
// if (item.ad.icon != null && item.ad.icon.imageUrl != null) {
// GlideUtils.loadImageView(mContext,)
// } else{
// holder.img_head_icon.setImageBitmap(item.ad.adLogo)
// }
}
holder
.
videoLayout
.
removeAllViews
()
if
(
view
?.
parent
!=
null
)
{
(
view
.
parent
as
ViewGroup
).
removeView
(
view
)
}
holder
.
videoLayout
.
addView
(
view
)
if
(
item
!=
null
)
{
changeUIVisibility
(
holder
,
item
.
type
)
}
}
private
fun
changeUIVisibility
(
holder
:
ViewHolder
,
type
:
Int
)
{
var
visibilable
=
true
if
(
type
==
DrawNativeVideoActivity
.
TYPE_AD_ITEM
)
{
visibilable
=
false
}
holder
.
img_play
.
visibility
=
if
(
visibilable
)
View
.
VISIBLE
else
View
.
GONE
holder
.
img_thumb
.
visibility
=
if
(
visibilable
)
View
.
VISIBLE
else
View
.
GONE
}
private
fun
getView
():
View
{
val
videoView
=
FullScreenVideoView
(
mContext
)
val
layoutParams
=
FrameLayout
.
LayoutParams
(
FrameLayout
.
LayoutParams
.
MATCH_PARENT
,
FrameLayout
.
LayoutParams
.
MATCH_PARENT
)
videoView
.
layoutParams
=
layoutParams
return
videoView
}
override
fun
getItemCount
():
Int
{
return
mDrawVideoData
.
size
}
inner
class
ViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
val
img_thumb
:
ImageView
=
itemView
.
findViewById
(
R
.
id
.
img_thumb
)
val
img_play
:
ImageView
=
itemView
.
findViewById
(
R
.
id
.
img_play
)
val
rootView
:
RelativeLayout
=
itemView
.
findViewById
(
R
.
id
.
root_view
)
val
videoLayout
:
FrameLayout
=
itemView
.
findViewById
(
R
.
id
.
video_layout
)
}
fun
setOnItemClickListener
(
listener
:
OnItemClickListener
)
{
mOnItemClickListener
=
listener
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/adapter/KylPageAdapter.kt
View file @
b3015b1b
...
...
@@ -168,14 +168,15 @@ class KylPageAdapter(val kylPageList: MutableList<KylBean.Data>) :
private
fun
bindDislikeCustom
(
dislike
:
View
,
ad
:
TTFeedAd
)
{
val
ttAdDislike
=
ad
.
getDislikeDialog
(
context
as
Activity
?)
if
(
ttAdDislike
!=
null
)
{
ad
.
getDislikeDialog
(
context
as
Activity
?).
setDislikeInteractionCallback
(
object
:
DislikeInteractionCallback
{
override
fun
onSelected
(
position
:
Int
,
value
:
String
)
{
}
override
fun
onCancel
()
{}
override
fun
onRefuse
()
{}
})
}
// if (ttAdDislike != null) {
// ad.getDislikeDialog(context as Activity?).setDislikeInteractionCallback(object : DislikeInteractionCallback {
// override fun onSelected(position: Int, value: String) {
// }
// override fun onCancel() {}
// override fun onRefuse() {}
// })
// }
dislike
.
setOnClickListener
{
ttAdDislike
!!
.
showDislikeDialog
()
}
}
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/KuYinYuePageFragment.kt
View file @
b3015b1b
...
...
@@ -5,10 +5,11 @@ import androidx.recyclerview.widget.GridLayoutManager
import
com.bytedance.sdk.openadsdk.*
import
com.mints.goodmoney.R
import
com.mints.goodmoney.manager.TtCsjAdManager
import
com.mints.goodmoney.mvp.model.DrawVideoBean
import
com.mints.goodmoney.mvp.model.KylBean
import
com.mints.goodmoney.mvp.presenters.KuYinYuePagePresenter
import
com.mints.goodmoney.mvp.views.KuYinYuePageView
import
com.mints.goodmoney.ui.activitys.
Kyl
VideoActivity
import
com.mints.goodmoney.ui.activitys.
DrawNative
VideoActivity
import
com.mints.goodmoney.ui.adapter.KylPageAdapter
import
com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import
com.mints.goodmoney.utils.LogUtil
...
...
@@ -62,11 +63,28 @@ class KuYinYuePageFragment(private val targetid: String) : LazyLoadBaseFragment(
}
override
fun
onItemClick
(
position
:
Int
)
{
if
(
kylData
!=
null
&&
kylData
.
size
>
0
)
{
if
(
kylData
.
size
>
0
)
{
// val bundle = Bundle()
// bundle.putString(KylVideoActivity.VIDEO_URL, kylData[position].url)
// bundle.putString(KylVideoActivity.VIDEO_ID, kylData[position].vedioId)
// readyGo(KylVideoActivity::class.java, bundle)
val
dataList
=
arrayListOf
<
DrawVideoBean
>()
val
index
=
position
%
PAGE_SIZE
// 余数
for
(
i
in
position
until
PAGE_SIZE
*
curPage
)
{
dataList
.
add
(
DrawVideoBean
(
DrawNativeVideoActivity
.
TYPE_COMMON_ITEM
,
null
,
kylData
[
index
/
PAGE_SIZE
+
i
].
vedioId
,
kylData
[
index
/
PAGE_SIZE
+
i
].
url
,
kylData
[
index
/
PAGE_SIZE
+
i
].
pvurl
))
}
val
bundle
=
Bundle
()
bundle
.
putString
(
KylVideoActivity
.
VIDEO_URL
,
kylData
[
position
].
url
)
bundle
.
putString
(
KylVideoActivity
.
VIDEO_ID
,
kylData
[
position
].
vedioId
)
readyGo
(
KylVideoActivity
::
class
.
java
,
bundle
)
bundle
.
putParcelableArrayList
(
DrawNativeVideoActivity
.
VIDEO_DATA
,
dataList
)
bundle
.
putInt
(
DrawNativeVideoActivity
.
PLAY_INDEX
,
index
)
bundle
.
putInt
(
DrawNativeVideoActivity
.
CURRENT_PAGE
,
curPage
)
bundle
.
putString
(
DrawNativeVideoActivity
.
TARGET_ID
,
targetid
)
readyGo
(
DrawNativeVideoActivity
::
class
.
java
,
bundle
)
}
}
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/MyFragment.kt
View file @
b3015b1b
...
...
@@ -762,7 +762,8 @@ class MyFragment : BaseFragment(),
}
R
.
id
.
iv_right_icon2
->
{
// 跳转QQ客服
jumpQQGroup
()
// jumpQQGroup()
readyGo
(
DrawNativeVideoActivity
::
class
.
java
)
}
R
.
id
.
item_customer_service
->
{
// 跳转加入QQ群
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/widgets/FullScreenVideoView.java
0 → 100644
View file @
b3015b1b
package
com
.
mints
.
goodmoney
.
ui
.
widgets
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.widget.VideoView
;
public
class
FullScreenVideoView
extends
VideoView
{
public
FullScreenVideoView
(
Context
context
)
{
super
(
context
);
}
public
FullScreenVideoView
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
public
FullScreenVideoView
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
int
width
=
getDefaultSize
(
0
,
widthMeasureSpec
);
int
height
=
getDefaultSize
(
0
,
heightMeasureSpec
);
setMeasuredDimension
(
width
,
height
);
}
}
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/widgets/dialog/DownloadProgressDialog.kt
View file @
b3015b1b
...
...
@@ -10,7 +10,6 @@ import android.widget.ImageView
import
android.widget.TextView
import
com.downloader.PRDownloader
import
com.downloader.Progress
import
com.mints.goodmoney.MintsApplication
import
com.mints.goodmoney.R
import
com.mints.goodmoney.utils.CacheUtil
import
com.mints.goodmoney.utils.Utils
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/utils/UIUtils.java
0 → 100644
View file @
b3015b1b
package
com
.
mints
.
goodmoney
.
utils
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.os.Build
;
import
android.text.TextUtils
;
import
android.util.DisplayMetrics
;
import
android.view.Display
;
import
android.view.DisplayCutout
;
import
android.view.View
;
import
android.view.WindowInsets
;
import
android.view.WindowManager
;
import
android.widget.FrameLayout
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
/**
* Created by bytedance on 2019/9/5.
*/
public
class
UIUtils
{
public
static
float
getScreenWidthDp
(
Context
context
){
final
float
scale
=
context
.
getResources
().
getDisplayMetrics
().
density
;
float
width
=
context
.
getResources
().
getDisplayMetrics
().
widthPixels
;
return
width
/
(
scale
<=
0
?
1
:
scale
)
+
0.5f
;
}
//全面屏、刘海屏适配
public
static
float
getHeight
(
Activity
activity
)
{
hideBottomUIMenu
(
activity
);
float
height
;
int
realHeight
=
getRealHeight
(
activity
);
if
(
UIUtils
.
hasNotchScreen
(
activity
))
{
height
=
px2dip
(
activity
,
realHeight
-
getStatusBarHeight
(
activity
));
}
else
{
height
=
px2dip
(
activity
,
realHeight
);
}
return
height
;
}
public
static
void
hideBottomUIMenu
(
Activity
activity
)
{
if
(
activity
==
null
)
{
return
;
}
try
{
//隐藏虚拟按键,并且全屏
if
(
Build
.
VERSION
.
SDK_INT
>
11
&&
Build
.
VERSION
.
SDK_INT
<
19
)
{
// lower api
View
v
=
activity
.
getWindow
().
getDecorView
();
v
.
setSystemUiVisibility
(
View
.
GONE
);
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
19
)
{
//for new api versions.
View
decorView
=
activity
.
getWindow
().
getDecorView
();
int
uiOptions
=
View
.
SYSTEM_UI_FLAG_LAYOUT_STABLE
|
View
.
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
View
.
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
View
.
SYSTEM_UI_FLAG_HIDE_NAVIGATION
// hide nav bar
// | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
|
View
.
SYSTEM_UI_FLAG_IMMERSIVE
;
decorView
.
setSystemUiVisibility
(
uiOptions
);
activity
.
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_NAVIGATION
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
//获取屏幕真实高度,不包含下方虚拟导航栏
public
static
int
getRealHeight
(
Context
context
)
{
WindowManager
windowManager
=
(
WindowManager
)
context
.
getSystemService
(
Context
.
WINDOW_SERVICE
);
Display
display
=
windowManager
.
getDefaultDisplay
();
DisplayMetrics
dm
=
new
DisplayMetrics
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
display
.
getRealMetrics
(
dm
);
}
else
{
display
.
getMetrics
(
dm
);
}
int
realHeight
=
dm
.
heightPixels
;
return
realHeight
;
}
//获取状态栏高度
public
static
float
getStatusBarHeight
(
Context
context
)
{
float
height
=
0
;
int
resourceId
=
context
.
getApplicationContext
().
getResources
().
getIdentifier
(
"status_bar_height"
,
"dimen"
,
"android"
);
if
(
resourceId
>
0
)
{
height
=
context
.
getApplicationContext
().
getResources
().
getDimensionPixelSize
(
resourceId
);
}
return
height
;
}
public
static
int
px2dip
(
Context
context
,
float
pxValue
)
{
final
float
scale
=
context
.
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
(
pxValue
/
(
scale
<=
0
?
1
:
scale
)
+
0.5f
);
}
/**
* 判断是否是刘海屏
* @return
*/
public
static
boolean
hasNotchScreen
(
Activity
activity
){
return
isAndroidPHasNotch
(
activity
)
||
getInt
(
"ro.miui.notch"
,
activity
)
==
1
||
hasNotchAtHuawei
(
activity
)
||
hasNotchAtOPPO
(
activity
)
||
hasNotchAtVivo
(
activity
);
}
/**
* Android P 刘海屏判断
* @param activity
* @return
*/
public
static
boolean
isAndroidPHasNotch
(
Activity
activity
){
boolean
result
=
false
;
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
P
)
{
DisplayCutout
displayCutout
=
null
;
try
{
WindowInsets
windowInsets
=
activity
.
getWindow
().
getDecorView
().
getRootWindowInsets
();
if
(
windowInsets
!=
null
)
{
displayCutout
=
windowInsets
.
getDisplayCutout
();
}
if
(
displayCutout
!=
null
)
{
result
=
true
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
result
;
}
/**
* 小米刘海屏判断.
* @return 0 if it is not notch ; return 1 means notch
* @throws IllegalArgumentException if the key exceeds 32 characters
*/
public
static
int
getInt
(
String
key
,
Activity
activity
)
{
int
result
=
0
;
if
(
isMiui
()){
try
{
ClassLoader
classLoader
=
activity
.
getClassLoader
();
@SuppressWarnings
(
"rawtypes"
)
Class
SystemProperties
=
classLoader
.
loadClass
(
"android.os.SystemProperties"
);
//参数类型
@SuppressWarnings
(
"rawtypes"
)
Class
[]
paramTypes
=
new
Class
[
2
];
paramTypes
[
0
]
=
String
.
class
;
paramTypes
[
1
]
=
int
.
class
;
Method
getInt
=
SystemProperties
.
getMethod
(
"getInt"
,
paramTypes
);
//参数
Object
[]
params
=
new
Object
[
2
];
params
[
0
]
=
new
String
(
key
);
params
[
1
]
=
new
Integer
(
0
);
result
=
(
Integer
)
getInt
.
invoke
(
SystemProperties
,
params
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
NoSuchMethodException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalArgumentException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
}
return
result
;
}
/**
* 华为刘海屏判断
* @return
*/
public
static
boolean
hasNotchAtHuawei
(
Context
context
)
{
boolean
ret
=
false
;
try
{
ClassLoader
classLoader
=
context
.
getClassLoader
();
Class
HwNotchSizeUtil
=
classLoader
.
loadClass
(
"com.huawei.android.util.HwNotchSizeUtil"
);
Method
get
=
HwNotchSizeUtil
.
getMethod
(
"hasNotchInScreen"
);
ret
=
(
boolean
)
get
.
invoke
(
HwNotchSizeUtil
);
}
catch
(
ClassNotFoundException
e
)
{
}
catch
(
NoSuchMethodException
e
)
{
}
catch
(
Exception
e
)
{
}
finally
{
return
ret
;
}
}
public
static
final
int
VIVO_NOTCH
=
0x00000020
;
//是否有刘海
public
static
final
int
VIVO_FILLET
=
0x00000008
;
//是否有圆角
/**
* VIVO刘海屏判断
* @return
*/
public
static
boolean
hasNotchAtVivo
(
Context
context
)
{
boolean
ret
=
false
;
try
{
ClassLoader
classLoader
=
context
.
getClassLoader
();
Class
FtFeature
=
classLoader
.
loadClass
(
"android.util.FtFeature"
);
Method
method
=
FtFeature
.
getMethod
(
"isFeatureSupport"
,
int
.
class
);
ret
=
(
boolean
)
method
.
invoke
(
FtFeature
,
VIVO_NOTCH
);
}
catch
(
ClassNotFoundException
e
)
{
}
catch
(
NoSuchMethodException
e
)
{
}
catch
(
Exception
e
)
{
}
finally
{
return
ret
;
}
}
/**
* O-P-P-O刘海屏判断
* @return
*/
public
static
boolean
hasNotchAtOPPO
(
Context
context
)
{
String
temp
=
"com.kllk.feature.screen.heteromorphism"
;
String
name
=
getKllkDecryptString
(
temp
);
return
context
.
getPackageManager
().
hasSystemFeature
(
name
);
}
public
static
boolean
isMiui
()
{
boolean
sIsMiui
=
false
;
try
{
Class
<?>
clz
=
Class
.
forName
(
"miui.os.Build"
);
if
(
clz
!=
null
)
{
sIsMiui
=
true
;
//noinspection ConstantConditions
return
sIsMiui
;
}
}
catch
(
Exception
e
)
{
// ignore
}
return
sIsMiui
;
}
/**
*用于o-p-p-o 版本隐私协议
*/
public
static
String
getKllkDecryptString
(
String
encryptionString
)
{
if
(
TextUtils
.
isEmpty
(
encryptionString
))
{
return
""
;
}
String
decryptTag
=
""
;
String
decryptCapitalized
=
"O"
+
"P"
+
"P"
+
"O"
;
String
decrypt
=
"o"
+
"p"
+
"p"
+
"o"
;
if
(
encryptionString
.
contains
(
"KLLK"
))
{
decryptTag
=
encryptionString
.
replace
(
"KLLK"
,
decryptCapitalized
);
}
else
if
(
encryptionString
.
contains
(
"kllk"
))
{
decryptTag
=
encryptionString
.
replace
(
"kllk"
,
decrypt
);
}
return
decryptTag
;
}
public
static
void
setViewSize
(
View
view
,
int
width
,
int
height
)
{
if
(
view
.
getParent
()
instanceof
FrameLayout
)
{
FrameLayout
.
LayoutParams
lp
=
(
FrameLayout
.
LayoutParams
)
view
.
getLayoutParams
();
lp
.
width
=
width
;
lp
.
height
=
height
;
view
.
setLayoutParams
(
lp
);
view
.
requestLayout
();
}
else
if
(
view
.
getParent
()
instanceof
RelativeLayout
)
{
RelativeLayout
.
LayoutParams
lp
=
(
RelativeLayout
.
LayoutParams
)
view
.
getLayoutParams
();
lp
.
width
=
width
;
lp
.
height
=
height
;
view
.
setLayoutParams
(
lp
);
view
.
requestLayout
();
}
else
if
(
view
.
getParent
()
instanceof
LinearLayout
)
{
LinearLayout
.
LayoutParams
lp
=
(
LinearLayout
.
LayoutParams
)
view
.
getLayoutParams
();
lp
.
width
=
width
;
lp
.
height
=
height
;
view
.
setLayoutParams
(
lp
);
view
.
requestLayout
();
}
}
}
GoodMoney/app/src/main/java/com/mints/goodmoney/utils/Utils.java
View file @
b3015b1b
...
...
@@ -26,9 +26,11 @@ import androidx.core.content.ContextCompat;
import
android.provider.Settings
;
import
android.text.TextUtils
;
import
android.view.DisplayCutout
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.Window
;
import
android.view.WindowInsets
;
import
android.view.WindowManager
;
import
android.view.accessibility.AccessibilityManager
;
...
...
GoodMoney/app/src/main/res/drawable/play_arrow.xml
0 → 100644
View file @
b3015b1b
<vector
android:alpha=
"0.61"
android:height=
"24dp"
android:viewportHeight=
"24.0"
android:viewportWidth=
"24.0"
android:width=
"24dp"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<path
android:fillColor=
"#99ffffff"
android:pathData=
"M8,5v14l11,-7z"
/>
</vector>
GoodMoney/app/src/main/res/layout/activity_draw_native_video.xml
0 → 100644
View file @
b3015b1b
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/black"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/recy_draw_native"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ImageView
android:id=
"@+id/ivBack"
android:layout_width=
"60dp"
android:layout_height=
"60dp"
android:layout_marginStart=
"5dp"
android:layout_marginTop=
"15dp"
android:padding=
"16dp"
android:src=
"@mipmap/ic_left_arrow"
/>
<TextView
android:id=
"@+id/ivVedio"
android:layout_width=
"match_parent"
android:layout_height=
"40dp"
android:layout_alignParentBottom=
"true"
android:layout_marginLeft=
"50dp"
android:layout_marginRight=
"50dp"
android:layout_marginBottom=
"100dp"
android:background=
"@drawable/shape_tv_gold"
android:gravity=
"center"
android:text=
"设置视频彩铃"
android:textColor=
"@color/white"
/>
<TextView
android:id=
"@+id/ivSetting"
android:layout_width=
"match_parent"
android:layout_height=
"40dp"
android:layout_alignParentBottom=
"true"
android:layout_marginLeft=
"50dp"
android:layout_marginRight=
"50dp"
android:layout_marginBottom=
"40dp"
android:background=
"@drawable/shape_tv_gold"
android:gravity=
"center"
android:text=
"看广告设置来电秀"
android:textColor=
"@color/white"
/>
</RelativeLayout>
</RelativeLayout>
GoodMoney/app/src/main/res/layout/item_view_pager.xml
0 → 100644
View file @
b3015b1b
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/root_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/black"
>
<FrameLayout
android:id=
"@+id/video_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:clickable=
"false"
android:focusable=
"false"
/>
<ImageView
android:id=
"@+id/img_thumb"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:clickable=
"false"
android:focusable=
"false"
android:scaleType=
"centerCrop"
/>
<ImageView
android:id=
"@+id/img_play"
android:layout_width=
"100dp"
android:layout_height=
"100dp"
android:layout_centerInParent=
"true"
android:alpha=
"0"
android:clickable=
"true"
android:focusable=
"true"
android:src=
"@drawable/play_arrow"
/>
</RelativeLayout>
\ 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