添加广告Topon1.3(4)
This commit is contained in:
parent
f39a933a0d
commit
8e415d712b
@ -49,11 +49,60 @@ dependencies {
|
|||||||
implementation ("com.google.code.gson:gson:2.10.1")
|
implementation ("com.google.code.gson:gson:2.10.1")
|
||||||
implementation("com.google.android.material:material:1.11.0")
|
implementation("com.google.android.material:material:1.11.0")
|
||||||
|
|
||||||
|
implementation ("com.mbridge.msdk.oversea:newinterstitial:16.7.71")
|
||||||
|
implementation ("com.mbridge.msdk.oversea:mbbid:16.7.61")
|
||||||
|
|
||||||
|
|
||||||
implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
|
implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
|
||||||
implementation("com.google.firebase:firebase-analytics-ktx")
|
implementation("com.google.firebase:firebase-analytics-ktx")
|
||||||
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
||||||
|
|
||||||
|
//-----------------------------TopOn 聚合(mintegral、unityads、liftoff(vungle)、Bigo)
|
||||||
|
//Anythink (Necessary)
|
||||||
|
implementation("com.anythink.sdk:core-tpn:6.3.68")
|
||||||
|
implementation("com.anythink.sdk:nativead-tpn:6.3.68")
|
||||||
|
implementation("com.anythink.sdk:banner-tpn:6.3.68")
|
||||||
|
implementation("com.anythink.sdk:interstitial-tpn:6.3.68")
|
||||||
|
implementation("com.anythink.sdk:rewardedvideo-tpn:6.3.68")
|
||||||
|
implementation("com.anythink.sdk:splash-tpn:6.3.68")
|
||||||
|
|
||||||
|
//Androidx (Necessary)
|
||||||
|
implementation("androidx.appcompat:appcompat:1.1.0")
|
||||||
|
implementation("androidx.browser:browser:1.4.0")
|
||||||
|
|
||||||
|
//Vungle
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-vungle:6.3.68")
|
||||||
|
implementation("com.vungle:vungle-ads:7.3.2")
|
||||||
|
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.3.68")
|
||||||
|
implementation("com.unity3d.ads:unity-ads:4.9.3")
|
||||||
|
|
||||||
|
//Bigo
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-bigo:6.3.68")
|
||||||
|
implementation("com.bigossp:bigo-ads:4.7.4")
|
||||||
|
|
||||||
|
//Mintegral
|
||||||
|
implementation("com.anythink.sdk:adapter-tpn-mintegral-nonchina:6.3.68")
|
||||||
|
implementation("com.mbridge.msdk.oversea:reward:16.7.51")
|
||||||
|
implementation("com.mbridge.msdk.oversea:newinterstitial:16.7.51")
|
||||||
|
implementation("com.mbridge.msdk.oversea:mbnative:16.7.51")
|
||||||
|
implementation("com.mbridge.msdk.oversea:mbnativeadvanced:16.7.51")
|
||||||
|
implementation("com.mbridge.msdk.oversea:mbsplash:16.7.51")
|
||||||
|
implementation("com.mbridge.msdk.oversea:mbbanner:16.7.51")
|
||||||
|
implementation("com.mbridge.msdk.oversea:mbbid:16.7.51")
|
||||||
|
implementation("androidx.recyclerview:recyclerview:1.1.0")
|
||||||
|
|
||||||
|
//Tramini
|
||||||
|
implementation("com.anythink.sdk:tramini-plugin-tpn:6.3.68")
|
||||||
|
//-----------------------------TopOn 聚合
|
||||||
|
|
||||||
|
|
||||||
|
// Debugger UI Tools
|
||||||
|
// implementation ("com.anythink.sdk:debugger-ui:1.0.7")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
75
app/proguard-rules.pro
vendored
75
app/proguard-rules.pro
vendored
@ -46,3 +46,78 @@
|
|||||||
-keep public class androidx.recyclerview.*{*;}
|
-keep public class androidx.recyclerview.*{*;}
|
||||||
-keep class com.mbridge.msdk.foundation.tools.FastKV{*;}
|
-keep class com.mbridge.msdk.foundation.tools.FastKV{*;}
|
||||||
-keep class com.mbridge.msdk.foundation.tools.FastKV$Builder{*;}
|
-keep class com.mbridge.msdk.foundation.tools.FastKV$Builder{*;}
|
||||||
|
|
||||||
|
#---------------------------------TopOn 聚合
|
||||||
|
# Vungle
|
||||||
|
-dontwarn com.vungle.ads.**
|
||||||
|
-keepclassmembers class com.vungle.ads.** {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Google
|
||||||
|
-keep class com.google.android.gms.** { *; }
|
||||||
|
-dontwarn com.google.android.gms.**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# START OkHttp + Okio
|
||||||
|
# JSR 305 annotations are for embedding nullability information.
|
||||||
|
-dontwarn javax.annotation.**
|
||||||
|
|
||||||
|
|
||||||
|
# A resource is loaded with a relative path so the package of this class must be preserved.
|
||||||
|
-adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz
|
||||||
|
|
||||||
|
|
||||||
|
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
|
||||||
|
-dontwarn org.codehaus.mojo.animal_sniffer.*
|
||||||
|
|
||||||
|
|
||||||
|
# OkHttp platform used only on JVM and when Conscrypt and other security providers are available.
|
||||||
|
-dontwarn okhttp3.internal.platform.**
|
||||||
|
-dontwarn org.conscrypt.**
|
||||||
|
-dontwarn org.bouncycastle.**
|
||||||
|
-dontwarn org.openjsse.**
|
||||||
|
|
||||||
|
|
||||||
|
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
|
||||||
|
-dontwarn org.codehaus.mojo.animal_sniffer.*
|
||||||
|
|
||||||
|
|
||||||
|
# END OkHttp + Okio
|
||||||
|
|
||||||
|
|
||||||
|
# START Protobuf
|
||||||
|
-dontwarn com.google.protobuf.**
|
||||||
|
-keepclassmembers class com.google.protobuf.** {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
|
||||||
|
|
||||||
|
|
||||||
|
# END Protobuf
|
||||||
|
-keepattributes Signature
|
||||||
|
-keepattributes *Annotation*
|
||||||
|
-keep class com.mbridge.** {*; }
|
||||||
|
-keep interface com.mbridge.** {*; }
|
||||||
|
-keep class android.support.v4.** { *; }
|
||||||
|
-dontwarn com.mbridge.**
|
||||||
|
-keep class **.R$* { public static final int mbridge*; }
|
||||||
|
-keep public class com.mbridge.* extends androidx.** { *; }
|
||||||
|
-keep public class androidx.viewpager.widget.PagerAdapter{ *; }
|
||||||
|
-keep interface androidx.annotation.IntDef{ *; }
|
||||||
|
-keep interface androidx.annotation.Nullable{ *; }
|
||||||
|
-keep interface androidx.annotation.CheckResult{ *; }
|
||||||
|
-keep interface androidx.annotation.NonNull{ *; }
|
||||||
|
-keep public class androidx.fragment.app.Fragment{ *; }
|
||||||
|
-keep public class androidx.core.content.FileProvider{ *; }
|
||||||
|
-keep public class androidx.core.app.NotificationCompat{ *; }
|
||||||
|
-keep public class androidx.appcompat.widget.AppCompatImageView { *; }
|
||||||
|
-keep public class androidx.recyclerview.*{ *; }
|
||||||
|
|
||||||
|
#---------------------------------TopOn 聚合
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,9 @@ import com.bumptech.glide.load.engine.GlideException;
|
|||||||
import com.bumptech.glide.request.RequestListener;
|
import com.bumptech.glide.request.RequestListener;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.example.funnysounds.R;
|
import com.example.funnysounds.R;
|
||||||
|
import com.example.funnysounds.ad.ADBean;
|
||||||
|
import com.example.funnysounds.ad.MBrManager;
|
||||||
|
import com.example.funnysounds.ad.onAdStatusListener;
|
||||||
import com.example.funnysounds.data.MyData;
|
import com.example.funnysounds.data.MyData;
|
||||||
import com.example.funnysounds.value.StaticValue;
|
import com.example.funnysounds.value.StaticValue;
|
||||||
|
|
||||||
@ -131,11 +134,41 @@ public class DetailActivity extends AppCompatActivity{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finish();
|
showad();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
private void showad() {
|
||||||
|
ADBean cache = MBrManager.getCache();
|
||||||
|
if(cache == null){
|
||||||
|
finish();
|
||||||
|
Log.d("-------fail","------showfail");
|
||||||
|
}else{
|
||||||
|
MBrManager.setCallBack(cache.getInterstitialHandler(), new onAdStatusListener() {
|
||||||
|
@Override
|
||||||
|
public void onLoaded() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFail() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onShowFail() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cache.getInterstitialHandler().showFromBid();
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|||||||
@ -19,6 +19,11 @@ import androidx.core.view.WindowInsetsCompat;
|
|||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import com.example.funnysounds.R;
|
import com.example.funnysounds.R;
|
||||||
|
import com.example.funnysounds.ad.ADBean;
|
||||||
|
import com.example.funnysounds.ad.MBrManager;
|
||||||
|
import com.example.funnysounds.ad.onAdStatusListener;
|
||||||
|
import com.example.funnysounds.resolve.Sounds;
|
||||||
|
import com.mbridge.msdk.newinterstitial.out.MBBidNewInterstitialHandler;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -27,34 +32,93 @@ import kotlin.Unit;
|
|||||||
|
|
||||||
public class IntoActivity extends AppCompatActivity {
|
public class IntoActivity extends AppCompatActivity {
|
||||||
private boolean needShow = true;
|
private boolean needShow = true;
|
||||||
|
public com.mbridge.msdk.newinterstitial.out.MBBidNewInterstitialHandler MBBidNewInterstitialHandler;
|
||||||
protected CountDownTimer countDownTimer;
|
protected CountDownTimer countDownTimer;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_into);
|
setContentView(R.layout.activity_into);
|
||||||
countDownTimer = new CountDownTimer(1000,500) {
|
countDownTimer = new CountDownTimer(11000,100) {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
|
if (needShow) {
|
||||||
|
startShowAd(false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFinish() {
|
public void onFinish() {
|
||||||
startMainActivity();
|
if (needShow) {
|
||||||
|
startShowAd(true);
|
||||||
|
// startMainActivity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
starttimer();
|
startAd();
|
||||||
|
}
|
||||||
|
private void startAd() {
|
||||||
|
if (!Sounds.initOK) {
|
||||||
|
IntentFilter intentFilter = new IntentFilter(Sounds.AD_INIT);
|
||||||
|
LocalBroadcastManager.getInstance(this).registerReceiver(new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
loadMyAdAndStart();
|
||||||
|
Log.d("------------", "------------1sucess");
|
||||||
|
}
|
||||||
|
},intentFilter);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
loadMyAdAndStart();
|
||||||
|
Log.d("------------", "------------2sucess");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void startShowAd(boolean is){
|
||||||
|
ADBean cache = MBrManager.getCache();
|
||||||
|
if(cache == null){
|
||||||
|
if(is){
|
||||||
|
startMainActivity();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
needShow = false;
|
||||||
|
MBrManager.setCallBack(cache.getInterstitialHandler(), new onAdStatusListener() {
|
||||||
|
@Override
|
||||||
|
public void onLoaded() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFail() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onShowFail() {
|
||||||
|
startMainActivity();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
startMainActivity();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cache.getInterstitialHandler().showFromBid();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void starttimer() {
|
private void loadMyAdAndStart() {
|
||||||
countDownTimer.start();
|
countDownTimer.start();
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
private void startMainActivity() {
|
private void startMainActivity() {
|
||||||
Intent intent = new Intent(this, MainActivity.class);
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|||||||
@ -79,7 +79,7 @@ public class MainActivity extends AppCompatActivity implements CategoryNameSound
|
|||||||
version_lay.setOnClickListener(new View.OnClickListener() {
|
version_lay.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Toast.makeText(MainActivity.this,"This Version is V1.2",Toast.LENGTH_SHORT).show();
|
Toast.makeText(MainActivity.this,"This Version is V1.3",Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SpecifisoundsActivity extends AppCompatActivity implements MyDataSounderListener,View.OnClickListener {
|
public class SpecifisoundsActivity extends AppCompatActivity implements MyDataSounderListener {
|
||||||
|
|
||||||
private ImageView imageView;
|
private ImageView imageView;
|
||||||
private CategoryList name;
|
private CategoryList name;
|
||||||
@ -49,7 +49,12 @@ public class SpecifisoundsActivity extends AppCompatActivity implements MyDataSo
|
|||||||
recyclerview_specific = findViewById(R.id.recyclerview_specific);
|
recyclerview_specific = findViewById(R.id.recyclerview_specific);
|
||||||
imageView = findViewById(R.id.imageview_back);
|
imageView = findViewById(R.id.imageview_back);
|
||||||
cName = findViewById(R.id.categoryname);
|
cName = findViewById(R.id.categoryname);
|
||||||
imageView.setOnClickListener(this);
|
imageView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
getData();
|
getData();
|
||||||
setSpecificRecycleView();
|
setSpecificRecycleView();
|
||||||
|
|
||||||
@ -60,15 +65,6 @@ public class SpecifisoundsActivity extends AppCompatActivity implements MyDataSo
|
|||||||
assert name != null;
|
assert name != null;
|
||||||
cName.setText(name.getCategoryName());
|
cName.setText(name.getCategoryName());
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
imageView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSpecificRecycleView(){
|
public void setSpecificRecycleView(){
|
||||||
MySpace mySpace = new MySpace(10,10,15);
|
MySpace mySpace = new MySpace(10,10,15);
|
||||||
@ -84,6 +80,4 @@ public class SpecifisoundsActivity extends AppCompatActivity implements MyDataSo
|
|||||||
public void onItemClickAction(MyData myData) {
|
public void onItemClickAction(MyData myData) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
27
app/src/main/java/com/example/funnysounds/ad/ADBean.java
Normal file
27
app/src/main/java/com/example/funnysounds/ad/ADBean.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.example.funnysounds.ad;
|
||||||
|
|
||||||
|
import com.mbridge.msdk.newinterstitial.out.MBBidNewInterstitialHandler;
|
||||||
|
|
||||||
|
public class ADBean {
|
||||||
|
|
||||||
|
private MBBidNewInterstitialHandler interstitialHandler;
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
public void setInterstitialHandler(MBBidNewInterstitialHandler interstitialHandler) {
|
||||||
|
this.interstitialHandler = interstitialHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToken(String token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MBBidNewInterstitialHandler getInterstitialHandler() {
|
||||||
|
return interstitialHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.example.funnysounds.ad
|
||||||
|
|
||||||
|
interface AdMsgListener {
|
||||||
|
fun msg(msg: String)
|
||||||
|
}
|
||||||
231
app/src/main/java/com/example/funnysounds/ad/MBrManager.java
Normal file
231
app/src/main/java/com/example/funnysounds/ad/MBrManager.java
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
package com.example.funnysounds.ad;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.example.funnysounds.resolve.Sounds;
|
||||||
|
import com.mbridge.msdk.MBridgeConstans;
|
||||||
|
import com.mbridge.msdk.mbbid.out.BidListennning;
|
||||||
|
import com.mbridge.msdk.mbbid.out.BidManager;
|
||||||
|
import com.mbridge.msdk.mbbid.out.BidResponsed;
|
||||||
|
import com.mbridge.msdk.newinterstitial.out.MBBidNewInterstitialHandler;
|
||||||
|
import com.mbridge.msdk.newinterstitial.out.NewInterstitialListener;
|
||||||
|
import com.mbridge.msdk.out.MBridgeIds;
|
||||||
|
import com.mbridge.msdk.out.RewardInfo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MBrManager {
|
||||||
|
|
||||||
|
public static String TAG = "------------ltt";
|
||||||
|
|
||||||
|
public static String[] placeIDs = new String[]{"n669738b37f8f2", "n1fon1upfbrc2p", "n669738b37f8f2"};
|
||||||
|
|
||||||
|
public static String[] unitIDs = new String[]{"3473086", "3473090", "3473092"};
|
||||||
|
|
||||||
|
public static List<ADBean> AdInstances = new ArrayList<>();
|
||||||
|
|
||||||
|
public static void getToken(String placeId, String unitId, onBidTokenListener listener) {
|
||||||
|
BidManager manager = new BidManager(placeId, unitId);
|
||||||
|
manager.setBidListener(new BidListennning() {
|
||||||
|
@Override
|
||||||
|
public void onFailed(String s) {
|
||||||
|
listener.onBidToken("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccessed(BidResponsed bidResponsed) {
|
||||||
|
String mBidToken = bidResponsed.getBidToken();
|
||||||
|
listener.onBidToken(mBidToken);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
manager.bid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadAllAd() {
|
||||||
|
if (AdInstances.size() > 0) {
|
||||||
|
for (ADBean adBean : AdInstances) {
|
||||||
|
if (!adBean.getInterstitialHandler().isBidReady()) {
|
||||||
|
adBean.getInterstitialHandler().loadFromBid(adBean.getToken());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(onInterHandlerListener listener) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
String finalPlaceId = placeIDs[i];
|
||||||
|
String unitId = unitIDs[i];
|
||||||
|
getToken(finalPlaceId, unitId, new onBidTokenListener() {
|
||||||
|
@Override
|
||||||
|
public void onBidToken(String token) {
|
||||||
|
MBBidNewInterstitialHandler mMBBidNewInterstitialHandler = new MBBidNewInterstitialHandler(Sounds.mAppContext, finalPlaceId, unitId);
|
||||||
|
ADBean adBean = new ADBean();
|
||||||
|
Log.d(TAG, "------------token=" + token);
|
||||||
|
adBean.setToken(token);
|
||||||
|
adBean.setInterstitialHandler(mMBBidNewInterstitialHandler);
|
||||||
|
setCallBack(mMBBidNewInterstitialHandler, new onAdStatusListener() {
|
||||||
|
@Override
|
||||||
|
public void onLoaded() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFail() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onShowFail() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mMBBidNewInterstitialHandler.loadFromBid(token);
|
||||||
|
AdInstances.add(adBean);
|
||||||
|
listener.onAddOK();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ADBean getCache() {
|
||||||
|
Collections.shuffle(AdInstances);
|
||||||
|
for (ADBean adBean : AdInstances) {
|
||||||
|
if (adBean.getInterstitialHandler().isBidReady()) {
|
||||||
|
return adBean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setCallBack(MBBidNewInterstitialHandler mbBidNewInterstitialHandler, onAdStatusListener listener) {
|
||||||
|
mbBidNewInterstitialHandler.setInterstitialVideoListener(new NewInterstitialListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadCampaignSuccess(MBridgeIds ids) {
|
||||||
|
/**
|
||||||
|
* 广告已填充
|
||||||
|
* @param ids 封装的广告id对象
|
||||||
|
*/
|
||||||
|
Log.i(TAG, "onLoadCampaignSuccess: " + Thread.currentThread() + " " + ids.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResourceLoadSuccess(MBridgeIds ids) {
|
||||||
|
/**
|
||||||
|
* 广告资源加载成功,可以播放
|
||||||
|
* @param ids 封装的广告id对象
|
||||||
|
*/
|
||||||
|
Log.i(TAG, "onResourceLoadSuccess: " + Thread.currentThread() + " " + ids.toString());
|
||||||
|
listener.onLoaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResourceLoadFail(MBridgeIds ids, String errorMsg) {
|
||||||
|
/**
|
||||||
|
* 广告加载失败
|
||||||
|
* @param errorMsg 加载错误原因
|
||||||
|
*/
|
||||||
|
listener.onLoadFail();
|
||||||
|
Log.e(TAG, "onResourceLoadFail errorMsg: " + errorMsg + " " + ids.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onShowFail(MBridgeIds ids, String errorMsg) {
|
||||||
|
/**
|
||||||
|
* 广告播放失败
|
||||||
|
* @param errorMsg 错误原因
|
||||||
|
*/
|
||||||
|
listener.onShowFail();
|
||||||
|
Log.e(TAG, "onShowFail: " + errorMsg + " " + ids.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdShow(MBridgeIds ids) {
|
||||||
|
/**
|
||||||
|
* 广告成功展示
|
||||||
|
*/
|
||||||
|
Log.i(TAG, "onAdShow: " + ids.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdClose(MBridgeIds ids, RewardInfo info) {
|
||||||
|
/**
|
||||||
|
* 广告关闭时调用
|
||||||
|
* @param info.isCompleteView如果为true,则表示已完全观看了视频
|
||||||
|
*/
|
||||||
|
loadAllAd();
|
||||||
|
listener.onClose();
|
||||||
|
Log.i(TAG, "onAdClose: " + "isCompleteView:" + info.isCompleteView() + " " + ids.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdClicked(MBridgeIds ids) {
|
||||||
|
/**
|
||||||
|
* 广告被点击
|
||||||
|
* @param 封装的广告id对象
|
||||||
|
*/
|
||||||
|
Log.i(TAG, "onAdClicked: " + ids.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVideoComplete(MBridgeIds ids) {
|
||||||
|
/**
|
||||||
|
* 广告播放完成时调用
|
||||||
|
* @param ids 封装的广告id对象
|
||||||
|
*/
|
||||||
|
Log.i(TAG, "onVideoComplete: " + ids.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdCloseWithNIReward(MBridgeIds ids, RewardInfo info) {
|
||||||
|
/**
|
||||||
|
* 如果开发人员设置了IV奖励,则在广告关闭时调用.
|
||||||
|
*
|
||||||
|
* @param 封装的广告id对象
|
||||||
|
* @param info.isCompleteView() 是否完全观看
|
||||||
|
*/
|
||||||
|
Log.i(TAG, "onAdCloseWithNIReward: " + ids.toString() + " " + info.toString());
|
||||||
|
|
||||||
|
Log.i(TAG, info.isCompleteView() ? "Video playback/playable is complete." : "Video playback/playable is not complete.");
|
||||||
|
|
||||||
|
int rewardAlertStatus = info.getRewardAlertStatus();
|
||||||
|
|
||||||
|
if (rewardAlertStatus == MBridgeConstans.IVREWARDALERT_STATUS_NOTSHOWN) {
|
||||||
|
Log.e(TAG, "The dialog is not show.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rewardAlertStatus == MBridgeConstans.IVREWARDALERT_STATUS_CLICKCONTINUE) {
|
||||||
|
Log.e(TAG, "The dialog's continue button clicked.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rewardAlertStatus == MBridgeConstans.IVREWARDALERT_STATUS_CLICKCANCEL) {
|
||||||
|
Log.e(TAG, "The dialog's cancel button clicked.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEndcardShow(MBridgeIds ids) {
|
||||||
|
/**
|
||||||
|
* 展示广告落地页时调用
|
||||||
|
* @param ids 封装的广告id对象
|
||||||
|
*/
|
||||||
|
Log.i(TAG, "onEndcardShow: " + ids.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.example.funnysounds.ad;
|
||||||
|
|
||||||
|
public interface onAdStatusListener {
|
||||||
|
|
||||||
|
void onLoaded();
|
||||||
|
void onLoadFail();
|
||||||
|
void onShowFail();
|
||||||
|
void onClose();
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.example.funnysounds.ad;
|
||||||
|
|
||||||
|
public interface onBidTokenListener {
|
||||||
|
|
||||||
|
void onBidToken(String token);
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.example.funnysounds.ad;
|
||||||
|
|
||||||
|
public interface onInterHandlerListener {
|
||||||
|
|
||||||
|
void onAddOK();
|
||||||
|
|
||||||
|
|
||||||
|
// void onLoaded();
|
||||||
|
// void onLoadFail();
|
||||||
|
// void onShowFail();
|
||||||
|
//
|
||||||
|
// void onClose();
|
||||||
|
}
|
||||||
@ -1,5 +1,7 @@
|
|||||||
package com.example.funnysounds.resolve;
|
package com.example.funnysounds.resolve;
|
||||||
|
|
||||||
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -11,10 +13,17 @@ import androidx.annotation.RequiresApi;
|
|||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
|
|
||||||
|
import com.anythink.core.api.ATSDK;
|
||||||
|
import com.anythink.core.api.NetTrafficeCallback;
|
||||||
|
import com.example.funnysounds.ad.MBrManager;
|
||||||
|
import com.example.funnysounds.ad.onInterHandlerListener;
|
||||||
import com.example.funnysounds.data.CategoryList;
|
import com.example.funnysounds.data.CategoryList;
|
||||||
import com.example.funnysounds.value.StaticValue;
|
import com.example.funnysounds.value.StaticValue;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.mbridge.msdk.MBridgeSDK;
|
||||||
|
import com.mbridge.msdk.out.MBridgeSDKFactory;
|
||||||
|
import com.mbridge.msdk.out.SDKInitStatusListener;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -34,7 +43,7 @@ public class Sounds extends Application {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
mAppContext = this;
|
mAppContext = this;
|
||||||
// init();
|
init();
|
||||||
try {
|
try {
|
||||||
InputStream open = getAssets().open("prank.json");
|
InputStream open = getAssets().open("prank.json");
|
||||||
String covertStr = Readfile.getCovertStr(open);
|
String covertStr = Readfile.getCovertStr(open);
|
||||||
@ -55,6 +64,48 @@ public class Sounds extends Application {
|
|||||||
}
|
}
|
||||||
return categoryList;
|
return categoryList;
|
||||||
}
|
}
|
||||||
|
public void init() {
|
||||||
|
ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResultCallback(boolean isEU) {
|
||||||
|
Log.e(TAG, "onResultCallback:" + isEU);
|
||||||
|
if (isEU && ATSDK.getGDPRDataLevel(Sounds.this) == ATSDK.UNKNOWN) {
|
||||||
|
ATSDK.showGdprAuth(mAppContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onErrorCallback(String errorMsg) {
|
||||||
|
Log.e(TAG, "onErrorCallback:" + errorMsg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
MBridgeSDK sdk = MBridgeSDKFactory.getMBridgeSDK();
|
||||||
|
Map<String, String> map = sdk.getMBConfigurationMap(AppId, AppKey);
|
||||||
|
sdk.init(map, this, new SDKInitStatusListener() {
|
||||||
|
@Override
|
||||||
|
public void onInitSuccess() {
|
||||||
|
Log.e(MBrManager.TAG, "onInitSuccess");
|
||||||
|
initOK = true;
|
||||||
|
MBrManager.init( new onInterHandlerListener() {
|
||||||
|
@Override
|
||||||
|
public void onAddOK() {
|
||||||
|
LocalBroadcastManager.getInstance(mAppContext).sendBroadcast(new Intent(AD_INIT));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInitFail(String errorMsg) {
|
||||||
|
Log.e(MBrManager.TAG, errorMsg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,9 @@ import com.example.funnysounds.R;
|
|||||||
import com.example.funnysounds.action.CategoryNameSoundsrListener;
|
import com.example.funnysounds.action.CategoryNameSoundsrListener;
|
||||||
import com.example.funnysounds.activity.SpecifisoundsActivity;
|
import com.example.funnysounds.activity.SpecifisoundsActivity;
|
||||||
|
|
||||||
|
import com.example.funnysounds.ad.ADBean;
|
||||||
|
import com.example.funnysounds.ad.MBrManager;
|
||||||
|
import com.example.funnysounds.ad.onAdStatusListener;
|
||||||
import com.example.funnysounds.data.CategoryList;
|
import com.example.funnysounds.data.CategoryList;
|
||||||
import com.example.funnysounds.value.StaticValue;
|
import com.example.funnysounds.value.StaticValue;
|
||||||
|
|
||||||
@ -76,13 +79,45 @@ public class CgNameAdapter extends RecyclerView.Adapter<CgViewHolder> {
|
|||||||
holder.getLayout_root().setOnClickListener(new View.OnClickListener() {
|
holder.getLayout_root().setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(myContext, SpecifisoundsActivity.class);
|
showad(categorylist);
|
||||||
intent.putExtra(StaticValue.key_category_name, categorylist);
|
|
||||||
myContext.startActivity(intent);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
private void showad(CategoryList cate) {
|
||||||
|
ADBean cache = MBrManager.getCache();
|
||||||
|
if(cache == null){
|
||||||
|
startSpecifiActivity(cate);
|
||||||
|
Log.d("-------fail","------showfail");
|
||||||
|
}else{
|
||||||
|
MBrManager.setCallBack(cache.getInterstitialHandler(), new onAdStatusListener() {
|
||||||
|
@Override
|
||||||
|
public void onLoaded() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFail() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onShowFail() {
|
||||||
|
startSpecifiActivity(cate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
startSpecifiActivity(cate);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cache.getInterstitialHandler().showFromBid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void startSpecifiActivity(CategoryList categoryList) {
|
||||||
|
Intent intent = new Intent(myContext, SpecifisoundsActivity.class);
|
||||||
|
intent.putExtra(StaticValue.key_category_name, categoryList);
|
||||||
|
myContext.startActivity(intent);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return dataCategoryList.size();
|
return dataCategoryList.size();
|
||||||
|
|||||||
@ -16,8 +16,15 @@ dependencyResolutionManagement {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
//Anythink(Core)
|
||||||
|
maven ("https://jfrog.anythinktech.com/artifactory/overseas_sdk")
|
||||||
|
//Mintegral
|
||||||
maven ("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
|
maven ("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
|
||||||
|
|
||||||
|
//TopOn集成测试工具
|
||||||
|
// maven ( "https://jfrog.anythinktech.com/artifactory/debugger")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user