接Max 1.0.1(2)
This commit is contained in:
parent
5947f23b9e
commit
f2d030e169
2
.gitignore
vendored
2
.gitignore
vendored
@ -14,3 +14,5 @@
|
||||
.cxx
|
||||
local.properties
|
||||
app/src/test/java/com/draw/painting/test/ExampleUnitTest.java
|
||||
.idea/
|
||||
.safedk/
|
||||
|
||||
@ -1,12 +1,19 @@
|
||||
|
||||
import java.util.Date
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id ("org.jetbrains.kotlin.android")
|
||||
// id("com.google.gms.google-services")
|
||||
// id("com.google.firebase.crashlytics")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("com.google.gms.google-services")
|
||||
id("com.google.firebase.crashlytics")
|
||||
id("applovin-quality-service")
|
||||
}
|
||||
|
||||
applovin {
|
||||
apiKey =
|
||||
"0pn_nPmNSunNT9Oq6nyqrUVTGfbFsZUoU47_B5ydJsLCvMPzZ8VdNFvemW1bfJfLlQ4WEgrD_fu3M4ep7hS9Ng"
|
||||
}
|
||||
|
||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||
android {
|
||||
namespace = "com.draw.painting.test"
|
||||
@ -17,9 +24,12 @@ android {
|
||||
applicationId = "com.draw.painting.helper"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
setProperty("archivesBaseName", "Painting Helper_V" + versionName + "(${versionCode})_$timestamp")
|
||||
versionCode = 2
|
||||
versionName = "1.0.1"
|
||||
setProperty(
|
||||
"archivesBaseName",
|
||||
"Painting Helper_V" + versionName + "(${versionCode})_$timestamp"
|
||||
)
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@ -39,7 +49,7 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
buildFeatures{
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
}
|
||||
}
|
||||
@ -55,46 +65,27 @@ dependencies {
|
||||
|
||||
val camerax_version = "1.1.0-beta01"
|
||||
//noinspection GradleDependency
|
||||
implementation ("androidx.camera:camera-core:${camerax_version}")
|
||||
implementation("androidx.camera:camera-core:${camerax_version}")
|
||||
//noinspection GradleDependency
|
||||
implementation ("androidx.camera:camera-camera2:${camerax_version}")
|
||||
implementation("androidx.camera:camera-camera2:${camerax_version}")
|
||||
//noinspection GradleDependency
|
||||
implementation ("androidx.camera:camera-lifecycle:${camerax_version}")
|
||||
implementation("androidx.camera:camera-lifecycle:${camerax_version}")
|
||||
//noinspection GradleDependency
|
||||
implementation ("androidx.camera:camera-video:${camerax_version}")
|
||||
implementation("androidx.camera:camera-video:${camerax_version}")
|
||||
//noinspection GradleDependency
|
||||
implementation ("androidx.camera:camera-view:${camerax_version}")
|
||||
implementation("androidx.camera:camera-view:${camerax_version}")
|
||||
//noinspection GradleDependency
|
||||
implementation ("androidx.camera:camera-extensions:${camerax_version}")
|
||||
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 ("com.ironsource.sdk:mediationsdk:8.1.0")
|
||||
// implementation ("com.ironsource:adqualitysdk:7.20.2")
|
||||
//
|
||||
// // Add Vungle Network(Liftoff Moneti)
|
||||
// implementation ("com.ironsource.adapters:vungleadapter:4.3.24")
|
||||
// implementation ("com.vungle:vungle-ads:7.3.2")
|
||||
//
|
||||
// //Mintegral
|
||||
// implementation ("com.mbridge.msdk.oversea:mbbid:16.7.71")
|
||||
// implementation ("com.mbridge.msdk.oversea:reward:16.7.71")
|
||||
// implementation ("com.mbridge.msdk.oversea:mbbanner:16.7.71")
|
||||
// implementation ("com.mbridge.msdk.oversea:newinterstitial:16.7.71")
|
||||
//
|
||||
// // Add Pangle Network
|
||||
// implementation ("com.ironsource.adapters:pangleadapter:4.3.26")
|
||||
// implementation ("com.pangle.global:ads-sdk:5.8.0.8")
|
||||
//
|
||||
// // Add UnityAds Network
|
||||
// implementation ("com.ironsource.adapters:unityadsadapter:4.3.40")
|
||||
// implementation ("com.unity3d.ads:unity-ads:4.12.0")
|
||||
|
||||
implementation("com.applovin:applovin-sdk:+")
|
||||
implementation("com.applovin.mediation:vungle-adapter:+")
|
||||
implementation("com.applovin.mediation:mintegral-adapter:+")
|
||||
implementation("com.applovin.mediation:bytedance-adapter:+")
|
||||
implementation("com.applovin.mediation:unityads-adapter:+")
|
||||
implementation(platform("com.google.firebase:firebase-bom:33.1.1"))
|
||||
implementation("com.google.firebase:firebase-crashlytics")
|
||||
implementation("com.google.firebase:firebase-analytics")
|
||||
|
||||
|
||||
}
|
||||
29
app/src/google-services.json
Normal file
29
app/src/google-services.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "21924510593",
|
||||
"project_id": "painting-helper",
|
||||
"storage_bucket": "painting-helper.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:21924510593:android:6d87dde89c34f4c8bc8680",
|
||||
"android_client_info": {
|
||||
"package_name": "com.draw.painting.helper"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyAjY1w9grBlztoWK_xncU7ImRySsoyKtms"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
@ -17,6 +17,7 @@
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
|
||||
<application
|
||||
android:name=".PaintingApp"
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
|
||||
8
app/src/main/java/com/draw/painting/test/Adcallback.java
Normal file
8
app/src/main/java/com/draw/painting/test/Adcallback.java
Normal file
@ -0,0 +1,8 @@
|
||||
package com.draw.painting.test;
|
||||
|
||||
import com.applovin.mediation.MaxAd;
|
||||
|
||||
public interface Adcallback {
|
||||
void onShowFail(MaxAd ad);
|
||||
void onAdHidden( );
|
||||
}
|
||||
@ -1,39 +1,51 @@
|
||||
package com.draw.painting.test;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.applovin.sdk.AppLovinMediationProvider;
|
||||
import com.applovin.sdk.AppLovinSdk;
|
||||
import com.applovin.sdk.AppLovinSdkConfiguration;
|
||||
import com.applovin.sdk.AppLovinSdkInitializationConfiguration;
|
||||
|
||||
|
||||
public class PaintingApp extends Application {
|
||||
|
||||
public static String Key_ViewDir = "pre_dir";
|
||||
|
||||
public static String Key_ISMAIN = "ismain";
|
||||
public static String Key_Camera = "camera_data";
|
||||
|
||||
public static PaintingApp app;
|
||||
public static String APP_KEY = "";
|
||||
|
||||
|
||||
private static Context context;
|
||||
public static final String AD_BROADCAST = "on_success_action";
|
||||
private static final String MAX_SDK = "27z51PI2aTeTbobe3ORmbnMCb97dZbW8zfHEBfRFzb2DlCRJaTQCNebHHVZ2aepZGpqkvO1J7noD4s8W2UwJew";
|
||||
public static Boolean initSDK = false;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
app = this;
|
||||
context = getApplicationContext();
|
||||
|
||||
initSDk();
|
||||
|
||||
}
|
||||
|
||||
private void initSDk() {
|
||||
// IronSource.init(this, APP_KEY, new InitializationListener() {
|
||||
// @Override
|
||||
// public void onInitializationComplete() {
|
||||
// // ironSource SDK is initialized
|
||||
// //加载插页广告
|
||||
// IronSourceAd.loadAd();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// //验证集成的成功 ,release的时候需要删除
|
||||
// IntegrationHelper.validateIntegration(this);
|
||||
|
||||
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder(MAX_SDK, this)
|
||||
.setMediationProvider(AppLovinMediationProvider.MAX)
|
||||
.build();
|
||||
AppLovinSdk.getInstance(this).initialize(initConfig, new AppLovinSdk.SdkInitializationListener() {
|
||||
@Override
|
||||
public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig) {
|
||||
initSDK = true;
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(AD_BROADCAST));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -9,21 +9,103 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Point;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.Range;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.camera.core.Camera;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import com.applovin.mediation.MaxAd;
|
||||
import com.applovin.mediation.MaxAdListener;
|
||||
import com.applovin.mediation.MaxError;
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd;
|
||||
import com.draw.painting.test.Adcallback;
|
||||
import com.draw.painting.test.PaintingApp;
|
||||
import com.draw.painting.test.ui.ALaucherActivity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Utils {
|
||||
|
||||
private static ArrayList<MaxInterstitialAd> adArrayList;
|
||||
private static final String one_AD = "fd0f2d1eca71b3a1";
|
||||
private static final String two_Ad = "f129bbb52cd84647";
|
||||
private static final String three_ad = "b42153354e619004";
|
||||
|
||||
|
||||
public static void setCallBcak(MaxInterstitialAd ad, Adcallback adcallback) {
|
||||
ad.setListener(new MaxAdListener() {
|
||||
@Override
|
||||
public void onAdLoaded(@NonNull MaxAd maxAd) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdDisplayed(@NonNull MaxAd maxAd) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdHidden(@NonNull MaxAd maxAd) {
|
||||
adcallback.onAdHidden();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdClicked(@NonNull MaxAd maxAd) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdLoadFailed(@NonNull String s, @NonNull MaxError maxError) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdDisplayFailed(@NonNull MaxAd maxAd, @NonNull MaxError maxError) {
|
||||
adcallback.onShowFail(maxAd);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static MaxInterstitialAd onCache(List<MaxInterstitialAd> list) {
|
||||
Collections.shuffle(list);
|
||||
for (MaxInterstitialAd ad : list) {
|
||||
if (ad.isReady()) {
|
||||
return ad;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<MaxInterstitialAd> getAllAd() {
|
||||
if (adArrayList == null) {
|
||||
adArrayList = new ArrayList<>();
|
||||
adArrayList.add(createAd(one_AD, PaintingApp.app));
|
||||
adArrayList.add(createAd(two_Ad, PaintingApp.app));
|
||||
adArrayList.add(createAd(three_ad, PaintingApp.app));
|
||||
}
|
||||
for (MaxInterstitialAd ad : adArrayList) {
|
||||
if (!ad.isReady()) {
|
||||
ad.loadAd();
|
||||
}
|
||||
}
|
||||
return adArrayList;
|
||||
}
|
||||
|
||||
private static MaxInterstitialAd createAd(String adUnitId, Context context) {
|
||||
MaxInterstitialAd ad = new MaxInterstitialAd(adUnitId, context);
|
||||
return ad;
|
||||
}
|
||||
|
||||
|
||||
public static int getRange(Camera camera) {
|
||||
Range<Integer> exposureCompensationRange = camera.getCameraInfo().getExposureState().getExposureCompensationRange();
|
||||
Integer upper = exposureCompensationRange.getUpper();
|
||||
@ -53,7 +135,8 @@ public class Utils {
|
||||
point.y = height;
|
||||
return point;
|
||||
}
|
||||
public static boolean checkPermission(Context context,String[] permissions) {
|
||||
|
||||
public static boolean checkPermission(Context context, String[] permissions) {
|
||||
boolean result = true;
|
||||
for (String per : permissions) {
|
||||
if (ActivityCompat.checkSelfPermission(context, per) != PackageManager.PERMISSION_GRANTED) {
|
||||
@ -63,6 +146,7 @@ public class Utils {
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public static Bitmap loadImageFromAssets(Context context, String fileName) {
|
||||
Bitmap bitmap = null;
|
||||
AssetManager assetManager = context.getAssets();
|
||||
|
||||
@ -1,23 +1,32 @@
|
||||
package com.draw.painting.test.ui;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.util.Log;
|
||||
|
||||
import com.draw.painting.test.R;
|
||||
import com.applovin.mediation.MaxAd;
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd;
|
||||
import com.draw.painting.test.Adcallback;
|
||||
import com.draw.painting.test.PaintingApp;
|
||||
import com.draw.painting.test.databinding.ActivityAlaucherBinding;
|
||||
import com.draw.painting.test.manager.Utils;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import java.util.List;
|
||||
|
||||
public class ALaucherActivity extends AppCompatActivity {
|
||||
|
||||
private ActivityAlaucherBinding binding;
|
||||
private long time = 2000;
|
||||
private long time = 11000;
|
||||
private CountDownTimer countDownTimer;
|
||||
private static List<MaxInterstitialAd> adsList;
|
||||
public static boolean isAlreadyShow = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -26,28 +35,73 @@ public class ALaucherActivity extends AppCompatActivity {
|
||||
setContentView(binding.getRoot());
|
||||
Utils.setStatusBarTextColor(this, true);
|
||||
|
||||
// countDownTimer = IronSourceAd.showWelComeAd(time, ALaucherActivity.this, IronSourceAd.adPlace1, new Function0<Unit>() {
|
||||
// @Override
|
||||
// public Unit invoke() {
|
||||
// enterMain();
|
||||
// return null;
|
||||
// }
|
||||
// });
|
||||
|
||||
countDownTimer = new CountDownTimer(time, 200) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
|
||||
if (!isAlreadyShow) {
|
||||
showAdOrStartView(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
enterMain();
|
||||
if (!isAlreadyShow) {
|
||||
showAdOrStartView(true);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
registerBroadcastReceiver();
|
||||
}
|
||||
|
||||
private void showAdOrStartView(boolean go) {
|
||||
MaxInterstitialAd cachedAd = Utils.onCache(adsList);
|
||||
if (cachedAd == null) {
|
||||
isAlreadyShow = false;
|
||||
if (go) {
|
||||
enterMain();
|
||||
}
|
||||
} else {
|
||||
isAlreadyShow = true;
|
||||
Utils.setCallBcak(cachedAd, new Adcallback() {
|
||||
@Override
|
||||
public void onShowFail(MaxAd ad) {
|
||||
isAlreadyShow = false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdHidden() {
|
||||
isAlreadyShow = true;
|
||||
enterMain();
|
||||
}
|
||||
});
|
||||
cachedAd.showAd();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerBroadcastReceiver() {
|
||||
if (!PaintingApp.initSDK) {
|
||||
BroadcastReceiver receiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
loadAndStartAd();
|
||||
}
|
||||
};
|
||||
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(receiver, new IntentFilter(PaintingApp.AD_BROADCAST));
|
||||
} else {
|
||||
loadAndStartAd();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadAndStartAd() {
|
||||
adsList = Utils.getAllAd();
|
||||
countDownTimer.start();
|
||||
}
|
||||
|
||||
|
||||
private void enterMain() {
|
||||
Intent intent = new Intent(ALaucherActivity.this, HomeActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
@ -32,11 +32,16 @@ import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.applovin.mediation.MaxAd;
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd;
|
||||
import com.draw.painting.test.Adcallback;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.draw.painting.test.PaintingApp;
|
||||
import com.draw.painting.test.R;
|
||||
import com.draw.painting.test.manager.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CameraActivity extends AppCompatActivity implements View.OnTouchListener, View.OnClickListener {
|
||||
private CameraSelector cameraSelector;
|
||||
private String[] permissions;
|
||||
@ -66,6 +71,9 @@ public class CameraActivity extends AppCompatActivity implements View.OnTouchLis
|
||||
|
||||
private String curBitmapPath;
|
||||
private boolean hasPermission = false;
|
||||
private boolean isMain;
|
||||
private String ismain;
|
||||
private static List<MaxInterstitialAd> adsList;
|
||||
private ActivityResultLauncher<Intent> intentActivityResultLauncher;
|
||||
|
||||
@Override
|
||||
@ -73,6 +81,15 @@ public class CameraActivity extends AppCompatActivity implements View.OnTouchLis
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_camera);
|
||||
Utils.setStatusBarTextColor(this, true);
|
||||
|
||||
adsList = Utils.getAllAd();
|
||||
Intent intent = getIntent();
|
||||
isMain = intent.getBooleanExtra(PaintingApp.Key_ISMAIN, false);
|
||||
|
||||
|
||||
showAd();
|
||||
|
||||
|
||||
previewView = findViewById(R.id.preview);
|
||||
imageView = findViewById(R.id.image);
|
||||
imBack = findViewById(R.id.back);
|
||||
@ -97,6 +114,26 @@ public class CameraActivity extends AppCompatActivity implements View.OnTouchLis
|
||||
initClick();
|
||||
}
|
||||
|
||||
private void showAd() {
|
||||
MaxInterstitialAd cachedAd = Utils.onCache(adsList);
|
||||
if (cachedAd == null) {
|
||||
|
||||
} else {
|
||||
Utils.setCallBcak(cachedAd, new Adcallback() {
|
||||
@Override
|
||||
public void onShowFail(MaxAd ad) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdHidden() {
|
||||
|
||||
}
|
||||
});
|
||||
cachedAd.showAd(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void onInitIm(float imW, float imH) {
|
||||
Point screen = Utils.getScreen(this);
|
||||
float newX = screen.x / 2f - imW / 2;
|
||||
@ -164,7 +201,14 @@ public class CameraActivity extends AppCompatActivity implements View.OnTouchLis
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.equals(imBack)) {
|
||||
finish();
|
||||
|
||||
if (isMain) {
|
||||
showAd();
|
||||
finish();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!hasPermission) {
|
||||
showNoPermission();
|
||||
@ -294,4 +338,15 @@ public class CameraActivity extends AppCompatActivity implements View.OnTouchLis
|
||||
private void showNoPermission() {
|
||||
Toast.makeText(this, getString(R.string.permission_fail), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
if (isMain) {
|
||||
showAd();
|
||||
finish();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -66,6 +66,7 @@ public class HomeFragment extends Fragment implements onClickListener {
|
||||
}else {
|
||||
intent = new Intent(requireContext(), CameraActivity.class);
|
||||
intent.putExtra(PaintingApp.Key_Camera,dir);
|
||||
intent.putExtra(PaintingApp.Key_ISMAIN,true);
|
||||
}
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
@ -6,6 +6,9 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import com.applovin.mediation.MaxAd;
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd;
|
||||
import com.draw.painting.test.Adcallback;
|
||||
import com.draw.painting.test.PaintingApp;
|
||||
import com.draw.painting.test.adapter.PreViewAdapter;
|
||||
import com.draw.painting.test.databinding.ActivityPreViewBinding;
|
||||
@ -18,15 +21,19 @@ public class PreViewActivity extends AppCompatActivity {
|
||||
private ActivityPreViewBinding preViewBinding;
|
||||
|
||||
private String dirStr;
|
||||
private static List<MaxInterstitialAd> adsList;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
preViewBinding = ActivityPreViewBinding.inflate(getLayoutInflater());
|
||||
setContentView(preViewBinding.getRoot());
|
||||
Utils.setStatusBarTextColor(this,true);
|
||||
Utils.setStatusBarTextColor(this, true);
|
||||
dirStr = getIntent().getStringExtra(PaintingApp.Key_ViewDir);
|
||||
preViewBinding.categoryName.setText(dirStr.substring(dirStr.lastIndexOf("_")+1));
|
||||
preViewBinding.categoryName.setText(dirStr.substring(dirStr.lastIndexOf("_") + 1));
|
||||
|
||||
adsList = Utils.getAllAd();
|
||||
|
||||
onInitList();
|
||||
onInitClick();
|
||||
}
|
||||
@ -44,9 +51,34 @@ public class PreViewActivity extends AppCompatActivity {
|
||||
preViewBinding.back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
finish();
|
||||
showAd();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showAd() {
|
||||
MaxInterstitialAd cachedAd = Utils.onCache(adsList);
|
||||
if (cachedAd == null) {
|
||||
finish();
|
||||
} else {
|
||||
Utils.setCallBcak(cachedAd, new Adcallback() {
|
||||
@Override
|
||||
public void onShowFail(MaxAd ad) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdHidden() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
cachedAd.showAd(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
showAd();
|
||||
}
|
||||
}
|
||||
@ -4,4 +4,9 @@ plugins {
|
||||
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
|
||||
}
|
||||
buildscript{
|
||||
dependencies{
|
||||
classpath("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,8 @@ pluginManagement {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
|
||||
maven { url = uri("https://artifacts.applovin.com/android") }
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
@ -10,11 +12,10 @@ dependencyResolutionManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
// maven ("https://android-sdk.is.com/")
|
||||
// //Mintegral
|
||||
// maven ("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
|
||||
// //Pangle
|
||||
// maven ("https://artifact.bytedance.com/repository/pangle")
|
||||
|
||||
maven { url = uri("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea") }
|
||||
maven { url = uri("https://artifact.bytedance.com/repository/pangle") }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user