Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_xunmi
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_xunmi
Commits
f990cdfb
Commit
f990cdfb
authored
Nov 05, 2020
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
95119d20
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
457 additions
and
403 deletions
+457
-403
build.gradle
position/app/build.gradle
+2
-0
TopOnNativeAd.kt
...ion/app/src/main/java/com/mints/xunmi/ad/TopOnNativeAd.kt
+8
-4
AppConfig.java
...n/app/src/main/java/com/mints/xunmi/common/AppConfig.java
+0
-4
VipPayManager.kt
...pp/src/main/java/com/mints/xunmi/manager/VipPayManager.kt
+14
-14
MainFragmentPresenter.kt
...a/com/mints/xunmi/mvp/presenters/MainFragmentPresenter.kt
+3
-0
CallMeActivity.kt
.../main/java/com/mints/xunmi/ui/activitys/CallMeActivity.kt
+1
-1
MainActivity.java
.../main/java/com/mints/xunmi/ui/activitys/MainActivity.java
+3
-0
SplashADActivity.java
...n/java/com/mints/xunmi/ui/activitys/SplashADActivity.java
+293
-293
SplashAdShowActivity.java
...va/com/mints/xunmi/ui/activitys/SplashAdShowActivity.java
+8
-1
SplashBackActivity.java
...java/com/mints/xunmi/ui/activitys/SplashBackActivity.java
+8
-1
MainFragment.kt
...src/main/java/com/mints/xunmi/ui/fragment/MainFragment.kt
+70
-28
MyFragment.kt
...p/src/main/java/com/mints/xunmi/ui/fragment/MyFragment.kt
+2
-40
PositionFragment.kt
...main/java/com/mints/xunmi/ui/fragment/PositionFragment.kt
+40
-15
SPUtil.java
position/app/src/main/java/com/mints/xunmi/utils/SPUtil.java
+4
-2
fragment_main_my.xml
position/app/src/main/res/layout/fragment_main_my.xml
+1
-0
No files found.
position/app/build.gradle
View file @
f990cdfb
...
@@ -214,6 +214,8 @@ dependencies {
...
@@ -214,6 +214,8 @@ dependencies {
// 三方接入
// 三方接入
// leakcanary
debugImplementation
'com.squareup.leakcanary:leakcanary-android:2.4'
// shareSdk
// shareSdk
implementation
project
(
':shareSdkLib'
)
implementation
project
(
':shareSdkLib'
)
// umeng
// umeng
...
...
position/app/src/main/java/com/mints/xunmi/ad/TopOnNativeAd.kt
View file @
f990cdfb
...
@@ -21,6 +21,7 @@ object TopOnNativeAd {
...
@@ -21,6 +21,7 @@ object TopOnNativeAd {
private
val
TAG
=
TopOnNativeAd
::
class
.
java
.
simpleName
private
val
TAG
=
TopOnNativeAd
::
class
.
java
.
simpleName
var
context
:
Context
?
=
null
var
atNatives
:
ATNative
?
=
null
var
atNatives
:
ATNative
?
=
null
var
mNativeAd
:
NativeAd
?
=
null
var
mNativeAd
:
NativeAd
?
=
null
var
anyThinkNativeAdView
:
ATNativeAdView
?
=
null
var
anyThinkNativeAdView
:
ATNativeAdView
?
=
null
...
@@ -32,6 +33,7 @@ object TopOnNativeAd {
...
@@ -32,6 +33,7 @@ object TopOnNativeAd {
* 应用初始化
* 应用初始化
*/
*/
fun
init
(
context
:
Context
)
{
fun
init
(
context
:
Context
)
{
this
.
context
=
context
atNatives
=
ATNative
(
context
,
TopOnManager
.
INFORMATION_ID
,
object
:
ATNativeNetworkListener
{
atNatives
=
ATNative
(
context
,
TopOnManager
.
INFORMATION_ID
,
object
:
ATNativeNetworkListener
{
override
fun
onNativeAdLoaded
()
{
override
fun
onNativeAdLoaded
()
{
LogUtil
.
e
(
TAG
,
"onNativeAdLoaded"
)
LogUtil
.
e
(
TAG
,
"onNativeAdLoaded"
)
...
@@ -61,16 +63,16 @@ object TopOnNativeAd {
...
@@ -61,16 +63,16 @@ object TopOnNativeAd {
/**
/**
* 预加载
* 预加载
*/
*/
fun
loadNativeAd
(
context
:
Context
,
frameLayout
:
FrameLayout
?)
{
fun
loadNativeAd
(
frameLayout
:
FrameLayout
?)
{
atNatives
?.
makeAdRequest
()
atNatives
?.
makeAdRequest
()
showNativeAd
(
context
,
frameLayout
)
showNativeAd
(
frameLayout
)
}
}
/**
/**
* 显示
* 显示
*/
*/
fun
showNativeAd
(
context
:
Context
,
frameLayout
:
FrameLayout
?)
{
private
fun
showNativeAd
(
frameLayout
:
FrameLayout
?)
{
val
nativeAd
=
atNatives
?.
nativeAd
val
nativeAd
=
atNatives
?.
nativeAd
nativeAd
?.
let
{
nativeAd
?.
let
{
if
(
mNativeAd
!=
null
)
{
if
(
mNativeAd
!=
null
)
{
...
@@ -118,7 +120,7 @@ object TopOnNativeAd {
...
@@ -118,7 +120,7 @@ object TopOnNativeAd {
it
.
prepare
(
anyThinkNativeAdView
,
anyThinkRender
.
getClickView
(),
null
)
it
.
prepare
(
anyThinkNativeAdView
,
anyThinkRender
.
getClickView
(),
null
)
if
(
anyThinkNativeAdView
!=
null
&&
anyThinkNativeAdView
!!
.
parent
==
null
)
{
if
(
anyThinkNativeAdView
!=
null
&&
anyThinkNativeAdView
!!
.
parent
==
null
)
{
frameLayout
?.
addView
(
anyThinkNativeAdView
,
FrameLayout
.
LayoutParams
(
context
.
getResources
()
.
getDisplayMetrics
().
widthPixels
,
containerHeight
))
frameLayout
?.
addView
(
anyThinkNativeAdView
,
FrameLayout
.
LayoutParams
(
context
?.
getResources
()
!!
.
getDisplayMetrics
().
widthPixels
,
containerHeight
))
}
}
}
}
}
}
...
@@ -138,6 +140,8 @@ object TopOnNativeAd {
...
@@ -138,6 +140,8 @@ object TopOnNativeAd {
}
}
fun
onDestroy
()
{
fun
onDestroy
()
{
anyThinkNativeAdView
?.
destory
()
mNativeAd
?.
destory
()
mNativeAd
?.
destory
()
context
=
null
}
}
}
}
\ No newline at end of file
position/app/src/main/java/com/mints/xunmi/common/AppConfig.java
View file @
f990cdfb
...
@@ -30,11 +30,7 @@ public class AppConfig {
...
@@ -30,11 +30,7 @@ public class AppConfig {
public
static
volatile
double
curLatitude
=
0
;
//纬度 39.977181
public
static
volatile
double
curLatitude
=
0
;
//纬度 39.977181
public
static
volatile
String
curAddress
=
"授权定位权限后获取位置"
;
//位置
public
static
volatile
String
curAddress
=
"授权定位权限后获取位置"
;
//位置
public
static
volatile
String
poiName
=
""
;
//位置
public
static
volatile
String
poiName
=
""
;
//位置
public
static
volatile
String
aoiName
=
""
;
//建筑
public
static
volatile
double
preChangeLongitude
=
1
;
//位置变化改变 上一次经度 116.307511
public
static
volatile
double
preChangeLatitude
=
1
;
//位置变化改变 上一次纬度 39.977181
// public static volatile int canSaveMinimumM = 50;//范围 米
public
static
volatile
int
canSaveMinimumM
=
1
;
//范围 米
public
static
volatile
int
canSaveMinimumM
=
1
;
//范围 米
...
...
position/app/src/main/java/com/mints/xunmi/manager/VipPayManager.kt
View file @
f990cdfb
...
@@ -35,7 +35,7 @@ class VipPayManager private constructor(activity: Activity) {
...
@@ -35,7 +35,7 @@ class VipPayManager private constructor(activity: Activity) {
private
fun
init
(
activity
:
Activity
)
{
private
fun
init
(
activity
:
Activity
)
{
this
.
activity
=
activity
this
.
activity
=
activity
spUtil
=
SPUtil
.
getInstance
(
activity
)
spUtil
=
SPUtil
.
getInstance
()
}
}
/**
/**
...
@@ -56,19 +56,19 @@ class VipPayManager private constructor(activity: Activity) {
...
@@ -56,19 +56,19 @@ class VipPayManager private constructor(activity: Activity) {
/**
/**
* 跳转支付界面 type-3 五折, type-4 全款
* 跳转支付界面 type-3 五折, type-4 全款
*/
*/
fun
gotoPayPage
(
type
:
Int
)
{
//
fun gotoPayPage(type: Int) {
if
(
activity
==
null
)
return
//
if (activity == null) return
//
if
(
TextUtils
.
equals
(
"onePrice"
,
spUtil
?.
getString
(
Constant
.
PAY_PAGE_TYPE
)))
{
//
if (TextUtils.equals("onePrice", spUtil?.getString(Constant.PAY_PAGE_TYPE))) {
//固定套餐
//
//固定套餐
readyGo
(
Vip2Activity
::
class
.
java
)
//
readyGo(Vip2Activity::class.java)
}
else
{
//
} else {
//多价格套餐
//
//多价格套餐
val
bundle
=
Bundle
()
//
val bundle = Bundle()
bundle
.
putInt
(
Constant
.
PRICE_TYPE
,
type
)
//
bundle.putInt(Constant.PRICE_TYPE, type)
readyGo
(
Vip3Activity
::
class
.
java
,
bundle
)
//
readyGo(Vip3Activity::class.java, bundle)
}
//
}
}
//
}
private
fun
readyGo
(
clazz
:
Class
<
*
>?)
{
private
fun
readyGo
(
clazz
:
Class
<
*
>?)
{
activity
.
let
{
activity
.
let
{
...
...
position/app/src/main/java/com/mints/xunmi/mvp/presenters/MainFragmentPresenter.kt
View file @
f990cdfb
...
@@ -26,6 +26,9 @@ import java.util.*
...
@@ -26,6 +26,9 @@ import java.util.*
class
MainFragmentPresenter
:
BasePresenter
<
MainFragmentView
>()
{
class
MainFragmentPresenter
:
BasePresenter
<
MainFragmentView
>()
{
/**
* 获取关心的人
*/
fun
getAllReqMy
()
{
fun
getAllReqMy
()
{
AppHttpManager
.
getInstance
(
loanApplication
)
AppHttpManager
.
getInstance
(
loanApplication
)
.
call
(
loanService
.
getCares
(),
.
call
(
loanService
.
getCares
(),
...
...
position/app/src/main/java/com/mints/xunmi/ui/activitys/CallMeActivity.kt
View file @
f990cdfb
...
@@ -30,7 +30,7 @@ class CallMeActivity : BaseActivity(), View.OnClickListener {
...
@@ -30,7 +30,7 @@ class CallMeActivity : BaseActivity(), View.OnClickListener {
if
(
UserManager
.
getInstance
().
vipFlag
)
{
if
(
UserManager
.
getInstance
().
vipFlag
)
{
rlCallmeQQ
.
visibility
=
View
.
VISIBLE
rlCallmeQQ
.
visibility
=
View
.
VISIBLE
val
phone
=
SPUtil
.
getInstance
(
context
).
getString
(
Constant
.
USER_TELEPHONE
)
val
phone
=
SPUtil
.
getInstance
().
getString
(
Constant
.
USER_TELEPHONE
)
tvCallPhone
.
text
=
phone
tvCallPhone
.
text
=
phone
}
else
{
}
else
{
rlCallmeQQ
.
visibility
=
View
.
GONE
rlCallmeQQ
.
visibility
=
View
.
GONE
...
...
position/app/src/main/java/com/mints/xunmi/ui/activitys/MainActivity.java
View file @
f990cdfb
...
@@ -15,6 +15,7 @@ import androidx.fragment.app.FragmentTransaction;
...
@@ -15,6 +15,7 @@ import androidx.fragment.app.FragmentTransaction;
import
com.mints.xunmi.MintsApplication
;
import
com.mints.xunmi.MintsApplication
;
import
com.mints.xunmi.R
;
import
com.mints.xunmi.R
;
import
com.mints.xunmi.ad.TopOnNativeAd
;
import
com.mints.xunmi.common.AppConfig
;
import
com.mints.xunmi.common.AppConfig
;
import
com.mints.xunmi.common.Constant
;
import
com.mints.xunmi.common.Constant
;
import
com.mints.xunmi.manager.MainAmapLocationManager
;
import
com.mints.xunmi.manager.MainAmapLocationManager
;
...
@@ -93,6 +94,8 @@ public class MainActivity extends BaseActivity implements MainView {
...
@@ -93,6 +94,8 @@ public class MainActivity extends BaseActivity implements MainView {
@Override
@Override
public
void
onDestroy
()
{
public
void
onDestroy
()
{
super
.
onDestroy
();
super
.
onDestroy
();
TopOnNativeAd
.
INSTANCE
.
onDestroy
();
}
}
@Override
@Override
...
...
position/app/src/main/java/com/mints/xunmi/ui/activitys/SplashADActivity.java
View file @
f990cdfb
package
com
.
mints
.
xunmi
.
ui
.
activitys
;
//package com.mints.xunmi.ui.activitys;
//
import
android.Manifest
;
//import android.Manifest;
import
android.annotation.TargetApi
;
//import android.annotation.TargetApi;
import
android.app.Activity
;
//import android.app.Activity;
import
android.content.pm.PackageManager
;
//import android.content.pm.PackageManager;
import
android.os.Build
;
//import android.os.Build;
import
android.os.Handler
;
//import android.os.Handler;
import
android.os.Looper
;
//import android.os.Looper;
import
android.util.Log
;
//import android.util.Log;
import
android.view.KeyEvent
;
//import android.view.KeyEvent;
import
android.view.View
;
//import android.view.View;
import
android.view.ViewGroup
;
//import android.view.ViewGroup;
import
android.widget.FrameLayout
;
//import android.widget.FrameLayout;
import
android.widget.ImageView
;
//import android.widget.ImageView;
import
android.widget.TextView
;
//import android.widget.TextView;
//
import
com.mints.library.net.netstatus.NetUtils
;
//import com.mints.library.net.netstatus.NetUtils;
import
com.mints.xunmi.R
;
//import com.mints.xunmi.R;
import
com.mints.xunmi.ui.activitys.base.BaseActivity
;
//import com.mints.xunmi.ui.activitys.base.BaseActivity;
import
com.mints.xunmi.utils.PreferencesService
;
//import com.mints.xunmi.utils.PreferencesService;
import
com.qq.e.ads.splash.SplashAD
;
//import com.qq.e.ads.splash.SplashAD;
import
com.qq.e.ads.splash.SplashADListener
;
//import com.qq.e.ads.splash.SplashADListener;
import
com.qq.e.comm.util.AdError
;
//import com.qq.e.comm.util.AdError;
//
import
java.util.ArrayList
;
//import java.util.ArrayList;
import
java.util.List
;
//import java.util.List;
//
import
butterknife.Bind
;
//import butterknife.Bind;
//
/**
///**
* 后台返回时每次都展示
// * 后台返回时每次都展示
*/
// */
public
class
SplashADActivity
extends
BaseActivity
implements
SplashADListener
{
//public class SplashADActivity extends BaseActivity implements SplashADListener {
//
@Bind
(
R
.
id
.
fl_splash
)
// @Bind(R.id.fl_splash)
FrameLayout
flSplashRoot
;
// FrameLayout flSplashRoot;
//
private
SplashAD
splashAD
;
// private SplashAD splashAD;
private
ViewGroup
container
;
// private ViewGroup container;
private
TextView
skipView
;
// private TextView skipView;
private
ImageView
splashHolder
;
// private ImageView splashHolder;
private
static
final
String
SKIP_TEXT
=
"点击跳过 %d"
;
// private static final String SKIP_TEXT = "点击跳过 %d";
//
public
boolean
canJump
=
false
;
// public boolean canJump = false;
private
PreferencesService
ps
;
// private PreferencesService ps;
//
/**
// /**
* 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo
// * 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo
* 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo
// * 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo
* 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值(单位ms)
// * 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值(单位ms)
**/
// **/
private
int
minSplashTimeWhenNoAD
=
3000
;
// private int minSplashTimeWhenNoAD = 3000;
/**
// /**
* 记录拉取广告的时间
// * 记录拉取广告的时间
*/
// */
private
long
fetchSplashADTime
=
0
;
// private long fetchSplashADTime = 0;
private
Handler
handler
=
new
Handler
(
Looper
.
getMainLooper
());
// private Handler handler = new Handler(Looper.getMainLooper());
//
@Override
// @Override
protected
int
getContentViewLayoutID
()
{
// protected int getContentViewLayoutID() {
return
R
.
layout
.
activity_splash_ylh
;
// return R.layout.activity_splash_ylh;
}
// }
//
@Override
// @Override
protected
void
initViewsAndEvents
()
{
// protected void initViewsAndEvents() {
if
(!
NetUtils
.
isNetworkConnected
(
getContext
()))
{
// if (!NetUtils.isNetworkConnected(getContext())) {
finish
();
// finish();
}
else
{
// } else {
//
try
{
// try {
container
=
(
ViewGroup
)
this
.
findViewById
(
R
.
id
.
splash_container
);
// container = (ViewGroup) this.findViewById(R.id.splash_container);
fetchSplashAD
(
this
,
container
,
skipView
,
getPosId
(),
this
,
0
);
}
catch
(
Exception
e
)
{
readyGoOtherActivity
();
}
// container = (ViewGroup) this.findViewById(R.id.splash_container);
// if (Build.VERSION.SDK_INT >= 23) {
// checkAndRequestPermission();
// } else {
// // 如果是Android6.0以下的机器,建议在manifest中配置相关权限,这里可以直接调用SDK
// fetchSplashAD(this, container, skipView, getPosId(), this, 0);
// fetchSplashAD(this, container, skipView, getPosId(), this, 0);
// } catch (Exception e) {
// readyGoOtherActivity();
// }
// }
}
//
}
//// container = (ViewGroup) this.findViewById(R.id.splash_container);
//// if (Build.VERSION.SDK_INT >= 23) {
@Override
//// checkAndRequestPermission();
protected
boolean
isApplyKitKatTranslucency
()
{
//// } else {
return
false
;
//// // 如果是Android6.0以下的机器,建议在manifest中配置相关权限,这里可以直接调用SDK
}
//// fetchSplashAD(this, container, skipView, getPosId(), this, 0);
//// }
private
String
getPosId
()
{
// }
String
posId
=
"9041722459847446"
;
// }
return
posId
;
//
}
// @Override
// protected boolean isApplyKitKatTranslucency() {
/**
// return false;
* ----------非常重要----------
// }
* <p>
//
* Android6.0以上的权限适配简单示例:
// private String getPosId() {
* <p>
// String posId = "9041722459847446";
* 如果targetSDKVersion >= 23,那么建议动态申请相关权限,再调用广点通SDK
// return posId;
* <p>
// }
* SDK不强制校验下列权限(即:无下面权限sdk也可正常工作),但建议开发者申请下面权限,尤其是READ_PHONE_STATE权限
//
* <p>
// /**
* READ_PHONE_STATE权限用于允许SDK获取用户标识,
// * ----------非常重要----------
* 针对单媒体的用户,允许获取权限的,投放定向广告;不允许获取权限的用户,投放通投广告,媒体可以选择是否把用户标识数据提供给优量汇,并承担相应广告填充和eCPM单价下降损失的结果。
// * <p>
* <p>
// * Android6.0以上的权限适配简单示例:
* Demo代码里是一个基本的权限申请示例,请开发者根据自己的场景合理地编写这部分代码来实现权限申请。
// * <p>
* 注意:下面的`checkSelfPermission`和`requestPermissions`方法都是在Android6.0的SDK中增加的API,如果您的App还没有适配到Android6.0以上,则不需要调用这些方法,直接调用广点通SDK即可。
// * 如果targetSDKVersion >= 23,那么建议动态申请相关权限,再调用广点通SDK
*/
// * <p>
@TargetApi
(
Build
.
VERSION_CODES
.
M
)
// * SDK不强制校验下列权限(即:无下面权限sdk也可正常工作),但建议开发者申请下面权限,尤其是READ_PHONE_STATE权限
private
void
checkAndRequestPermission
()
{
// * <p>
List
<
String
>
lackedPermission
=
new
ArrayList
<
String
>();
// * READ_PHONE_STATE权限用于允许SDK获取用户标识,
if
(!(
checkSelfPermission
(
Manifest
.
permission
.
READ_PHONE_STATE
)
==
PackageManager
.
PERMISSION_GRANTED
))
{
// * 针对单媒体的用户,允许获取权限的,投放定向广告;不允许获取权限的用户,投放通投广告,媒体可以选择是否把用户标识数据提供给优量汇,并承担相应广告填充和eCPM单价下降损失的结果。
lackedPermission
.
add
(
Manifest
.
permission
.
READ_PHONE_STATE
);
// * <p>
}
// * Demo代码里是一个基本的权限申请示例,请开发者根据自己的场景合理地编写这部分代码来实现权限申请。
// * 注意:下面的`checkSelfPermission`和`requestPermissions`方法都是在Android6.0的SDK中增加的API,如果您的App还没有适配到Android6.0以上,则不需要调用这些方法,直接调用广点通SDK即可。
if
(!(
checkSelfPermission
(
Manifest
.
permission
.
ACCESS_FINE_LOCATION
)
==
PackageManager
.
PERMISSION_GRANTED
))
{
// */
lackedPermission
.
add
(
Manifest
.
permission
.
ACCESS_FINE_LOCATION
);
// @TargetApi(Build.VERSION_CODES.M)
}
// private void checkAndRequestPermission() {
// List<String> lackedPermission = new ArrayList<String>();
// 快手SDK所需相关权限,存储权限,此处配置作用于流量分配功能,关于流量分配,详情请咨询商务;如果您的APP不需要快手SDK的流量分配功能,则无需申请SD卡权限
// if (!(checkSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED)) {
if
(!(
checkSelfPermission
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
)
==
PackageManager
.
PERMISSION_GRANTED
))
{
// lackedPermission.add(Manifest.permission.READ_PHONE_STATE);
lackedPermission
.
add
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
);
// }
}
//
if
(!(
checkSelfPermission
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
==
PackageManager
.
PERMISSION_GRANTED
))
{
// if (!(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)) {
lackedPermission
.
add
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
);
// lackedPermission.add(Manifest.permission.ACCESS_FINE_LOCATION);
}
// }
//
// 如果需要的权限都已经有了,那么直接调用SDK
// // 快手SDK所需相关权限,存储权限,此处配置作用于流量分配功能,关于流量分配,详情请咨询商务;如果您的APP不需要快手SDK的流量分配功能,则无需申请SD卡权限
if
(
lackedPermission
.
size
()
==
0
)
{
// if (!(checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) {
fetchSplashAD
(
this
,
container
,
skipView
,
getPosId
(),
this
,
0
);
// lackedPermission.add(Manifest.permission.READ_EXTERNAL_STORAGE);
}
else
{
// }
// 否则,建议请求所缺少的权限,在onRequestPermissionsResult中再看是否获得权限
// if (!(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) {
String
[]
requestPermissions
=
new
String
[
lackedPermission
.
size
()];
// lackedPermission.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
lackedPermission
.
toArray
(
requestPermissions
);
// }
requestPermissions
(
requestPermissions
,
1024
);
//
}
// // 如果需要的权限都已经有了,那么直接调用SDK
}
// if (lackedPermission.size() == 0) {
// fetchSplashAD(this, container, skipView, getPosId(), this, 0);
private
boolean
hasAllPermissionsGranted
(
int
[]
grantResults
)
{
// } else {
for
(
int
grantResult
:
grantResults
)
{
// // 否则,建议请求所缺少的权限,在onRequestPermissionsResult中再看是否获得权限
if
(
grantResult
==
PackageManager
.
PERMISSION_DENIED
)
{
// String[] requestPermissions = new String[lackedPermission.size()];
return
false
;
// lackedPermission.toArray(requestPermissions);
}
// requestPermissions(requestPermissions, 1024);
}
// }
return
true
;
// }
}
//
// private boolean hasAllPermissionsGranted(int[] grantResults) {
@Override
// for (int grantResult : grantResults) {
public
void
onRequestPermissionsResult
(
int
requestCode
,
String
[]
permissions
,
int
[]
grantResults
)
{
// if (grantResult == PackageManager.PERMISSION_DENIED) {
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
// return false;
if
(
requestCode
==
1024
&&
hasAllPermissionsGranted
(
grantResults
))
{
// }
fetchSplashAD
(
this
,
container
,
skipView
,
getPosId
(),
this
,
0
);
// }
}
else
{
// return true;
// Toast.makeText(this, "应用缺少必要的权限!请点击\"权限\",打开所需要的权限。", Toast.LENGTH_LONG).show();
// }
// Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
//
// intent.setData(Uri.parse("package:" + getPackageName()));
// @Override
// startActivity(intent);
// public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
// finish();
// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
readyGoOtherActivity
();
// if (requestCode == 1024 && hasAllPermissionsGranted(grantResults)) {
}
// fetchSplashAD(this, container, skipView, getPosId(), this, 0);
}
// } else {
//// Toast.makeText(this, "应用缺少必要的权限!请点击\"权限\",打开所需要的权限。", Toast.LENGTH_LONG).show();
/**
//// Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
* 拉取开屏广告,开屏广告的构造方法有3种,详细说明请参考开发者文档。
//// intent.setData(Uri.parse("package:" + getPackageName()));
*
//// startActivity(intent);
* @param activity 展示广告的activity
//// finish();
* @param adContainer 展示广告的大容器
// readyGoOtherActivity();
* @param skipContainer 自定义的跳过按钮:传入该view给SDK后,SDK会自动给它绑定点击跳过事件。SkipView的样式可以由开发者自由定制,其尺寸限制请参考activity_splash.xml或者接入文档中的说明。
// }
* @param posId 广告位ID
// }
* @param adListener 广告状态监听器
//
* @param fetchDelay 拉取广告的超时时长:取值范围[3000, 5000],设为0表示使用广点通SDK默认的超时时长。
// /**
*/
// * 拉取开屏广告,开屏广告的构造方法有3种,详细说明请参考开发者文档。
private
void
fetchSplashAD
(
Activity
activity
,
ViewGroup
adContainer
,
View
skipContainer
,
// *
String
posId
,
SplashADListener
adListener
,
int
fetchDelay
)
{
// * @param activity 展示广告的activity
fetchSplashADTime
=
System
.
currentTimeMillis
();
// * @param adContainer 展示广告的大容器
splashAD
=
new
SplashAD
(
activity
,
skipContainer
,
posId
,
adListener
,
fetchDelay
);
// * @param skipContainer 自定义的跳过按钮:传入该view给SDK后,SDK会自动给它绑定点击跳过事件。SkipView的样式可以由开发者自由定制,其尺寸限制请参考activity_splash.xml或者接入文档中的说明。
splashAD
.
fetchAndShowIn
(
adContainer
);
// * @param posId 广告位ID
}
// * @param adListener 广告状态监听器
// * @param fetchDelay 拉取广告的超时时长:取值范围[3000, 5000],设为0表示使用广点通SDK默认的超时时长。
@Override
// */
public
void
onADPresent
()
{
// private void fetchSplashAD(Activity activity, ViewGroup adContainer, View skipContainer,
Log
.
i
(
"AD_DEMO"
,
"SplashADPresent"
);
// String posId, SplashADListener adListener, int fetchDelay) {
}
// fetchSplashADTime = System.currentTimeMillis();
// splashAD = new SplashAD(activity, skipContainer, posId, adListener, fetchDelay);
@Override
// splashAD.fetchAndShowIn(adContainer);
public
void
onADClicked
()
{
// }
Log
.
i
(
"AD_DEMO"
,
"SplashADClicked clickUrl: "
//
+
(
splashAD
.
getExt
()
!=
null
?
splashAD
.
getExt
().
get
(
"clickUrl"
)
:
""
));
// @Override
}
// public void onADPresent() {
// Log.i("AD_DEMO", "SplashADPresent");
/**
// }
* 倒计时回调,返回广告还将被展示的剩余时间。
//
* 通过这个接口,开发者可以自行决定是否显示倒计时提示,或者还剩几秒的时候显示倒计时
// @Override
*
// public void onADClicked() {
* @param millisUntilFinished 剩余毫秒数
// Log.i("AD_DEMO", "SplashADClicked clickUrl: "
*/
// + (splashAD.getExt() != null ? splashAD.getExt().get("clickUrl") : ""));
@Override
// }
public
void
onADTick
(
long
millisUntilFinished
)
{
//
Log
.
i
(
"AD_DEMO"
,
"SplashADTick "
+
millisUntilFinished
+
"ms"
);
// /**
if
(
skipView
!=
null
)
{
// * 倒计时回调,返回广告还将被展示的剩余时间。
skipView
.
setText
(
String
.
format
(
SKIP_TEXT
,
Math
.
round
(
millisUntilFinished
/
1000
f
)));
// * 通过这个接口,开发者可以自行决定是否显示倒计时提示,或者还剩几秒的时候显示倒计时
}
// *
}
// * @param millisUntilFinished 剩余毫秒数
// */
@Override
// @Override
public
void
onADExposure
()
{
// public void onADTick(long millisUntilFinished) {
Log
.
i
(
"AD_DEMO"
,
"SplashADExposure"
);
// Log.i("AD_DEMO", "SplashADTick " + millisUntilFinished + "ms");
}
// if (skipView != null) {
// skipView.setText(String.format(SKIP_TEXT, Math.round(millisUntilFinished / 1000f)));
@Override
// }
public
void
onADLoaded
(
long
expireTimestamp
)
{
// }
Log
.
i
(
"AD_DEMO"
,
"SplashADFetch expireTimestamp: "
+
expireTimestamp
//
+
", eCPMLevel = "
+
splashAD
.
getECPMLevel
());
// @Override
}
// public void onADExposure() {
// Log.i("AD_DEMO", "SplashADExposure");
@Override
// }
public
void
onADDismissed
()
{
//
Log
.
i
(
"AD_DEMO"
,
"SplashADDismissed"
);
// @Override
next
();
// public void onADLoaded(long expireTimestamp) {
}
// Log.i("AD_DEMO", "SplashADFetch expireTimestamp: " + expireTimestamp
// + ", eCPMLevel = " + splashAD.getECPMLevel());
@Override
// }
public
void
onNoAD
(
AdError
error
)
{
//
String
str
=
String
.
format
(
"LoadSplashADFail, eCode=%d, errorMsg=%s"
,
error
.
getErrorCode
(),
// @Override
error
.
getErrorMsg
());
// public void onADDismissed() {
Log
.
i
(
"AD_DEMO"
,
str
);
// Log.i("AD_DEMO", "SplashADDismissed");
/**
// next();
* 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo
// }
* 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo
//
* 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值
// @Override
**/
// public void onNoAD(AdError error) {
long
alreadyDelayMills
=
System
.
currentTimeMillis
()
-
fetchSplashADTime
;
//从拉广告开始到onNoAD已经消耗了多少时间
// String str = String.format("LoadSplashADFail, eCode=%d, errorMsg=%s", error.getErrorCode(),
long
shouldDelayMills
=
alreadyDelayMills
>
minSplashTimeWhenNoAD
?
0
:
minSplashTimeWhenNoAD
// error.getErrorMsg());
-
alreadyDelayMills
;
//为防止加载广告失败后立刻跳离开屏可能造成的视觉上类似于"闪退"的情况,根据设置的minSplashTimeWhenNoAD
// Log.i("AD_DEMO", str);
// 计算出还需要延时多久
// /**
handler
.
postDelayed
(
new
Runnable
()
{
// * 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo
@Override
// * 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo
public
void
run
()
{
// * 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值
readyGoOtherActivity
();
// **/
}
// long alreadyDelayMills = System.currentTimeMillis() - fetchSplashADTime;//从拉广告开始到onNoAD已经消耗了多少时间
},
shouldDelayMills
);
// long shouldDelayMills = alreadyDelayMills > minSplashTimeWhenNoAD ? 0 : minSplashTimeWhenNoAD
}
// - alreadyDelayMills;//为防止加载广告失败后立刻跳离开屏可能造成的视觉上类似于"闪退"的情况,根据设置的minSplashTimeWhenNoAD
// // 计算出还需要延时多久
/**
// handler.postDelayed(new Runnable() {
* 设置一个变量来控制当前开屏页面是否可以跳转,当开屏广告为普链类广告时,点击会打开一个广告落地页,此时开发者还不能打开自己的App主页。当从广告落地页返回以后,
// @Override
* 才可以跳转到开发者自己的App主页;当开屏广告是App类广告时只会下载App。
// public void run() {
*/
// readyGoOtherActivity();
private
void
next
()
{
// }
if
(
canJump
)
{
// }, shouldDelayMills);
readyGoOtherActivity
();
// }
}
else
{
//
canJump
=
true
;
// /**
}
// * 设置一个变量来控制当前开屏页面是否可以跳转,当开屏广告为普链类广告时,点击会打开一个广告落地页,此时开发者还不能打开自己的App主页。当从广告落地页返回以后,
}
// * 才可以跳转到开发者自己的App主页;当开屏广告是App类广告时只会下载App。
// */
@Override
// private void next() {
protected
void
onPause
()
{
// if (canJump) {
super
.
onPause
();
// readyGoOtherActivity();
canJump
=
false
;
// } else {
}
// canJump = true;
// }
@Override
// }
protected
void
onResume
()
{
//
super
.
onResume
();
// @Override
if
(
canJump
)
{
// protected void onPause() {
next
();
// super.onPause();
}
// canJump = false;
canJump
=
true
;
// }
}
//
// @Override
@Override
// protected void onResume() {
protected
void
onDestroy
()
{
// super.onResume();
super
.
onDestroy
();
// if (canJump) {
handler
.
removeCallbacksAndMessages
(
null
);
// next();
}
// }
// canJump = true;
/**
// }
* 开屏页一定要禁止用户对返回按钮的控制,否则将可能导致用户手动退出了App而广告无法正常曝光和计费
//
*/
// @Override
@Override
// protected void onDestroy() {
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
// super.onDestroy();
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
)
{
// handler.removeCallbacksAndMessages(null);
return
true
;
// }
}
//
return
super
.
onKeyDown
(
keyCode
,
event
);
// /**
}
// * 开屏页一定要禁止用户对返回按钮的控制,否则将可能导致用户手动退出了App而广告无法正常曝光和计费
// */
private
void
readyGoOtherActivity
()
{
// @Override
finish
();
// public boolean onKeyDown(int keyCode, KeyEvent event) {
}
// if (keyCode == KeyEvent.KEYCODE_BACK) {
}
// return true;
// }
// return super.onKeyDown(keyCode, event);
// }
//
// private void readyGoOtherActivity() {
// finish();
// }
//}
position/app/src/main/java/com/mints/xunmi/ui/activitys/SplashAdShowActivity.java
View file @
f990cdfb
...
@@ -2,6 +2,7 @@ package com.mints.xunmi.ui.activitys;
...
@@ -2,6 +2,7 @@ package com.mints.xunmi.ui.activitys;
import
android.os.CountDownTimer
;
import
android.os.CountDownTimer
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.FrameLayout
;
import
android.widget.FrameLayout
;
...
@@ -163,5 +164,11 @@ public class SplashAdShowActivity extends BaseActivity implements ATSplashAdList
...
@@ -163,5 +164,11 @@ public class SplashAdShowActivity extends BaseActivity implements ATSplashAdList
}
}
}
}
@Override
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
)
{
return
true
;
}
return
super
.
onKeyDown
(
keyCode
,
event
);
}
}
}
position/app/src/main/java/com/mints/xunmi/ui/activitys/SplashBackActivity.java
View file @
f990cdfb
...
@@ -2,6 +2,7 @@ package com.mints.xunmi.ui.activitys;
...
@@ -2,6 +2,7 @@ package com.mints.xunmi.ui.activitys;
import
android.os.CountDownTimer
;
import
android.os.CountDownTimer
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.FrameLayout
;
import
android.widget.FrameLayout
;
...
@@ -128,5 +129,11 @@ public class SplashBackActivity extends BaseActivity implements ATSplashAdListen
...
@@ -128,5 +129,11 @@ public class SplashBackActivity extends BaseActivity implements ATSplashAdListen
}
}
}
}
@Override
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
)
{
return
true
;
}
return
super
.
onKeyDown
(
keyCode
,
event
);
}
}
}
position/app/src/main/java/com/mints/xunmi/ui/fragment/MainFragment.kt
View file @
f990cdfb
...
@@ -3,14 +3,13 @@ package com.mints.xunmi.ui.fragment
...
@@ -3,14 +3,13 @@ package com.mints.xunmi.ui.fragment
import
android.Manifest
import
android.Manifest
import
android.os.Build
import
android.os.Build
import
android.os.Bundle
import
android.os.Bundle
import
android.os.Message
import
android.text.TextUtils
import
android.text.TextUtils
import
android.view.View
import
android.view.View
import
android.widget.FrameLayout
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.LinearLayoutManager
import
com.mints.library.recyclerview.HeaderAndFooterRecyclerViewAdapter
import
com.mints.library.recyclerview.HeaderAndFooterRecyclerViewAdapter
import
com.mints.library.recyclerview.RecyclerViewUtils
import
com.mints.library.recyclerview.RecyclerViewUtils
import
com.mints.library.utils.nodoubleclick.AntiShake
import
com.mints.library.utils.nodoubleclick.AntiShake
import
com.mints.xunmi.BuildConfig
import
com.mints.xunmi.R
import
com.mints.xunmi.R
import
com.mints.xunmi.ad.TopOnNativeAd
import
com.mints.xunmi.ad.TopOnNativeAd
import
com.mints.xunmi.common.AppConfig
import
com.mints.xunmi.common.AppConfig
...
@@ -26,7 +25,10 @@ import com.mints.xunmi.ui.adapter.MyConcernedPeopleAdapter
...
@@ -26,7 +25,10 @@ import com.mints.xunmi.ui.adapter.MyConcernedPeopleAdapter
import
com.mints.xunmi.ui.adapter.MyMainConcernedPeopleAdapterFooter
import
com.mints.xunmi.ui.adapter.MyMainConcernedPeopleAdapterFooter
import
com.mints.xunmi.ui.fragment.base.BaseFragment
import
com.mints.xunmi.ui.fragment.base.BaseFragment
import
com.mints.xunmi.ui.widgets.*
import
com.mints.xunmi.ui.widgets.*
import
com.mints.xunmi.utils.LogUtil
import
com.mints.xunmi.utils.SPUtil
import
com.mints.xunmi.utils.SPUtil
import
com.mints.xunmi.utils.WeakHandler
import
com.mints.xunmi.utils.WeakHandler.IHandler
import
com.tbruyelle.rxpermissions.RxPermissions
import
com.tbruyelle.rxpermissions.RxPermissions
import
kotlinx.android.synthetic.main.fragment_main_first.*
import
kotlinx.android.synthetic.main.fragment_main_first.*
...
@@ -36,10 +38,17 @@ import kotlinx.android.synthetic.main.fragment_main_first.*
...
@@ -36,10 +38,17 @@ import kotlinx.android.synthetic.main.fragment_main_first.*
* 时间:2020/6/4 17:30
* 时间:2020/6/4 17:30
*/
*/
class
MainFragment
:
BaseFragment
()
class
MainFragment
:
BaseFragment
()
,
MainFragmentView
,
MyConcernedPeopleAdapter
.
OnItemClickListener
,
View
.
OnClickListener
{
,
MainFragmentView
,
MyConcernedPeopleAdapter
.
OnItemClickListener
,
View
.
OnClickListener
,
IHandler
{
private
val
TAG
=
MainFragment
::
class
.
java
.
simpleName
private
val
TAG
=
MainFragment
::
class
.
java
.
simpleName
/*首页位置刷新相关*/
private
var
refreshLocationFlag
=
true
private
val
LOCATION_TIME
:
Long
=
3000
private
val
LOCATION_MSG
:
Int
=
102
private
var
mHandler
:
WeakHandler
?
=
null
private
var
friendsSetBottomDialog
:
FriendsSetBottomDialog
?
=
null
private
var
friendsSetBottomDialog
:
FriendsSetBottomDialog
?
=
null
private
var
powerDialog
:
PowerDialog
?
=
null
private
var
powerDialog
:
PowerDialog
?
=
null
private
var
messageDialog
:
MessageDialog
?
=
null
private
var
messageDialog
:
MessageDialog
?
=
null
...
@@ -69,7 +78,7 @@ class MainFragment : BaseFragment()
...
@@ -69,7 +78,7 @@ class MainFragment : BaseFragment()
context
?.
let
{
context
?.
let
{
TopOnNativeAd
.
init
(
it
)
TopOnNativeAd
.
init
(
it
)
TopOnNativeAd
.
loadNativeAd
(
it
,
null
)
TopOnNativeAd
.
loadNativeAd
(
null
)
}
}
linearLayoutManager
=
LinearLayoutManager
(
activity
)
linearLayoutManager
=
LinearLayoutManager
(
activity
)
...
@@ -85,6 +94,8 @@ class MainFragment : BaseFragment()
...
@@ -85,6 +94,8 @@ class MainFragment : BaseFragment()
// discountDialog()
// discountDialog()
// }
// }
// }
// }
mHandler
=
WeakHandler
(
this
)
}
}
override
fun
onHiddenChanged
(
hidden
:
Boolean
)
{
override
fun
onHiddenChanged
(
hidden
:
Boolean
)
{
...
@@ -129,27 +140,34 @@ class MainFragment : BaseFragment()
...
@@ -129,27 +140,34 @@ class MainFragment : BaseFragment()
getCares
(
null
)
getCares
(
null
)
mainFragmentPresenter
?.
userLogin
(
context
!!
)
mainFragmentPresenter
?.
userLogin
(
context
!!
)
}
}
// refreshLocationFlag = true
mHandler
?.
sendEmptyMessageDelayed
(
LOCATION_MSG
,
LOCATION_TIME
)
}
}
}
}
override
fun
onPause
()
{
super
.
onPause
()
refreshLocationFlag
=
false
}
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
super
.
onDestroy
()
super
.
onDestroy
()
mHandler
?.
removeCallbacksAndMessages
(
null
)
mHandler
=
null
mainFragmentPresenter
.
detachView
()
mainFragmentPresenter
.
detachView
()
}
}
override
fun
getCares
(
data
:
MyCareBean
?)
{
override
fun
getCares
(
data
:
MyCareBean
?)
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
())
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
())
{
myConcernedPeopleBeanArrayList
=
arrayListOf
<
MyCareBean
.
ListBean
>()
myConcernedPeopleBeanArrayList
=
arrayListOf
<
MyCareBean
.
ListBean
>()
val
people
=
MyCareBean
.
ListBean
()
myConcernedPeopleBeanArrayList
?.
addAll
(
listOf
(
getMyLocationInfo
()))
people
.
cmobile
=
"我自己"
people
.
update
=
System
.
currentTimeMillis
()
/
1000
people
.
gpsMsg
=
AppConfig
.
curAddress
people
.
cuid
=
Constant
.
MY_USER_UID
(
myConcernedPeopleBeanArrayList
as
ArrayList
<
MyCareBean
.
ListBean
>).
addAll
(
listOf
(
people
))
if
(
data
!=
null
&&
data
.
list
!=
null
&&
data
.
list
.
size
>
0
)
{
if
(
data
!=
null
&&
data
.
list
!=
null
&&
data
.
list
.
size
>
0
)
{
(
myConcernedPeopleBeanArrayList
as
ArrayList
<
MyCareBean
.
ListBean
>)
.
addAll
(
data
.
list
)
myConcernedPeopleBeanArrayList
?
.
addAll
(
data
.
list
)
}
}
initRvView
()
initRvView
()
...
@@ -298,7 +316,7 @@ class MainFragment : BaseFragment()
...
@@ -298,7 +316,7 @@ class MainFragment : BaseFragment()
}
}
private
fun
initManager
()
{
private
fun
initManager
()
{
spUtil
=
SPUtil
.
getInstance
(
context
)
spUtil
=
SPUtil
.
getInstance
()
userManager
=
UserManager
.
getInstance
()
userManager
=
UserManager
.
getInstance
()
// 首次安装APP时,只弹一次权限声明
// 首次安装APP时,只弹一次权限声明
...
@@ -410,22 +428,46 @@ class MainFragment : BaseFragment()
...
@@ -410,22 +428,46 @@ class MainFragment : BaseFragment()
* 五折弹窗
* 五折弹窗
*/
*/
private
fun
discountDialog
()
{
private
fun
discountDialog
()
{
discountDialog
=
DiscountDialog
(
context
,
object
:
DialogListener
()
{
// discountDialog = DiscountDialog(context, object : DialogListener() {
override
fun
onClick
(
v
:
View
)
{
// override fun onClick(v: View) {
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
()
&&
// if (activity != null && !activity!!.isFinishing() &&
discountDialog
!=
null
&&
discountDialog
!!
.
isShowing
())
{
// discountDialog != null && discountDialog!!.isShowing()) {
discountDialog
!!
.
onDestory
()
// discountDialog!!.onDestory()
discountDialog
!!
.
dismiss
()
// discountDialog!!.dismiss()
}
// }
when
(
v
.
id
)
{
// when (v.id) {
R
.
id
.
tv_dialog_discount
->
{
// R.id.tv_dialog_discount -> {
if
(!
userManager
?.
vipFlag
!!
)
{
// if (!userManager?.vipFlag!!) {
activity
?.
let
{
VipPayManager
.
getInstance
(
it
)
!!
.
gotoPayPage
(
3
)
}
// activity?.let { VipPayManager.getInstance(it)!!.gotoPayPage(3) }
}
// }
}
// }
}
// }
// }
// })
// discountDialog!!.show()
}
override
fun
handleMsg
(
msg
:
Message
?)
{
if
(
msg
?.
what
==
LOCATION_MSG
)
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
()
&&
refreshLocationFlag
)
{
LogUtil
.
d
(
TAG
,
"mainfragment handleMsg"
)
mHandler
?.
sendEmptyMessageDelayed
(
LOCATION_MSG
,
LOCATION_TIME
)
myConcernedPeopleBeanArrayList
?.
set
(
0
,
getMyLocationInfo
())
myConcernedPeopleAdapter
.
notifyItemChanged
(
0
)
}
}
}
)
}
discountDialog
!!
.
show
()
}
}
fun
getMyLocationInfo
():
MyCareBean
.
ListBean
{
val
people
=
MyCareBean
.
ListBean
()
people
.
cmobile
=
"我自己"
people
.
update
=
System
.
currentTimeMillis
()
/
1000
people
.
gpsMsg
=
AppConfig
.
curAddress
people
.
cuid
=
Constant
.
MY_USER_UID
return
people
}
}
}
\ No newline at end of file
position/app/src/main/java/com/mints/xunmi/ui/fragment/MyFragment.kt
View file @
f990cdfb
...
@@ -68,7 +68,7 @@ class MyFragment : BaseFragment()
...
@@ -68,7 +68,7 @@ class MyFragment : BaseFragment()
}
}
myPresenter
.
attachView
(
this
)
myPresenter
.
attachView
(
this
)
spUtil
=
SPUtil
.
getInstance
(
context
)
spUtil
=
SPUtil
.
getInstance
()
userManager
=
UserManager
.
getInstance
()
userManager
=
UserManager
.
getInstance
()
drawable
=
activity
?.
let
{
ContextCompat
.
getDrawable
(
it
,
R
.
mipmap
.
ic_launcher
)
}
drawable
=
activity
?.
let
{
ContextCompat
.
getDrawable
(
it
,
R
.
mipmap
.
ic_launcher
)
}
initListener
()
initListener
()
...
@@ -92,7 +92,7 @@ class MyFragment : BaseFragment()
...
@@ -92,7 +92,7 @@ class MyFragment : BaseFragment()
myPresenter
?.
userLogin
(
context
!!
)
myPresenter
?.
userLogin
(
context
!!
)
}
}
// context?.let { TopOnNativeAd.loadNativeAd(it, flMyAdContainer) }
TopOnNativeAd
.
loadNativeAd
(
flMyAdContainer
)
}
}
}
}
...
@@ -168,7 +168,6 @@ class MyFragment : BaseFragment()
...
@@ -168,7 +168,6 @@ class MyFragment : BaseFragment()
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
super
.
onDestroy
()
super
.
onDestroy
()
TopOnNativeAd
.
onDestroy
()
myPresenter
.
detachView
()
myPresenter
.
detachView
()
}
}
...
@@ -187,12 +186,6 @@ class MyFragment : BaseFragment()
...
@@ -187,12 +186,6 @@ class MyFragment : BaseFragment()
override
fun
getSysBaseMsg
(
msgNum
:
Int
,
notifyNum
:
Int
,
phone
:
String
)
{
override
fun
getSysBaseMsg
(
msgNum
:
Int
,
notifyNum
:
Int
,
phone
:
String
)
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
())
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
())
{
// if (msgNum >= 1) {
// ivMyFragmentNofity.setImageResource(R.mipmap.ic_main_msg_enable)
// } else {
// ivMyFragmentNofity.setImageResource(R.mipmap.ic_main_msg)
// }
if
(
notifyNum
>=
1
)
{
if
(
notifyNum
>=
1
)
{
messageDialog
()
messageDialog
()
}
}
...
@@ -271,21 +264,6 @@ class MyFragment : BaseFragment()
...
@@ -271,21 +264,6 @@ class MyFragment : BaseFragment()
readyGo
(
WebActivity
::
class
.
java
,
bundle
)
readyGo
(
WebActivity
::
class
.
java
,
bundle
)
}
}
R
.
id
.
rlMyShare
->
{
R
.
id
.
rlMyShare
->
{
// sendSMS(BuildConfig.MainIp + "instructions.html")
// val wechat_sp = ShareParams()
// wechat_sp.shareType = Platform.SHARE_WEBPAGE
// wechat_sp.title = Constant.SHARE_TITLE
// wechat_sp.text = Constant.SHARE_CONTENT
// wechat_sp.imageData = ImageUtil.drawableToBitmap(drawable)
// wechat_sp.url = Constant.SHARE_URL
// val wechat = ShareSDK.getPlatform(Wechat.NAME)
// if (wechat.isClientValid) {
// // 执行图文分享
// wechat.share(wechat_sp)
// } else {
// showToast("请先安装微信")
// }
bottomDialog
=
BottomDialog
.
create
(
supportFragmentManager
)
bottomDialog
=
BottomDialog
.
create
(
supportFragmentManager
)
.
setViewListener
{
v
->
.
setViewListener
{
v
->
v
.
findViewById
<
LinearLayout
>(
R
.
id
.
llDialogShareWx
).
setOnClickListener
(
this
)
v
.
findViewById
<
LinearLayout
>(
R
.
id
.
llDialogShareWx
).
setOnClickListener
(
this
)
...
@@ -326,22 +304,6 @@ class MyFragment : BaseFragment()
...
@@ -326,22 +304,6 @@ class MyFragment : BaseFragment()
}
}
AppPackageUsageUtils
.
gotoMessage
(
context
,
""
)
AppPackageUsageUtils
.
gotoMessage
(
context
,
""
)
// val sp = ShareParams()
// sp.title = Constant.SHARE_TITLE
// sp.titleUrl = Constant.SHARE_URL
// sp.text = Constant.SHARE_CONTENT
// sp.site = getString(R.string.app_name)
// sp.siteUrl = Constant.SHARE_URL
// val qq = ShareSDK.getPlatform(QQ.NAME)
// if (qq.isClientValid) {
// // 执行图文分享
// qq.share(sp)
// } else {
// showToast("请先安装QQ")
// }
}
}
R
.
id
.
tvDialogShareNext
->
{
R
.
id
.
tvDialogShareNext
->
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
())
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
())
{
...
...
position/app/src/main/java/com/mints/xunmi/ui/fragment/PositionFragment.kt
View file @
f990cdfb
...
@@ -6,6 +6,7 @@ import android.content.Intent
...
@@ -6,6 +6,7 @@ import android.content.Intent
import
android.net.Uri
import
android.net.Uri
import
android.os.Build
import
android.os.Build
import
android.os.Bundle
import
android.os.Bundle
import
android.os.Message
import
android.provider.Settings
import
android.provider.Settings
import
android.text.TextUtils
import
android.text.TextUtils
import
android.view.LayoutInflater
import
android.view.LayoutInflater
...
@@ -29,6 +30,7 @@ import com.mints.xunmi.ui.activitys.CarePeopleActivity
...
@@ -29,6 +30,7 @@ import com.mints.xunmi.ui.activitys.CarePeopleActivity
import
com.mints.xunmi.ui.activitys.MyLocusActivity
import
com.mints.xunmi.ui.activitys.MyLocusActivity
import
com.mints.xunmi.utils.LogUtil
import
com.mints.xunmi.utils.LogUtil
import
com.mints.xunmi.utils.TimeRender
import
com.mints.xunmi.utils.TimeRender
import
com.mints.xunmi.utils.WeakHandler
import
com.tbruyelle.rxpermissions.RxPermissions
import
com.tbruyelle.rxpermissions.RxPermissions
import
kotlinx.android.synthetic.main.fragment_main_position.*
import
kotlinx.android.synthetic.main.fragment_main_position.*
import
java.util.*
import
java.util.*
...
@@ -39,10 +41,16 @@ import java.util.*
...
@@ -39,10 +41,16 @@ import java.util.*
* 时间:2020/6/4 17:30
* 时间:2020/6/4 17:30
*/
*/
class
PositionFragment
:
Fragment
()
class
PositionFragment
:
Fragment
()
,
PositionView
,
View
.
OnClickListener
{
,
PositionView
,
View
.
OnClickListener
,
WeakHandler
.
IHandler
{
private
val
TAG
=
PositionFragment
::
class
.
java
.
simpleName
private
val
TAG
=
PositionFragment
::
class
.
java
.
simpleName
/*首页位置刷新相关*/
private
var
refreshLocationFlag
=
true
private
val
LOCATION_TIME
:
Long
=
3000
private
val
LOCATION_MSG
:
Int
=
103
private
var
mHandler
:
WeakHandler
?
=
null
private
lateinit
var
positionPresenter
:
PositionPresenter
private
lateinit
var
positionPresenter
:
PositionPresenter
private
var
mapLayout
:
View
?
=
null
private
var
mapLayout
:
View
?
=
null
...
@@ -82,6 +90,7 @@ class PositionFragment : Fragment()
...
@@ -82,6 +90,7 @@ class PositionFragment : Fragment()
positionPresenter
?.
userLogin
(
context
!!
)
positionPresenter
?.
userLogin
(
context
!!
)
}
}
mHandler
=
WeakHandler
(
this
)
initMapStyle
()
initMapStyle
()
initListener
()
initListener
()
...
@@ -120,19 +129,21 @@ class PositionFragment : Fragment()
...
@@ -120,19 +129,21 @@ class PositionFragment : Fragment()
override
fun
onResume
()
{
override
fun
onResume
()
{
super
.
onResume
()
super
.
onResume
()
if
(
AppConfig
.
fragmentClickFlag
===
Constant
.
FRAGMENT_CLICK_POSITION
)
{
if
(
AppConfig
.
fragmentClickFlag
===
Constant
.
FRAGMENT_CLICK_POSITION
)
{
tvFragmentPositionPosition
.
text
=
AppConfig
.
curAddress
tvFragmentPositionPosition
.
text
=
AppConfig
.
curAddress
tvFragmentPositionDate
.
text
=
TimeRender
.
formatDate
(
Date
(),
TimeRender
.
ALL_FORMAT_LINE2
)
tvFragmentPositionDate
.
text
=
TimeRender
.
formatDate
(
Date
(),
TimeRender
.
ALL_FORMAT_LINE2
)
if
(
mapPosition
!=
null
)
{
if
(
mapPosition
!=
null
)
{
mapPosition
.
onResume
()
mapPosition
.
onResume
()
}
}
LogUtil
.
d
(
TAG
,
" PositionFragment onResume"
)
mHandler
?.
sendEmptyMessageDelayed
(
LOCATION_MSG
,
LOCATION_TIME
)
}
}
}
}
override
fun
onPause
()
{
override
fun
onPause
()
{
super
.
onPause
()
super
.
onPause
()
refreshLocationFlag
=
false
if
(
mapPosition
!=
null
)
{
if
(
mapPosition
!=
null
)
{
mapPosition
.
onPause
()
mapPosition
.
onPause
()
}
}
...
@@ -148,6 +159,9 @@ class PositionFragment : Fragment()
...
@@ -148,6 +159,9 @@ class PositionFragment : Fragment()
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
super
.
onDestroy
()
super
.
onDestroy
()
mHandler
?.
removeCallbacksAndMessages
(
null
)
mHandler
=
null
mMap
?.
let
{
mMap
?.
let
{
mMap
!!
.
setOnMyLocationChangeListener
(
null
)
mMap
!!
.
setOnMyLocationChangeListener
(
null
)
mMap
=
null
mMap
=
null
...
@@ -191,20 +205,20 @@ class PositionFragment : Fragment()
...
@@ -191,20 +205,20 @@ class PositionFragment : Fragment()
// 实现定位蓝点
// 实现定位蓝点
myLocationStyle
=
MyLocationStyle
()
//初始化定位蓝点样式类myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE)//连续定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动。(1秒1次定位)如果不设置myLocationType,默认也会执行此种模式。
myLocationStyle
=
MyLocationStyle
()
//初始化定位蓝点样式类myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE)//连续定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动。(1秒1次定位)如果不设置myLocationType,默认也会执行此种模式。
myLocationStyle
?.
let
{
myLocationStyle
?.
let
{
myLocationStyle
!!
.
showMyLocation
(
true
)
//设置是否显示定位小蓝点,用于满足只想使用定位,不想使用定位小蓝点的场景,设置false以后图面上不再有定位蓝点的概念,但是会持续回调位置信息。
it
.
showMyLocation
(
true
)
//设置是否显示定位小蓝点,用于满足只想使用定位,不想使用定位小蓝点的场景,设置false以后图面上不再有定位蓝点的概念,但是会持续回调位置信息。
myLocationStyle
!!
.
interval
(
5000
)
//设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。
it
.
interval
(
5000
)
//设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。
}
}
mMap
?.
let
{
mMap
?.
let
{
uiSettings
=
mMap
!!
.
getUiSettings
()
uiSettings
=
it
.
getUiSettings
()
mMap
!!
.
moveCamera
(
CameraUpdateFactory
.
zoomTo
(
16F
))
//设置希望展示的地图缩放级别
it
.
moveCamera
(
CameraUpdateFactory
.
zoomTo
(
16F
))
//设置希望展示的地图缩放级别
mMap
!!
.
setMyLocationStyle
(
myLocationStyle
!!
.
myLocationType
(
MyLocationStyle
.
LOCATION_TYPE_LOCATION_ROTATE
))
//连续定位、且将视角移动到地图中心点,定位蓝点跟随设备移动
it
.
setMyLocationStyle
(
myLocationStyle
!!
.
myLocationType
(
MyLocationStyle
.
LOCATION_TYPE_LOCATION_ROTATE
))
//连续定位、且将视角移动到地图中心点,定位蓝点跟随设备移动
mMap
!!
.
setMyLocationEnabled
(
true
)
// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。
it
.
setMyLocationEnabled
(
true
)
// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。
}
}
uiSettings
?.
let
{
uiSettings
?.
let
{
uiSettings
!!
.
setMyLocationButtonEnabled
(
false
)
//设置默认定位按钮是否显示
it
.
setMyLocationButtonEnabled
(
false
)
//设置默认定位按钮是否显示
uiSettings
!!
.
setScaleControlsEnabled
(
false
)
//设置地图默认的比例尺是否显示
it
.
setScaleControlsEnabled
(
false
)
//设置地图默认的比例尺是否显示
uiSettings
!!
.
setZoomControlsEnabled
(
false
)
//设置缩放按钮
it
.
setZoomControlsEnabled
(
false
)
//设置缩放按钮
}
}
}
}
...
@@ -215,15 +229,12 @@ class PositionFragment : Fragment()
...
@@ -215,15 +229,12 @@ class PositionFragment : Fragment()
}
}
override
fun
showLoading
(
msg
:
String
?)
{
override
fun
showLoading
(
msg
:
String
?)
{
TODO
(
"Not yet implemented"
)
}
}
override
fun
showToast
(
msg
:
String
?)
{
override
fun
showToast
(
msg
:
String
?)
{
TODO
(
"Not yet implemented"
)
}
}
override
fun
hideLoading
()
{
override
fun
hideLoading
()
{
TODO
(
"Not yet implemented"
)
}
}
override
fun
getBaseApplication
():
MintsApplication
=
activity
?.
application
as
MintsApplication
override
fun
getBaseApplication
():
MintsApplication
=
activity
?.
application
as
MintsApplication
...
@@ -263,4 +274,18 @@ class PositionFragment : Fragment()
...
@@ -263,4 +274,18 @@ class PositionFragment : Fragment()
builder
.
setCancelable
(
false
)
builder
.
setCancelable
(
false
)
builder
.
show
()
builder
.
show
()
}
}
override
fun
handleMsg
(
msg
:
Message
?)
{
if
(
msg
?.
what
==
LOCATION_MSG
)
{
if
(
activity
!=
null
&&
!
activity
!!
.
isFinishing
()
&&
refreshLocationFlag
)
{
LogUtil
.
d
(
TAG
,
"PositionFragment handleMsg"
)
tvFragmentPositionPosition
?.
text
=
AppConfig
.
curAddress
tvFragmentPositionDate
?.
text
=
TimeRender
.
formatDate
(
Date
(),
TimeRender
.
ALL_FORMAT_LINE2
)
mHandler
?.
sendEmptyMessageDelayed
(
LOCATION_MSG
,
LOCATION_TIME
)
}
}
}
}
}
\ No newline at end of file
position/app/src/main/java/com/mints/xunmi/utils/SPUtil.java
View file @
f990cdfb
...
@@ -3,6 +3,8 @@ package com.mints.xunmi.utils;
...
@@ -3,6 +3,8 @@ package com.mints.xunmi.utils;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
com.mints.xunmi.MintsApplication
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -22,9 +24,9 @@ public class SPUtil {
...
@@ -22,9 +24,9 @@ public class SPUtil {
private
static
SPUtil
spUtil
;
private
static
SPUtil
spUtil
;
public
static
SPUtil
getInstance
(
Context
context
)
{
public
static
SPUtil
getInstance
()
{
if
(
spUtil
==
null
)
{
if
(
spUtil
==
null
)
{
mContext
=
context
;
mContext
=
MintsApplication
.
getContext
()
;
spUtil
=
new
SPUtil
();
spUtil
=
new
SPUtil
();
mPreferences
=
mContext
.
getSharedPreferences
(
mShareName
,
Context
.
MODE_PRIVATE
);
mPreferences
=
mContext
.
getSharedPreferences
(
mShareName
,
Context
.
MODE_PRIVATE
);
}
}
...
...
position/app/src/main/res/layout/fragment_main_my.xml
View file @
f990cdfb
...
@@ -399,6 +399,7 @@
...
@@ -399,6 +399,7 @@
android:scaleType=
"fitXY"
android:scaleType=
"fitXY"
android:layout_gravity=
"center_horizontal"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"20pt"
android:layout_marginTop=
"20pt"
android:layout_marginBottom=
"20pt"
android:src=
"@mipmap/bg_banner"
/>
android:src=
"@mipmap/bg_banner"
/>
</LinearLayout>
</LinearLayout>
...
...
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