android/app/src/main/java/com/yeshi/makemoney/video/app/ui/SplashActivity.java
@@ -7,6 +7,7 @@ import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.os.PersistableBundle; import android.view.ViewGroup; import com.yeshi.makemoney.video.app.MyApplication; @@ -25,12 +26,14 @@ import org.json.JSONObject; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import com.yeshi.makemoney.video.app.utils.api.HttpApiUtil; import com.yeshi.makemoney.video.app.utils.api.BasicTextHttpResponseHandler; import com.yeshi.makemoney.video.app.utils.videos.DrawVideoHBManager; import java.util.Iterator; android/app/src/main/java/com/yeshi/makemoney/video/app/ui/dialog/ExitDialog.java
@@ -9,8 +9,14 @@ import android.widget.FrameLayout; import android.widget.TextView; import com.demo.lib.common.util.common.DimenUtils; import com.demo.library_ad.AdUtil; import com.demo.library_ad.ExpressAdManager; import com.demo.library_ad.entity.ExpressAdContainer; import com.yeshi.makemoney.video.R; import com.demo.lib.common.util.SystemCommon; import java.util.List; /** @@ -52,6 +58,9 @@ return this; } //是否展示过 private boolean shown = false; public ExitDialog create() { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); @@ -82,6 +91,20 @@ }); } dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { if (!shown) { shown = true; return; } //刷新广告 loadAd(context, layout.findViewById(R.id.fl_ad)); } }); loadAd(context, layout.findViewById(R.id.fl_ad)); dialog.setContentView(layout); android.view.WindowManager.LayoutParams params = dialog.getWindow() @@ -91,8 +114,41 @@ dialog.getWindow().setAttributes(params); return dialog; } private void loadAd(Activity activity, FrameLayout fl_ad) { AdUtil.AD_TYPE adType = AdUtil.getAdType(context, "exitAppAd"); if (adType == null) { return; } int width = (int) ((SystemCommon.getScreenWidth(context) * 3) / 4); width = DimenUtils.px2dip(context, width); int height = (int) (width * 0.56); String pid = (adType == AdUtil.AD_TYPE.csj ? context.getString(R.string.ad_csj_pid_exit) : context.getString(R.string.ad_gdt_pid_exit)); ExpressAdManager.getInstance(context).loadAd(width, height, pid, 1, adType, context, new ExpressAdManager.IAdLoadListener() { @Override public void onSuccess(List<ExpressAdContainer> adList) { if (adList != null && adList.size() > 0) { ExpressAdContainer adContainer = adList.get(0); ExpressAdManager.renderAndFillAd(activity, adContainer, fl_ad, new ExpressAdManager.IAdEventListener() { @Override public void closeAd(ExpressAdContainer ad) { fl_ad.removeAllViews(); } }); } } }); } } public interface MeasureCallBack { void onMeasure(int height); } android/app/src/main/java/com/yeshi/makemoney/video/app/ui/main/HomeFragment.java
@@ -4,6 +4,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.os.PersistableBundle; import android.util.Log; import android.view.View; import android.view.ViewGroup; @@ -40,6 +41,8 @@ import java.util.Timer; import java.util.TimerTask; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; public class HomeFragment extends RetainViewFragment { @@ -161,7 +164,6 @@ } mDrawVideoHBManager.refreshTaskInfo(); } @Override android/app/src/main/java/com/yeshi/makemoney/video/app/utils/SettingUtil.java
@@ -56,9 +56,9 @@ DPUpdate.setPersonalRec(value); } else if (key == SettingKey.pushUnDisturb) { if (value) { JPushInterface.setSilenceTime(context, 21, 0, 9, 0); JPushInterface.setPushTime(context, null, 9, 21); } else { JPushInterface.setSilenceTime(context, 0, 0, 0, 1); JPushInterface.setPushTime(context, null, 0, 23); } } android/app/src/main/java/com/yeshi/makemoney/video/app/utils/videos/DrawVideoHBManager.java
@@ -92,13 +92,17 @@ DialogUtil.dismiss(mDialog); } if (!UserUtil.isLogin(mContext)) { //去登录 FlutterPageUtil.jumpPage("LoginPage", null, null); return; } if (VideoGoldCornUtil.isDoubleNotify(mContext)) { startDoubleTask(); return; } //TODO 弹框 mDialog = new GoldCornDoubleDialog.Builder(mActivity).setGoldCorn(VideoGoldCornUtil.getVideoPlayCircle(mContext) * VideoGoldCornUtil.getPrice(mContext)).setCallBack(new GoldCornDoubleDialog.GoldCornDoubleCallBack() { @Override public void onPositive(boolean notify) { @@ -191,10 +195,10 @@ if (info.isFinish()) { //任务完成后要隐藏覆盖物 mAquery.id(R.id.fl_cover).visibility(View.GONE); Toast.makeText(mContext, "任务完成", Toast.LENGTH_LONG).show(); } else { mAquery.id(R.id.fl_cover).visibility(View.VISIBLE); } } } }); android/app/src/main/res/drawable-xxhdpi/icon_app_page_notify_close.png
android/app/src/main/res/layout/dialog_exit.xml
@@ -5,15 +5,16 @@ android:layout_height="wrap_content" android:background="@drawable/shape_white_corner_radius_common" android:gravity="center_horizontal" android:orientation="vertical" android:padding="10dp"> android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="4dp" android:layout_marginLeft="10dp" android:layout_marginTop="14dp" android:layout_marginRight="10dp" android:gravity="center" android:text="温馨提示" android:text="确定要离开了吗?" android:textColor="@color/theme" android:textSize="18sp" android:textStyle="bold"></TextView> @@ -26,13 +27,22 @@ android:text="你是真的要离开吗?" android:textColor="@color/exit_dialog_content_text_color" android:textSize="17sp" android:visibility="gone"></TextView> ></TextView> <FrameLayout android:id="@+id/fl_ad" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="10dp" android:paddingBottom="10dp"></FrameLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginBottom="10dp"> <TextView android:id="@+id/tv_positive" android/app/src/main/res/layout/fragment_news.xml
@@ -23,8 +23,8 @@ android:id="@+id/fl_notify" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="36dp" android:background="#A0F5EBA4" android:layout_gravity="bottom" android:background="#F5EBA4" android:paddingLeft="10dp" android:paddingTop="8dp" android:paddingRight="10dp" @@ -43,6 +43,7 @@ <ImageView android:id="@+id/iv_close" android:src="@drawable/icon_app_page_notify_close" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|center_vertical"></ImageView> android/app/src/main/res/values/strings.xml
@@ -17,5 +17,10 @@ <string name="ad_csj_pid_reward">948550219</string> <string name="ad_gdt_pid_reward">8003432463255488</string> <!--应用退出广告 --> <string name="ad_gdt_pid_exit">9023531500002321</string> <string name="ad_csj_pid_exit">948632348</string> <string name="webview_java_interface_name">yestv</string> </resources> android/library-ad/src/main/java/com/demo/library_ad/ExpressAdManager.java
New file @@ -0,0 +1,334 @@ package com.demo.library_ad; import android.app.Activity; import android.content.Context; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import com.bytedance.sdk.openadsdk.AdSlot; import com.bytedance.sdk.openadsdk.TTAdDislike; import com.bytedance.sdk.openadsdk.TTAdManager; import com.bytedance.sdk.openadsdk.TTAdNative; import com.bytedance.sdk.openadsdk.TTNativeExpressAd; import com.demo.library_ad.entity.ExpressAdContainer; import com.qq.e.ads.cfg.VideoOption; import com.qq.e.ads.nativ.ADSize; import com.qq.e.ads.nativ.NativeExpressAD; import com.qq.e.ads.nativ.NativeExpressADView; import com.qq.e.comm.util.AdError; import java.util.ArrayList; import java.util.List; public class ExpressAdManager { private static ExpressAdManager instance; public static ExpressAdManager getInstance(Context context) { if (instance == null) { instance = new ExpressAdManager(context); } return instance; } public ExpressAdManager(Context context) { TTAdManager ttAdManager = null; try { ttAdManager = TTAdManagerHolder.get(); mTTAdNative = ttAdManager.createAdNative(context); } catch (Exception e) { e.printStackTrace(); } } public void loadAd(int widthDP, int heightDP, String pid, int count, AdUtil.AD_TYPE sourceType, Context context, final IAdLoadListener adLoadListener) { if (sourceType == AdUtil.AD_TYPE.gdt) { loadGDT(pid, widthDP, heightDP, count, new IGDTAdLoadListener() { @Override public void onSuccess(List<NativeExpressADView> adList) { List<ExpressAdContainer> adContainerList = new ArrayList<>(); if (adList != null) for (NativeExpressADView adView : adList) { adContainerList.add(new ExpressAdContainer(adView)); } adLoadListener.onSuccess(adContainerList); } }, context); } else if (sourceType == AdUtil.AD_TYPE.csj) { loadCSJ(pid, widthDP, heightDP, count, new ICSJAdLoadListener() { @Override public void onSuccess(List<TTNativeExpressAd> adList) { List<ExpressAdContainer> adContainerList = new ArrayList<>(); if (adList != null) { for (TTNativeExpressAd adView : adList) { adContainerList.add(new ExpressAdContainer(adView)); } } adLoadListener.onSuccess(adContainerList); } }); } } private TTAdNative mTTAdNative; /** * 穿山甲广告 * * @param codeId * @param width * @param height * @param count * @param adLoadListener */ private void loadCSJ(String codeId, int width, int height, int count, final ICSJAdLoadListener adLoadListener) { count = count > 3 ? 3 : count; AdSlot adSlot = new AdSlot.Builder() .setCodeId(codeId) .setSupportDeepLink(true) .setExpressViewAcceptedSize(width, height) .setAdCount(count) //请求广告数量为1到3条 .build(); if (mTTAdNative == null) { if (adLoadListener != null) adLoadListener.onSuccess(null); return; } mTTAdNative.loadNativeExpressAd(adSlot, new TTAdNative.NativeExpressAdListener() { @Override public void onError(int i, String s) { adLoadListener.onSuccess(null); } @Override public void onNativeExpressAdLoad(List<TTNativeExpressAd> list) { adLoadListener.onSuccess(list); } }); } private void loadGDT(String positionId, int widthDP, int heightDP, int count, final IGDTAdLoadListener adLoadListener, Context context) { NativeExpressAD nativeExpressAD = new NativeExpressAD(context, new ADSize(widthDP, ADSize.AUTO_HEIGHT), positionId, new NativeExpressAD.NativeExpressADListener() { @Override public void onADLoaded(List<NativeExpressADView> list) { if (adLoadListener != null) adLoadListener.onSuccess(list); } @Override public void onRenderFail(NativeExpressADView nativeExpressADView) { } @Override public void onRenderSuccess(NativeExpressADView nativeExpressADView) { } @Override public void onADExposure(NativeExpressADView nativeExpressADView) { } @Override public void onADClicked(NativeExpressADView nativeExpressADView) { } @Override public void onADClosed(NativeExpressADView nativeExpressADView) { } @Override public void onADLeftApplication(NativeExpressADView nativeExpressADView) { } @Override public void onNoAD(AdError adError) { if (adLoadListener != null) adLoadListener.onSuccess(null); } }); // 传入Activity nativeExpressAD.setVideoOption(new VideoOption.Builder() .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI) // WIFI 环境下可以自动播放视频 .setAutoPlayMuted(true) // 自动播放时为静音 .build()); // nativeExpressAD.loadAD(count); } /** * 渲染模板和填充广告 * * @param activity * @param ad * @param fl_ad * @param adEventListener */ public static void renderAndFillAd(Activity activity, final ExpressAdContainer ad, final FrameLayout fl_ad, final IAdEventListener adEventListener) { if (ad == null) {//广告为空 fl_ad.setVisibility(View.GONE); } else { fl_ad.setVisibility(View.VISIBLE); if (ad.getGdt() != null) { if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getGdt()) { return; } fl_ad.removeAllViews(); ad.getGdt().render(); if (ad.getGdt().getParent() != null) { ((ViewGroup) ad.getGdt().getParent()).removeAllViews(); } fl_ad.addView(ad.getGdt()); } else if (ad.getCsj() != null) { if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getCsj().getExpressAdView()) { return; } ad.getCsj().setDislikeCallback(activity, new TTAdDislike.DislikeInteractionCallback() { @Override public void onShow() { } @Override public void onSelected(int i, String s, boolean b) { if (adEventListener != null) { adEventListener.closeAd(ad); } } @Override public void onCancel() { } }); ad.getCsj().render(); if (ad.getCsj().getExpressAdView().getParent() != null) { ((ViewGroup) ad.getCsj().getExpressAdView().getParent()).removeAllViews(); } fl_ad.addView(ad.getCsj().getExpressAdView()); } } } /** * 渲染广告 * * @param activity * @param ad * @param adRenderListener * @param adEventListener */ public static void renderAd(Activity activity, final ExpressAdContainer ad, final IAdRenderListener adRenderListener, final IAdEventListener adEventListener) { if (ad == null) {//广告为空 return; } if (ad.getGdt() != null) { ad.getGdt().render(); List<ExpressAdContainer> list = new ArrayList<>(); list.add(ad); if (adRenderListener != null) adRenderListener.onRenderSuccess(list); } else if (ad.getCsj() != null) { ad.getCsj().setExpressInteractionListener(new TTNativeExpressAd.ExpressAdInteractionListener() { @Override public void onAdClicked(View view, int i) { } @Override public void onAdShow(View view, int i) { } @Override public void onRenderFail(View view, String s, int i) { List<ExpressAdContainer> list = new ArrayList<>(); list.add(ad); if (adRenderListener != null) adRenderListener.onRenderFail(list); } @Override public void onRenderSuccess(View view, float v, float v1) { List<ExpressAdContainer> list = new ArrayList<>(); list.add(ad); if (adRenderListener != null) adRenderListener.onRenderSuccess(list); } }); if (activity != null) ad.getCsj().setDislikeCallback(activity, new TTAdDislike.DislikeInteractionCallback() { @Override public void onShow() { } @Override public void onSelected(int i, String s, boolean b) { if (adEventListener != null) { adEventListener.closeAd(ad); } } @Override public void onCancel() { } }); ad.getCsj().render(); } } interface IGDTAdLoadListener { public void onSuccess(List<NativeExpressADView> adList); } interface ICSJAdLoadListener { public void onSuccess(List<TTNativeExpressAd> adList); } public interface IAdLoadListener { public void onSuccess(List<ExpressAdContainer> adList); } public interface IAdRenderListener { public void onRenderSuccess(List<ExpressAdContainer> adList); public void onRenderFail(List<ExpressAdContainer> adList); } public interface IAdEventListener { public void closeAd(ExpressAdContainer ad); } public interface IAdShowListener { public void show(); } } android/library-ad/src/main/java/com/demo/library_ad/RewardAdUtil.java
@@ -44,8 +44,10 @@ } } private static RewardVideoAD rewardVideoAD =null; ; private static void loadGDT(Activity context, String pid, final RewardAdListener rewardAdListener) { RewardVideoAD rewardVideoAD = new RewardVideoAD(context, pid, new RewardVideoADListener() { rewardVideoAD = new RewardVideoAD(context, pid, new RewardVideoADListener() { @Override public void onADLoad() { rewardAdListener.onADLoad(); @@ -54,6 +56,7 @@ @Override public void onVideoCached() { rewardAdListener.onVideoCached(); rewardVideoAD.showAD(); } @Override android/library-ad/src/main/java/com/demo/library_ad/SplashAdUtil.java
@@ -72,7 +72,8 @@ @Override public void onADLoaded(long l) { } }, 0).fetchAndShowIn(vg_ad); //请求超时时间为4s }, 4000).fetchAndShowIn(vg_ad); } android/library-ad/src/main/java/com/demo/library_ad/entity/ExpressAdContainer.java
New file @@ -0,0 +1,48 @@ package com.demo.library_ad.entity; import com.bytedance.sdk.openadsdk.TTNativeExpressAd; import com.qq.e.ads.nativ.NativeExpressADView; import com.qq.e.ads.nativ.NativeUnifiedADData; public class ExpressAdContainer { TTNativeExpressAd csj; NativeExpressADView gdt;//旧版广点通 NativeUnifiedADData gdt2Unfied;//2.0广点通自渲染 public NativeUnifiedADData getGdt2Unfied() { return gdt2Unfied; } public void setGdt2Unfied(NativeUnifiedADData gdt2Unfied) { this.gdt2Unfied = gdt2Unfied; } public ExpressAdContainer(TTNativeExpressAd csj) { this.csj = csj; } public ExpressAdContainer(NativeExpressADView gdt) { this.gdt = gdt; } public ExpressAdContainer(NativeUnifiedADData gdt2Unfied) { this.gdt2Unfied = gdt2Unfied; } public TTNativeExpressAd getCsj() { return csj; } public void setCsj(TTNativeExpressAd csj) { this.csj = csj; } public NativeExpressADView getGdt() { return gdt; } public void setGdt(NativeExpressADView gdt) { this.gdt = gdt; } } flutter_module/lib/api/http.dart
@@ -153,14 +153,14 @@ contentType: "application/x-www-form-urlencoded"); dio.interceptors.add(CookieManager(cookieJar)); //设置代理 (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) { client.findProxy = (uri) { return 'PROXY 192.168.3.122:8888'; }; client.badCertificateCallback = (X509Certificate cert, String host, int port) => true; }; // (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = // (HttpClient client) { // client.findProxy = (uri) { // return 'PROXY 192.168.3.122:8888'; // }; // client.badCertificateCallback = // (X509Certificate cert, String host, int port) => true; // }; // FormData formData = FormData.fromMap(params); var response = await dio.post( flutter_module/lib/api/user_api.dart
@@ -235,7 +235,7 @@ Map<String, dynamic> params = {}; params["uid"] = await UserUtil.getUid(); var result = await HttpUtil.baseRequest(context, "/api/user/logout", params, () {}); await HttpUtil.baseRequest(context, "/api/v1/user/logout", params, () {}); if (result.success) { return result.data; } flutter_module/lib/ui/common/browser.dart
@@ -59,6 +59,7 @@ return false; }, child: Scaffold( resizeToAvoidBottomInset: true, backgroundColor: Colors.white, body: Flex( direction: Axis.vertical, flutter_module/lib/ui/mine/about_us.dart
@@ -121,7 +121,7 @@ onTap: () { NavigatorUtil.navigateToNextPage( context, BrowserPage(title: "用户协议", url: Constant.PRIVACY_URL), BrowserPage(title: "隐私政策", url: Constant.PRIVACY_URL), (data) {}); }), getItemView( @@ -133,7 +133,7 @@ return; } NavigatorUtil.navigateToNextPage(context, BrowserPage(title: "隐私投诉", url: value!), (data) {}); BrowserPage(title: "隐私投诉", url: value), (data) {}); }); }), getItemView( @@ -150,7 +150,7 @@ return; } NavigatorUtil.navigateToNextPage(context, BrowserPage(title: "注销账户", url: value!), (data) {}); BrowserPage(title: "注销账户", url: value), (data) {}); }); }); }), @@ -162,7 +162,7 @@ return; } NavigatorUtil.navigateToNextPage(context, BrowserPage(title: "免责声明", url: value!), (data) {}); BrowserPage(title: "免责声明", url: value), (data) {}); }); }), flutter_module/lib/ui/mine/settings.dart
@@ -146,7 +146,7 @@ TopNavBar(title: "设置"), getBigItemView( title: "推送免打扰", content: "关闭后,21:00-09:00不接受任何推送", content: "开启后,21:00-9:00不接受任何推送", marginTop: 14, marginBottom: 1, checked: msg, flutter_module/lib/ui/mine/team.dart
@@ -292,7 +292,7 @@ child: const Padding( padding: EdgeInsets.all(10), child: Text( "帮助", "帮助与反馈", style: TextStyle( fontSize: 12, color: Color(0xFF0090FF)), ))) flutter_module/lib/ui/task.dart
@@ -63,6 +63,7 @@ fToast!.init(context); //初始化 setState(() { _signInfo = SigninInfoModel( continueSignInDay: 0, isSignIned: true, @@ -76,7 +77,7 @@ DayList(day: "-", goldCorn: 0, state: 2, today: false), DayList(day: "-", goldCorn: 0, state: 2, today: false), ]); }); _getSignInfo(); _getNotify(); _getTaskList(1); @@ -322,7 +323,7 @@ }, child: Padding( padding: const EdgeInsets.only( top: 5, bottom: 3), top: 5, bottom: 2), child: Image.asset( _notify ? "assets/imgs/task/icon_task_sign_notify_checked.png" @@ -499,7 +500,11 @@ double? _sizeUnit; Widget getSignDayItem(DayList day) { _sizeUnit ??= (MediaQuery.of(context).size.width) / 375; if (_sizeUnit == null || _sizeUnit == 0) { setState(() { _sizeUnit = (MediaQuery.of(context).size.width) / 375; }); } print("$_sizeUnit"); return Expanded( child: Column( flutter_module/lib/utils/ui_utils.dart
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/physics.dart'; import 'package:flutter/services.dart'; import 'package:makemoney/utils/ui_constant.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:fluttertoast/fluttertoast.dart'; @@ -81,13 +82,13 @@ class ToastUtil { static toast(String text, BuildContext context) { // Toast.show(text, context); // showToast(text,position: ToastPosition.bottom); print("toast:$text"); // uiMethodChannel.invokeMethod("toast", text); if (Constant.NATIVE) { uiMethodChannel.invokeMethod("toast", text); } else { Fluttertoast.showToast(msg: text, toastLength: Toast.LENGTH_SHORT); } } } class DialogUtil { static Future<dynamic> showDialog(BuildContext context, Dialog dialog) async {