V1.0.2(3) Max集成
This commit is contained in:
parent
3604fa40c9
commit
fd2a78e8d8
@ -8,19 +8,24 @@ plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
id("org.jetbrains.kotlin.android")
|
||||
kotlin("kapt")
|
||||
id("com.google.gms.google-services")
|
||||
id("com.google.firebase.crashlytics")
|
||||
id("applovin-quality-service")
|
||||
}
|
||||
applovin{
|
||||
apiKey = "yatmRma9RKlsVe1if4NVbCKUizbmnIgxrtP84RJ2FMcQ5IfcZmuauBmU10zf9CTTaOJrzeIoGCmgT7uTlyigFN"
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.app.wallpaper"
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
//com.wallpapers.gallery
|
||||
applicationId = "com.wallpapers.gallery.test"
|
||||
applicationId = "com.wallpapers.gallery"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 2
|
||||
versionName = "1.0.1"
|
||||
versionCode = 3
|
||||
versionName = "1.0.2"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
setProperty("archivesBaseName", "Wallpapers Gallery_V" + versionName + "(${versionCode})_$timestamp")
|
||||
}
|
||||
@ -64,4 +69,16 @@ dependencies {
|
||||
implementation("com.github.bumptech.glide:glide:4.16.0")
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
kapt("androidx.room:room-compiler:2.5.0")
|
||||
|
||||
|
||||
//----------------firebase
|
||||
implementation(platform("com.google.firebase:firebase-bom:33.1.1"))
|
||||
implementation("com.google.firebase:firebase-crashlytics")
|
||||
implementation("com.google.firebase:firebase-analytics")
|
||||
|
||||
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:+")
|
||||
}
|
||||
|
||||
29
app/google-services.json
Normal file
29
app/google-services.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "304045442827",
|
||||
"project_id": "wallpapers-gallery-c67ad",
|
||||
"storage_bucket": "wallpapers-gallery-c67ad.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:304045442827:android:1dce401517ecf5ac7e040e",
|
||||
"android_client_info": {
|
||||
"package_name": "com.wallpapers.gallery"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyA8nyGCajR1zisI1bc-Do9LevbhXmyAz3w"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
@ -33,7 +33,7 @@ public class ImageDownloadTask extends AsyncTask<String, Void, Boolean> {
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
Uri uri = a.saveToGallery(SetData.getContext(), inputStream);
|
||||
Uri uri = a.saveToGallery(SetData.context, inputStream);
|
||||
if(uri == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -4,11 +4,18 @@ import android.app.AlertDialog;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.app.wallpaper.R;
|
||||
import com.applovin.sdk.AppLovinMediationProvider;
|
||||
import com.applovin.sdk.AppLovinSdk;
|
||||
import com.applovin.sdk.AppLovinSdkConfiguration;
|
||||
import com.applovin.sdk.AppLovinSdkInitializationConfiguration;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
@ -22,21 +29,22 @@ import java.util.List;
|
||||
|
||||
public class SetData extends Application {
|
||||
|
||||
private static final List<GetWalls> AllWalls=new ArrayList<>();
|
||||
private static final List<Urldata> dataUrls=new ArrayList<>();
|
||||
static Context context;
|
||||
public static final String abc="app_database";
|
||||
public static final int vs=1;
|
||||
private static final List<GetWalls> AllWalls = new ArrayList<>();
|
||||
private static final List<Urldata> dataUrls = new ArrayList<>();
|
||||
public static Context context;
|
||||
public static final String abc = "app_database";
|
||||
public static final int vs = 1;
|
||||
|
||||
|
||||
public static Context getContext() {
|
||||
return context;
|
||||
}
|
||||
public static final String TAG = "Wallpaper Gallery";
|
||||
public static boolean initSDkOK = false;
|
||||
public static String initAction = "ACTION_INIT";
|
||||
private String SDK_KEY = "Kwbl2wDLdNgp3kE8gk7WW_CCEBAee8xOIUJZQtEdNZX1iwclqFHlbgrUJt_g4zzSHJosSKIN13gv5Lqoe0bPvg";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
context = getBaseContext();
|
||||
initMAxSDk();
|
||||
try {
|
||||
InputStream open = getAssets().open("test_new.json");
|
||||
String covertStr = ReadFile.getCovertStr(open);
|
||||
@ -44,12 +52,12 @@ public class SetData extends Application {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<GetWalls>>() {
|
||||
}.getType();
|
||||
List<GetWalls> catas=gson.fromJson(covertStr,type);
|
||||
for (GetWalls categories:catas){
|
||||
List<GetWalls> catas = gson.fromJson(covertStr, type);
|
||||
for (GetWalls categories : catas) {
|
||||
AllWalls.add(categories);
|
||||
for (Urldata urldata:categories.getList()){
|
||||
dataUrls.add(urldata);
|
||||
}
|
||||
for (Urldata urldata : categories.getList()) {
|
||||
dataUrls.add(urldata);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -68,4 +76,19 @@ public class SetData extends Application {
|
||||
public static List<GetWalls> getCataDatas() {
|
||||
return AllWalls;
|
||||
}
|
||||
|
||||
|
||||
private void initMAxSDk() {
|
||||
|
||||
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder(SDK_KEY, this)
|
||||
.setMediationProvider(AppLovinMediationProvider.MAX)
|
||||
.build();
|
||||
AppLovinSdk.getInstance(this).initialize(initConfig, new AppLovinSdk.SdkInitializationListener() {
|
||||
@Override
|
||||
public void onSdkInitialized(AppLovinSdkConfiguration appLovinSdkConfiguration) {
|
||||
initSDkOK = true;
|
||||
LocalBroadcastManager.getInstance(SetData.this).sendBroadcast(new Intent(initAction));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
11
app/src/main/java/com/app/wallpaper/max/MaxListener.java
Normal file
11
app/src/main/java/com/app/wallpaper/max/MaxListener.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.app.wallpaper.max;
|
||||
|
||||
import com.applovin.mediation.MaxAd;
|
||||
|
||||
public interface MaxListener {
|
||||
void onFail(MaxAd ad);
|
||||
|
||||
void onShowSuccess(MaxAd ad);
|
||||
|
||||
void onHidden();
|
||||
}
|
||||
178
app/src/main/java/com/app/wallpaper/max/MaxManager.java
Normal file
178
app/src/main/java/com/app/wallpaper/max/MaxManager.java
Normal file
@ -0,0 +1,178 @@
|
||||
package com.app.wallpaper.max;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.app.wallpaper.getdata.SetData;
|
||||
import com.app.wallpaper.myact.ViewActivity;
|
||||
import com.applovin.mediation.MaxAd;
|
||||
import com.applovin.mediation.MaxAdListener;
|
||||
import com.applovin.mediation.MaxError;
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MaxManager {
|
||||
/**
|
||||
* 56c10d02546aeb64
|
||||
* 977383f7d5ee3ef6
|
||||
* b49eb7193c367a07
|
||||
*/
|
||||
private static final String one_AD = "56c10d02546aeb64";
|
||||
private static final String two_Ad = "977383f7d5ee3ef6";
|
||||
private static final String three_ad = "b49eb7193c367a07";
|
||||
|
||||
|
||||
public static final int type_no_cache = 0;
|
||||
public static final int type_has_cache = 1;
|
||||
public static final int type_show_success = 2;
|
||||
public static final int type_show_close = 3;
|
||||
public static final int type_show_fail = 4;
|
||||
|
||||
private static List<MaxInterstitialAd> adList = new ArrayList<>();
|
||||
|
||||
public static MaxInterstitialAd getAd(List<MaxInterstitialAd> list) {
|
||||
Collections.shuffle(list);
|
||||
for (MaxInterstitialAd ad : list) {
|
||||
if (ad.isReady()) {
|
||||
return ad;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<MaxInterstitialAd> onLoadAd() {
|
||||
if (adList.isEmpty()) {
|
||||
MaxInterstitialAd AdT = new MaxInterstitialAd(two_Ad, SetData.context);
|
||||
MaxInterstitialAd AdOne = new MaxInterstitialAd(one_AD, SetData.context);
|
||||
MaxInterstitialAd AdThree = new MaxInterstitialAd(three_ad, SetData.context);
|
||||
adList.add(AdOne);
|
||||
adList.add(AdT);
|
||||
adList.add(AdThree);
|
||||
}
|
||||
|
||||
for (MaxInterstitialAd ad : adList) {
|
||||
if (!ad.isReady()) {
|
||||
setMyListener(ad, new MaxListener() {
|
||||
@Override
|
||||
public void onFail(MaxAd ad) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowSuccess(MaxAd ad) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHidden() {
|
||||
|
||||
}
|
||||
});
|
||||
ad.loadAd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return adList;
|
||||
}
|
||||
|
||||
public static void setMyListener(MaxInterstitialAd ad, MaxListener maxListener) {
|
||||
ad.setListener(new MaxAdListener() {
|
||||
@Override
|
||||
public void onAdLoaded(@NonNull MaxAd maxAd) {
|
||||
Log.d(SetData.TAG, "-------onAdLoaded-----maxAd=" + maxAd.getAdUnitId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdDisplayed(@NonNull MaxAd maxAd) {
|
||||
Log.d(SetData.TAG, "-------onAdDisplayed-----maxAd=" + maxAd.getAdUnitId());
|
||||
maxListener.onShowSuccess(maxAd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdHidden(@NonNull MaxAd maxAd) {
|
||||
Log.d(SetData.TAG, "-------onAdHidden-----maxAd=" + maxAd.getAdUnitId());
|
||||
maxListener.onHidden();
|
||||
setMyListener(ad, new MaxListener() {
|
||||
@Override
|
||||
public void onFail(MaxAd ad) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowSuccess(MaxAd ad) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHidden() {
|
||||
|
||||
}
|
||||
});
|
||||
ad.loadAd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdClicked(@NonNull MaxAd maxAd) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdLoadFailed(@NonNull String s, @NonNull MaxError maxError) {
|
||||
Log.d(SetData.TAG, "-------onAdLoadFailed-----s=" + s+"----maxError="+maxError.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdDisplayFailed(@NonNull MaxAd maxAd, @NonNull MaxError maxError) {
|
||||
maxListener.onFail(maxAd);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected static void ShowAd(Activity activity, onAdStatusListener listener) {
|
||||
MaxInterstitialAd ad = MaxManager.getAd(adList);
|
||||
if (ad == null) {
|
||||
listener.onAdStatus(type_no_cache);
|
||||
} else {
|
||||
listener.onAdStatus(type_has_cache);
|
||||
MaxManager.setMyListener(ad, new MaxListener() {
|
||||
@Override
|
||||
public void onFail(MaxAd ad) {
|
||||
listener.onAdStatus(type_show_fail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowSuccess(MaxAd ad) {
|
||||
listener.onAdStatus(type_show_success);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHidden() {
|
||||
listener.onAdStatus(type_show_close);
|
||||
}
|
||||
});
|
||||
ad.showAd(activity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void startShowMaxAd(Activity activity, onAdAfterAction listener) {
|
||||
MaxManager.ShowAd(activity, new onAdStatusListener() {
|
||||
@Override
|
||||
public void onAdStatus(int type) {
|
||||
if (type == MaxManager.type_show_close || type == MaxManager.type_show_fail || type == MaxManager.type_no_cache) {
|
||||
if (listener != null)
|
||||
listener.onAction();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
77
app/src/main/java/com/app/wallpaper/max/WelComManager.kt
Normal file
77
app/src/main/java/com/app/wallpaper/max/WelComManager.kt
Normal file
@ -0,0 +1,77 @@
|
||||
package com.app.wallpaper.max
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.os.CountDownTimer
|
||||
import android.util.Log
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.app.wallpaper.getdata.SetData
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd
|
||||
|
||||
|
||||
|
||||
object WelComManager {
|
||||
|
||||
private lateinit var timer: CountDownTimer
|
||||
|
||||
private var need_Show = true
|
||||
|
||||
private lateinit var lists: List<MaxInterstitialAd>
|
||||
|
||||
@JvmStatic
|
||||
fun initTimer(activity: Activity, countTime: Long,countAction: (Long) -> Unit, goMainAction: () -> Unit): CountDownTimer {
|
||||
need_Show = true
|
||||
timer = object : CountDownTimer(countTime, 100) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
countAction.invoke(millisUntilFinished)
|
||||
if (need_Show) {
|
||||
MaxManager.ShowAd(activity) {
|
||||
Log.d(SetData.TAG, "--onTick----------it=$it")
|
||||
if (it == MaxManager.type_has_cache) {
|
||||
need_Show = false
|
||||
}
|
||||
if (it == MaxManager.type_show_close || it == MaxManager.type_show_fail) {
|
||||
Log.d(SetData.TAG, "--onTick---------enter")
|
||||
goMainAction.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
if (need_Show) {
|
||||
MaxManager.ShowAd(activity) {
|
||||
if (it == MaxManager.type_show_close || it == MaxManager.type_show_fail || it == MaxManager.type_no_cache) {
|
||||
Log.d(SetData.TAG, "--onFinish---------enter")
|
||||
goMainAction.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
startAd(activity)
|
||||
return timer
|
||||
}
|
||||
|
||||
private fun startAd(activity: Activity) {
|
||||
if (!SetData.initSDkOK) {
|
||||
LocalBroadcastManager.getInstance(activity)
|
||||
.registerReceiver(object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
lists = MaxManager.onLoadAd()
|
||||
timer.start()
|
||||
Log.d(SetData.TAG, "------------1sucess")
|
||||
}
|
||||
}, IntentFilter(SetData.initAction))
|
||||
} else {
|
||||
lists = MaxManager.onLoadAd()
|
||||
timer.start()
|
||||
Log.d(SetData.TAG, "------------2sucess")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.app.wallpaper.max;
|
||||
|
||||
public interface onAdAfterAction {
|
||||
|
||||
void onAction();
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.app.wallpaper.max;
|
||||
|
||||
public interface onAdStatusListener {
|
||||
|
||||
void onAdStatus(int type);
|
||||
}
|
||||
@ -3,57 +3,70 @@ package com.app.wallpaper.myact;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.app.wallpaper.databinding.ActivityLogin2Binding;
|
||||
import com.app.wallpaper.max.WelComManager;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
private ActivityLogin2Binding binding;
|
||||
private Handler handler = new Handler();
|
||||
|
||||
private CountDownTimer countDownTimer;
|
||||
|
||||
private long time = 10000;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityLogin2Binding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
EdgeToEdge.enable(this);
|
||||
handler.postDelayed(new Runnable() {
|
||||
|
||||
countDownTimer = WelComManager.initTimer(LoginActivity.this, time, new Function1<Long, Unit>() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 使用 ValueAnimator 创建进度条动画
|
||||
ValueAnimator animation = ValueAnimator.ofInt(0, binding.progressBar.getMax());
|
||||
animation.setDuration(2500); // 动画时长
|
||||
animation.setInterpolator(new DecelerateInterpolator()); // 减速插值器
|
||||
animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
binding.progressBar.setProgress((int) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
animation.start();
|
||||
// 动画结束后跳转到新页面
|
||||
animation.addListener(new android.animation.Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(android.animation.Animator animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(android.animation.Animator animation) {
|
||||
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish(); // 可选:结束当前 Activity
|
||||
}
|
||||
@Override
|
||||
public void onAnimationCancel(android.animation.Animator animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(android.animation.Animator animation) {}
|
||||
});
|
||||
public Unit invoke(Long aLong) {
|
||||
float percentage = 100 - ((float) aLong / time) * 100;
|
||||
int round = Math.round(percentage);
|
||||
binding.progressBar.setProgress(round);
|
||||
return null;
|
||||
}
|
||||
}, 1000);
|
||||
}, new Function0<Unit>() {
|
||||
@Override
|
||||
public Unit invoke() {
|
||||
binding.progressBar.setProgress(100);
|
||||
goMain();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void goMain() {
|
||||
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish(); // 可选:结束当前 Activity
|
||||
}
|
||||
|
||||
}
|
||||
@ -22,6 +22,7 @@ import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.app.wallpaper.R;
|
||||
import com.app.wallpaper.databinding.ActivityMainBinding;
|
||||
import com.app.wallpaper.max.MaxManager;
|
||||
import com.app.wallpaper.myada.MainFragmentAddapter;
|
||||
import com.app.wallpaper.myfra.HomeFragment;
|
||||
import com.app.wallpaper.myfra.MyfavFragment;
|
||||
@ -44,6 +45,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
binding.getRoot();
|
||||
setContentView(binding.getRoot());
|
||||
MaxManager.onLoadAd();
|
||||
checkPermission(this, STORAGE_PERMISSION_CODE);
|
||||
mfragmentList.add(new HomeFragment());
|
||||
mfragmentList.add(new MyfavFragment());
|
||||
|
||||
@ -32,6 +32,9 @@ import com.app.wallpaper.R;
|
||||
import com.app.wallpaper.databinding.ActivityViewBinding;
|
||||
import com.app.wallpaper.donwload.ImageDownloadTask;
|
||||
import com.app.wallpaper.getdata.SetData;
|
||||
import com.app.wallpaper.max.MaxManager;
|
||||
import com.app.wallpaper.max.onAdAfterAction;
|
||||
import com.app.wallpaper.max.onAdStatusListener;
|
||||
import com.app.wallpaper.mydao.AppDatabase;
|
||||
import com.app.wallpaper.mydao.InterfaceDao;
|
||||
import com.app.wallpaper.mydao.MyEntity;
|
||||
@ -47,9 +50,10 @@ import java.io.OutputStream;
|
||||
|
||||
public class ViewActivity extends AppCompatActivity {
|
||||
private ActivityViewBinding binding;
|
||||
private int position, cataId, Id,position1;
|
||||
private int position, cataId, Id, position1;
|
||||
private WallpaperManager wallpaperManager;
|
||||
private String sourUrl;
|
||||
private String thmbeUrl;
|
||||
private InterfaceDao interfaceDao;
|
||||
private AppDatabase appDatabase;
|
||||
private MyEntity myEntitys = new MyEntity();
|
||||
@ -62,6 +66,8 @@ public class ViewActivity extends AppCompatActivity {
|
||||
EdgeToEdge.enable(this);
|
||||
binding = ActivityViewBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
MaxManager.onLoadAd();
|
||||
binding.progressbar1.setVisibility(View.VISIBLE);
|
||||
intenttData();
|
||||
wallpaperManager = WallpaperManager.getInstance(this);
|
||||
appDatabase = AppDatabase.getDatabase(this);
|
||||
@ -73,15 +79,35 @@ public class ViewActivity extends AppCompatActivity {
|
||||
showView();
|
||||
interfaceDao = appDatabase.interfaceDao();
|
||||
initJudge();
|
||||
binding.back.setOnClickListener(view -> finish());
|
||||
binding.back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MaxManager.startShowMaxAd(ViewActivity.this, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
setButtonLisenner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
MaxManager.startShowMaxAd(ViewActivity.this, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void intenttData() {
|
||||
position1 = getIntent().getIntExtra("position1", 0);
|
||||
if (position1 != 0) {
|
||||
position = position1;
|
||||
}else {
|
||||
} else {
|
||||
position = getIntent().getIntExtra("position", 0);
|
||||
}
|
||||
cataId = getIntent().getIntExtra("cataId", 0);
|
||||
@ -107,14 +133,20 @@ public class ViewActivity extends AppCompatActivity {
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
private void setButtonLisenner() {
|
||||
binding.donwload.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (sourUrl != null) {
|
||||
downloadTask = new ImageDownloadTask(getBaseContext(), ViewActivity.this);
|
||||
downloadTask.execute(sourUrl);
|
||||
binding.progressbar1.setVisibility(View.VISIBLE);
|
||||
MaxManager.startShowMaxAd(ViewActivity.this, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
downloadTask = new ImageDownloadTask(getBaseContext(), ViewActivity.this);
|
||||
downloadTask.execute(sourUrl);
|
||||
binding.progressbar1.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Toast.makeText(ViewActivity.this, "Failed to download image...", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@ -123,8 +155,15 @@ public class ViewActivity extends AppCompatActivity {
|
||||
binding.apply.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
loadPreview(sourUrl);
|
||||
binding.progressbar1.setVisibility(View.VISIBLE);
|
||||
MaxManager.startShowMaxAd(ViewActivity.this, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
binding.progressbar1.setVisibility(View.VISIBLE);
|
||||
loadPreview(sourUrl);
|
||||
binding.progressbar1.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
binding.like.setOnClickListener(new View.OnClickListener() {
|
||||
@ -136,12 +175,12 @@ public class ViewActivity extends AppCompatActivity {
|
||||
if (myEntitys == null) {
|
||||
MyEntity myEntity1 = interfaceDao.getImageSou(sourUrl);
|
||||
if (myEntity1 == null) {
|
||||
if (cataId==0) {
|
||||
if (cataId == 0) {
|
||||
MyEntity myEntity = new MyEntity();
|
||||
myEntity.setImagePre(SetData.getDataUrls().get(position).getPreUrl());
|
||||
myEntity.setImageSou(sourUrl);
|
||||
new InsertImageTask().execute(myEntity);
|
||||
}else {
|
||||
} else {
|
||||
MyEntity myEntity = new MyEntity();
|
||||
myEntity.setImagePre(SetData.getCataDatas().get(cataId).getList().get(position).getPreUrl());
|
||||
myEntity.setImageSou(sourUrl);
|
||||
@ -164,8 +203,7 @@ public class ViewActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
MyEntity myEntity2 = myEntitys;
|
||||
interfaceDao.deleteUser(myEntity2);
|
||||
runOnUiThread(new Runnable() {
|
||||
@ -205,32 +243,44 @@ public class ViewActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
}
|
||||
private void showView() {
|
||||
ViewFragment viewFragment;
|
||||
if (myEntitys == null) {
|
||||
if (cataId == 0) {
|
||||
viewFragment = ViewFragment.newInstance(SetData
|
||||
.getDataUrls().get(position).getSourceUrl());
|
||||
} else {
|
||||
viewFragment = ViewFragment.newInstance(SetData.
|
||||
getCataDatas().get(cataId).getList().
|
||||
get(position).getSourceUrl());
|
||||
}
|
||||
} else {
|
||||
viewFragment = ViewFragment.newInstance(myEntitys.getImageUrl2());
|
||||
}
|
||||
binding.viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
return viewFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 1;
|
||||
private void showView() {
|
||||
String sourceUrl;
|
||||
if (myEntitys == null) {
|
||||
if (cataId == 0) {
|
||||
sourceUrl = SetData
|
||||
.getDataUrls().get(position).getSourceUrl();
|
||||
} else {
|
||||
sourceUrl = SetData.
|
||||
getCataDatas().get(cataId).getList().
|
||||
get(position).getSourceUrl();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sourceUrl = myEntitys.getImageUrl2();
|
||||
}
|
||||
Glide.with(this)
|
||||
.asDrawable()
|
||||
.load(sourceUrl)
|
||||
.into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
binding.progressbar1.setVisibility(View.GONE);
|
||||
binding.imageView.setImageDrawable(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
super.onLoadFailed(errorDrawable);
|
||||
binding.progressbar1.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
binding.progressbar1.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void loadPreview(String preURl) {
|
||||
@ -240,15 +290,22 @@ public class ViewActivity extends AppCompatActivity {
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
binding.progressbar1.setVisibility(View.VISIBLE);
|
||||
setPhoneWallpaper(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
super.onLoadFailed(errorDrawable);
|
||||
binding.progressbar1.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
binding.progressbar1.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setPhoneWallpaper(Bitmap bitmap) {
|
||||
try {
|
||||
wallpaperManager.setBitmap(bitmap);
|
||||
@ -257,6 +314,7 @@ public class ViewActivity extends AppCompatActivity {
|
||||
binding.progressbar1.setVisibility(View.GONE);
|
||||
} catch (IOException ioException) {
|
||||
Toast.makeText(this, "Setting failed, ", Toast.LENGTH_SHORT).show();
|
||||
binding.progressbar1.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,4 +327,5 @@ public class ViewActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -4,6 +4,8 @@ import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
@ -54,6 +56,7 @@ public class HomeFragment extends Fragment implements OnItemHome {
|
||||
Bundle savedInstanceState) {
|
||||
binding = FragmentHomeBinding.inflate(getLayoutInflater());
|
||||
binding.tablay.setupWithViewPager(binding.viewPagerTab);
|
||||
|
||||
urldata = SetData.getDataUrls();
|
||||
drawerLayout = requireActivity().findViewById(R.id.drawer_layout);
|
||||
navigationView = requireActivity().findViewById(R.id.nav_view);
|
||||
@ -117,7 +120,12 @@ public class HomeFragment extends Fragment implements OnItemHome {
|
||||
LayoutInflater inflater = getLayoutInflater();
|
||||
View dialogView = inflater.inflate(R.layout.alterdialog, null);
|
||||
builder.setCustomTitle(dialogView);
|
||||
builder.setMessage("The current version is 1.0.0")
|
||||
String version = "1.0.1";
|
||||
PackageInfo info = getInfo();
|
||||
if (info != null) {
|
||||
version = info.versionName;
|
||||
}
|
||||
builder.setMessage("The current version is " + version)
|
||||
.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
@ -127,6 +135,16 @@ public class HomeFragment extends Fragment implements OnItemHome {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private PackageInfo getInfo() {
|
||||
try {
|
||||
PackageInfo packageInfo = SetData.context.getPackageManager().getPackageInfo(SetData.context.getPackageName(), 0);
|
||||
return packageInfo;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnitemClick(int position) {
|
||||
Intent intent = new Intent(getContext(), ViewActivity.class);
|
||||
|
||||
@ -56,7 +56,7 @@ public class LoadDataFragment extends Fragment implements OnItemHome, OnLoaditem
|
||||
StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
|
||||
binding.contentRe.setLayoutManager(staggeredGridLayoutManager);
|
||||
LoadDataAdapter loadDataAdapter = new LoadDataAdapter(SetData.getCataDatas(), getContext(), position, SetData.getDataUrls());
|
||||
binding.contentRe.addItemDecoration(new MyItemDecoration(SetData.getContext(), 20, 20, 15));
|
||||
binding.contentRe.addItemDecoration(new MyItemDecoration(SetData.context, 20, 20, 15));
|
||||
loadDataAdapter.setInfoWallPaperListener((OnItemHome) this, (OnLoaditem) this);
|
||||
binding.contentRe.setAdapter(loadDataAdapter);
|
||||
return binding.getRoot();
|
||||
|
||||
@ -125,7 +125,7 @@ public class MyfavFragment extends Fragment implements OnFavority {
|
||||
binding.myfra.setLayoutManager(staggeredGridLayoutManager);
|
||||
myfavorityAdapter = new MyfavorityAdapter(getContext(), datas);
|
||||
myfavorityAdapter.setInfoWallPaperListener((OnFavority) this);
|
||||
binding.myfra.addItemDecoration(new MyItemDecoration(SetData.getContext(),20,20,15));
|
||||
binding.myfra.addItemDecoration(new MyItemDecoration(SetData.context,20,20,15));
|
||||
binding.myfra.setAdapter(myfavorityAdapter);
|
||||
}
|
||||
@Override
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 426 B |
Binary file not shown.
|
Before Width: | Height: | Size: 636 B |
35
app/src/main/res/drawable/icon_about.xml
Normal file
35
app/src/main/res/drawable/icon_about.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="20"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:pathData="M2.5,15.833V4.167C2.5,3.246 3.246,2.5 4.167,2.5H17.5V14.167V17.5H4.167C3.246,17.5 2.5,16.754 2.5,15.833Z"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="1.66667"
|
||||
android:fillColor="#00000000"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#2A2E33"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M7.5,6.667H12.5"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="1.66667"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#2A2E33"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M7.5,10.003H10.833"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="1.66667"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#2A2E33"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M2.5,14.167H17.5"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="1.66667"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#2A2E33"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
||||
27
app/src/main/res/drawable/icon_version.xml
Normal file
27
app/src/main/res/drawable/icon_version.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="20"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:pathData="M10,10m-7.5,0a7.5,7.5 0,1 1,15 0a7.5,7.5 0,1 1,-15 0"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="1.66667"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#2A2E33"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M10,14.457V9.457"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="1.66667"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#2A2E33"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M10,6.669L10,5.836"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="1.66667"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#2A2E33"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
||||
@ -1,5 +1,4 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#4DFFFFFF" /> <!-- 你可以设置边框内的颜色 -->
|
||||
<solid android:color="#4D000000" /> <!-- 你可以设置边框内的颜色 -->
|
||||
<corners android:radius="42dp"/> <!-- 设置圆角的半径 -->
|
||||
<stroke android:width="1dp" android:color="#00000000"/>
|
||||
</shape>
|
||||
@ -6,8 +6,9 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/view_pager"
|
||||
<ImageView
|
||||
android:id="@+id/image_view"
|
||||
android:scaleType="centerCrop"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
@ -17,7 +18,7 @@
|
||||
android:layout_height="50dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:scrollbarSize="5dp"
|
||||
android:indeterminateTint="@color/white"
|
||||
android:indeterminateTint="@color/pink"
|
||||
android:visibility="gone"/>
|
||||
|
||||
|
||||
@ -118,7 +119,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="@string/aplly"
|
||||
android:text="@string/apply"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:background="#00000000"
|
||||
app:tabIndicatorHeight="0dp"
|
||||
android:scrollbarSize="32dp"
|
||||
app:tabBackground="@drawable/tab_back"
|
||||
app:tabGravity="center"
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<item
|
||||
android:id="@+id/about"
|
||||
android:icon="@drawable/about"
|
||||
android:icon="@drawable/icon_about"
|
||||
android:title="@string/about" />
|
||||
<item
|
||||
android:id="@+id/feedback"
|
||||
android:icon="@drawable/faceback"
|
||||
android:icon="@drawable/icon_version"
|
||||
android:title="@string/feedback" />
|
||||
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<string name="privacy_policy">Privacy policy</string>
|
||||
<string name="feedback">Feedback</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="aplly">Aplly</string>
|
||||
<string name="apply">apply</string>
|
||||
<string name="like">Like</string>
|
||||
<string name="share">Share</string>
|
||||
<string name="no_favorite_wallpapers_have_been_added_yet">No favorite wallpapers have been added yet</string>
|
||||
|
||||
@ -3,4 +3,11 @@ plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
|
||||
kotlin("kapt") version "1.9.0"
|
||||
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:+")
|
||||
}
|
||||
}
|
||||
@ -9,6 +9,7 @@ pluginManagement {
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven { url = uri("https://artifacts.applovin.com/android") }
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
@ -16,9 +17,11 @@ dependencyResolutionManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea") }
|
||||
maven { url = uri("https://artifact.bytedance.com/repository/pangle") }
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "Wallpaper"
|
||||
rootProject.name = "Wallpapers Gallery"
|
||||
include(":app")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user