接入topon
This commit is contained in:
parent
9d68f4fa04
commit
a3a483cfb5
@ -4,8 +4,8 @@ import java.text.SimpleDateFormat
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
// id("com.google.firebase.crashlytics")
|
||||
// id("com.google.gms.google-services")
|
||||
id("com.google.firebase.crashlytics")
|
||||
id("com.google.gms.google-services")
|
||||
id("io.objectbox")
|
||||
}
|
||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||
@ -64,103 +64,102 @@ dependencies {
|
||||
implementation("androidx.camera:camera-camera2:${camerax_version}")
|
||||
//noinspection GradleDependency
|
||||
implementation("androidx.camera:camera-lifecycle:${camerax_version}")
|
||||
//noinspection GradleDependency
|
||||
// implementation("androidx.camera:camera-video:${camerax_version}")
|
||||
|
||||
//noinspection GradleDependency
|
||||
implementation("androidx.camera:camera-view:${camerax_version}")
|
||||
//noinspection GradleDependency
|
||||
implementation("androidx.camera:camera-extensions:${camerax_version}")
|
||||
|
||||
// implementation(platform("com.google.firebase:firebase-bom:33.1.1"))
|
||||
// implementation("com.google.firebase:firebase-crashlytics")
|
||||
// implementation("com.google.firebase:firebase-analytics")
|
||||
implementation(platform("com.google.firebase:firebase-bom:33.1.1"))
|
||||
implementation("com.google.firebase:firebase-crashlytics")
|
||||
implementation("com.google.firebase:firebase-analytics")
|
||||
|
||||
////-----------------------------------------------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")
|
||||
//-----------------------------------------------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")
|
||||
|
||||
}
|
||||
29
app/google-services.json
Normal file
29
app/google-services.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "329883980559",
|
||||
"project_id": "ar-paint-drawing",
|
||||
"storage_bucket": "ar-paint-drawing.firebasestorage.app"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:329883980559:android:3e6be88c306e7435a2247a",
|
||||
"android_client_info": {
|
||||
"package_name": "com.paint.ar.drawing"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyBW3qjmlJ9Z3cvqfBUYo1u1ixNm9qj6Ea4"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
@ -3,6 +3,8 @@ package com.paint.ar.drawing;
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Typeface;
|
||||
|
||||
import com.anythink.core.api.ATSDK;
|
||||
import com.anythink.core.api.NetTrafficeCallback;
|
||||
import com.paint.ar.drawing.ob.ObManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -19,9 +21,9 @@ public class MyApp extends android.app.Application {
|
||||
|
||||
public static MyApp app;
|
||||
|
||||
// private String APPId ="h67505d35951dc";
|
||||
//
|
||||
// private String AppKey ="a81d17e5cc10cd96a65fe75c0ffd15334";
|
||||
private String APPId ="";
|
||||
|
||||
private String AppKey ="";
|
||||
|
||||
public static Typeface defaultFont;
|
||||
|
||||
@ -31,29 +33,29 @@ public class MyApp extends android.app.Application {
|
||||
app = this;
|
||||
AssetManager assets = getAssets();
|
||||
defaultFont = Typeface.createFromAsset(assets, "myfont.ttf");
|
||||
|
||||
initSDk();
|
||||
ObManager.init(this);
|
||||
|
||||
}
|
||||
|
||||
private void initSDk(){
|
||||
// ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
||||
//
|
||||
// @Override
|
||||
// public void onResultCallback(boolean isEU) {
|
||||
// if (isEU && ATSDK.getGDPRDataLevel(MyApplication.this) == ATSDK.UNKNOWN) {
|
||||
// ATSDK.showGdprAuth(MyApplication.this);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onErrorCallback(String errorMsg) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// ATSDK.init( this, APPId, AppKey);
|
||||
// ;
|
||||
ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
||||
|
||||
@Override
|
||||
public void onResultCallback(boolean isEU) {
|
||||
if (isEU && ATSDK.getGDPRDataLevel(MyApp.this) == ATSDK.UNKNOWN) {
|
||||
ATSDK.showGdprAuth(MyApp.this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onErrorCallback(String errorMsg) {
|
||||
|
||||
}
|
||||
});
|
||||
ATSDK.init( this, APPId, AppKey);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -10,6 +10,8 @@ import com.paint.ar.drawing.MyApp;
|
||||
import com.paint.ar.drawing.adapter.AllAdapter;
|
||||
import com.paint.ar.drawing.databinding.ActivityAllBinding;
|
||||
import com.paint.ar.drawing.helper.Utils;
|
||||
import com.paint.ar.drawing.topon.AdManager;
|
||||
import com.paint.ar.drawing.topon.onActionListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -49,12 +51,14 @@ public class AllActivity extends AppCompatActivity {
|
||||
preViewBinding.back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AdManager.showTopOn(AllActivity.this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -121,12 +121,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == 0) {
|
||||
Log.d(MyApp.TAG,"----------onRequestPermissionsResult-");
|
||||
fragmentAlbum.permissionResult();
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
// if (requestCode == 0) {
|
||||
// Log.d(MyApp.TAG,"----------onRequestPermissionsResult-");
|
||||
// fragmentAlbum.permissionResult();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@ -8,6 +8,9 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.paint.ar.drawing.databinding.ActivityWelcomeBinding;
|
||||
import com.paint.ar.drawing.helper.Utils;
|
||||
import com.paint.ar.drawing.topon.AdManager;
|
||||
import com.paint.ar.drawing.topon.CountAction;
|
||||
import com.paint.ar.drawing.topon.GoMainAction;
|
||||
|
||||
public class WelActivity extends AppCompatActivity {
|
||||
|
||||
@ -16,7 +19,6 @@ public class WelActivity extends AppCompatActivity {
|
||||
private CountDownTimer countDownTimer;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -25,21 +27,23 @@ public class WelActivity extends AppCompatActivity {
|
||||
Utils.setStatusBarTextColor(this, true);
|
||||
|
||||
|
||||
countDownTimer= new CountDownTimer(time,100) {
|
||||
countDownTimer = AdManager.showWelcomeAd(this, time, new CountAction() {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
public void onCount(long millisUntilFinished) {
|
||||
int progressPercentage = (int) ((100 * millisUntilFinished) / time);
|
||||
int Percentage = 100 - progressPercentage;
|
||||
binding.loadingPb.setProgress(Percentage);
|
||||
}
|
||||
|
||||
}, new GoMainAction() {
|
||||
@Override
|
||||
public void onFinish() {
|
||||
public void onGo() {
|
||||
enterMain();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
countDownTimer.start();
|
||||
}
|
||||
|
||||
private void enterMain() {
|
||||
binding.loadingPb.setProgress(100);
|
||||
Intent intent = new Intent(WelActivity.this, MainActivity.class);
|
||||
|
||||
@ -16,6 +16,9 @@ import com.paint.ar.drawing.R;
|
||||
import com.paint.ar.drawing.helper.Utils;
|
||||
import com.paint.ar.drawing.MyApp;
|
||||
import com.paint.ar.drawing.activity.CameraActivity;
|
||||
import com.paint.ar.drawing.topon.AdManager;
|
||||
import com.paint.ar.drawing.topon.onActionListener;
|
||||
import com.vungle.ads.Ad;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -54,12 +57,18 @@ public class AllAdapter extends RecyclerView.Adapter<AllAdapter.HomeVH> {
|
||||
holder.cardView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AdManager.showTopOn(mCon, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Intent intent = new Intent(mCon, CameraActivity.class);
|
||||
intent.putExtra(MyApp.Key_Camera, name);
|
||||
mCon.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -19,14 +19,18 @@ import com.paint.ar.drawing.ob.ObManager;
|
||||
import com.paint.ar.drawing.ob.DataImport;
|
||||
import com.paint.ar.drawing.MyApp;
|
||||
import com.paint.ar.drawing.activity.CameraActivity;
|
||||
import com.paint.ar.drawing.topon.AdManager;
|
||||
import com.paint.ar.drawing.topon.onActionListener;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ImportAdapter extends RecyclerView.Adapter<ImportAdapter.HomeVH> {
|
||||
|
||||
|
||||
private Activity mCon;
|
||||
|
||||
private WeakReference<Activity> mCon;
|
||||
private List<DataImport> data = new ArrayList<>();
|
||||
|
||||
|
||||
@ -35,7 +39,7 @@ public class ImportAdapter extends RecyclerView.Adapter<ImportAdapter.HomeVH> {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public ImportAdapter(Activity mCon) {
|
||||
this.mCon = mCon;
|
||||
this.mCon = new WeakReference<>(mCon);
|
||||
}
|
||||
|
||||
public void addData(DataImport newData){
|
||||
@ -63,7 +67,7 @@ public class ImportAdapter extends RecyclerView.Adapter<ImportAdapter.HomeVH> {
|
||||
@Override
|
||||
public void run() {
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(path);
|
||||
mCon.runOnUiThread(()->{
|
||||
mCon.get().runOnUiThread(()->{
|
||||
holder.previewIm.setImageBitmap(bitmap);
|
||||
});
|
||||
|
||||
@ -75,9 +79,15 @@ public class ImportAdapter extends RecyclerView.Adapter<ImportAdapter.HomeVH> {
|
||||
holder.cardView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(mCon, CameraActivity.class);
|
||||
AdManager.showTopOn(mCon.get(), new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Intent intent = new Intent(mCon.get(), CameraActivity.class);
|
||||
intent.putExtra(MyApp.Key_Camera, path);
|
||||
mCon.startActivity(intent);
|
||||
mCon.get().startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
holder.imDelete.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@ -18,6 +18,8 @@ import com.paint.ar.drawing.ob.DataLocal;
|
||||
import com.paint.ar.drawing.helper.Utils;
|
||||
import com.paint.ar.drawing.MyApp;
|
||||
import com.paint.ar.drawing.activity.CameraActivity;
|
||||
import com.paint.ar.drawing.topon.AdManager;
|
||||
import com.paint.ar.drawing.topon.onActionListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -63,6 +65,9 @@ public class LikeAdapter extends RecyclerView.Adapter<LikeAdapter.HomeVH> {
|
||||
holder.cardView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AdManager.showTopOn(mCon, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Intent intent = new Intent(mCon, CameraActivity.class);
|
||||
intent.putExtra(MyApp.Key_Camera, name);
|
||||
mCon.startActivity(intent);
|
||||
@ -70,6 +75,9 @@ public class LikeAdapter extends RecyclerView.Adapter<LikeAdapter.HomeVH> {
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
@ -13,10 +13,10 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.result.ActivityResultCallback;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
@ -27,9 +27,12 @@ import com.paint.ar.drawing.ob.ObManager;
|
||||
import com.paint.ar.drawing.adapter.ImportAdapter;
|
||||
import com.paint.ar.drawing.helper.Utils;
|
||||
import com.paint.ar.drawing.MyApp;
|
||||
import com.paint.ar.drawing.topon.AdManager;
|
||||
import com.paint.ar.drawing.topon.onActionListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FragmentAlbum extends Fragment {
|
||||
private FragmentImportBinding binding;
|
||||
@ -37,13 +40,18 @@ public class FragmentAlbum extends Fragment {
|
||||
|
||||
private ImportAdapter importAdapter;
|
||||
private ActivityResultLauncher<Intent> intentActivityResultLauncher;
|
||||
private ActivityResultLauncher<String[]> requestImportPermission;
|
||||
|
||||
public FragmentAlbum() {
|
||||
|
||||
}
|
||||
|
||||
public static FragmentAlbum newInstance() {
|
||||
FragmentAlbum fragment = new FragmentAlbum();
|
||||
return fragment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@ -58,11 +66,41 @@ public class FragmentAlbum extends Fragment {
|
||||
binding.btnImport.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AdManager.showTopOn(requireActivity(), new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
checkPermission();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
requestImportPermission = registerForActivityResult(
|
||||
new ActivityResultContracts.RequestMultiplePermissions(), new ActivityResultCallback<Map<String, Boolean>>() {
|
||||
@Override
|
||||
public void onActivityResult(Map<String, Boolean> o) {
|
||||
boolean allGranted = true;
|
||||
for (Map.Entry<String, Boolean> entry : o.entrySet()) {
|
||||
String permission = entry.getKey();
|
||||
boolean isGranted = entry.getValue();
|
||||
if (isGranted) {
|
||||
} else {
|
||||
allGranted = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (allGranted) {
|
||||
startIntent();
|
||||
Log.d(MyApp.TAG, "All permissions granted!");
|
||||
} else {
|
||||
Toast.makeText(requireContext(), getString(R.string.permission_denied), Toast.LENGTH_SHORT).show();
|
||||
Log.d(MyApp.TAG, "Some permissions were denied!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
intentActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
|
||||
Uri imageUri = result.getData().getData();
|
||||
@ -134,10 +172,8 @@ public class FragmentAlbum extends Fragment {
|
||||
permissions = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
}
|
||||
if (!Utils.checkPermission(requireActivity(), permissions)) {
|
||||
|
||||
ActivityCompat.requestPermissions( requireActivity(), permissions, 0);
|
||||
requestImportPermission.launch(permissions);
|
||||
} else {
|
||||
|
||||
startIntent();
|
||||
}
|
||||
}
|
||||
@ -148,28 +184,9 @@ public class FragmentAlbum extends Fragment {
|
||||
intentActivityResultLauncher.launch(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == 0) {
|
||||
if (Utils.checkPermission(requireActivity(), permissions)) {
|
||||
|
||||
startIntent();
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void permissionResult(){
|
||||
if (Utils.checkPermission(requireActivity(), permissions)) {
|
||||
|
||||
startIntent();
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void loadImport() {
|
||||
importAdapter = new ImportAdapter(requireActivity());
|
||||
|
||||
10
app/src/main/java/com/paint/ar/drawing/topon/AdListener.java
Normal file
10
app/src/main/java/com/paint/ar/drawing/topon/AdListener.java
Normal file
@ -0,0 +1,10 @@
|
||||
package com.paint.ar.drawing.topon;
|
||||
|
||||
public interface AdListener {
|
||||
void loadFail(String placeId);
|
||||
void showSuccess();
|
||||
|
||||
void showFail();
|
||||
|
||||
void showClose();
|
||||
}
|
||||
246
app/src/main/java/com/paint/ar/drawing/topon/AdManager.java
Normal file
246
app/src/main/java/com/paint/ar/drawing/topon/AdManager.java
Normal file
@ -0,0 +1,246 @@
|
||||
package com.paint.ar.drawing.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.paint.ar.drawing.MyApp;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
private static final String place1Id = "";
|
||||
private static final String place2Id = "";
|
||||
private static final String place3Id = "";
|
||||
|
||||
|
||||
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(MyApp.app, place1Id);
|
||||
ATInterstitial mInterstitialAd2 = new ATInterstitial(MyApp.app, place2Id);
|
||||
ATInterstitial mInterstitialAd3 = new ATInterstitial(MyApp.app, 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(MyApp.TAG, "-has Cache------------");
|
||||
return ad;
|
||||
}
|
||||
}
|
||||
Log.d(MyApp.TAG, "-No Cache------------");
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void setCallBack(ATInterstitial ad, AdListener listener) {
|
||||
ad.setAdListener(new ATInterstitialListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdLoaded() {
|
||||
Log.d(MyApp.TAG, "LoadLoaded " + ad.mPlacementId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdLoadFail(AdError adError) {
|
||||
listener.loadFail(ad.mPlacementId);
|
||||
Log.d(MyApp.TAG, "LoadFail:--" + ad.mPlacementId + "--" + adError.getCode() + "---" + adError.getDesc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdClicked(ATAdInfo atAdInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdShow(ATAdInfo atAdInfo) {
|
||||
Log.d(MyApp.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(MyApp.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.paint.ar.drawing.topon;
|
||||
|
||||
public interface AdStatusAction {
|
||||
void onStatus(int adType);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.paint.ar.drawing.topon;
|
||||
|
||||
public interface CountAction {
|
||||
void onCount(long millisUntilFinished);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.paint.ar.drawing.topon;
|
||||
|
||||
public interface GoMainAction {
|
||||
void onGo();
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.paint.ar.drawing.topon;
|
||||
|
||||
public interface onActionListener {
|
||||
|
||||
void onAction();
|
||||
}
|
||||
@ -9,4 +9,5 @@
|
||||
<string name="import_fail">Import failed, please try again</string>
|
||||
<string name="import_im_too_big">Too big, the image should not be larger than 5M</string>
|
||||
<string name="import_already">Already imported</string>
|
||||
<string name="permission_denied">Permission denied, cannot access file</string>
|
||||
</resources>
|
||||
@ -2,12 +2,11 @@
|
||||
plugins {
|
||||
id("com.android.application") version "8.1.0" apply false
|
||||
id("org.jetbrains.kotlin.android") version "1.8.20" apply false
|
||||
// id("com.google.gms.google-services") version "4.3.15" apply false
|
||||
// id ("com.google.firebase.crashlytics") version "2.9.2" apply false
|
||||
id("com.google.gms.google-services") version "4.3.15" apply false
|
||||
id ("com.google.firebase.crashlytics") version "2.9.2" apply false
|
||||
}
|
||||
buildscript{
|
||||
dependencies{
|
||||
// classpath("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
|
||||
classpath("io.objectbox:objectbox-gradle-plugin:4.0.3")
|
||||
}
|
||||
}
|
||||
@ -13,25 +13,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")
|
||||
//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