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
3bef1432
Commit
3bef1432
authored
Jan 08, 2021
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
高额任务代码优化
parent
b6f69dae
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
184 deletions
+87
-184
Constant.kt
.../app/src/main/java/com/mints/goodmoney/common/Constant.kt
+4
-3
AppTryPlayManager.kt
...ain/java/com/mints/goodmoney/manager/AppTryPlayManager.kt
+0
-16
GsonConverterFactory.java
...in/java/com/mints/goodmoney/net/GsonConverterFactory.java
+2
-1
MainMyAdapter.kt
...main/java/com/mints/goodmoney/ui/adapter/MainMyAdapter.kt
+1
-1
MyFragment.kt
...c/main/java/com/mints/goodmoney/ui/fragment/MyFragment.kt
+80
-73
AppPackageUsageUtils.java
.../java/com/mints/goodmoney/utils/AppPackageUsageUtils.java
+0
-90
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/common/Constant.kt
View file @
3bef1432
...
...
@@ -189,7 +189,7 @@ object Constant {
var
SHARE_CONTENT
=
"邀请码【${UserManager.getInstance().codeID}】,共享新模式,快来加入跟我一起赚钱吧"
// var SHARE_URL: String = BuildConfig.MainIp + "share/shareFriend.html?ruid=" + UserManager.getInstance().getUserID() + "&channel=" + CommonUtils.getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME")
var
SHARE_URL
:
String
=
BuildConfig
.
MainIp
+
"wxShare/toShare?shareId="
+
UserManager
.
getInstance
().
getUserID
()
var
SHARE_URL
:
String
=
BuildConfig
.
MainIp
+
"wxShare/toShare?shareId="
+
UserManager
.
getInstance
().
userID
// 首页视频时长 单位-秒
const
val
MAIN_VEDIO_TIME
=
"main_vedio_time"
...
...
@@ -221,6 +221,7 @@ object Constant {
// 是否是高额任务
const
val
IS_HIGH_TASK
=
"is_high_task"
// 高额任务包名
const
val
PKG_HIGH_TASK
=
"pkg_high_task"
// 高额任务分享包名变量存储
const
val
HIGH_TASK_PKG_NAME
=
"high_task_pkg_name"
}
GoodMoney/app/src/main/java/com/mints/goodmoney/manager/AppTryPlayManager.kt
View file @
3bef1432
...
...
@@ -8,27 +8,11 @@ import com.mints.goodmoney.utils.AppUtil
*/
object
AppTryPlayManager
{
// 第一次打开时间
// private var openTime = 0L
// private var currentPkg = ""
fun
toTryPlay
(
pkg
:
String
)
{
// if (currentPkg != pkg) {
// openTime = AppUtil.getAppUseTime(MintsApplication.getContext(), pkg)
AppUtil
.
openThirdApp
(
MintsApplication
.
getContext
(),
pkg
)
// val eventMessage = EventMessage(Constant.IS_HIGH_TASK, pkg)
// RxBus.getDefault().postSticky(eventMessage)
// currentPkg = pkg
// }
}
fun
getTryPlayIsOK
(
pkg
:
String
):
Boolean
{
// val currentUseTime = AppUtil.getAppUseTime(MintsApplication.getContext(), pkg)
// openTime = 0L
// currentPkg = ""
// LogUtil.d("currentUseTime ->" + currentUseTime + "-- openTime ->" + openTime)
// return currentUseTime - openTime >= 100
val
timePkgUsed
=
AppUtil
.
getTimePkgUsed
(
MintsApplication
.
getContext
(),
pkg
)
return
timePkgUsed
>=
30
}
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/net/GsonConverterFactory.java
View file @
3bef1432
...
...
@@ -18,6 +18,7 @@ import java.io.Writer;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Type
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
...
...
@@ -119,7 +120,7 @@ public class GsonConverterFactory extends Converter.Factory {
// 主要用于对Part、PartMap、Body注解的处理
final
class
GsonRequestBodyConverter
<
T
>
implements
Converter
<
T
,
RequestBody
>
{
private
final
MediaType
MEDIA_TYPE
=
MediaType
.
parse
(
"application/json; charset=UTF-8"
);
private
final
Charset
UTF_8
=
Charset
.
forName
(
"UTF-8"
)
;
private
final
Charset
UTF_8
=
StandardCharsets
.
UTF_8
;
private
final
Gson
gson
;
private
final
Type
type
;
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/adapter/MainMyAdapter.kt
View file @
3bef1432
...
...
@@ -103,7 +103,7 @@ class MainMyAdapter(context: Context, taskData: MutableList<MyInfo.AutoListBean>
holder
.
itemTaskClick
.
setTextColor
(
Color
.
WHITE
)
}
2
->
{
if
(
taskBean
.
baseConfig
.
taskId
==
APP_VEDIO
||
taskBean
.
baseConfig
.
taskId
==
TO_SHARE_NEWS
)
{
if
(
taskBean
.
baseConfig
.
taskId
==
APP_VEDIO
||
taskBean
.
baseConfig
.
taskId
==
APP_HiGH_ACTIVITY
)
{
holder
.
itemTaskClick
.
setBackgroundResource
(
R
.
drawable
.
shape_btn_gury
)
holder
.
itemTaskClick
.
setTextColor
(
Color
.
WHITE
)
}
else
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/MyFragment.kt
View file @
3bef1432
...
...
@@ -34,10 +34,7 @@ import com.mints.goodmoney.ui.widgets.CustomDialogAsApple
import
com.mints.goodmoney.ui.widgets.DialogListener
import
com.mints.goodmoney.ui.widgets.ShareDialog
import
com.mints.goodmoney.ui.widgets.seekbar.BubbleUtils
import
com.mints.goodmoney.utils.AppUtil
import
com.mints.goodmoney.utils.LogUtil
import
com.mints.goodmoney.utils.QQJumpUtil
import
com.mints.goodmoney.utils.SpanUtils
import
com.mints.goodmoney.utils.*
import
com.mints.library.net.netstatus.NetUtils
import
com.mints.library.utils.CommonUtils
import
com.mints.library.utils.GlideUtils
...
...
@@ -180,6 +177,7 @@ class MyFragment : BaseFragment(),
myPresenter
.
detachView
()
if
(
mReceiverBroadcastReceiver
!=
null
)
{
mContext
.
stopService
(
Intent
(
context
,
AppInstallService
::
class
.
java
))
mContext
.
unregisterReceiver
(
mReceiverBroadcastReceiver
)
}
}
...
...
@@ -491,19 +489,32 @@ class MyFragment : BaseFragment(),
mCurrentPkg
=
null
}
3
->
{
if
(
mCurrentPkg
==
null
)
{
// 如果当前包名为空,获取本地存储的包名
mCurrentPkg
=
PreferencesService
.
getInstance
(
mContext
).
getString
(
Constant
.
HIGH_TASK_PKG_NAME
)
}
if
(
mCurrentPkg
==
null
)
{
showToast
(
"任务异常,请重试~"
)
myPresenter
.
setHighTaskType
(
"0"
)
AppConfig
.
isHighTask
=
false
}
else
{
AppConfig
.
isHighTask
=
true
AppTryPlayManager
.
toTryPlay
(
mCurrentPkg
!!
)
if
(
AppUtil
.
checkPackInfo
(
mContext
,
mCurrentPkg
!!
))
{
AppTryPlayManager
.
toTryPlay
(
mCurrentPkg
!!
)
AppConfig
.
isHighTask
=
true
}
else
{
showToast
(
"未找到当前APP、可能被卸载,请重试~"
)
myPresenter
.
setHighTaskType
(
"0"
)
AppConfig
.
isHighTask
=
false
}
}
}
}
}
}
// 跳转分享文章
MainMyAdapter
.
TO_SHARE_NEWS
->
{
if
(!
UserManager
.
getInstance
().
userIsLogin
())
{
readyGo
(
WxLoginActivity
::
class
.
java
)
...
...
@@ -866,9 +877,8 @@ class MyFragment : BaseFragment(),
return
}
}
shareArticle
(
300
)
}
shareArticle
(
300
)
}
else
->
{
if
(!
TextUtils
.
isEmpty
(
hotBean
.
url
)
&&
!
TextUtils
.
isEmpty
(
hotBean
.
title
))
{
...
...
@@ -971,6 +981,68 @@ class MyFragment : BaseFragment(),
}
}
private
fun
initManager
()
{
BannerManager
.
init
()
vedioAdingManager
=
VedioAdingManager
.
getInstance
(
activity
)
if
(!
TextUtils
.
isEmpty
(
userManager
.
userID
))
{
// 登录成功的用户初始化鱼丸盒子
if
(
userManager
.
userIsLogin
())
{
YwhzManager
.
init
(
baseApplication
)
}
}
// 聚乐云初始化
SceneManager
.
initScene
()
SceneManager
.
signIn
(
requireActivity
())
}
private
fun
initView
()
{
tv_title
.
text
=
"个人中心"
view_title
.
text
=
"每日任务"
iv_right_icon
.
visibility
=
View
.
VISIBLE
iv_right_icon
.
setImageResource
(
R
.
mipmap
.
ic_settings
)
iv_right_icon2
.
visibility
=
View
.
VISIBLE
iv_right_icon2
.
setImageResource
(
R
.
mipmap
.
icon_customer_service
)
iv_right_icon2
.
setOnClickListener
(
this
)
item_title_id
.
setOnClickListener
(
this
)
iv_right_icon
.
setOnClickListener
(
this
)
btn_withdraw
.
setOnClickListener
(
this
)
btn_coinRecord
.
setOnClickListener
(
this
)
item_title_invitecode
.
setOnClickListener
(
this
)
item_title_invitecode_copy
.
setOnClickListener
(
this
)
ll_my_login
.
setOnClickListener
(
this
)
item_customer_service
.
setOnClickListener
(
this
)
item_promotions_egv
.
onItemClickListener
=
this
}
/**
* 初始化Recyclerview
*/
private
fun
initRecy
()
{
recy_my
.
addItemDecoration
(
DividerItemDecoration
(
mContext
,
DividerItemDecoration
.
VERTICAL
))
recy_my
.
setItemViewCacheSize
(
10
)
mainMyAdapter
=
MainMyAdapter
(
mContext
,
dataList
)
recy_my
.
adapter
=
mainMyAdapter
mainMyAdapter
?.
setOnItemChildClickListener
(
this
)
}
/**
* 设置视频权重
*/
private
fun
initAdWeight
(
data
:
UserTaskMsgBean
)
{
vedioAdingManager
.
initAdWeight
(
data
.
vedioRules
.
csJ_VEDIO
.
rate
,
data
.
vedioRules
.
ylH_VEDIO
.
rate
,
data
.
vedioRules
.
sdhZ_VEDIO
.
rate
,
data
.
vedioRules
.
fL_VEDIO
.
rate
)
LogUtil
.
d
(
TAG
,
"首页权重值:csjWeight:${data.vedioRules.csJ_VEDIO.rate} ylhWeight:${data.vedioRules.ylH_VEDIO.rate} sdhzWeight:${data.vedioRules.sdhZ_VEDIO.rate} flWeight:${data.vedioRules.fL_VEDIO.rate}"
)
// 广告视频数
AppConfig
.
csjVedioAdCount
=
data
.
vedioRules
.
csJ_VEDIO
.
surplus
AppConfig
.
ylhAdCount
=
data
.
vedioRules
.
ylH_VEDIO
.
surplus
AppConfig
.
wnVedioAdCount
=
data
.
vedioRules
.
sdhZ_VEDIO
.
surplus
AppConfig
.
flVedioAdCount
=
data
.
vedioRules
.
fL_VEDIO
.
surplus
LogUtil
.
d
(
TAG
,
"首页视频数:csjCount:${AppConfig.csjVedioAdCount} ylhCount:${AppConfig.ylhAdCount} sdhzCount:${AppConfig.wnVedioAdCount} flCount:${AppConfig.flVedioAdCount}"
)
}
/**
* 跳转QQ群弹框
*/
...
...
@@ -1056,68 +1128,6 @@ class MyFragment : BaseFragment(),
shareDialog
.
show
()
}
private
fun
initManager
()
{
BannerManager
.
init
()
vedioAdingManager
=
VedioAdingManager
.
getInstance
(
activity
)
if
(!
TextUtils
.
isEmpty
(
userManager
.
userID
))
{
// 登录成功的用户初始化鱼丸盒子
if
(
userManager
.
userIsLogin
())
{
YwhzManager
.
init
(
baseApplication
)
}
}
// 聚乐云初始化
SceneManager
.
initScene
()
SceneManager
.
signIn
(
requireActivity
())
}
private
fun
initView
()
{
tv_title
.
text
=
"个人中心"
view_title
.
text
=
"每日任务"
iv_right_icon
.
visibility
=
View
.
VISIBLE
iv_right_icon
.
setImageResource
(
R
.
mipmap
.
ic_settings
)
iv_right_icon2
.
visibility
=
View
.
VISIBLE
iv_right_icon2
.
setImageResource
(
R
.
mipmap
.
icon_customer_service
)
iv_right_icon2
.
setOnClickListener
(
this
)
item_title_id
.
setOnClickListener
(
this
)
iv_right_icon
.
setOnClickListener
(
this
)
btn_withdraw
.
setOnClickListener
(
this
)
btn_coinRecord
.
setOnClickListener
(
this
)
item_title_invitecode
.
setOnClickListener
(
this
)
item_title_invitecode_copy
.
setOnClickListener
(
this
)
ll_my_login
.
setOnClickListener
(
this
)
item_customer_service
.
setOnClickListener
(
this
)
item_promotions_egv
.
onItemClickListener
=
this
}
/**
* 初始化Recyclerview
*/
private
fun
initRecy
()
{
recy_my
.
addItemDecoration
(
DividerItemDecoration
(
mContext
,
DividerItemDecoration
.
VERTICAL
))
recy_my
.
setItemViewCacheSize
(
10
)
mainMyAdapter
=
MainMyAdapter
(
mContext
,
dataList
)
recy_my
.
adapter
=
mainMyAdapter
mainMyAdapter
?.
setOnItemChildClickListener
(
this
)
}
/**
* 设置视频权重
*/
private
fun
initAdWeight
(
data
:
UserTaskMsgBean
)
{
vedioAdingManager
.
initAdWeight
(
data
.
vedioRules
.
csJ_VEDIO
.
rate
,
data
.
vedioRules
.
ylH_VEDIO
.
rate
,
data
.
vedioRules
.
sdhZ_VEDIO
.
rate
,
data
.
vedioRules
.
fL_VEDIO
.
rate
)
LogUtil
.
d
(
TAG
,
"首页权重值:csjWeight:${data.vedioRules.csJ_VEDIO.rate} ylhWeight:${data.vedioRules.ylH_VEDIO.rate} sdhzWeight:${data.vedioRules.sdhZ_VEDIO.rate} flWeight:${data.vedioRules.fL_VEDIO.rate}"
)
// 广告视频数
AppConfig
.
csjVedioAdCount
=
data
.
vedioRules
.
csJ_VEDIO
.
surplus
AppConfig
.
ylhAdCount
=
data
.
vedioRules
.
ylH_VEDIO
.
surplus
AppConfig
.
wnVedioAdCount
=
data
.
vedioRules
.
sdhZ_VEDIO
.
surplus
AppConfig
.
flVedioAdCount
=
data
.
vedioRules
.
fL_VEDIO
.
surplus
LogUtil
.
d
(
TAG
,
"首页视频数:csjCount:${AppConfig.csjVedioAdCount} ylhCount:${AppConfig.ylhAdCount} sdhzCount:${AppConfig.wnVedioAdCount} flCount:${AppConfig.flVedioAdCount}"
)
}
/**
* 分享文章
*/
...
...
@@ -1162,9 +1172,6 @@ class MyFragment : BaseFragment(),
vedioAdingManager
.
setIsHighWeight
(
true
)
awardVedio
(
taskBean
.
otherConfig
.
coin
,
Constant
.
CARRIER_HIGH_ACTIVITY
)
//
mContext
.
startService
(
Intent
(
context
,
AppInstallService
::
class
.
java
))
// 注册高额任务广播监听
registerBroad
()
}
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/utils/AppPackageUsageUtils.java
deleted
100644 → 0
View file @
b6f69dae
package
com
.
mints
.
goodmoney
.
utils
;
import
android.app.AppOpsManager
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.content.pm.ResolveInfo
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.provider.Settings
;
import
androidx.core.app.NotificationManagerCompat
;
import
java.util.List
;
public
class
AppPackageUsageUtils
{
/**
* 判断当前设备中是否有"有权查看使用情况的应用程序"这个选项
*
* @param context
* @return
*/
public
static
boolean
isNoOption
(
Context
context
)
{
PackageManager
packageManager
=
context
.
getPackageManager
();
Intent
intent
=
new
Intent
(
Settings
.
ACTION_USAGE_ACCESS_SETTINGS
);
List
<
ResolveInfo
>
list
=
packageManager
.
queryIntentActivities
(
intent
,
PackageManager
.
MATCH_DEFAULT_ONLY
);
return
list
.
size
()
>
0
;
}
/**
* 判断这个选项的打开状态
*
* @param context
* @return
*/
public
static
boolean
isNoSwitch
(
Context
context
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
AppOpsManager
appOpsManager
=
(
AppOpsManager
)
context
.
getSystemService
(
Context
.
APP_OPS_SERVICE
);
int
mode
=
appOpsManager
.
checkOpNoThrow
(
AppOpsManager
.
OPSTR_GET_USAGE_STATS
,
android
.
os
.
Process
.
myUid
(),
context
.
getPackageName
());
return
mode
==
AppOpsManager
.
MODE_ALLOWED
;
}
return
false
;
}
/**
* 判断当前app在手机中是否开启了允许消息推送 true-打开了消息通知
*
* @param context
* @return
*/
public
static
boolean
isNotificationEnabled
(
Context
context
)
{
boolean
isOpened
=
false
;
try
{
isOpened
=
NotificationManagerCompat
.
from
(
context
).
areNotificationsEnabled
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
isOpened
=
false
;
}
return
isOpened
;
}
/**
*打开手机消息设置页面
*
* @param context
*/
public
static
void
gotoSet
(
Context
context
)
{
Intent
intent
=
new
Intent
();
if
(
Build
.
VERSION
.
SDK_INT
>=
26
)
{
// android 8.0引导
intent
.
setAction
(
"android.settings.APP_NOTIFICATION_SETTINGS"
);
intent
.
putExtra
(
"android.provider.extra.APP_PACKAGE"
,
context
.
getPackageName
());
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
21
)
{
// android 5.0-7.0
intent
.
setAction
(
"android.settings.APP_NOTIFICATION_SETTINGS"
);
intent
.
putExtra
(
"app_package"
,
context
.
getPackageName
());
intent
.
putExtra
(
"app_uid"
,
context
.
getApplicationInfo
().
uid
);
}
else
{
// 其他
intent
.
setAction
(
"android.settings.APPLICATION_DETAILS_SETTINGS"
);
intent
.
setData
(
Uri
.
fromParts
(
"package"
,
context
.
getPackageName
(),
null
));
}
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
context
.
startActivity
(
intent
);
}
}
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