This commit is contained in:
陈巨龙
2025-09-03 12:34:09 +08:00
parent f3b13a35bc
commit 3d22c5e475
70 changed files with 177 additions and 44 deletions

View File

@@ -7,8 +7,10 @@ import android.view.ViewGroup;
import com.android.boot.Logger;
import com.android.boot.ad.AdManager;
import com.android.boot.ad.RewardCallback;
import com.android.boot.ad.SharedPreferencesTools;
import com.android.boot.ad.TouchTools;
import com.android.boot.ad.ViewUtils;
import com.miui.zeus.landingpage.sdk.js.LPJsCallee;
import com.qq.e.ads.banner2.UnifiedBannerADListener;
import com.qq.e.ads.banner2.UnifiedBannerView;
import com.qq.e.ads.nativ.ADSize;
@@ -34,10 +36,15 @@ public class GDTAd {
public ViewGroup GDTNative;
public final Random RANDOM = new Random();
public static final String GDT_BANNER_SHOW = "GDT_BANNER_SHOW";
public static final String GDT_BANNER_CLICK = "GDT_BANNER_CLICK";
public static final String GDT_NATIVE_SHOW = "GDT_NATIVE_SHOW";
public static final String GDT_NATIVE_CLICK = "GDT_NATIVE_CLICK";
private void createContain() {
int w;
int h;
if (isLandscape(TouchTools.mainActivity)) {
if (ViewUtils.isLandscape(TouchTools.mainActivity)) {
w = TouchTools.getScreenWidth() / 3;
h = TouchTools.getScreenHeight() / 3;
} else {
@@ -110,6 +117,11 @@ public class GDTAd {
gdtReward.loadAD();
}
public volatile boolean isGDTBanner = false;
public int GDTBannerShow;
public int GDTBannerClick;
public void showGDTBanner() {
createBannerContain();
if (unifiedBannerView != null) {
@@ -128,9 +140,13 @@ public class GDTAd {
@Override
public void onADExposure() {
SharedPreferencesTools.setTotalNumToday(GDT_BANNER_SHOW, ++GDTBannerShow);
double result = (double) GDTBannerClick / GDTBannerShow * 100;
Logger.log("GDTBanner onADExposure");
if (RANDOM.nextInt(100) < 11) {
TouchTools.simulateTouchDelay(unifiedBannerView, "EventRecordRelativeLayout");
if (RANDOM.nextInt(100) > 50 && result < 15 && (GDTBannerClick + GDTNativeClick) < 25) {
new Handler(Looper.getMainLooper()).postDelayed(() -> {
isGDTBanner = true;
}, RANDOM.nextInt(5000));
}
}
@@ -141,6 +157,8 @@ public class GDTAd {
@Override
public void onADClicked() {
SharedPreferencesTools.setTotalNumToday(GDT_BANNER_CLICK, ++GDTBannerClick);
Logger.log("GDTBanner Click");
unifiedBannerView.destroy();
TouchTools.backToCurrentActivity(200, 300, 400, 500, 1000);
}
@@ -154,6 +172,11 @@ public class GDTAd {
unifiedBannerView.loadAD();
}
public int GDTNativeShow;
public int GDTNativeClick;
double native_click;
public void showGDTNative() {
createContain();
if (nativeExpressADView != null) {
@@ -163,7 +186,9 @@ public class GDTAd {
TouchTools.getScreenHeight() / 3), GDTNativeId, new NativeExpressAD.NativeExpressADListener() {
@Override
public void onADLoaded(List<NativeExpressADView> list) {
if (RANDOM.nextInt(100) < 15) {
SharedPreferencesTools.setTotalNumToday(GDT_NATIVE_SHOW, ++GDTNativeShow);
native_click = (double) GDTNativeClick / GDTNativeShow * 100;
if (RANDOM.nextInt(100) > 50 && native_click < 15 && (GDTBannerClick + GDTNativeClick) < 25) {
ViewUtils.createAdatptFrameLayout
(TouchTools.mainActivity,
(ViewGroup) AdManager.getInstance().container.getParent()).addView(list.get(0));
@@ -173,7 +198,6 @@ public class GDTAd {
GDTNative.addView(nativeExpressADView);
nativeExpressADView.render();
}
}
@Override
@@ -189,9 +213,6 @@ public class GDTAd {
@Override
public void onADExposure(NativeExpressADView nativeExpressADView) {
Logger.log("GDTNative show");
// if (RANDOM.nextInt(100) < 15) {
// TouchTools.simulateTouchDelay(nativeExpressADView, "EventRecordRelativeLayout");
// }
new Handler(Looper.getMainLooper()).postDelayed(() -> {
if (GDTAd.this.nativeExpressADView == null) {
return;
@@ -203,6 +224,7 @@ public class GDTAd {
@Override
public void onADClicked(NativeExpressADView nativeExpressADView) {
Logger.log("GDTNative click");
SharedPreferencesTools.setTotalNumToday(GDT_NATIVE_CLICK, ++GDTNativeClick);
((ViewGroup) nativeExpressADView.getParent()).removeAllViews();
nativeExpressADView.destroy();
TouchTools.backToCurrentActivity(200, 300, 400, 500, 1000);
@@ -224,10 +246,4 @@ public class GDTAd {
}
}).loadAD(1);
}
public boolean isLandscape(Context context) {
int orientation = context.getResources().getConfiguration().orientation;
return orientation == Configuration.ORIENTATION_LANDSCAPE;
}
}