Kaynağa Gözat

增加开屏页广告切换,是自己的广告还是穿山甲广告,修改友盟2.1.9版本的bug

xieshengqi 5 yıl önce
ebeveyn
işleme
2844f55eb2

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

@@ -139,21 +139,25 @@ public class SplashActivity extends FragmentActivity implements WeakHandler.IHan
139 139
             if (LoginStatusUtil.isLoginin()) {
140 140
                 sendData();
141 141
             }
142
-//            boolean isAD = (boolean) SPUtil.get(this, Constant.System.SWITCH_AD, false);
143
-//            isAD = true;
144
-//            if (isAD) {
145
-            //加载穿山甲开屏广告
146
-            //step2:创建TTAdNative对象
147
-            mTTAdNative = TTAdManagerHolder.get().createAdNative(this);
148
-            //在合适的时机申请权限,如read_phone_state,防止获取不了imei时候,下载类广告没有填充的问题
149
-            //在开屏时候申请不太合适,因为该页面倒计时结束或者请求超时会跳转,在该页面申请权限,体验不好
150
-            // TTAdManagerHolder.getInstance(this).requestPermissionIfNecessary(this);
151
-            loadSplashAd();
152
-//            } else {
153
-//                //加载自己的广告
154
-//                loadLocationAd();
155
-//            }
142
+            //广告位是否打开
143
+            boolean isOpenSplashAd = (boolean) SPUtil.get(this, Constant.System.SWITCH_SPLASH_AD, true);
144
+            if (isOpenSplashAd) {
145
+                boolean isAD = (boolean) SPUtil.get(this, Constant.System.SWITCH_AD, true);
146
+                isAD = false;
147
+                if (isAD) {
148
+                    //加载穿山甲开屏广告
149
+                    //step2:创建TTAdNative对象
150
+                    mTTAdNative = TTAdManagerHolder.get().createAdNative(this);
151
+                    //在合适的时机申请权限,如read_phone_state,防止获取不了imei时候,下载类广告没有填充的问题
152
+                    //在开屏时候申请不太合适,因为该页面倒计时结束或者请求超时会跳转,在该页面申请权限,体验不好
153
+                    // TTAdManagerHolder.getInstance(this).requestPermissionIfNecessary(this);
154
+                    loadSplashAd();
155
+                } else {
156
+                    //加载自己的广告
157
+                    loadLocationAd();
158
+                }
156 159
 //
160
+            }
157 161
             getChannleStatus(false);
158 162
 
159 163
         }
@@ -164,8 +168,11 @@ public class SplashActivity extends FragmentActivity implements WeakHandler.IHan
164 168
      */
