V1.0.1(2) 接入topon
This commit is contained in:
parent
d842022ad5
commit
4e346acf5a
@ -68,93 +68,94 @@ dependencies {
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------TopOn(Mintegral、Pangle、UnitAds、Digital Turbine(Fyber)、Chartboost&Helium、Ironsource、Liftoff(Vungle)、Inmobi、Start.io、Appnext、Bigo)
|
||||
|
||||
// //Anythink (Necessary)
|
||||
// implementation("com.anythink.sdk:core-tpn:6.4.07")
|
||||
// implementation("com.anythink.sdk:nativead-tpn:6.4.07")
|
||||
// implementation("com.anythink.sdk:banner-tpn:6.4.07")
|
||||
// implementation("com.anythink.sdk:interstitial-tpn:6.4.07")
|
||||
// implementation("com.anythink.sdk:rewardedvideo-tpn:6.4.07")
|
||||
// implementation("com.anythink.sdk:splash-tpn:6.4.07")
|
||||
//
|
||||
// //Androidx (Necessary)
|
||||
// implementation("androidx.appcompat:appcompat:1.1.0")
|
||||
// implementation("androidx.browser:browser:1.4.0")
|
||||
//
|
||||
// //StartApp
|
||||
// implementation("com.anythink.sdk:adapter-tpn-startapp:6.4.07")
|
||||
// implementation("com.startapp:inapp-sdk:5.0.2")
|
||||
//
|
||||
// //Appnext
|
||||
// implementation("com.anythink.sdk:adapter-tpn-appnext:6.4.07")
|
||||
// implementation("com.appnext.sdk:ads:2.7.1.473")
|
||||
// implementation("com.appnext.sdk:banners:2.7.1.473")
|
||||
// implementation("com.appnext.sdk:native-ads2:2.7.1.473")
|
||||
// implementation("com.appnext.sdk:actions:2.4.6.472")
|
||||
// implementation("androidx.constraintlayout:constraintlayout:2.0.4")
|
||||
//
|
||||
// //Vungle
|
||||
// implementation("com.anythink.sdk:adapter-tpn-vungle:6.4.07")
|
||||
// implementation("com.vungle:vungle-ads:7.4.0")
|
||||
// implementation("com.google.android.gms:play-services-basement:18.1.0")
|
||||
// implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
//
|
||||
// //UnityAds
|
||||
// implementation("com.anythink.sdk:adapter-tpn-unityads:6.4.07")
|
||||
// implementation("com.unity3d.ads:unity-ads:4.12.2")
|
||||
//
|
||||
// //Ironsource
|
||||
// implementation("com.anythink.sdk:adapter-tpn-ironsource:6.4.07")
|
||||
// implementation("com.ironsource.sdk:mediationsdk:8.2.1")
|
||||
// implementation("com.google.android.gms:play-services-appset:16.0.2")
|
||||
// implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
// implementation("com.google.android.gms:play-services-basement:18.1.0")
|
||||
//
|
||||
// //Bigo
|
||||
// implementation("com.anythink.sdk:adapter-tpn-bigo:6.4.07")
|
||||
// implementation("com.bigossp:bigo-ads:4.9.0")
|
||||
//
|
||||
// //Pangle
|
||||
// implementation("com.anythink.sdk:adapter-tpn-pangle-nonchina:6.4.07")
|
||||
// implementation("com.pangle.global:ads-sdk:6.1.0.9")
|
||||
// implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
//
|
||||
// //Inmobi
|
||||
// implementation("com.anythink.sdk:adapter-tpn-inmobi:6.4.07")
|
||||
// implementation("com.inmobi.monetization:inmobi-ads-kotlin:10.7.5")
|
||||
//
|
||||
// //Mintegral
|
||||
// implementation("com.anythink.sdk:adapter-tpn-mintegral-nonchina:6.4.07")
|
||||
// implementation("com.mbridge.msdk.oversea:reward:16.8.11")
|
||||
// implementation("com.mbridge.msdk.oversea:newinterstitial:16.8.11")
|
||||
// implementation("com.mbridge.msdk.oversea:mbnative:16.8.11")
|
||||
// implementation("com.mbridge.msdk.oversea:mbnativeadvanced:16.8.11")
|
||||
// implementation("com.mbridge.msdk.oversea:mbsplash:16.8.11")
|
||||
// implementation("com.mbridge.msdk.oversea:mbbanner:16.8.11")
|
||||
// implementation("com.mbridge.msdk.oversea:mbbid:16.8.11")
|
||||
// implementation("androidx.recyclerview:recyclerview:1.1.0")
|
||||
//
|
||||
// //Chartboost
|
||||
// implementation("com.anythink.sdk:adapter-tpn-chartboost:6.4.07")
|
||||
// implementation("com.chartboost:chartboost-sdk:9.7.0")
|
||||
// implementation("com.chartboost:chartboost-mediation-sdk:4.9.1")
|
||||
// implementation("com.chartboost:chartboost-mediation-adapter-chartboost:4.9.7.0.0")
|
||||
// implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0")
|
||||
// implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")
|
||||
// implementation("com.squareup.okhttp3:okhttp:4.10.0")
|
||||
// implementation("com.squareup.retrofit2:converter-scalars:2.9.0")
|
||||
// implementation("com.squareup.retrofit2:retrofit:2.9.0")
|
||||
// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")
|
||||
// implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
|
||||
//
|
||||
// //Fyber
|
||||
// implementation("com.anythink.sdk:adapter-tpn-fyber:6.4.07")
|
||||
// implementation("com.fyber:marketplace-sdk:8.3.0")
|
||||
// implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
//
|
||||
// // Debugger UI Tools
|
||||
// implementation ("com.anythink.sdk:debugger-ui:1.0.7")
|
||||
//Anythink (Necessary)
|
||||
implementation("com.anythink.sdk:core-tpn:6.4.07")
|
||||
implementation("com.anythink.sdk:nativead-tpn:6.4.07")
|
||||
implementation("com.anythink.sdk:banner-tpn:6.4.07")
|
||||
implementation("com.anythink.sdk:interstitial-tpn:6.4.07")
|
||||
implementation("com.anythink.sdk:rewardedvideo-tpn:6.4.07")
|
||||
implementation("com.anythink.sdk:splash-tpn:6.4.07")
|
||||
|
||||
//Androidx (Necessary)
|
||||
implementation("androidx.appcompat:appcompat:1.1.0")
|
||||
implementation("androidx.browser:browser:1.4.0")
|
||||
|
||||
//StartApp
|
||||
implementation("com.anythink.sdk:adapter-tpn-startapp:6.4.07")
|
||||
implementation("com.startapp:inapp-sdk:5.0.2")
|
||||
|
||||
//Appnext
|
||||
implementation("com.anythink.sdk:adapter-tpn-appnext:6.4.07")
|
||||
implementation("com.appnext.sdk:ads:2.7.1.473")
|
||||
implementation("com.appnext.sdk:banners:2.7.1.473")
|
||||
implementation("com.appnext.sdk:native-ads2:2.7.1.473")
|
||||
implementation("com.appnext.sdk:actions:2.4.6.472")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
|
||||
|
||||
//Vungle
|
||||
implementation("com.anythink.sdk:adapter-tpn-vungle:6.4.07")
|
||||
implementation("com.vungle:vungle-ads:7.4.0")
|
||||
implementation("com.google.android.gms:play-services-basement:18.1.0")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
|
||||
//UnityAds
|
||||
implementation("com.anythink.sdk:adapter-tpn-unityads:6.4.07")
|
||||
implementation("com.unity3d.ads:unity-ads:4.12.2")
|
||||
|
||||
//Ironsource
|
||||
implementation("com.anythink.sdk:adapter-tpn-ironsource:6.4.07")
|
||||
implementation("com.ironsource.sdk:mediationsdk:8.2.1")
|
||||
implementation("com.google.android.gms:play-services-appset:16.0.2")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
implementation("com.google.android.gms:play-services-basement:18.1.0")
|
||||
|
||||
//Bigo
|
||||
implementation("com.anythink.sdk:adapter-tpn-bigo:6.4.07")
|
||||
implementation("com.bigossp:bigo-ads:4.9.0")
|
||||
|
||||
//Pangle
|
||||
implementation("com.anythink.sdk:adapter-tpn-pangle-nonchina:6.4.07")
|
||||
implementation("com.pangle.global:ads-sdk:6.1.0.9")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
|
||||
//Inmobi
|
||||
implementation("com.anythink.sdk:adapter-tpn-inmobi:6.4.07")
|
||||
implementation("com.inmobi.monetization:inmobi-ads-kotlin:10.7.5")
|
||||
|
||||
//Mintegral
|
||||
implementation("com.anythink.sdk:adapter-tpn-mintegral-nonchina:6.4.07")
|
||||
implementation("com.mbridge.msdk.oversea:reward:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:newinterstitial:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:mbnative:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:mbnativeadvanced:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:mbsplash:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:mbbanner:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:mbbid:16.8.11")
|
||||
implementation("androidx.recyclerview:recyclerview:1.1.0")
|
||||
|
||||
//Chartboost
|
||||
implementation("com.anythink.sdk:adapter-tpn-chartboost:6.4.07")
|
||||
implementation("com.chartboost:chartboost-sdk:9.7.0")
|
||||
implementation("com.chartboost:chartboost-mediation-sdk:4.9.1")
|
||||
implementation("com.chartboost:chartboost-mediation-adapter-chartboost:4.9.7.0.0")
|
||||
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0")
|
||||
implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")
|
||||
implementation("com.squareup.okhttp3:okhttp:4.10.0")
|
||||
implementation("com.squareup.retrofit2:converter-scalars:2.9.0")
|
||||
implementation("com.squareup.retrofit2:retrofit:2.9.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
|
||||
|
||||
//Fyber
|
||||
implementation("com.anythink.sdk:adapter-tpn-fyber:6.4.07")
|
||||
implementation("com.fyber:marketplace-sdk:8.3.0")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
|
||||
// Debugger UI Tools
|
||||
//implementation ("com.anythink.sdk:debugger-ui:1.0.7")
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -5,7 +5,10 @@ import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.Log;
|
||||
|
||||
import com.anythink.core.api.ATSDK;
|
||||
import com.anythink.core.api.NetTrafficeCallback;
|
||||
import com.hd.wallpaper.free.walls.json.Category;
|
||||
import com.hd.wallpaper.free.walls.topon.AdManager;
|
||||
import com.hd.wallpaper.free.walls.utils.CommonUtils;
|
||||
import com.hd.wallpaper.free.walls.utils.CommonKt;
|
||||
import com.hd.wallpaper.free.walls.db.DbManager;
|
||||
@ -24,9 +27,9 @@ public class MyWallpaper extends Application {
|
||||
public static String TAG = "-------MyApp---------";
|
||||
public static Typeface defaultFont;
|
||||
|
||||
// private String APPId="h673ddf8ae8467";
|
||||
// private String AppKey="a17cd7a62720b00498a8dc5c538c92303";
|
||||
// private String debug_Key="";
|
||||
private String APPId = "h676a28fcee6ba";
|
||||
private String AppKey = "a638be5768ab74c7fec0343d3b77b216e";
|
||||
private String debug_Key = "";
|
||||
|
||||
private String animasName = "Animals.json";
|
||||
private String exName = "experimental.json";
|
||||
@ -35,37 +38,39 @@ public class MyWallpaper extends Application {
|
||||
private String pattName = "patterns.json";
|
||||
private String streetName = "street.json";
|
||||
private String travelName = "travel.json";
|
||||
private static List<Category> data = new ArrayList<>();
|
||||
private static List<Category> data = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mAppContext = this;
|
||||
defaultFont = Typeface.createFromAsset(getAssets(), "custfont.ttf");
|
||||
DbManager.init(this);
|
||||
String[] names = {animasName,exName,filmName,natureName,pattName,streetName,travelName};
|
||||
String[] names = {animasName, exName, filmName, natureName, pattName, streetName, travelName};
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for(String name:names){
|
||||
for (String name : names) {
|
||||
InputStream open = getAssets().open(name);
|
||||
String covertStr = CommonUtils.getCovertStr(open);
|
||||
if (!covertStr.isEmpty()) {
|
||||
List<Data> data1 = CommonKt.INSTANCE.getData(covertStr);
|
||||
Category category = new Category();
|
||||
String realName = name.substring(0, name.indexOf("."));
|
||||
String realName = name.substring(0, name.indexOf("."));
|
||||
category.setClassName(realName);
|
||||
List<Data> data2 = data1.subList(10, 200);
|
||||
List<Data> data2 = data1.subList(0, 200);
|
||||
category.setDataList(data2);
|
||||
data.add(category);
|
||||
}
|
||||
}
|
||||
Log.d(MyWallpaper.TAG,"------------data complete");
|
||||
Log.d(MyWallpaper.TAG, "------------data complete");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
initTop();
|
||||
}
|
||||
|
||||
public static List<Category> getData() {
|
||||
@ -74,29 +79,28 @@ public class MyWallpaper extends Application {
|
||||
}
|
||||
|
||||
|
||||
private void initTop() {
|
||||
ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
||||
|
||||
// private void initTop(){
|
||||
// ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
||||
//
|
||||
// @Override
|
||||
// public void onResultCallback(boolean isEU) {
|
||||
// Log.e(TAG, "onResultCallback:" + isEU);
|
||||
// if (isEU && ATSDK.getGDPRDataLevel( MyApp.mAppContext) == ATSDK.UNKNOWN) {
|
||||
// ATSDK.showGdprAuth(MyApp.mAppContext);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onErrorCallback(String errorMsg) {
|
||||
// Log.e(TAG, "onErrorCallback:" + errorMsg);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// ATSDK.init( this, APPId, AppKey);
|
||||
// //测试工具
|
||||
//// ATDebuggerUITest.showDebuggerUI(this,debug_Key);
|
||||
// AdManager.loadAllAd();
|
||||
//
|
||||
// }
|
||||
@Override
|
||||
public void onResultCallback(boolean isEU) {
|
||||
Log.e(TAG, "onResultCallback:" + isEU);
|
||||
if (isEU && ATSDK.getGDPRDataLevel(MyWallpaper.mAppContext) == ATSDK.UNKNOWN) {
|
||||
ATSDK.showGdprAuth(MyWallpaper.mAppContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onErrorCallback(String errorMsg) {
|
||||
Log.e(TAG, "onErrorCallback:" + errorMsg);
|
||||
}
|
||||
});
|
||||
|
||||
ATSDK.init(this, APPId, AppKey);
|
||||
//测试工具
|
||||
// ATDebuggerUITest.showDebuggerUI(this,debug_Key);
|
||||
AdManager.loadAllAd();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package com.hd.wallpaper.free.walls.topon;
|
||||
|
||||
public interface AdListener {
|
||||
void loadFail(String placeId);
|
||||
void showSuccess();
|
||||
|
||||
void showFail();
|
||||
|
||||
void showClose();
|
||||
}
|
||||
@ -0,0 +1,253 @@
|
||||
package com.hd.wallpaper.free.walls.topon;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.CountDownTimer;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.anythink.core.api.ATAdInfo;
|
||||
import com.anythink.core.api.AdError;
|
||||
import com.anythink.interstitial.api.ATInterstitial;
|
||||
import com.anythink.interstitial.api.ATInterstitialListener;
|
||||
import com.hd.wallpaper.free.walls.MyWallpaper;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AdManager {
|
||||
|
||||
private static final int type_no_cache = 0;
|
||||
private static final int type_has_cache = 1;
|
||||
private static final int type_show_success = 2;
|
||||
private static final int type_show_close = 3;
|
||||
private static final int type_show_fail = 4;
|
||||
|
||||
/**
|
||||
HD_INST_3
|
||||
n676a291a69e33
|
||||
HD_INST_2
|
||||
n676a291a3bfe2
|
||||
HD_INST_1
|
||||
n676a291a0d7c3
|
||||
*/
|
||||
|
||||
private static final String place1Id = "n676a291a69e33";
|
||||
private static final String place2Id = "n676a291a3bfe2";
|
||||
private static final String place3Id = "n676a291a0d7c3";
|
||||
|
||||
|
||||
private static boolean place1LoadFail = false;
|
||||
private static boolean place2LoadFail = false;
|
||||
private static boolean place3LoadFail = false;
|
||||
|
||||
private static boolean alreadyShow = false;
|
||||
|
||||
private static List<ATInterstitial> list = new ArrayList<>();
|
||||
|
||||
|
||||
public static void loadAllAd() {
|
||||
if (list.size() == 0) {
|
||||
ATInterstitial mInterstitialAd1 = new ATInterstitial(MyWallpaper.mAppContext, place1Id);
|
||||
ATInterstitial mInterstitialAd2 = new ATInterstitial(MyWallpaper.mAppContext, place2Id);
|
||||
ATInterstitial mInterstitialAd3 = new ATInterstitial(MyWallpaper.mAppContext, place3Id);
|
||||
list.add(mInterstitialAd1);
|
||||
list.add(mInterstitialAd2);
|
||||
list.add(mInterstitialAd3);
|
||||
}
|
||||
for (ATInterstitial ad : list) {
|
||||
if (!ad.isAdReady()) {
|
||||
setCallBack(ad, new AdListener() {
|
||||
@Override
|
||||
public void loadFail(@NonNull String placeId) {
|
||||
if (placeId.equals(place1Id)) {
|
||||
place1LoadFail = true;
|
||||
}
|
||||
if (placeId.equals(place2Id)) {
|
||||
place2LoadFail = true;
|
||||
}
|
||||
if (placeId.equals(place3Id)) {
|
||||
place3LoadFail = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showFail() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showClose() {
|
||||
|
||||
}
|
||||
});
|
||||
ad.load();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static ATInterstitial getReadyAd() {
|
||||
Collections.shuffle(list);
|
||||
for (ATInterstitial ad : list) {
|
||||
if (ad.isAdReady()) {
|
||||
Log.d(MyWallpaper.TAG, "-has Cache------------");
|
||||
return ad;
|
||||
}
|
||||
}
|
||||
Log.d(MyWallpaper.TAG, "-No Cache------------");
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void setCallBack(ATInterstitial ad, AdListener listener) {
|
||||
ad.setAdListener(new ATInterstitialListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdLoaded() {
|
||||
Log.d(MyWallpaper.TAG, "LoadLoaded " + ad.mPlacementId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdLoadFail(AdError adError) {
|
||||
listener.loadFail(ad.mPlacementId);
|
||||
Log.d(MyWallpaper.TAG, "LoadFail:--" + ad.mPlacementId + "--" + adError.getCode() + "---" + adError.getDesc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdClicked(ATAdInfo atAdInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdShow(ATAdInfo atAdInfo) {
|
||||
Log.d(MyWallpaper.TAG, "AdShow " + atAdInfo.getShowId());
|
||||
listener.showSuccess();
|
||||
ad.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdClose(ATAdInfo atAdInfo) {
|
||||
listener.showClose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdVideoStart(ATAdInfo atAdInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdVideoEnd(ATAdInfo atAdInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdVideoError(AdError adError) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static CountDownTimer showWelcomeAd(
|
||||
Activity activity,
|
||||
Long totalTim,
|
||||
CountAction countAction,
|
||||
GoMainAction goMain
|
||||
) {
|
||||
Log.d(MyWallpaper.TAG,"----------alreadyShow="+alreadyShow);
|
||||
alreadyShow = false;
|
||||
CountDownTimer timer = new CountDownTimer(totalTim, 100) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
countAction.onCount(millisUntilFinished);
|
||||
if (!alreadyShow) {
|
||||
showAD(activity, new AdStatusAction() {
|
||||
@Override
|
||||
public void onStatus(int adType) {
|
||||
if (adType == type_has_cache) {
|
||||
alreadyShow = true;
|
||||
}
|
||||
if (adType == type_show_close || adType == type_show_fail) {
|
||||
goMain.onGo();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
if (!alreadyShow) {
|
||||
showTopOn(activity, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
goMain.onGo();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return timer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void showAD(Activity activity, AdStatusAction action) {
|
||||
ATInterstitial readyAd = getReadyAd();
|
||||
if (readyAd != null) {
|
||||
action.onStatus(type_has_cache);
|
||||
setCallBack(readyAd, new AdListener() {
|
||||
@Override
|
||||
public void loadFail(@NonNull String placeId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showSuccess() {
|
||||
action.onStatus(type_show_success);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showFail() {
|
||||
action.onStatus(type_show_fail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showClose() {
|
||||
action.onStatus(type_show_close);
|
||||
}
|
||||
});
|
||||
readyAd.show(activity);
|
||||
} else {
|
||||
action.onStatus(type_no_cache);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void showTopOn(Activity activity, onActionListener listener) {
|
||||
showAD(activity, new AdStatusAction() {
|
||||
@Override
|
||||
public void onStatus(int adType) {
|
||||
if (adType == type_no_cache || adType == type_show_close || adType == type_show_fail) {
|
||||
listener.onAction();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.hd.wallpaper.free.walls.topon;
|
||||
|
||||
public interface AdStatusAction {
|
||||
void onStatus(int adType);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.hd.wallpaper.free.walls.topon;
|
||||
|
||||
public interface CountAction {
|
||||
void onCount(long millisUntilFinished);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.hd.wallpaper.free.walls.topon;
|
||||
|
||||
public interface GoMainAction {
|
||||
void onGo();
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.hd.wallpaper.free.walls.topon;
|
||||
|
||||
public interface onActionListener {
|
||||
|
||||
void onAction();
|
||||
}
|
||||
@ -13,6 +13,7 @@ import com.google.android.material.tabs.TabLayout;
|
||||
import com.hd.wallpaper.free.walls.R;
|
||||
import com.hd.wallpaper.free.walls.databinding.ActivityMainBinding;
|
||||
import com.hd.wallpaper.free.walls.databinding.TabCustomViewBinding;
|
||||
import com.hd.wallpaper.free.walls.topon.AdManager;
|
||||
import com.hd.wallpaper.free.walls.utils.CommonUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -29,11 +30,10 @@ public class ActivityMain extends AppCompatActivity {
|
||||
vb = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
CommonUtils.initFull(this,false);
|
||||
setContentView(vb.getRoot());
|
||||
|
||||
|
||||
List<Fragment> list = new ArrayList<>();
|
||||
list.add(FragmentHome.newInstance(0));
|
||||
list.add(FragmentLike.newInstance());
|
||||
AdManager.loadAllAd();
|
||||
|
||||
|
||||
int[] ints = {R.drawable.selector_tab_home, R.drawable.selector_tab_like,R.drawable.selector_tab_download};
|
||||
|
||||
@ -29,6 +29,8 @@ import com.hd.wallpaper.free.walls.databinding.ActivitySetBinding;
|
||||
import com.hd.wallpaper.free.walls.db.DbManager;
|
||||
import com.hd.wallpaper.free.walls.json.Data;
|
||||
import com.hd.wallpaper.free.walls.mylistener.TypeListener;
|
||||
import com.hd.wallpaper.free.walls.topon.AdManager;
|
||||
import com.hd.wallpaper.free.walls.topon.onActionListener;
|
||||
import com.hd.wallpaper.free.walls.utils.CommonKt;
|
||||
import com.hd.wallpaper.free.walls.utils.CommonUtils;
|
||||
|
||||
@ -65,6 +67,7 @@ public class ActivitySet extends AppCompatActivity implements TypeListener {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
vb = ActivitySetBinding.inflate(getLayoutInflater());
|
||||
AdManager.loadAllAd();
|
||||
CommonUtils.initFull(this, true);
|
||||
setContentView(vb.getRoot());
|
||||
weakReference = new WeakReference<>(this);
|
||||
@ -95,7 +98,7 @@ public class ActivitySet extends AppCompatActivity implements TypeListener {
|
||||
int height = vb.imageviewPreview.getHeight();
|
||||
|
||||
int[] screenWidthHeight = CommonUtils.getScreenWidthHeight(this);
|
||||
Log.d(MyWallpaper.TAG,"--------width="+screenWidthHeight[0]+"----height="+screenWidthHeight[1]);
|
||||
Log.d(MyWallpaper.TAG, "--------width=" + screenWidthHeight[0] + "----height=" + screenWidthHeight[1]);
|
||||
if (file.exists()) {
|
||||
Glide.with(this)
|
||||
.load(file)
|
||||
@ -155,22 +158,42 @@ public class ActivitySet extends AppCompatActivity implements TypeListener {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
AdManager.showTopOn(ActivitySet.this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initClick() {
|
||||
vb.imageviewBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
AdManager.showTopOn(ActivitySet.this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
vb.buttonSet.setOnClickListener(v -> {
|
||||
if (dialogSetType == null) {
|
||||
dialogSetType = new DialogSetType();
|
||||
dialogSetType.setListener(ActivitySet.this);
|
||||
}
|
||||
if (!dialogSetType.isAdded()) {
|
||||
dialogSetType.show(getSupportFragmentManager(), "");
|
||||
}
|
||||
AdManager.showTopOn(ActivitySet.this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
if (dialogSetType == null) {
|
||||
dialogSetType = new DialogSetType();
|
||||
dialogSetType.setListener(ActivitySet.this);
|
||||
}
|
||||
if (!dialogSetType.isAdded()) {
|
||||
dialogSetType.show(getSupportFragmentManager(), "");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@ -190,11 +213,17 @@ public class ActivitySet extends AppCompatActivity implements TypeListener {
|
||||
vb.layoutDownload.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean permission = CommonKt.INSTANCE.requestPermission(ActivitySet.this, permissionCode);
|
||||
if (!permission) {
|
||||
return;
|
||||
}
|
||||
startSaveToAlbum();
|
||||
|
||||
AdManager.showTopOn(ActivitySet.this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
boolean permission = CommonKt.INSTANCE.requestPermission(ActivitySet.this, permissionCode);
|
||||
if (!permission) {
|
||||
return;
|
||||
}
|
||||
startSaveToAlbum();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
@ -203,12 +232,7 @@ public class ActivitySet extends AppCompatActivity implements TypeListener {
|
||||
|
||||
private void startSaveToAlbum() {
|
||||
showDownloadLoading(true);
|
||||
// File file = new File(mSavePath);
|
||||
// if (file.exists()) {
|
||||
// Log.d(MyWallpaper.TAG, "-----------Download 1");
|
||||
// startSave(file);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (downloadFile != null && downloadFile.exists()) {
|
||||
Log.d(MyWallpaper.TAG, "-----------Download 2");
|
||||
startSave(downloadFile);
|
||||
@ -317,20 +341,20 @@ public class ActivitySet extends AppCompatActivity implements TypeListener {
|
||||
Log.d(MyWallpaper.TAG, "--------onSelectType=" + Thread.currentThread().getName());
|
||||
showSetWallpaperLoading(true);
|
||||
if (downloadFile != null) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setWallpaper(downloadFile, type);
|
||||
}
|
||||
}).start();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setWallpaper(downloadFile, type);
|
||||
}
|
||||
}).start();
|
||||
} else if (fullDrawable != null) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
File file = new File(CommonUtils.saveDrawableToFile(fullDrawable, mSavePath));
|
||||
setWallpaper(file, type);
|
||||
}
|
||||
}).start();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
File file = new File(CommonUtils.saveDrawableToFile(fullDrawable, mSavePath));
|
||||
setWallpaper(file, type);
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
call = CommonKt.INSTANCE.downloadFile(fullUrl, mSavePath, new Function2<Boolean, InputStream, Unit>() {
|
||||
@Override
|
||||
@ -400,13 +424,13 @@ public class ActivitySet extends AppCompatActivity implements TypeListener {
|
||||
}
|
||||
});
|
||||
} catch (Exception exception) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showSetWallpaperLoading(false);
|
||||
Toast.makeText(ActivitySet.this, getString(R.string.set_fail), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showSetWallpaperLoading(false);
|
||||
Toast.makeText(ActivitySet.this, getString(R.string.set_fail), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,9 @@ import android.widget.TextView;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.hd.wallpaper.free.walls.databinding.ActivityWelcomeBinding;
|
||||
import com.hd.wallpaper.free.walls.topon.AdManager;
|
||||
import com.hd.wallpaper.free.walls.topon.CountAction;
|
||||
import com.hd.wallpaper.free.walls.topon.GoMainAction;
|
||||
import com.hd.wallpaper.free.walls.utils.CommonUtils;
|
||||
|
||||
public class ActivityWelcome extends AppCompatActivity {
|
||||
@ -16,7 +19,7 @@ public class ActivityWelcome extends AppCompatActivity {
|
||||
private CountDownTimer countDownTimer;
|
||||
private ActivityWelcomeBinding vb;
|
||||
|
||||
private long totalTime = 2000;
|
||||
private long totalTime = 11000;
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
@ -27,43 +30,25 @@ public class ActivityWelcome extends AppCompatActivity {
|
||||
setContentView(vb.getRoot());
|
||||
|
||||
|
||||
countDownTimer = new CountDownTimer(totalTime,100) {
|
||||
countDownTimer = AdManager.showWelcomeAd(ActivityWelcome.this, totalTime, new CountAction() {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
public void onCount(long millisUntilFinished) {
|
||||
int progressPercentage = (int) ((100 * millisUntilFinished) / totalTime);
|
||||
|
||||
int countdownPercentage = 100 - progressPercentage;
|
||||
|
||||
vb.progressbar.setProgress(countdownPercentage);
|
||||
}
|
||||
|
||||
}, new GoMainAction() {
|
||||
@Override
|
||||
public void onFinish() {
|
||||
public void onGo() {
|
||||
vb.progressbar.setProgress(100);
|
||||
Intent intent = new Intent(ActivityWelcome.this, ActivityMain.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// countDownTimer = AdManager.showWelcomeAd(this, totalTime, new CountAction() {
|
||||
// @Override
|
||||
// public void onCount(long millisUntilFinished) {
|
||||
// int progressPercentage = (int) ((100 * millisUntilFinished) / totalTime);
|
||||
//
|
||||
// int countdownPercentage = 100 - progressPercentage;
|
||||
//
|
||||
// vb.progressbar.setProgress(countdownPercentage);
|
||||
// }
|
||||
// }, new GoMainAction() {
|
||||
// @Override
|
||||
// public void onGo() {
|
||||
// vb.progressbar.setProgress(100);
|
||||
// Intent intent = new Intent(WElActivity.this, HomeActivity.class);
|
||||
// startActivity(intent);
|
||||
// finish();
|
||||
// }
|
||||
// });
|
||||
countDownTimer.start();
|
||||
|
||||
}
|
||||
|
||||
@ -16,6 +16,8 @@ import com.hd.wallpaper.free.walls.adapter.AdapterPreView;
|
||||
import com.hd.wallpaper.free.walls.databinding.FragmentChildBinding;
|
||||
import com.hd.wallpaper.free.walls.json.Data;
|
||||
import com.hd.wallpaper.free.walls.mylistener.ItemClickListener;
|
||||
import com.hd.wallpaper.free.walls.topon.AdManager;
|
||||
import com.hd.wallpaper.free.walls.topon.onActionListener;
|
||||
import com.hd.wallpaper.free.walls.utils.CommonUtils;
|
||||
import com.hd.wallpaper.free.walls.utils.ItemSpace;
|
||||
|
||||
@ -77,31 +79,22 @@ public class FragmentChild extends Fragment implements ItemClickListener {
|
||||
vb.list.setAdapter(adapterPreView);
|
||||
|
||||
|
||||
// DbManager.addOnAddOrRemoveListener(new OnAddListener() {
|
||||
// @Override
|
||||
// public void onAdd(Data data) {
|
||||
// int index = userList.indexOf(data);
|
||||
// Log.d(MyWallpaper.TAG, "---mIndex=" + mIndex + "----onAdd index=" + index);
|
||||
// adapterPreView.notifyItemChanged(index);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onRemove(Data data) {
|
||||
// int index = userList.indexOf(data);
|
||||
// adapterPreView.notifyItemChanged(index);
|
||||
// Log.d(MyWallpaper.TAG, "---mIndex=" + mIndex + "----onRemove index=" + index);
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onItemClickAction(Data info) {
|
||||
Log.d(MyWallpaper.TAG, "--info=" + info.getImId());
|
||||
Intent intent = new Intent(requireContext(), ActivitySet.class);
|
||||
intent.putExtra(CommonUtils.key_info, info);
|
||||
startActivity(intent);
|
||||
AdManager.showTopOn(requireActivity(), new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Intent intent = new Intent(requireContext(), ActivitySet.class);
|
||||
intent.putExtra(CommonUtils.key_info, info);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -18,6 +18,8 @@ import com.hd.wallpaper.free.walls.db.DbManager;
|
||||
import com.hd.wallpaper.free.walls.json.Data;
|
||||
import com.hd.wallpaper.free.walls.mylistener.ItemClickListener;
|
||||
import com.hd.wallpaper.free.walls.mylistener.OnLikeListener;
|
||||
import com.hd.wallpaper.free.walls.topon.AdManager;
|
||||
import com.hd.wallpaper.free.walls.topon.onActionListener;
|
||||
import com.hd.wallpaper.free.walls.utils.CommonUtils;
|
||||
import com.hd.wallpaper.free.walls.utils.ItemSpace;
|
||||
|
||||
@ -83,9 +85,14 @@ public class FragmentLike extends Fragment implements ItemClickListener {
|
||||
|
||||
@Override
|
||||
public void onItemClickAction(Data info) {
|
||||
Intent intent = new Intent(requireContext(), ActivitySet.class);
|
||||
intent.putExtra(CommonUtils.key_info, info);
|
||||
startActivity(intent);
|
||||
AdManager.showTopOn(requireActivity(), new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Intent intent = new Intent(requireContext(), ActivitySet.class);
|
||||
intent.putExtra(CommonUtils.key_info, info);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -106,7 +106,7 @@ object CommonKt {
|
||||
|
||||
indexOf = download.indexOf("/download")
|
||||
substring = download.substring(host.length, indexOf)
|
||||
// Log.d(MyApp.TAG, "i=$i----------substring=$substring")
|
||||
// Log.d(MyWallpaper.TAG, "i=$i----------substring=$substring")
|
||||
|
||||
bean = Data().apply {
|
||||
imId = substring
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/im_back" />
|
||||
android:src="@drawable/icon_back" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressbar"
|
||||
|
||||
@ -11,27 +11,26 @@ dependencyResolutionManagement {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
//
|
||||
// //Anythink(Core)
|
||||
// maven ("https://jfrog.anythinktech.com/artifactory/overseas_sdk")
|
||||
//
|
||||
// //Appnext
|
||||
// maven ("https://dl.appnext.com")
|
||||
//
|
||||
// //Ironsource
|
||||
// maven ("https://android-sdk.is.com/")
|
||||
//
|
||||
// //Pangle
|
||||
// maven ("https://artifact.bytedance.com/repository/pangle")
|
||||
//
|
||||
// //Mintegral
|
||||
// maven ("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
|
||||
//
|
||||
// //Chartboost
|
||||
// maven ("https://cboost.jfrog.io/artifactory/chartboost-ads")
|
||||
// maven ("https://cboost.jfrog.io/artifactory/chartboost-mediation")
|
||||
//
|
||||
// //TopOn集成测试工具
|
||||
//Anythink(Core)
|
||||
maven ("https://jfrog.anythinktech.com/artifactory/overseas_sdk")
|
||||
|
||||
//Appnext
|
||||
maven ("https://dl.appnext.com")
|
||||
|
||||
//Ironsource
|
||||
maven ("https://android-sdk.is.com/")
|
||||
|
||||
//Pangle
|
||||
maven ("https://artifact.bytedance.com/repository/pangle")
|
||||
|
||||
//Mintegral
|
||||
maven ("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
|
||||
|
||||
//Chartboost
|
||||
maven ("https://cboost.jfrog.io/artifactory/chartboost-ads")
|
||||
maven ("https://cboost.jfrog.io/artifactory/chartboost-mediation")
|
||||
|
||||
//TopOn集成测试工具
|
||||
// maven ( "https://jfrog.anythinktech.com/artifactory/debugger")
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user