Преглед на файлове

穿山甲广告优化,增加android10获取设备号判断

xieshengqi преди 5 години
родител
ревизия
367d8dac34

+ 20 - 0
app/src/androidTest/java/com/kuxuan/moneynote/ui/activitys/person/MainTest.java

@@ -0,0 +1,20 @@
1
+package com.kuxuan.moneynote.ui.activitys.person;
2
+
3
+/**
4
+ * create by ${xieshengqi}
5
+ * create time 2019-10-24
6
+ */
7
+public class MainTest {
8
+
9
+
10
+
11
+    public static void main(String []args){
12
+
13
+
14
+
15
+
16
+    }
17
+
18
+
19
+
20
+}

+ 25 - 20
app/src/main/java/com/kuxuan/moneynote/MyApplication.java

@@ -96,6 +96,7 @@ public class MyApplication extends MultiDexApplication {
96 96
 //        }
97 97
 //        LeakCanary.install(this);
98 98
 //、
99
+
99 100
         Myapp.context = getApplicationContext();
100 101
         //初始化活动页的上传参数
101 102
         typeface = Typeface.createFromAsset(getAssets(), "fonts/share.ttf");
@@ -106,26 +107,7 @@ public class MyApplication extends MultiDexApplication {
106 107
         CidVersionInterceptor.init(BuildConfig.CHANNLE, BuildConfig.VERSION_NAME);
107 108
         com.xieshengqi.kuxuanactivitymd.util.DisplayUtil.init(this);
108 109
         DbManager.init();
109
-        //友盟配置
110
-        UMConfigure.setLogEnabled(true);
111
-        UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, null);
112
-        UMUtils.setChannel(this, BuildConfig.CHANNLE);
113
-        //设置友盟采集模式
114
-
115
-        MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.LEGACY_MANUAL);
116
-//友盟支持在子线程中统计自定义事件
117
-        UMConfigure.setProcessEvent(true);
118
-        QueuedWork.isUseThreadPool = false;
119
-        UMShareAPI.get(this);
120
-        UIUtils.getInstance(this);
121
-//        DisplayUtil.init(this);
122
-//        initComponent();
123
-//        initJpush();
124
-        //各个平台的配置,建议放在全局Application或者程序入口
125
-        {
126
-            PlatformConfig.setWeixin("wxee1937fe7fbf238d", "2016584eff63b03b5a911d41c12519b3");
127
-            PlatformConfig.setQQZone("1106442579", "JOrDegUoYlf0m73n");
128
-        }
110
+        umengConfig();
129 111
         initTTAdSdk();
130 112
         initPush();
131 113
         //api 27后监听网络变化
@@ -157,6 +139,29 @@ public class MyApplication extends MultiDexApplication {
157 139
     }
158 140
 
159 141
     /**
142
+     * 友盟初始化
143
+     */
144
+    private void umengConfig(){
145
+        //友盟配置
146
+        UMConfigure.setLogEnabled(true);
147
+        UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, null);
148
+        UMUtils.setChannel(this, BuildConfig.CHANNLE);
149
+        //设置友盟采集模式
150
+
151
+        MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.LEGACY_MANUAL);
152
+//友盟支持在子线程中统计自定义事件
153
+        UMConfigure.setProcessEvent(true);
154
+        QueuedWork.isUseThreadPool = false;
155
+        UMShareAPI.get(this);
156
+        UIUtils.getInstance(this);
157
+        //各个平台的配置,建议放在全局Application或者程序入口
158
+        {
159
+            PlatformConfig.setWeixin("wxee1937fe7fbf238d", "2016584eff63b03b5a911d41c12519b3");
160
+            PlatformConfig.setQQZone("1106442579", "JOrDegUoYlf0m73n");
161
+        }
162
+    }
163
+
164
+    /**
160 165
      * 推送配置
161 166
      */