165 169
     private void loadLocationAd() {
166 170
         //获取保存的url
167
-        String imageUrl = (String) SPUtil.get(this, Constant.System.IMAGE_URL, "");
171
+        final String imageUrl = (String) SPUtil.get(this, Constant.System.IMAGE_URL, "");
168 172
         final String linkUrl = (String) SPUtil.get(this, Constant.System.LINK_URL, "");
173
+        if(TextUtils.isEmpty(imageUrl)){
174
+            return;
175
+        }
169 176
         Glide.with(this).load(imageUrl).into(new SimpleTarget<GlideDrawable>() {
170 177
             @Override
171 178
             public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
@@ -176,6 +183,9 @@ public class SplashActivity extends FragmentActivity implements WeakHandler.IHan
176 183
                 mSplashContainer.removeAllViews();
177 184
                 //把SplashView 添加到ViewGroup中,注意开屏广告view:width >=70%屏幕宽;height >=50%屏幕宽
178 185
                 ImageView imageView = (ImageView) getImageView(resource);
186
+                FrameLayout.LayoutParams p = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,FrameLayout.LayoutParams.MATCH_PARENT);
187
+                imageView.setLayoutParams(p);
188
+                imageView.setScaleType(ImageView.ScaleType.FIT_XY);
179 189
                 mSplashContainer.addView(imageView);
180 190
 //添加一个自定义倒计时功能
181 191
                 mSplashContainer.addView(getCountTimeView());

+ 3 - 1
app/src/main/java/com/kuxuan/moneynote/api/ApiService.java

@@ -3,8 +3,10 @@ package com.kuxuan.moneynote.api;
3 3
 
4 4
 import com.kuxuan.moneynote.ad.AdStatus;
5 5
 import com.kuxuan.moneynote.json.ActivityJson;
6
+import com.kuxuan.moneynote.json.AdJson;
6 7
 import com.kuxuan.moneynote.json.AliPayInfo;
7 8
 import com.kuxuan.moneynote.json.BaseJson;
9
+import com.kuxuan.moneynote.json.BeanNewJson;
8 10
 import com.kuxuan.moneynote.json.BillJson;
9 11
 import com.kuxuan.moneynote.json.BindEmailStatus;
10 12
 import com.kuxuan.moneynote.json.CashConfigJson;
@@ -772,7 +774,7 @@ public interface ApiService {
772 774
      * @return
773 775
      */
774 776
     @POST("Advert/V1/getAdvert")
775
-    Observable<Object> getAdvert(@Body ADBody aDbody);
777
+    Observable<BeanNewJson<ArrayList<AdJson>>> getAdvert(@Body ADBody aDbody);
776 778
 
777 779
 }
778 780
 

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

@@ -11,11 +11,11 @@ public class Constant {
11 11
     //手机号正则,11位手机号
12 12
     public static final String REGEX_MOBILE = "[1][3,4,5,7,8][0-9]{9}$";
13 13
     //测试接口(没用报403)
14
-//    public static final String BASE_URL = "http://182.92.118.1:8060/api/";
14
+    public static final String BASE_URL = "http://182.92.118.1:8060/api/";
15 15
     //仿真环境
16 16
 //    public static final String BASE_URL = "http://develop.money.726p.com/api/";
17 17
     //线上环境
18
-    public static final String BASE_URL = "https://accountapi.726p.com/api/";
18
+//    public static final String BASE_URL = "https://accountapi.726p.com/api/";
19 19
 //    public static final String BASE_URL = "http://47.93.190.105:2796/api/";
20 20
     //获取token必须使用这个url
21 21
     public static final String TOKEN_BASE_URL = "https://apimoney.726p.com/api/";
@@ -60,6 +60,8 @@ public class Constant {
60 60
         public static final String IMAGE_URL = "image_url_ad";
61 61
         //自己广告的跳转链接
62 62
         public static final String LINK_URL = "link_url_ad";
63
+        //开屏广告位开关
64
+        public static final String SWITCH_SPLASH_AD = "switch_splash_ad";
63 65
         //默认预算
64 66
         public static final long NORMAL_NUM = 3000;
65 67
         public static final String CURRENT_YEAR = "current_year";

+ 72 - 0
app/src/main/java/com/kuxuan/moneynote/json/AdJson.java

@@ -0,0 +1,72 @@
1
+package com.kuxuan.moneynote.json;
2
+
3
+import java.io.Serializable;
4
+
5
+/**
6
+ * create by ${xieshengqi}
7
+ * create time 2019-08-21
8
+ */
9
+public class AdJson implements Serializable {
10
+
11
+//    {
12
+//        "id": 1,
13
+//            "name": "老王",
14
+//            "advert_text": "",
15
+//            "img_url": "http://182.92.118.1:8070/laowana.png",
16
+//            "advert_url": "http://www.baidu.com"
17
+//    }
18
+    private int id;
19
+    private String name;
20
+    private String advert_text;
21
+    private String img_url;
22
+    private String advert_url;
23
+    private int advert_type;
24
+
25
+    public int getId() {
26
+        return id;
27
+    }
28
+
29
+    public void setId(int id) {
30
+        this.id = id;
31
+    }
32
+
33
+    public String getName() {
34
+        return name;
35
+    }
36
+
37
+    public void setName(String name) {
38
+        this.name = name;
39
+    }
40
+
41
+    public String getAdvert_text() {
42
+        return advert_text;
43
+    }
44
+
45
+    public void setAdvert_text(String advert_text) {
46
+        this.advert_text = advert_text;
47
+    }
48
+
49
+    public String getImg_url() {
50
+        return img_url;
51
+    }
52
+
53
+    public void setImg_url(String img_url) {
54
+        this.img_url = img_url;
55
+    }
56
+
57
+    public String getAdvert_url() {
58
+        return advert_url;
59
+    }
60
+
61
+    public void setAdvert_url(String advert_url) {
62
+        this.advert_url = advert_url;
63
+    }
64
+
65
+    public int getAdvert_type() {
66
+        return advert_type;
67
+    }
68
+
69
+    public void setAdvert_type(int advert_type) {
70
+        this.advert_type = advert_type;
71
+    }
72
+}

+ 2 - 2
app/src/main/java/com/kuxuan/moneynote/receiver/DownLoadReceiver.java

@@ -11,7 +11,7 @@ import android.content.Intent;
11 11
 public class DownLoadReceiver  extends BroadcastReceiver {
12 12
     @Override
13 13
     public void onReceive(Context context, Intent intent) {
14
-        Intent i = new Intent(context, com.kuxuan.moneynote.servier.DownLoadService.class);
15
-        context.startService(i);
14
+//        Intent i = new Intent(context, com.kuxuan.moneynote.servier.DownLoadService.class);
15
+//        context.startService(i);
16 16
     }
17 17
 }

+ 37 - 4
app/src/main/java/com/kuxuan/moneynote/ui/activitys/MainActivity.java

@@ -68,7 +68,9 @@ import com.kuxuan.moneynote.common.Constant;
68 68
 import com.kuxuan.moneynote.db.BillCategoreDaoOperator;
69 69
 import com.kuxuan.moneynote.db.CategoryDaoOperator;
70 70
 import com.kuxuan.moneynote.gold.GoldManager;
71
+import com.kuxuan.moneynote.json.AdJson;
71 72
 import com.kuxuan.moneynote.json.BaseJson;
73
+import com.kuxuan.moneynote.json.BeanNewJson;
72 74
 import com.kuxuan.moneynote.json.GlodJson;
73 75
 import com.kuxuan.moneynote.json.UploadBeanJson;
74 76
 import com.kuxuan.moneynote.json.UploadDbjson;
@@ -197,7 +199,7 @@ public class MainActivity extends BaseFragmentActivity implements MineFragment.o
197 199
             });
198 200
         }
199 201
         GoldManager.getInstance().getUserCoin();
200
-//        getSplashAd();
202
+        getSplashAd();
201 203
     }
