添加广告Topon1.4(5)
This commit is contained in:
parent
e2013d78ea
commit
0304f20a16
@ -1,9 +1,13 @@
|
|||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.application)
|
alias(libs.plugins.android.application)
|
||||||
|
id("org.jetbrains.kotlin.android")
|
||||||
id("com.google.gms.google-services")
|
id("com.google.gms.google-services")
|
||||||
id("com.google.firebase.crashlytics")
|
id("com.google.firebase.crashlytics")
|
||||||
}
|
}
|
||||||
|
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||||
android {
|
android {
|
||||||
namespace = "com.example.funnysounds"
|
namespace = "com.example.funnysounds"
|
||||||
compileSdk = 34
|
compileSdk = 34
|
||||||
@ -12,9 +16,9 @@ android {
|
|||||||
applicationId = "com.funny.sounds.hd"
|
applicationId = "com.funny.sounds.hd"
|
||||||
minSdk = 23
|
minSdk = 23
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 4
|
versionCode = 5
|
||||||
versionName = "1.3"
|
versionName = "1.4"
|
||||||
|
setProperty("archivesBaseName", "FunnySounds_v" + versionName + "(${versionCode})_$timestamp")
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +35,11 @@ android {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kotlinOptions{
|
||||||
|
jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding = true
|
viewBinding = true
|
||||||
}
|
}
|
||||||
@ -101,7 +110,7 @@ dependencies {
|
|||||||
|
|
||||||
|
|
||||||
// Debugger UI Tools
|
// Debugger UI Tools
|
||||||
// implementation ("com.anythink.sdk:debugger-ui:1.0.7")
|
implementation ("com.anythink.sdk:debugger-ui:1.0.7")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,30 +1,18 @@
|
|||||||
package com.example.funnysounds.activity;
|
package com.example.funnysounds.activity;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.SeekBar;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.core.graphics.Insets;
|
|
||||||
import androidx.core.view.ViewCompat;
|
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.DataSource;
|
import com.bumptech.glide.load.DataSource;
|
||||||
@ -32,16 +20,16 @@ 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.topon.AdManager;
|
||||||
import com.example.funnysounds.value.StaticValue;
|
import com.example.funnysounds.value.StaticValue;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Timer;
|
import kotlin.Unit;
|
||||||
import java.util.TimerTask;
|
import kotlin.jvm.functions.Function1;
|
||||||
|
|
||||||
public class DetailActivity extends AppCompatActivity{
|
public class DetailActivity extends AppCompatActivity{
|
||||||
private String name;
|
private String name;
|
||||||
@ -106,6 +94,10 @@ public class DetailActivity extends AppCompatActivity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
AdManager.showAD(DetailActivity.this, new Function1<Integer, Unit>() {
|
||||||
|
@Override
|
||||||
|
public Unit invoke(Integer integer) {
|
||||||
|
if (integer == AdManager.type_no_cache || integer == AdManager.type_show_close || integer == AdManager.type_show_fail) {
|
||||||
btn_play_pause.setBackgroundResource(R.mipmap.stop);
|
btn_play_pause.setBackgroundResource(R.mipmap.stop);
|
||||||
mediaPlayer = new MediaPlayer();
|
mediaPlayer = new MediaPlayer();
|
||||||
try {
|
try {
|
||||||
@ -123,6 +115,12 @@ public class DetailActivity extends AppCompatActivity{
|
|||||||
play = true;
|
play = true;
|
||||||
mediaPlayer.prepareAsync();
|
mediaPlayer.prepareAsync();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
imageView2.setOnClickListener(new View.OnClickListener() {
|
imageView2.setOnClickListener(new View.OnClickListener() {
|
||||||
@ -133,42 +131,12 @@ public class DetailActivity extends AppCompatActivity{
|
|||||||
mediaPlayer.stop();
|
mediaPlayer.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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();
|
||||||
|
|||||||
@ -1,117 +1,39 @@
|
|||||||
package com.example.funnysounds.activity;
|
package com.example.funnysounds.activity;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.net.wifi.p2p.WifiP2pManager;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.graphics.Insets;
|
|
||||||
import androidx.core.view.ViewCompat;
|
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
|
||||||
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.topon.AdManager;
|
||||||
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 kotlin.Unit;
|
import kotlin.Unit;
|
||||||
|
import kotlin.jvm.functions.Function0;
|
||||||
|
|
||||||
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;
|
public com.mbridge.msdk.newinterstitial.out.MBBidNewInterstitialHandler MBBidNewInterstitialHandler;
|
||||||
protected CountDownTimer countDownTimer;
|
protected CountDownTimer countDownTimer;
|
||||||
|
private Long tim = 11000L;
|
||||||
@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(11000,100) {
|
countDownTimer = AdManager.showWelcomeAd(IntoActivity.this, tim, new Function0<Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public Unit invoke() {
|
||||||
if (needShow) {
|
|
||||||
startShowAd(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinish() {
|
|
||||||
if (needShow) {
|
|
||||||
startShowAd(true);
|
|
||||||
// startMainActivity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
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();
|
startMainActivity();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cache.getInterstitialHandler().showFromBid();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@ -107,7 +107,7 @@ public class MainActivity extends AppCompatActivity implements CategoryNameSound
|
|||||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
|
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
|
||||||
recyclerview_sounds.setLayoutManager(gridLayoutManager);
|
recyclerview_sounds.setLayoutManager(gridLayoutManager);
|
||||||
recyclerview_sounds.addItemDecoration(mySpace);
|
recyclerview_sounds.addItemDecoration(mySpace);
|
||||||
CgNameAdapter cgNameAdapter = new CgNameAdapter(Sounds.getUserList(), this);
|
CgNameAdapter cgNameAdapter = new CgNameAdapter(Sounds.getUserList(), MainActivity.this);
|
||||||
cgNameAdapter.setCategoryNameSoundsListener(this);
|
cgNameAdapter.setCategoryNameSoundsListener(this);
|
||||||
recyclerview_sounds.setAdapter(cgNameAdapter);
|
recyclerview_sounds.setAdapter(cgNameAdapter);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import com.example.funnysounds.resolve.MySpace;
|
|||||||
import com.example.funnysounds.resolve.Sounds;
|
import com.example.funnysounds.resolve.Sounds;
|
||||||
import com.example.funnysounds.soundsadapter.CgNameAdapter;
|
import com.example.funnysounds.soundsadapter.CgNameAdapter;
|
||||||
import com.example.funnysounds.soundsadapter.DataAdapter;
|
import com.example.funnysounds.soundsadapter.DataAdapter;
|
||||||
|
import com.example.funnysounds.topon.AdManager;
|
||||||
import com.example.funnysounds.value.StaticValue;
|
import com.example.funnysounds.value.StaticValue;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@ -31,6 +32,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import kotlin.Unit;
|
||||||
|
import kotlin.jvm.functions.Function1;
|
||||||
|
|
||||||
public class SpecifisoundsActivity extends AppCompatActivity implements MyDataSounderListener {
|
public class SpecifisoundsActivity extends AppCompatActivity implements MyDataSounderListener {
|
||||||
|
|
||||||
private ImageView imageView;
|
private ImageView imageView;
|
||||||
@ -52,26 +56,47 @@ public class SpecifisoundsActivity extends AppCompatActivity implements MyDataSo
|
|||||||
imageView.setOnClickListener(new View.OnClickListener() {
|
imageView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
finish();
|
showad(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
getData();
|
getData();
|
||||||
setSpecificRecycleView();
|
setSpecificRecycleView();
|
||||||
|
|
||||||
}
|
}
|
||||||
public void getData(){
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
super.onBackPressed();
|
||||||
|
showad(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showad(boolean isFinish) {
|
||||||
|
AdManager.showAD(SpecifisoundsActivity.this, new Function1<Integer, Unit>() {
|
||||||
|
@Override
|
||||||
|
public Unit invoke(Integer integer) {
|
||||||
|
if (integer == AdManager.type_no_cache || integer == AdManager.type_show_close || integer == AdManager.type_show_fail) {
|
||||||
|
if (isFinish)
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void getData() {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
name = (CategoryList) intent.getSerializableExtra(StaticValue.key_category_name);
|
name = (CategoryList) intent.getSerializableExtra(StaticValue.key_category_name);
|
||||||
assert name != null;
|
assert name != null;
|
||||||
cName.setText(name.getCategoryName());
|
cName.setText(name.getCategoryName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpecificRecycleView(){
|
public void setSpecificRecycleView() {
|
||||||
MySpace mySpace = new MySpace(10,10,15);
|
MySpace mySpace = new MySpace(10, 10, 15);
|
||||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(this,2);
|
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
|
||||||
recyclerview_specific.setLayoutManager(gridLayoutManager);
|
recyclerview_specific.setLayoutManager(gridLayoutManager);
|
||||||
recyclerview_specific.addItemDecoration(mySpace);
|
recyclerview_specific.addItemDecoration(mySpace);
|
||||||
DataAdapter dataAdapter = new DataAdapter(name.getList(),this);
|
DataAdapter dataAdapter = new DataAdapter(name.getList(), this);
|
||||||
dataAdapter.setMyDataSounderListener(this);
|
dataAdapter.setMyDataSounderListener(this);
|
||||||
recyclerview_specific.setAdapter(dataAdapter);
|
recyclerview_specific.setAdapter(dataAdapter);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
package com.example.funnysounds.ad
|
|
||||||
|
|
||||||
interface AdMsgListener {
|
|
||||||
fun msg(msg: String)
|
|
||||||
}
|
|
||||||
@ -1,231 +0,0 @@
|
|||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
package com.example.funnysounds.ad;
|
|
||||||
|
|
||||||
public interface onAdStatusListener {
|
|
||||||
|
|
||||||
void onLoaded();
|
|
||||||
void onLoadFail();
|
|
||||||
void onShowFail();
|
|
||||||
void onClose();
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
package com.example.funnysounds.ad;
|
|
||||||
|
|
||||||
public interface onBidTokenListener {
|
|
||||||
|
|
||||||
void onBidToken(String token);
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
package com.example.funnysounds.ad;
|
|
||||||
|
|
||||||
public interface onInterHandlerListener {
|
|
||||||
|
|
||||||
void onAddOK();
|
|
||||||
|
|
||||||
|
|
||||||
// void onLoaded();
|
|
||||||
// void onLoadFail();
|
|
||||||
// void onShowFail();
|
|
||||||
//
|
|
||||||
// void onClose();
|
|
||||||
}
|
|
||||||
@ -5,20 +5,16 @@ 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;
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
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.ATSDK;
|
||||||
import com.anythink.core.api.NetTrafficeCallback;
|
import com.anythink.core.api.NetTrafficeCallback;
|
||||||
import com.example.funnysounds.ad.MBrManager;
|
import com.anythink.debug.api.ATDebuggerUITest;
|
||||||
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.topon.AdManager;
|
||||||
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.MBridgeSDK;
|
||||||
@ -33,16 +29,20 @@ import java.util.Map;
|
|||||||
public class Sounds extends Application {
|
public class Sounds extends Application {
|
||||||
public static final String AD_INIT = "on_SDK_action";
|
public static final String AD_INIT = "on_SDK_action";
|
||||||
public static Context mAppContext;
|
public static Context mAppContext;
|
||||||
|
public static Sounds context;
|
||||||
public static boolean initOK = false;
|
public static boolean initOK = false;
|
||||||
|
public static String TAG = "-----AD";
|
||||||
private static List<CategoryList> categoryList;
|
private static List<CategoryList> categoryList;
|
||||||
private String MAX_INIT_ACTION = "ad_action";
|
private String MAX_INIT_ACTION = "ad_action";
|
||||||
private String AppId = "299723";
|
private String AppId = "h66a0be1be1a43";
|
||||||
private String AppKey = "c70a4a739f660e03fef52c6222c38e1a";
|
private String AppKey = "a7fce863e6f891c168d9a87cbe49cb3d8";
|
||||||
|
private String debugKey = "a7fce863e6f891c168d9a87cbe49cb3d8";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
mAppContext = this;
|
mAppContext = this;
|
||||||
|
context = this;
|
||||||
init();
|
init();
|
||||||
try {
|
try {
|
||||||
InputStream open = getAssets().open("prank.json");
|
InputStream open = getAssets().open("prank.json");
|
||||||
@ -65,6 +65,7 @@ public class Sounds extends Application {
|
|||||||
return categoryList;
|
return categoryList;
|
||||||
}
|
}
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
||||||
ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -81,31 +82,9 @@ public class Sounds extends Application {
|
|||||||
Log.e(TAG, "onErrorCallback:" + errorMsg);
|
Log.e(TAG, "onErrorCallback:" + errorMsg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
ATSDK.init( this, AppId, AppKey);
|
||||||
MBridgeSDK sdk = MBridgeSDKFactory.getMBridgeSDK();
|
AdManager.loadAllAd();
|
||||||
Map<String, String> map = sdk.getMBConfigurationMap(AppId, AppKey);
|
// ATDebuggerUITest.showDebuggerUI(this,debugKey);
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
package com.example.funnysounds.soundsadapter;
|
package com.example.funnysounds.soundsadapter;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -24,33 +22,33 @@ import com.bumptech.glide.request.target.Target;
|
|||||||
import com.example.funnysounds.R;
|
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.topon.AdManager;
|
||||||
import com.example.funnysounds.value.StaticValue;
|
import com.example.funnysounds.value.StaticValue;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import kotlin.Unit;
|
||||||
|
import kotlin.jvm.functions.Function1;
|
||||||
|
|
||||||
public class CgNameAdapter extends RecyclerView.Adapter<CgViewHolder> {
|
public class CgNameAdapter extends RecyclerView.Adapter<CgViewHolder> {
|
||||||
private List<CategoryList> dataCategoryList;
|
private List<CategoryList> dataCategoryList;
|
||||||
private Context myContext;
|
private Activity myContext;
|
||||||
private CategoryNameSoundsrListener cgNameSoundsrListener;
|
private CategoryNameSoundsrListener cgNameSoundsrListener;
|
||||||
|
|
||||||
public void setCategoryNameSoundsListener(CategoryNameSoundsrListener categoryNameSoundsrListener)
|
public void setCategoryNameSoundsListener(CategoryNameSoundsrListener categoryNameSoundsrListener) {
|
||||||
{
|
|
||||||
this.cgNameSoundsrListener = categoryNameSoundsrListener;
|
this.cgNameSoundsrListener = categoryNameSoundsrListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CgNameAdapter(List<CategoryList> cglist,Context mycontext){
|
public CgNameAdapter(List<CategoryList> cglist, Activity mycontext) {
|
||||||
dataCategoryList = cglist;
|
dataCategoryList = cglist;
|
||||||
myContext = mycontext;
|
myContext = mycontext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public CgViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public CgViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
View itemview = LayoutInflater.from(myContext).inflate(R.layout.sounds_adapterlist,parent,false);
|
View itemview = LayoutInflater.from(myContext).inflate(R.layout.sounds_adapterlist, parent, false);
|
||||||
return new CgViewHolder(itemview);
|
return new CgViewHolder(itemview);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,45 +77,19 @@ 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) {
|
||||||
showad(categorylist);
|
startSpecifiActivity(categorylist);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
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) {
|
private void startSpecifiActivity(CategoryList categoryList) {
|
||||||
Intent intent = new Intent(myContext, SpecifisoundsActivity.class);
|
Intent intent = new Intent(myContext, SpecifisoundsActivity.class);
|
||||||
intent.putExtra(StaticValue.key_category_name, categoryList);
|
intent.putExtra(StaticValue.key_category_name, categoryList);
|
||||||
myContext.startActivity(intent);
|
myContext.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return dataCategoryList.size();
|
return dataCategoryList.size();
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.example.funnysounds.topon
|
||||||
|
|
||||||
|
interface AdListener {
|
||||||
|
fun showSuccess()
|
||||||
|
|
||||||
|
fun showFail()
|
||||||
|
|
||||||
|
fun showClose()
|
||||||
|
}
|
||||||
175
app/src/main/java/com/example/funnysounds/topon/AdManager.kt
Normal file
175
app/src/main/java/com/example/funnysounds/topon/AdManager.kt
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
package com.example.funnysounds.topon
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.os.CountDownTimer
|
||||||
|
import android.util.Log
|
||||||
|
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.example.funnysounds.resolve.Sounds
|
||||||
|
|
||||||
|
|
||||||
|
object AdManager {
|
||||||
|
|
||||||
|
|
||||||
|
const val type_no_cache = 0
|
||||||
|
const val type_has_cache = 1
|
||||||
|
const val type_show_success = 2
|
||||||
|
const val type_show_close = 3
|
||||||
|
const val type_show_fail = 4
|
||||||
|
|
||||||
|
|
||||||
|
const val place1Id = "n66a0be565fa6d"
|
||||||
|
const val place2Id = "n66a0be5614478"
|
||||||
|
const val place3Id = "n66a0be55b7bbe"
|
||||||
|
|
||||||
|
val list = mutableListOf<ATInterstitial>()
|
||||||
|
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun loadAllAd() {
|
||||||
|
if (list.size <= 0) {
|
||||||
|
val mInterstitialAd1 = ATInterstitial(Sounds.context, place1Id)
|
||||||
|
val mInterstitialAd2 = ATInterstitial(Sounds.context, place2Id)
|
||||||
|
val mInterstitialAd3 = ATInterstitial(Sounds.context, place3Id)
|
||||||
|
list.add(mInterstitialAd1)
|
||||||
|
list.add(mInterstitialAd2)
|
||||||
|
list.add(mInterstitialAd3)
|
||||||
|
}
|
||||||
|
for (ad in list) {
|
||||||
|
if (!ad.isAdReady) {
|
||||||
|
setCallBack(ad,object : AdListener {
|
||||||
|
override fun showSuccess() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun showFail() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun showClose() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
ad.load()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@JvmStatic
|
||||||
|
fun getReadyAd(): ATInterstitial? {
|
||||||
|
list.shuffle()
|
||||||
|
for (ad in list) {
|
||||||
|
if (ad.isAdReady) {
|
||||||
|
return ad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun showWelcomeAd(activity: Activity,totalTim: Long, goMain: () -> Unit): CountDownTimer {
|
||||||
|
var alreadyShow = false
|
||||||
|
var timer = object : CountDownTimer(totalTim, 100) {
|
||||||
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
|
if (!alreadyShow) {
|
||||||
|
showAD(activity) {
|
||||||
|
if (it == type_has_cache) {
|
||||||
|
alreadyShow = true
|
||||||
|
}
|
||||||
|
if (it == type_show_close || it == type_show_fail) {
|
||||||
|
goMain.invoke()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFinish() {
|
||||||
|
if (!alreadyShow) {
|
||||||
|
showAD(activity) {
|
||||||
|
if (it == type_show_close || it == type_show_fail || it == type_no_cache) {
|
||||||
|
goMain.invoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return timer
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setCallBack(ad: ATInterstitial, listener: AdListener) {
|
||||||
|
ad.setAdListener(object : ATInterstitialListener {
|
||||||
|
override fun onInterstitialAdLoaded() {
|
||||||
|
Log.d(Sounds.TAG, "LoadLoaded ${ad.mPlacementId}")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInterstitialAdLoadFail(p0: AdError?) {
|
||||||
|
Log.d(Sounds.TAG, "LoadFail:${p0?.code} ${p0?.desc}")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInterstitialAdClicked(p0: ATAdInfo?) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInterstitialAdShow(p0: ATAdInfo?) {
|
||||||
|
Log.d(Sounds.TAG, "AdShow ${p0?.showId} ")
|
||||||
|
listener.showSuccess()
|
||||||
|
ad.load()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInterstitialAdClose(p0: ATAdInfo?) {
|
||||||
|
listener.showClose()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInterstitialAdVideoStart(p0: ATAdInfo?) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInterstitialAdVideoEnd(p0: ATAdInfo?) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInterstitialAdVideoError(p0: AdError?) {
|
||||||
|
listener.showFail()
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun showAD(activity: Activity, action: (type: Int) -> Unit) {
|
||||||
|
val readyAd = getReadyAd()
|
||||||
|
if (readyAd!= null) {
|
||||||
|
Log.d(Sounds.TAG, "readyAd ${readyAd.mPlacementId} ")
|
||||||
|
action.invoke(type_has_cache)
|
||||||
|
setCallBack(readyAd,object : AdListener {
|
||||||
|
override fun showSuccess() {
|
||||||
|
action.invoke(type_show_success)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun showFail() {
|
||||||
|
action.invoke(type_show_fail)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun showClose() {
|
||||||
|
action.invoke(type_show_close)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
readyAd.show(activity)
|
||||||
|
} else {
|
||||||
|
action.invoke(type_no_cache)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -22,7 +22,7 @@ dependencyResolutionManagement {
|
|||||||
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集成测试工具
|
//TopOn集成测试工具
|
||||||
// maven ( "https://jfrog.anythinktech.com/artifactory/debugger")
|
maven ( "https://jfrog.anythinktech.com/artifactory/debugger")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user