162 167
     private void initPush() {

+ 33 - 25
app/src/main/java/com/kuxuan/moneynote/SplashActivity.java

@@ -8,6 +8,7 @@ import android.content.Context;
8 8
 import android.content.Intent;
9 9
 import android.content.pm.PackageManager;
10 10
 import android.graphics.Color;
11
+import android.os.Build;
11 12
 import android.os.Bundle;
12 13
 import android.os.CountDownTimer;
13 14
 import android.os.Message;
@@ -217,34 +218,41 @@ public class SplashActivity extends FragmentActivity implements WeakHandler.IHan
217 218
      * 获取权限信息
218 219
      */
219 220
     private void getImeipermission() {
220
-        RxPermissions rxPermission = new RxPermissions(SplashActivity.this);
221
-        rxPermission
222
-                .requestEach(
223
-                        android.Manifest.permission.READ_PHONE_STATE
224
-                )
225
-                .subscribe(new io.reactivex.functions.Consumer<Permission>() {
226
-                    @Override
227
-                    public void accept(Permission permission) throws Exception {
228
-                        if (permission.granted) {
229
-                            // 用户已经同意该权限
230
-                            if (permission.name.equals("android.permission.READ_PHONE_STATE")) {
231
-                                getIMEI(SplashActivity.this);
221
+        //在android10以前可以获取设备号标识
222
+        if(Build.VERSION.SDK_INT<=Build.VERSION_CODES.P){
223
+            RxPermissions rxPermission = new RxPermissions(SplashActivity.this);
224
+            rxPermission
225
+                    .requestEach(
226
+                            android.Manifest.permission.READ_PHONE_STATE
227
+                    )
228
+                    .subscribe(new io.reactivex.functions.Consumer<Permission>() {
229
+                        @Override
230
+                        public void accept(Permission permission) throws Exception {
231
+                            if (permission.granted) {
232
+                                // 用户已经同意该权限
233
+                                if (permission.name.equals("android.permission.READ_PHONE_STATE")) {
234
+                                    getIMEI(SplashActivity.this);
235
+                                }
236
+
237
+                            } else if (permission.shouldShowRequestPermissionRationale) {
238
+                                // 用户拒绝了该权限,没有选中『不再询问』(Never ask again),那么下次再次启动时,还会提示请求权限的对话框
239
+                                if (permission.name.equals("android.permission.READ_PHONE_STATE")) {
240
+                                    getAndroidId();
241
+                                }
242
+                            } else {
243
+                                // 用户拒绝了该权限,并且选中『不再询问』
244
+                                if (permission.name.equals("android.permission.READ_PHONE_STATE")) {
245
+                                    getAndroidId();
246
+                                }
232 247
                             }
233 248
 
234
-                        } else if (permission.shouldShowRequestPermissionRationale) {
235
-                            // 用户拒绝了该权限,没有选中『不再询问』(Never ask again),那么下次再次启动时,还会提示请求权限的对话框
236
-                            if (permission.name.equals("android.permission.READ_PHONE_STATE")) {
237
-                                getAndroidId();
238
-                            }
239
-                        } else {
240
-                            // 用户拒绝了该权限,并且选中『不再询问』
241
-                            if (permission.name.equals("android.permission.READ_PHONE_STATE")) {
242
-                                getAndroidId();
243
-                            }
244 249
                         }
250
+                    });
251
+        }else{
252
+            //在android10系统获取不到IMEI
253
+            Log.e("IMEI设备号:","android10系统");
254
+        }
245 255
 
246
-                    }
247
-                });
248 256
     }
249 257
 
250 258
     /**
@@ -282,6 +290,7 @@ public class SplashActivity extends FragmentActivity implements WeakHandler.IHan
282 290
     private void getAndroidId() {
283 291
         String m_szAndroidID = ImeiUtil.getUniqueId(this);
284 292
         if (!TextUtils.isEmpty(m_szAndroidID))
293
+            Log.e("IMEIAndroidId设备号:",m_szAndroidID);
285 294
             SPUtil.putAndApply(this, Constant.Imei.ANDROIDID, m_szAndroidID);
286 295
     }
287 296
 
@@ -483,7 +492,6 @@ public class SplashActivity extends FragmentActivity implements WeakHandler.IHan
483 492
      * 跳转到主页面
484 493
      */
485 494
     private void goToMainActivity() {
486
-
487 495
         goMain();
488 496
 
489 497
     }

+ 9 - 8
app/src/main/java/com/kuxuan/moneynote/ad/AdDialog.java

@@ -6,6 +6,7 @@ import android.animation.ObjectAnimator;
6 6
 import android.animation.ValueAnimator;
7 7
 import android.app.Activity;
8 8
 import android.app.Dialog;
9
+import android.content.Context;
9 10
 import android.content.DialogInterface;
10 11
 import android.content.Intent;
11 12
 import android.graphics.Bitmap;
@@ -195,11 +196,12 @@ public class AdDialog {
195 196
     private String moneyCount = "0";
196 197
 
197 198
 
198
-    public AdDialog(Activity context) {
199
+    public AdDialog(Activity context,TTAdNative mTTAdNative) {
199 200
         this.activity = context;
200
-        mTTAdNative = TTAdManagerHolder.get().createAdNative(activity);
201
-        //step3:(可选,强烈建议在合适的时机调用):申请部分权限,如read_phone_state,防止获取不了imei时候,下载类广告没有填充的问题。
202
-        TTAdManagerHolder.get().requestPermissionIfNecessary(activity);
201
+        this.mTTAdNative = mTTAdNative;
202
+//        mTTAdNative = TTAdManagerHolder.get().createAdNative(activity);
203
+//        //step3:(可选,强烈建议在合适的时机调用):申请部分权限,如read_phone_state,防止获取不了imei时候,下载类广告没有填充的问题。
204
+//        TTAdManagerHolder.get().requestPermissionIfNecessary(activity);
203 205
 //        this.mAQuery = new AQuery2(activity);
204 206
         mRequestManager = Glide.with(MyApplication.getInstance());
205 207
 
@@ -226,7 +228,6 @@ public class AdDialog {
226 228
      * @param isDouble
227 229
      */
228 230
     public void updataGoldForNet(final int type, final String advert_id, final boolean isQiandao, final boolean isDouble) {
229
-
230 231
         RetrofitClient.getApiService().getAdvertCoin(new GlodBody(type, advert_id, isDouble ? 2 : 1, quesition_id == -1 ? 0 : quesition_id)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new MyObsever<BaseJson<GlodJson>>() {
231 232
             @Override
232 233
             public void onError(ExceptionHandle.ResponeThrowable e) {
@@ -296,8 +297,8 @@ public class AdDialog {
296 297
     }
297 298
 
298 299
 
299
-    public AdDialog builder() {
300
-        return this;
300
+    public static AdDialog builder(Activity context,TTAdNative mTTAdNative) {
301
+        return new AdDialog(context,mTTAdNative);
301 302
     }
302 303
 
303 304
 
@@ -855,6 +856,7 @@ public class AdDialog {
855 856
     public void dismiss() {
856 857
         if (mAdDialog != null)
857 858
             mAdDialog.dismiss();
859
+
858 860
     }
859 861
 
860 862
     TextView tv_money;
@@ -1544,7 +1546,6 @@ public class AdDialog {
1544 1546
                 dismiss();
1545 1547
             }
1546 1548
         });
1547
-
1548 1549
     }
1549 1550
 
1550 1551
 

+ 1 - 1
app/src/main/java/com/kuxuan/moneynote/common/Constant.java

@@ -21,7 +21,7 @@ public class Constant {
21 21
     public static final String TOKEN_BASE_URL = "https://apimoney.726p.com/api/";
22 22
     public static final String MD5 = "b4b80c2676828f1df375684100f56d48";
23 23
 
24
-    public static final long TOKEN_FAIL_DAY = 7 * 24 * 60 * 60 * 1000L;
24
+        public static final long TOKEN_FAIL_DAY = 7 * 24 * 60 * 60 * 1000L;
25 25
 //    public static final long TOKEN_FAIL_DAY = 60*1000L;
26 26
 
27 27
     public static final int REQUEST_CODE = 0X20;

+ 50 - 25
app/src/main/java/com/kuxuan/moneynote/ui/activitys/MainActivity.java

@@ -10,6 +10,7 @@ import android.graphics.Bitmap;
10 10
 import android.graphics.Color;
11 11
 import android.graphics.drawable.GradientDrawable;
12 12
 import android.net.Uri;
13
+import android.os.Build;
13 14
 import android.os.Bundle;
14 15
 import android.os.Looper;
15 16
 import android.support.v4.app.ActivityCompat;
@@ -221,6 +222,10 @@ public class MainActivity extends BaseFragmentActivity implements MineFragment.o
221 222
 //        Bundle data = in.getExtras();
222 223
 //        if (data != null) {
223 224
 //            String link_type = data.getString("link_type");
225
+//            //防止在应用内跳转出现错误
226
+//            if(TextUtils.isEmpty(link_type)){
227
+//                return;
228
+//            }
224 229
 //            String url = data.getString("url");
225 230
 //            String link_name = data.getString("link_name");
226 231
 //            if (link_type.equals("2")) {
@@ -233,10 +238,15 @@ public class MainActivity extends BaseFragmentActivity implements MineFragment.o
233 238
 //                startActivity(intent);
234 239
 //            } else if (link_type.equals("3")) {
235 240
 //                //跳转应用市场
236
-//                AppMarketUtil.gotoHWMarket(this);
237
-//            }else{
238
-//        pushType = Integer.parseInt(data.getString("tab"));
239
-//    }
241
+//                AppMarketUtil.gotoMarket(this);
242
+//            } else {
243
+//                try {
244
+//                    Log.e("oppopush", data.getString("tab"));
245
+//                    pushType = Integer.parseInt(data.getString("tab"))-1;
246
+//                } catch (Exception e) {
247
+//
248
+//                }
249
+//            }
240 250
 //
241 251
 //        }
242 252
     }
@@ -309,6 +319,8 @@ public class MainActivity extends BaseFragmentActivity implements MineFragment.o
309 319
                             //关闭广告
310 320
                             SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.SWITCH_SPLASH_AD, false);
311 321
                         } else {
322
+//                            showImageDialog("http://101.200.89.115:8072/uploads/20191021/1571637124686670.png", "https://accountapi.726p.com/qianduo/active-tkl/11-active.html", "双十一活动", "0");
323
+
312 324
                             //打开广告
313 325
                             SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.SWITCH_SPLASH_AD, true);
314 326
                             if (advert_type == 1) {
@@ -990,7 +1002,9 @@ public class MainActivity extends BaseFragmentActivity implements MineFragment.o
990 1002
      * @param coin
991 1003
      */
992 1004
     private void showDialogForGold(String coin) {
993
-        adDialog = new AdDialog(this).builder().setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
1005
+        if (mTTAdNative == null)
1006
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(this);
1007
+        adDialog =  AdDialog.builder(this,mTTAdNative).setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
994 1008
             @Override
995 1009
             public void getGoldDouble(int task_type, String pk) {
996 1010
 
@@ -1021,10 +1035,10 @@ public class MainActivity extends BaseFragmentActivity implements MineFragment.o
1021 1035
      * @param allMoney
1022 1036
      * @param currentMoney
1023 1037
      */
1024
-    private void showMyMoneyDialog(int allMoney, int currentMoney) {
1025
-        new AdDialog(this).builder().prepareToShowMyMoney(ADConstants.AD_OPEN_APP_TIMER, allMoney, currentMoney);
1026
-
1027
-    }
1038
+//    private void showMyMoneyDialog(int allMoney, int currentMoney) {
1039
+//        new AdDialog(this).builder().prepareToShowMyMoney(ADConstants.AD_OPEN_APP_TIMER, allMoney, currentMoney);
1040
+//
1041
+//    }
1028 1042
 
1029 1043
 
1030 1044
     private int currentSelectPosition;
@@ -1221,26 +1235,37 @@ public class MainActivity extends BaseFragmentActivity implements MineFragment.o
1221 1235
      * @return
1222 1236
      */
1223 1237
     public void getIMEI(Context context) {
1224
-        try {
1225
-            //实例化TelephonyManager对象
1226
-            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
1227
-            String imei = null;
1228
-            //获取IMEI号
1229
-            if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
1230
-                imei = telephonyManager.getDeviceId();
1231
-                //在次做个验证,也不是什么时候都能获取到的啊
1232
-                if (imei == null) {
1233
-                    imei = "";
1234
-                }
1235
-                if (!TextUtils.isEmpty(imei)) {
1236
-                    SPUtil.putAndApply(this, Constant.Imei.IMEI, imei);
1238
+        //在android10以前可以获取设备号标识
1239
+        if(Build.VERSION.SDK_INT<=Build.VERSION_CODES.P){
1240
+            try {
1241
+                //实例化TelephonyManager对象
1242
+                TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
1243
+                String imei = null;
1244
+                //获取IMEI号
1245
+                if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
1246
+                    imei = telephonyManager.getDeviceId();
1247
+                    //在次做个验证,也不是什么时候都能获取到的啊
1248
+                    if (imei == null) {
1249
+                        imei = "";
1250
+                    }
1251
+                    if (!TextUtils.isEmpty(imei)) {
1252
+                        Log.e("IMEI设备号:",imei);
1253
+                        SPUtil.putAndApply(this, Constant.Imei.IMEI, imei);
1254
+                    } else {
1255
+                        Log.e("IMEI设备号:","没有获取到");
1256
+                    }
1237 1257
                 } else {
1258
+                    getImeipermission();
1238 1259
                 }
1239
-            } else {
1240
-                getImeipermission();
1260
+            } catch (Exception e) {
1241 1261
             }
1242
-        } catch (Exception e) {
1262
+        }else{
1263
+            //在android10系统获取不到IMEI
1264
+            Log.e("IMEI设备号:","android10系统");
1265
+
1243 1266
         }
1267
+
1268
+
1244 1269
     }
1245 1270
 
1246 1271
 

+ 15 - 10
app/src/main/java/com/kuxuan/moneynote/ui/activitys/category/CategoryPresent.java

@@ -321,16 +321,21 @@ public class CategoryPresent extends CategoryContract.CategoryPresent {
321 321
         mModel.addCategory(new MVPListener<Object>() {
322 322
             @Override
323 323
             public void onSuccess(Object content) {
324
-                mCategoryList.add(mRemoveList.get(position));
325
-                mRemoveList.remove(position);
326
-                mAdapter.notifyItemInserted(mCategoryList.size() - 1);
327
-                mAddAdapter.notifyItemRemoved(position);
328
-                if (mRemoveList.size() < 1) {
329
-                    if (view != null)
330
-                        view.getNullOrNot(false);
331
-                } else {
332
-                    if (view != null)
333
-                        view.getNullOrNot(true);
324
+                try {
325
+                    mCategoryList.add(mRemoveList.get(position));
326
+                    mRemoveList.remove(position);
327
+                    mAdapter.notifyItemInserted(mCategoryList.size() - 1);
328
+                    mAddAdapter.notifyItemRemoved(position);
329
+                    if (mRemoveList.size() < 1) {
330
+                        if (view != null)
331
+                            view.getNullOrNot(false);
332
+                    } else {
333
+                        if (view != null)
334
+                            view.getNullOrNot(true);
335
+                    }
336
+
337
+                }catch (Exception e){
338
+
334 339
                 }
335 340
 
336 341
             }

+ 18 - 7
app/src/main/java/com/kuxuan/moneynote/ui/fragments/MoneyTaskFragmentActivity.java

@@ -1154,8 +1154,9 @@ private RequestManager mRequestManager;
1154 1154
      * @param currentMoney
1155 1155
      */
1156 1156
     private void showMyMoneyDialog(int allMoney, int currentMoney) {
1157
-
1158
-        final AdDialog adDialog = new AdDialog(this).builder().prepareToShowMyMoney(ADConstants.AD_OPEN_APP_TIMER, allMoney, currentMoney);
1157
+        if (mTTAdNative == null)
1158
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(this);
1159
+        final AdDialog adDialog =  AdDialog.builder(this,mTTAdNative).prepareToShowMyMoney(ADConstants.AD_OPEN_APP_TIMER, allMoney, currentMoney);
1159 1160
         adDialog.getmAdDialog().setOnDismissListener(new DialogInterface.OnDismissListener() {
1160 1161
             @Override
1161 1162
             public void onDismiss(DialogInterface dialog) {
@@ -1179,7 +1180,9 @@ private RequestManager mRequestManager;
1179 1180
         if (this.isFinishing()) {
1180 1181
             return;
1181 1182
         }
1182
-        final AdDialog adDialog = new AdDialog(this).builder().preprearToShowGameInfo(ADConstants.AD_OPEN_APP_TIMER, id, startScore, endScore, isRight, quesiton_id, gameHtmlInfo).setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
1183
+        if (mTTAdNative == null)
1184
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(this);
1185
+        final AdDialog adDialog =  AdDialog.builder(this,mTTAdNative).preprearToShowGameInfo(ADConstants.AD_OPEN_APP_TIMER, id, startScore, endScore, isRight, quesiton_id, gameHtmlInfo).setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
1183 1186
             @Override
1184 1187
             public void getGoldDouble(int task_type, String pk) {
1185 1188
 
@@ -1234,7 +1237,9 @@ private RequestManager mRequestManager;
1234 1237
 
1235 1238
     private void showNextTimeDialog(long nextTime) {
1236 1239
 
1237
-        AdDialog adDialog = new AdDialog(this).builder().prepareToShowNextTime(nextTime * 1000, new OnAdDialogClickListener() {
1240
+        if (mTTAdNative == null)
1241
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(this);
1242
+        final AdDialog adDialog =  AdDialog.builder(this,mTTAdNative).prepareToShowNextTime(nextTime * 1000, new OnAdDialogClickListener() {
1238 1243
             @Override
1239 1244
             public void onPositiveClick() {
1240 1245
                 //跳转限时领取
@@ -1250,7 +1255,9 @@ private RequestManager mRequestManager;
1250 1255
         if(isFinishing()){
1251 1256
             return;
1252 1257
         }
1253
-        final AdDialog adDialog = new AdDialog(this).builder().prepareToShowLimitDialog(ADConstants.AD_OPEN_APP_TIMER).setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
1258
+        if (mTTAdNative == null)
1259
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(this);
1260
+        final AdDialog adDialog =  AdDialog.builder(this,mTTAdNative).prepareToShowLimitDialog(ADConstants.AD_OPEN_APP_TIMER).setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
1254 1261
             @Override
1255 1262
             public void getGoldDouble(int task_type, String pk) {
1256 1263
 
@@ -1286,7 +1293,9 @@ private RequestManager mRequestManager;
1286 1293
      */
1287 1294
     private void showExchangeData(int allMoney, int todayMoney, int ratio) {
1288 1295
 
1289
-        final AdDialog adDialog = new AdDialog(this).builder().prepareToShowExchangeCoin(allMoney, todayMoney, ratio, new OnAdDialogClickListener() {
1296
+        if (mTTAdNative == null)
1297
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(this);
1298
+        final AdDialog adDialog =  AdDialog.builder(this,mTTAdNative).prepareToShowExchangeCoin(allMoney, todayMoney, ratio, new OnAdDialogClickListener() {
1290 1299
             @Override
1291 1300
             public void onPositiveClick() {
1292 1301
                 //兑换现金
@@ -1346,7 +1355,9 @@ private RequestManager mRequestManager;
1346 1355
      */
1347 1356
     private void showCheckInDialog(int signDay, int score, int task_type) {
1348 1357
 
1349
-        final AdDialog adDialog = new AdDialog(this).builder().setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
1358
+        if (mTTAdNative == null)
1359
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(this);
1360
+        final AdDialog adDialog =  AdDialog.builder(this,mTTAdNative).setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
1350 1361
             @Override
1351 1362
             public void getGoldDouble(int task_type, String pk) {
1352 1363
 

+ 3 - 1
app/src/main/java/com/kuxuan/moneynote/ui/fragments/NewsFragment.java

@@ -1188,7 +1188,9 @@ public class NewsFragment extends BaseFragment {
1188 1188
     AdDialog adDialog;
1189 1189
 
1190 1190
     private void showGoldDialog(String coin, final int position) {
1191
-        adDialog = new AdDialog(getActivity()).builder().setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
1191
+        if (mTTAdNative == null)
1192
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(getActivity());
1193
+          adDialog =  AdDialog.builder(getActivity(),mTTAdNative).setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
1192 1194
             @Override
1193 1195
             public void getGoldDouble(int task_type, String pk) {
1194 1196
 

+ 21 - 22
app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialFragment.java

@@ -655,28 +655,27 @@ public class DetialFragment extends MVPFragment<DetialPresent, DetialModel> impl
655 655
      * 展示定时任务弹窗
656 656
      */
657 657
     private void showTimerDialog(String money, long seconds) {
658
-
659
-        timeAdDialog = new AdDialog(getActivity()).builder().setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
660
-            @Override
661
-            public void getGoldDouble(int task_type, String pk) {
662
-                Intent intent = new Intent(getActivity(), FullSreenVideoActivity.class);
663
-                intent.putExtra(FullSreenVideoActivity.TASK_TYPE, task_type);
664
-                intent.putExtra(FullSreenVideoActivity.PK, pk);
665
-                startActivityForResult(intent, FullSreenVideoActivity.REQUEST_CODE);
666
-
667
-            }
668
-
669
-            @Override
670
-            public void onGoldGetSuccess() {
671
-                EventBus.getDefault().post(new GoldGetForNetEvent());
672
-                getGoldTimerTask(false);
673
-            }
674
-
675
-            @Override
676
-            public void onDialogDismiss() {
677
-
678
-            }
679
-        }).prepareToShowTimer(ADConstants.AD_OPEN_APP_TIMER, money, seconds, 2);
658
+//        timeAdDialog = AdDialog.builder(getActivity(),).setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
659
+//            @Override
660
+//            public void getGoldDouble(int task_type, String pk) {
661
+//                Intent intent = new Intent(getActivity(), FullSreenVideoActivity.class);
662
+//                intent.putExtra(FullSreenVideoActivity.TASK_TYPE, task_type);
663
+//                intent.putExtra(FullSreenVideoActivity.PK, pk);
664
+//                startActivityForResult(intent, FullSreenVideoActivity.REQUEST_CODE);
665
+//
666
+//            }
667
+//
668
+//            @Override
669
+//            public void onGoldGetSuccess() {
670
+//                EventBus.getDefault().post(new GoldGetForNetEvent());
671
+//                getGoldTimerTask(false);
672
+//            }
673
+//
674
+//            @Override
675
+//            public void onDialogDismiss() {
676
+//
677
+//            }
678
+//        }).prepareToShowTimer(ADConstants.AD_OPEN_APP_TIMER, money, seconds, 2);
680 679
 
681 680
     }
682 681
 

+ 21 - 10
app/src/main/java/com/kuxuan/moneynote/ui/fragments/goldtab/GoldFragment.java

@@ -38,10 +38,12 @@ import com.bumptech.glide.load.resource.drawable.GlideDrawable;
38 38
 import com.bumptech.glide.load.resource.gif.GifDrawable;
39 39
 import com.bumptech.glide.request.animation.GlideAnimation;
40 40
 import com.bumptech.glide.request.target.SimpleTarget;
41
+import com.bytedance.sdk.openadsdk.TTAdNative;
41 42
 import com.kuxuan.moneynote.MyApplication;
42 43
 import com.kuxuan.moneynote.R;
43 44
 import com.kuxuan.moneynote.ad.ADConstants;
44 45
 import com.kuxuan.moneynote.ad.AdDialog;
46
+import com.kuxuan.moneynote.ad.TTAdManagerHolder;
45 47
 import com.kuxuan.moneynote.api.ExceptionHandle;
46 48
 import com.kuxuan.moneynote.api.MyObsever;
47 49
 import com.kuxuan.moneynote.api.RetrofitClient;
@@ -314,7 +316,7 @@ public class GoldFragment extends BaseFragment {
314 316
                     //直接下载
315 317
                     try {
316 318
 //                        DownLoadManager.downLoadForNoMsg(getActivity(), gameGoldInfo.getUrl());
317
-                        DownLoadManager.getInstance().download(gameGoldInfo.getUrl(),"download.apk");
319
+                        DownLoadManager.getInstance().download(gameGoldInfo.getUrl(), "download.apk");
318 320
 //                        try {
319 321
 //                            Uri uri = Uri.parse(gameGoldInfo.getUrl());
320 322
 //                            Intent url_intent = new Intent(Intent.ACTION_VIEW,uri);
@@ -325,12 +327,12 @@ public class GoldFragment extends BaseFragment {
325 327
                     } catch (Exception e) {
326 328
 
327 329
                     }
328
-                } else if(gameGoldInfo.getLink_type()==3) {
330
+                } else if (gameGoldInfo.getLink_type() == 3) {
329 331
                     //跳转阅读赚钱
330 332
 //                    startActivity();
331 333
                     MobclickAgent.onEvent(getActivity(), "tab_news");
332 334
                     startActivityForResult(new Intent(getActivity(), NewsFindActivity.class), Constant.Code_Request.REQUESTCODE);
333
-                }else {
335
+                } else {
334 336
                     if (TextUtils.isEmpty(gameGoldInfo.getId())) {
335 337
                         intent.putExtra("isThirdGame", true);
336 338
                     } else {
@@ -595,6 +597,7 @@ public class GoldFragment extends BaseFragment {
595 597
     private int mTodayMoney;
596 598
     private int ratio;
597 599
 
600
+    private TTAdNative mTTAdNative;
598 601
 
599 602
     /**
600 603
      * 弹出兑换现金弹窗
@@ -604,7 +607,9 @@ public class GoldFragment extends BaseFragment {
604 607
 //            isRunning = false;
605 608
 //            return;
606 609
 //        }
607
-        final AdDialog adDialog = new AdDialog(getActivity()).builder().prepareToShowExchangeCoin(mAllMoney, mTodayMoney, ratio, new OnAdDialogClickListener() {
610
+        if (mTTAdNative == null)
611
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(getActivity());
612
+        AdDialog adDialog = AdDialog.builder(getActivity(), mTTAdNative).prepareToShowExchangeCoin(mAllMoney, mTodayMoney, ratio, new OnAdDialogClickListener() {
608 613
             @Override
609 614
             public void onPositiveClick() {
610 615
                 //兑换现金
@@ -638,7 +643,6 @@ public class GoldFragment extends BaseFragment {
638 643
             @Override
639 644
             public void onDismiss(DialogInterface dialog) {
640 645
                 isRunning = false;
641
-
642 646
             }
643 647
         });
644 648
     }
@@ -801,8 +805,9 @@ public class GoldFragment extends BaseFragment {
801 805
             isRunning = false;
802 806
             return;
803 807
         }
804
-
805
-        final AdDialog adDialog = new AdDialog(getActivity()).builder().prepareToShowMyMoney(ADConstants.AD_OPEN_APP_TIMER, allMoney, currentMoney);
808
+        if (mTTAdNative == null)
809
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(getActivity());
810
+        final AdDialog adDialog =  AdDialog.builder(getActivity(),mTTAdNative).prepareToShowMyMoney(ADConstants.AD_OPEN_APP_TIMER, allMoney, currentMoney);
806 811
         adDialog.getmAdDialog().setOnDismissListener(new DialogInterface.OnDismissListener() {
807 812
             @Override
808 813
             public void onDismiss(DialogInterface dialog) {
@@ -877,7 +882,9 @@ public class GoldFragment extends BaseFragment {
877 882
             isRunning = false;
878 883
             return;
879 884
         }
880
-        AdDialog adDialog = new AdDialog(getActivity()).builder().prepareToShowNextTime(nextTime, new OnAdDialogClickListener() {
885
+        if (mTTAdNative == null)
886
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(getActivity());
887
+        final AdDialog adDialog =  AdDialog.builder(getActivity(),mTTAdNative).prepareToShowNextTime(nextTime, new OnAdDialogClickListener() {
881 888
             @Override
882 889
             public void onPositiveClick() {
883 890
                 //跳转限时领取
@@ -901,7 +908,9 @@ public class GoldFragment extends BaseFragment {
901 908
             isRunning = false;
902 909
             return;
903 910
         }
904
-        final AdDialog adDialog = new AdDialog(getActivity()).builder().prepareToShowLimitDialog(ADConstants.AD_OPEN_APP_TIMER).setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
911
+        if (mTTAdNative == null)
912
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(getActivity());
913
+        final AdDialog adDialog =  AdDialog.builder(getActivity(),mTTAdNative).prepareToShowLimitDialog(ADConstants.AD_OPEN_APP_TIMER).setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
905 914
             @Override
906 915
             public void getGoldDouble(int task_type, String pk) {
907 916
 
@@ -975,7 +984,9 @@ public class GoldFragment extends BaseFragment {
975 984
             isRunning = false;
976 985
             return;
977 986
         }
978
-        final AdDialog adDialog = new AdDialog(getActivity()).builder().setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
987
+        if (mTTAdNative == null)
988
+            mTTAdNative = TTAdManagerHolder.get().createAdNative(getActivity());
989
+        final AdDialog adDialog =  AdDialog.builder(getActivity(),mTTAdNative).setOnGoldGetListener(new AdDialog.OnGoldGetListener() {
979 990
             @Override
980 991
             public void getGoldDouble(int task_type, String pk) {
981 992
 

+ 1 - 0
app/src/main/res/layout/dialog_score_award.xml

@@ -24,6 +24,7 @@
24 24
             android:layout_width="wrap_content"
25 25
             android:layout_height="wrap_content"
26 26
             android:padding="10dp"
27
+            android:layout_centerHorizontal="true"
27 28
             android:layout_alignParentBottom="true"
28 29
             android:scaleType="centerInside"
29 30
             android:src="@mipmap/icon_close_white" />

+ 2 - 2
build.gradle

@@ -31,8 +31,8 @@ task clean(type: Delete) {
31 31
     delete rootProject.buildDir
32 32
 }
33 33
 ext {
34
-    versionCode = 49
35
-    versionName = "2.2.3"
34
+    versionCode = 50
35
+    versionName = "2.2.4"
36 36
     minSdkVersion = 19
37 37
     targetSdkVersion = 28
38 38
     compileSdkVersion = 28

+ 1 - 0
kuxuanactivitymd/src/main/java/com/xieshengqi/kuxuanactivitymd/util/DisplayUtil.java

@@ -139,6 +139,7 @@ public class DisplayUtil {
139 139
 
140 140
     private static void checkInit() {
141 141
         if (metrics == null) {
142
+
142 143
             throw new NullPointerException("Place init DisplayUtil");
143 144
         }
144 145
     }