202 204
 
203 205
     /**
@@ -212,7 +214,7 @@ public class MainActivity extends BaseFragmentActivity implements MineFragment.o
212 214
 //                .client(client)
213 215
 //                .build();
214 216
 //        ApiService apiService = retrofit.create(ApiService.class);
215
-       RetrofitClient.getAdApiService().getAdvert(new ADBody("22")).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new MyObsever<Object>() {
217
+        RetrofitClient.getAdApiService().getAdvert(new ADBody("22")).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new MyObsever<BeanNewJson<ArrayList<AdJson>>>() {
216 218
             @Override
217 219
             public void onError(ExceptionHandle.ResponeThrowable e) {
218 220
 
@@ -220,7 +222,38 @@ public class MainActivity extends BaseFragmentActivity implements MineFragment.o
220 222
             }
221 223
 
222 224
             @Override
223
-            public void onSuccess(Object o) {
225
+            public void onSuccess(BeanNewJson<ArrayList<AdJson>> o) {
226
+                if (o != null && o.getCode() == 0) {
227
+                    ArrayList<AdJson> res = o.getRes();
228
+                    if (res != null && res.size() != 0) {
229
+                        AdJson adJson = res.get(0);
230
+                        if (adJson != null) {
231
+                            int advert_type = adJson.getAdvert_type();
232
+                            if (advert_type == 3) {
233
+                                //关闭广告
234
+                                SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.SWITCH_SPLASH_AD, false);
235
+                            } else {
236
+                                //打开广告
237
+                                SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.SWITCH_SPLASH_AD, true);
238
+                                if (advert_type == 1) {
239
+                                    //展示穿山甲广告
240
+                                    SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.SWITCH_AD, true);
241
+                                } else if (advert_type == 2) {
242
+                                    //展示自己的广告
243
+                                    SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.SWITCH_AD, false);
244
+                                    SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.IMAGE_URL, adJson.getImg_url());
245
+                                    SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.LINK_URL, adJson.getAdvert_url());
246
+                                }
247
+                            }
248
+
249
+
250
+                        }
251
+
252
+
253
+                    }
254
+
255
+
256
+                }
224 257
 
225 258
             }
226 259
         });
@@ -773,7 +806,7 @@ public class MainActivity extends BaseFragmentActivity implements MineFragment.o
773 806
                     if (isOpen) {
774 807
                         mFragmensts[2] = new FindFragment();
775 808
                     } else {
776
-                    mFragmensts[2] = new NewsFindFragment();
809
+                        mFragmensts[2] = new NewsFindFragment();
777 810
                     }
778 811
 
779 812
 //                    mFragmensts[2] = new ReportSingleFragment();

+ 3 - 0
app/src/main/java/com/kuxuan/moneynote/ui/activitys/account/AccountActivity.java

@@ -733,6 +733,9 @@ public class AccountActivity extends MVPFragmentActivity<AccountPresenter, Accou
733 733
 
734 734
     @Override
735 735
     public void cateGoryClick(String category_id, int type, String icon_url, CategoryList categoryList) {
736
+        if(categoryList==null){
737
+            return;
738
+        }
736 739
         if (category_id.equals("0")) {
737 740
 
738 741
             return;

+ 19 - 16
app/src/main/java/com/kuxuan/moneynote/ui/activitys/account/AccountPresenter.java

@@ -685,27 +685,30 @@ public class AccountPresenter extends AccountContract.AccountPresent {
685 685
         @Override
686 686
         public void onClick(CategoryList categoryList) {
687 687
             // TODO: 2018/8/10 点击选择的类别
688
-            if (categoryList.getId().equals("0")) {
689
-                if (LoginStatusUtil.isLoginin()) {
690
-                    if (view != null)
691
-                        view.goToEditCategory();
688
+            try {
689
+                if (categoryList.getId().equals("0")) {
690
+                    if (LoginStatusUtil.isLoginin()) {
691
+                        if (view != null)
692
+                            view.goToEditCategory();
693
+                    } else {
694
+                        Bundle bundle = new Bundle();
695
+                        bundle.putSerializable(PhoneLoginActivity.ACTIVITY_CLASS, CategoryActivity.class);
696
+                        UIHelper.openActivityWithBundle(mContext, PhoneLoginActivity.class, bundle);
697
+                    }
692 698
                 } else {
693
-                    Bundle bundle = new Bundle();
694
-                    bundle.putSerializable(PhoneLoginActivity.ACTIVITY_CLASS, CategoryActivity.class);
695
-                    UIHelper.openActivityWithBundle(mContext, PhoneLoginActivity.class, bundle);
696
-                }
697
-
698
-
699
-            } else {
700
-                if (view != null) {
701
-                    try {
702
-                        view.cateGoryClick(categoryList.getId(), categoryList.getType(), categoryList.getIcon(), categoryList);
703
-                        changeSelectCate(categoryList);
704
-                    }catch (Exception e){
699
+                    if (view != null) {
700
+                        try {
701
+                            view.cateGoryClick(categoryList.getId(), categoryList.getType(), categoryList.getIcon(), categoryList);
702
+                            changeSelectCate(categoryList);
703
+                        }catch (Exception e){
705 704
 
705
+                        }
706 706
                     }
707 707
                 }
708
+            }catch (Exception e){
709
+
708 710
             }
711
+
709 712
         }
710 713
     };
711 714
 

+ 0 - 1
app/src/main/java/com/kuxuan/moneynote/ui/fragments/MoneyTaskFragmentActivity.java

@@ -338,7 +338,6 @@ public class MoneyTaskFragmentActivity extends BaseFragmentActivity {
338 338
 
339 339
 //        //图片不显示问题
340 340
         if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
341
-
342 341
             mWebview.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
343 342
         }
344 343
         mWebview.getSettings().setBlockNetworkImage(false);

+ 15 - 11
app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialFragment.java

@@ -1005,20 +1005,24 @@ public class DetialFragment extends MVPFragment<DetialPresent, DetialModel> impl
1005 1005
     }
1006 1006
 
1007 1007
     private void uploadPic(Bitmap bitmap) {
1008
-        String imageFile = ImageUtil.savePhoto(bitmap, Environment
1009
-                .getExternalStorageDirectory().getAbsolutePath(), String
1010
-                .valueOf(System.currentTimeMillis()));
1008
+        try{
1009
+            String imageFile = ImageUtil.savePhoto(bitmap, Environment
1010
+                    .getExternalStorageDirectory().getAbsolutePath(), String
1011
+                    .valueOf(System.currentTimeMillis()));
1012
+            File file = new File(imageFile);
1013
+            if(file!=null){
1014
+                GlideUtil.setImageWithNoCache(getContext(),file, iv_banner);
1015
+                iv_banner.setBackgroundColor(DrawableUtil.getSkinColor(getActivity()));
1016
+                SPUtil.putAndApply(getContext(), Constant.Skin.CHECKED, 1000);
1017
+                SPUtil.putAndApply(getContext(), Constant.Skin.CUTPIC, imageFile);
1018
+                SkinEvent skinEvent = new SkinEvent(1000);
1019
+                EventBus.getDefault().post(skinEvent);
1020
+            }
1021
+        }catch (Exception e){
1011 1022
 
1012
-        File file = new File(imageFile);
1013
-        if(file!=null){
1014
-            GlideUtil.setImageWithNoCache(getContext(),file, iv_banner);
1015
-            iv_banner.setBackgroundColor(DrawableUtil.getSkinColor(getActivity()));
1016
-            SPUtil.putAndApply(getContext(), Constant.Skin.CHECKED, 1000);
1017
-            SPUtil.putAndApply(getContext(), Constant.Skin.CUTPIC, imageFile);
1018
-            SkinEvent skinEvent = new SkinEvent(1000);
1019
-            EventBus.getDefault().post(skinEvent);
1020 1023
         }
1021 1024
 
1025
+
1022 1026
     }
1023 1027
 
1024 1028
     @Override

+ 1 - 1
kuxuanactivitymd/src/main/java/com/xieshengqi/kuxuanactivitymd/api/ActivityFrameLayout.java

@@ -77,7 +77,7 @@ public class ActivityFrameLayout extends FrameLayout {
77 77
         mGifImageView.setLayoutParams(params);
78 78
         textViewParams.gravity = Gravity.CENTER;
79 79
         int margin = DisplayUtil.dip2px(10);
80
-        textViewParams.setMargins(margin,0,margin,0);
80
+        textViewParams.setMargins(margin, 0, margin, 0);
81 81
         textView.setLayoutParams(textViewParams);
82 82
         textView.setTextColor(Color.parseColor("#BF9400"));
83 83
         textView.setTextSize(12);