diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index cb0f416..6aefe71 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.jetbrainsKotlinAndroid)
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
+ kotlin("kapt")
}
@@ -19,8 +20,8 @@ android {
applicationId = "com.wallart.art.wallpapers.hd"
minSdk = 23
targetSdk = 34
- versionCode = 5
- versionName = "1.0.4"
+ versionCode =6
+ versionName = "1.0.5"
setProperty("archivesBaseName", "Art Wallpaper_V" + versionName + "(${versionCode})_$timestamp")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
@@ -58,9 +59,7 @@ dependencies {
androidTestImplementation(libs.androidx.espresso.core)
//tabLayout
implementation("io.github.h07000223:flycoTabLayout:3.0.0")
- //下拉刷新上拉加载
-// implementation("io.github.scwang90:refresh-layout-kernel:2.0.5") //核心必须依赖
-// implementation("io.github.scwang90:refresh-header-classics:2.0.5") //经典刷新头
+
//okhttp
implementation("com.squareup.okhttp3:okhttp:4.9.2")
implementation("commons-codec:commons-codec:1.11")
@@ -68,8 +67,6 @@ dependencies {
implementation("com.github.bumptech.glide:glide:4.15.1")
annotationProcessor("com.github.bumptech.glide:compiler:4.11.0")
-// implementation("com.squareup.retrofit2:retrofit:2.9.0")
-// implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.7.2")
implementation("pub.devrel:easypermissions:3.0.0")
@@ -77,6 +74,9 @@ dependencies {
implementation ("com.google.code.gson:gson:2.10.1")
+ val room_version = "2.6.1"
+ implementation ("androidx.room:room-runtime:$room_version")
+ kapt("androidx.room:room-compiler:$room_version")
implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
implementation("com.google.firebase:firebase-analytics-ktx")
@@ -122,8 +122,7 @@ dependencies {
implementation("com.mbridge.msdk.oversea:mbbid:16.7.51")
implementation("androidx.recyclerview:recyclerview:1.1.0")
- //Tramini
- implementation("com.anythink.sdk:tramini-plugin-tpn:6.3.68")
+
//-----------------------------TopOn 聚合
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
index 35ebe71..6ecb727 100644
--- a/app/proguard-rules.pro
+++ b/app/proguard-rules.pro
@@ -19,19 +19,42 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
+#
+# -keep class com.cute.girl.hd.pink.img.wallpaper.db.CategoryData { *; }
+# -keep class com.cute.girl.hd.pink.img.wallpaper.db.Data { *; }
+#
+# -dontwarn org.bouncycastle.jsse.BCSSLParameters
+# -dontwarn org.bouncycastle.jsse.BCSSLSocket
+# -dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
+# -dontwarn org.conscrypt.Conscrypt$Version
+# -dontwarn org.conscrypt.Conscrypt
+# -dontwarn org.conscrypt.ConscryptHostnameVerifier
+# -dontwarn org.openjsse.javax.net.ssl.SSLParameters
+# -dontwarn org.openjsse.javax.net.ssl.SSLSocket
+# -dontwarn org.openjsse.net.ssl.OpenJSSE
+
+
+
+# 保持 Room 的核心类不被混淆
+-keep class androidx.room.** { *; }
+-keep class androidx.sqlite.db.** { *; }
+
+# 保持 Room 数据库类的基本结构
+-keep class * extends androidx.room.RoomDatabase { *; }
+
+# 保持 Room DAO 接口
+-keep @androidx.room.Dao interface * { *; }
+-keep @androidx.room.Dao class * { *; }
+
+# 保持 Room 实体类
+-keep @androidx.room.Entity class * { *; }
+
+# 保持 Room 的注解类
+-keep @androidx.room.Database class * { *; }
+
+
- -keep class com.cute.girl.hd.pink.img.wallpaper.entity.CategoryData { *; }
- -keep class com.cute.girl.hd.pink.img.wallpaper.entity.Data { *; }
- -dontwarn org.bouncycastle.jsse.BCSSLParameters
- -dontwarn org.bouncycastle.jsse.BCSSLSocket
- -dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
- -dontwarn org.conscrypt.Conscrypt$Version
- -dontwarn org.conscrypt.Conscrypt
- -dontwarn org.conscrypt.ConscryptHostnameVerifier
- -dontwarn org.openjsse.javax.net.ssl.SSLParameters
- -dontwarn org.openjsse.javax.net.ssl.SSLSocket
- -dontwarn org.openjsse.net.ssl.OpenJSSE
#---------------------------------TopOn 聚合
# Vungle
diff --git a/app/src/main/assets/ArtWallpaper_PrivacyPolicy.html b/app/src/main/assets/ArtWallpaper_PrivacyPolicy.html
new file mode 100644
index 0000000..3901481
--- /dev/null
+++ b/app/src/main/assets/ArtWallpaper_PrivacyPolicy.html
@@ -0,0 +1,68 @@
+
+
+
+
+ Privacy Policy
+
+
+
+Privacy Policy
+May 23, 2024
+
+We provides this Privacy Policy to help you understand how we collect, use and disclose information, including what you may provide to us or that we obtain from our products and services. We treat your privacy very seriously. Your privacy is important to us.
+
+Information Collection and Use
+
+For a better experience, while using our Service, We may require you to provide us with certain personally identifiable information add whatever else you collect here, e.g. users name, address, location, pictures. The information that We request will be retained on your device and is not collected by us in any way retained by us and used as described in this privacy policy.
+
+The app does use third-party services that may collect information used to identify you.
+
+Please refer to the privacy policy of the third-party service provider used by the application:
+
+ - Google Play Services
+ - Google Analytics for Firebase
+ - Firebase Crashlytics
+ - Unity
+ - AppLovin
+ - Vungle
+
+
+Log Data
+
+We want to inform you that whenever you use our Service, in a case of an error in the app We collect data and information (through third-party products) on your phone called Log Data. This Log Data may include information such as your device Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app when utilizing our Service, the time and date of your use of the Service, and other statistics.
+
+Cookies
+
+Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device's internal memory.
+This Service does not use these “cookies” explicitly. However, the app may use third-party code and libraries that use “cookies” to collect information and improve their services. You have the option to either accept or refuse these cookies and know when a cookie is being sent to your device. If you choose to refuse our cookies, you may not be able to use some portions of this Service.
+
+Service Providers
+
+We may employ third-party companies and individuals due to the following reasons:
+
+To facilitate our Service;
+To provide the Service on our behalf;To perform Service-related services; orTo assist us in analyzing how our Service is used.
+We want to inform users of this Service that these third parties have access to their Personal Information. The reason is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the information for any other purpose.
+
+Security
+
+We value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and We cannot guarantee its absolute security.
+
+Links to Other Sites
+
+This Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by us. Therefore, We strongly advise you to review the Privacy Policy of these websites. We have no control over and assume no responsibility for the content, privacy policies, or practices of any third-party sites or services.
+
+Children’s Privacy
+
+These Services do not address anyone under the age of 13. We do not knowingly collect personally identifiable information from children under 13 years of age. In the case We discover that a child under 13 has provided us with personal information, We immediately delete this from our servers. If you are a parent or guardian and you are aware that your child has provided us with personal information, please contact us so that We will be able to do the necessary actions.
+
+Changes to This Privacy Policy
+
+We may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any changes. We will notify you of any changes by posting the new Privacy Policy on this page.
+
+PRIVACY QUESTIONS
+
+We may update Privacy Policy from time to time. When we change the policy in a material way, a notice will be posted on our website along with the updated Privacy Policy.
+
+If you have any questions or concerns about our Privacy Policy or data processing, please contact us: RaymundoMeerdinkP9@gmail.com.
+
\ No newline at end of file
diff --git a/app/src/main/assets/test_new.json b/app/src/main/assets/wallpaper.json
similarity index 96%
rename from app/src/main/assets/test_new.json
rename to app/src/main/assets/wallpaper.json
index b86455f..d18c095 100644
--- a/app/src/main/assets/test_new.json
+++ b/app/src/main/assets/wallpaper.json
@@ -1,6 +1,7 @@
[
{
"name": "feature",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/d799900c0ed4448a858fabe9a97adb74.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/0778d29d9df3135981fa983db6447d4c.jpeg",
@@ -102,6 +103,7 @@
},
{
"name": "recent",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/35b096446e9a5d5f48ceb0200a8f998a.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/e3e9cfd7ecb0f9291a40577ccd5a6041.jpeg",
@@ -191,6 +193,7 @@
},
{
"name": "popular",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/450cfe73f9504835f27f7e86dff24d7f.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/cb1e57d9a8a8b74bd9da3a59d048b5f5.jpeg",
@@ -280,6 +283,7 @@
},
{
"name": "anime",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/4dedaccf8e3cdec4bab521ba2714735d.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/78a53756b869919dea40478e803165fe.jpeg",
@@ -333,6 +337,7 @@
},
{
"name": "unicorn",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/66e51fb0c777083a33c87169ff431c27.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/f394722f00db0df931ea62d8e0f1f273.jpeg",
@@ -386,6 +391,7 @@
},
{
"name": "kitty",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/77b08753cd065bd8e60873b1c119538d.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/0b52fe7cc5b2cf2d11cda94cf6dd77a9.jpeg",
@@ -439,6 +445,7 @@
},
{
"name": "puppies",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/29c711336f36473a3cacd4d9661f953a.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/d86f07746d129601913d2bf09599f6e8.jpeg",
@@ -492,6 +499,7 @@
},
{
"name": "flowers",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/c7a1784fb016359f7a62a882333cc83b.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/2a05f339aa023822a6b07c843910241d.jpeg",
@@ -545,6 +553,7 @@
},
{
"name": "eiffel tower",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/b6cde087dab857fdb24b0f0abd2385fa.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/d7ea774c7936847034e7d47c6a4c3621.jpeg",
@@ -598,6 +607,7 @@
},
{
"name": "dreamy",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/b66b86b24e7d5998b3ea5a6536929fa6.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/078a2934e9bd4e91691040427e42c1cf.jpeg",
@@ -651,6 +661,7 @@
},
{
"name": "animals",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/ad04501013a619c9b579dc2d9e593bf2.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/10a20226dda3cf01850566e1cfe2e57b.jpeg",
@@ -704,6 +715,7 @@
},
{
"name": "nature",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/aeaf0a95791d5064adf22a0dffc59692.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/0a0068552c7716f4e62b52389be2e7aa.jpeg",
@@ -757,6 +769,7 @@
},
{
"name": "cute",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/7a5e9212400d93fd5f5d6c1848b3d76e.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/6a53bf315f64477d85ceb46298475b8d.jpeg",
@@ -810,6 +823,7 @@
},
{
"name": "cute",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/6af1ac41c0bda2023d5b8268b7e1295b.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/24281fc765fce9da4c3d9d86e1e9ccf3.jpeg",
@@ -863,6 +877,7 @@
},
{
"name": "beautiful",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/0045a8e120149c1088dcc90669b4e08c.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/a2e09a56793fbf9e8104833a199cf332.jpeg",
@@ -916,6 +931,7 @@
},
{
"name": "love",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/7929459c12e04cfdc0613518a620b44b.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/93d96dd6956db5e77d25d83b9f46624c.jpeg",
@@ -969,6 +985,7 @@
},
{
"name": "quotes",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/3deec3b8eaeff16459a684cef5224b9b.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/ffdee201ab115879fd038a7f529d7d2c.jpeg",
@@ -1022,6 +1039,7 @@
},
{
"name": "kawaii",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/59eecae04d88aafdfc27dbdbed3f7206.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/de00f68d508f814beb905cd2fcb105b6.jpeg",
@@ -1075,6 +1093,7 @@
},
{
"name": "butterflies",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/2be531772db23680710b0ae0f6bbd6b1.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/14bec2138e0dbbb8269fcd823373ec81.jpeg",
@@ -1128,6 +1147,7 @@
},
{
"name": "ice-cream",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/0bf796c657ed4d6f71a87506f78d5810.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/1bbcf0d4423449788cbc823441a3639a.jpeg",
@@ -1181,6 +1201,7 @@
},
{
"name": "birds",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/eb8cff06bba7da5f3bdc7171815f30b0.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/d027d5c75d46118a8ff86257f87a7818.jpeg",
@@ -1234,6 +1255,7 @@
},
{
"name": "candy",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/e249865fcb0a40a9e64fbb125b467643.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/d0522722bb51d48e79670f07e4ec94ed.jpeg",
@@ -1287,6 +1309,7 @@
},
{
"name": "illustration",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/0bd89baff334793eac9ea18c651d43b5.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/741a4f4e3c11a30f5f250eabb255f3d5.jpeg",
@@ -1340,6 +1363,7 @@
},
{
"name": "colorful",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/2af2a4d4e9ab05a8ed888fb4a704ee07.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/668845fe70cd30c376a78f566e4b89c6.jpeg",
@@ -1393,6 +1417,7 @@
},
{
"name": "pattern",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/9e75b52e8e3fee0ad35f4145935c2cb2.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/8b570d932db8d172bb9c1aca58972d4d.jpeg",
@@ -1446,6 +1471,7 @@
},
{
"name": "floral",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/2831602ba02537da94d995723ccf7267.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/4ae5e4942ebe89d59e9cdc92b2805ccb.jpeg",
@@ -1499,6 +1525,7 @@
},
{
"name": "cakes",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/b18657ce8505fca699060de13b37ce03.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/96e101029fa82cad3fba032e4d907874.jpeg",
@@ -1540,6 +1567,7 @@
},
{
"name": "abstract",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/043429d95275d9ac3b571751507632d1.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/4bff588558b80ede14e99fdeeef127ad.jpeg",
@@ -1593,6 +1621,7 @@
},
{
"name": "amoled",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/c7e353bebb4b98ecd4cd3d5311fcc84d.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/13362a433eeb77a8fddc8c5a75291d57.jpeg",
@@ -1646,6 +1675,7 @@
},
{
"name": "vintage",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/0d7fe05abaa5a041d26b3c0541533f88.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/a4e335102bf1bd6e2b9a305afff7c9b0.jpeg",
@@ -1699,6 +1729,7 @@
},
{
"name": "cool",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/0d183f9e2cc4ad2626d58bf60ef423e6.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/de36a2eae65bb24a433f22d2de2adf2f.jpeg",
@@ -1752,6 +1783,7 @@
},
{
"name": "variety",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/fe57f912ce3eedf20716b20335b92a7a.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/3a5965c4291dba859c4b7f0b196f99c2.jpeg",
@@ -1805,6 +1837,7 @@
},
{
"name": "funny",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/b2e70fdc63bcefd5846f136da3975f9c.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/1bd4c32c2eb2045a19c4cf7afb8201d4.jpeg",
@@ -1858,6 +1891,7 @@
},
{
"name": "food",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/d04ee07feb44c02fcf92a7c3094370fb.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/3a49c824f553e1b8f2ce743cb89e1b6c.jpeg",
@@ -1911,6 +1945,7 @@
},
{
"name": "fashion",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/d9fb7a20ef94b3c8379eeabd2f085211.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/f90e441b77b209c856bb2441ba11bac4.jpeg",
@@ -1964,6 +1999,7 @@
},
{
"name": "sad",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/3670282caa3a1b93913827c103476de4.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/c59007c4e8b3befb96dbecb3ec326cc1.jpeg",
@@ -2017,6 +2053,7 @@
},
{
"name": "music",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/ba895bdb432d5ae1315777e89f07b2de.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/d5f3a2230952dab694ff0a80825e0a9d.jpeg",
@@ -2038,6 +2075,7 @@
},
{
"name": "fruit",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/25defad4df6676943fee66672cd9c469.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/e0f64bd789ef513368865c9f42adfaab.jpeg",
@@ -2091,6 +2129,7 @@
},
{
"name": "doll",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/cf99a915f6e25f8a84edb0297ae5d5a7.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/8adbcdd5abe61cc2210d8d5bdc7343e8.jpeg",
@@ -2144,6 +2183,7 @@
},
{
"name": "teddy",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/0cd0f61b1feaaca0be9d35baecfa9fb3.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/03b962f4e3ff5cc220544c6589a49482.jpeg",
@@ -2169,10 +2209,6 @@
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/498b2956356743dd61bcf43c5e2bdfe5.jpeg",
"preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/44f01787f33c354865ef2e0235a52bb7.jpeg"
},
- {
- "sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/8739a1033149540124a0c9bf2dca71b2.jpeg",
- "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/dd3608457a2915a29de559f59927babc.jpeg"
- },
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/30448f7b2fe2bcdf037fc3d1fc971751.jpeg",
"preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/998df3180fbf701806e8fcdff50880fc.jpeg"
@@ -2197,6 +2233,7 @@
},
{
"name": "winter",
+ "preUrl": "https://resource-sg-public.lux-ad.com/wallpaper/8497b431b92946723d7acbd1c9836bde.jpeg",
"list": [
{
"sourceUrl": "https://resource-sg-public.lux-ad.com/wallpaper/028622eed6c6083a721b5c6af19053d1.jpeg",
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/MyApp.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/MyApp.kt
index ad5814a..7cf4339 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/MyApp.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/MyApp.kt
@@ -5,10 +5,14 @@ import android.util.Log
import com.anythink.core.api.ATSDK
import com.anythink.core.api.NetTrafficeCallback
//import com.anythink.debug.api.ATDebuggerUITest
-import com.cute.girl.hd.pink.img.wallpaper.entity.CategoryData
-import com.cute.girl.hd.pink.img.wallpaper.entity.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.Category
+import com.cute.girl.hd.pink.img.wallpaper.db.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.MyDatabase
import com.cute.girl.hd.pink.img.wallpaper.topon.AdManager
import com.liulishuo.filedownloader.FileDownloader
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
import org.json.JSONArray
import java.io.BufferedReader
import java.io.ByteArrayOutputStream
@@ -23,15 +27,19 @@ import java.nio.charset.StandardCharsets
class MyApp : Application() {
companion object {
lateinit var app: MyApp
- lateinit var myData: List
+ const val DB_Table_category = "Category"
+ const val DB_Table_wallpaper = "Wallpaper"
+ const val DB_NAME = "Art_Wallpaper"
+ const val DB_VERSION = 1
+ lateinit var myData: List
const val TAG = "=============="
- const val AD_INIT_ACTION = "on_success_action"
- var initSDK = false
+
}
- private val APPId="h66978895679a9"
- private val APPKey="00c254f2caba04948f14c41014ac5f33"
- private val debug_key="fe06c76b794f95216f98e5982ae8f335fc558956"
+
+ private val APPId = "h66978895679a9"
+ private val APPKey = "00c254f2caba04948f14c41014ac5f33"
+ private val debug_key = "fe06c76b794f95216f98e5982ae8f335fc558956"
override fun onCreate() {
super.onCreate()
app = this
@@ -41,65 +49,55 @@ class MyApp : Application() {
}
private fun readJson() {
- val openFd = assets.open("test_new.json")
- val pathDe = cacheDir.path + "/res.json"
- if (File(pathDe).exists()) {
- myData = fileToData(pathDe)
- return
- }
- if (writeFile(openFd, pathDe)) {
- myData = fileToData(pathDe)
+ CoroutineScope(Dispatchers.IO).launch {
+ val queryAll = MyDatabase.myDatabase.CategoryDao().queryAllData()
+ Log.d("-----------", "------queryAll=${queryAll.size}")
+ if (queryAll.isEmpty()) {
+ val openFd = assets.open("wallpaper.json")
+ fileToData(openFd)
+ }
+
+
}
}
- private fun fileToData(path: String): List {
- val jsonStr = getJsonStr(path)
- var data = mutableListOf()
+ private fun fileToData(assetInput: InputStream) {
+ val jsonStr = getJsonStr(assetInput)
val array = JSONArray(jsonStr)
for (i in 0 until array.length()) {
val any = array.getJSONObject(i)
val title = any.getString("name")
+ val covert = any.getString("preUrl")
+
+ val categoryId = MyDatabase.myDatabase.CategoryDao()
+ .insertData(Category(title = title, covert = covert))
val jsonArray = any.getJSONArray("list")
- var data1 = mutableListOf()
for (k in 0 until jsonArray.length()) {
val jsonObject = jsonArray.getJSONObject(k)
val source = jsonObject.getString("sourceUrl")
val preview = jsonObject.getString("preUrl")
- data1.add(Data(preview, source))
+ MyDatabase.myDatabase.WallpaperDao()
+ .insertWallpaper(
+ Data(
+ categoryId = categoryId,
+ sourceURl = source,
+ previewURl = preview
+ )
+ )
+
}
- data.add(CategoryData(title, data1))
}
- return data
}
- fun writeFile(input: InputStream, filePath: String): Boolean {
- val byte = ByteArray(4096)
- val output = ByteArrayOutputStream()
- var l: Int
- while (input.read(byte).also { l = it } != -1) {
- output.write(byte, 0, l)
- }
- val fileDe = File(filePath)
- if (!fileDe.exists()) {
- fileDe.createNewFile()
- }
- val fileOutputStream = FileOutputStream(filePath)
- fileOutputStream.write(output.toByteArray())
- output.close()
- fileOutputStream.close()
- return true
-
- }
-
- fun getJsonStr(resPath: String): String {
+ fun getJsonStr(input: InputStream): String {
val stringWriter = StringWriter()
- val input = FileInputStream(resPath)
+
val charArray = CharArray(input.available())
var l = 0;
val bufReader = BufferedReader(InputStreamReader(input, StandardCharsets.UTF_8))
@@ -129,7 +127,7 @@ class MyApp : Application() {
})
- ATSDK.init( this, APPId, APPKey)
+ ATSDK.init(this, APPId, APPKey)
AdManager.loadAllAd()
//测试工具
// ATDebuggerUITest.showDebuggerUI(this,debug_key)
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/CategoryAdapter.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/CategoryAdapter.kt
index 0e200f4..3a637dd 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/CategoryAdapter.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/CategoryAdapter.kt
@@ -13,13 +13,13 @@ import com.bumptech.glide.request.target.Target
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestListener
import com.cute.girl.hd.pink.img.wallpaper.databinding.ItemCategoryBinding
-import com.cute.girl.hd.pink.img.wallpaper.entity.CategoryData
-import com.cute.girl.hd.pink.img.wallpaper.entity.GCategory
+import com.cute.girl.hd.pink.img.wallpaper.db.Category
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.hide
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.show
-class CategoryAdapter(private val ctx: Context, private val list: List) :
+class CategoryAdapter(private val ctx: Context) :
RecyclerView.Adapter() {
+ private var list: List = emptyList()
private var mListener: OnItemClickListener? = null
@@ -27,6 +27,12 @@ class CategoryAdapter(private val ctx: Context, private val list: List){
+ list = data
+ notifyDataSetChanged()
+ }
+
+
override fun onBindViewHolder(holder: VH, position: Int) {
if (list.isEmpty()) {
return
@@ -43,7 +49,7 @@ class CategoryAdapter(private val ctx: Context, private val list: List {
override fun onLoadFailed(
@@ -80,7 +86,7 @@ class CategoryAdapter(private val ctx: Context, private val list: List) :
+class CategoryDetailAdapter(private val ctx: Context) :
RecyclerView.Adapter() {
-
+ private var list: List = emptyList()
private var mListener: OnItemClickListener? = null
+
+
+ fun updateData(mList:List){
+ list = mList
+ notifyDataSetChanged()
+ }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
return VH(ItemImageBinding.inflate(LayoutInflater.from(ctx), parent, false))
}
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/CategoryPagerAdapter.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/CategoryPagerAdapter.kt
deleted file mode 100644
index e247f66..0000000
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/CategoryPagerAdapter.kt
+++ /dev/null
@@ -1,107 +0,0 @@
-package com.cute.girl.hd.pink.img.wallpaper.adapter
-
-import android.content.Context
-import android.graphics.drawable.Drawable
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.recyclerview.widget.RecyclerView
-import com.bumptech.glide.Glide
-import com.bumptech.glide.load.DataSource
-import com.bumptech.glide.load.engine.GlideException
-import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
-import com.bumptech.glide.request.RequestListener
-import com.bumptech.glide.request.target.Target
-import com.cute.girl.hd.pink.img.wallpaper.databinding.ItemPreviewBinding
-import com.cute.girl.hd.pink.img.wallpaper.entity.Data
-import com.cute.girl.hd.pink.img.wallpaper.entity.GCategoryDetail
-import com.cute.girl.hd.pink.img.wallpaper.utils.DownloadUtil
-import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.hide
-import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.show
-
-class CategoryPagerAdapter(private val ctx: Context, private val list: MutableList) :
- RecyclerView.Adapter() {
-
- private var mListener: OnItemClickListener? = null
-
- override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
- return VH(ItemPreviewBinding.inflate(LayoutInflater.from(ctx), parent, false))
- }
-
- override fun onBindViewHolder(holder: VH, position: Int) {
- if (list.isEmpty()) {
- return
- }
- if (position >= list.size) {
- return
- }
- val bean = list[position]
- holder.mItemBinding?.ivPlaceholder?.show()
-
-
- val url = if (DownloadUtil.isExist(bean.sourceURl, bean.getTag())) {
- DownloadUtil.getFilePath(bean.getTag())
- } else {
- bean.previewURl
- }
-
-// val url =bean.previewURl
-
- holder.mItemBinding?.ivWallpaper?.let {
- Glide.with(ctx)
- .load(url)
- .transition(DrawableTransitionOptions.withCrossFade())
- .listener(object : RequestListener {
- override fun onLoadFailed(
- e: GlideException?,
- model: Any?,
- target: Target?,
- isFirstResource: Boolean
- ): Boolean {
- holder.mItemBinding?.ivPlaceholder?.show()
- return false
- }
-
- override fun onResourceReady(
- resource: Drawable?,
- model: Any?,
- target: Target?,
- dataSource: DataSource?,
- isFirstResource: Boolean
- ): Boolean {
- holder.mItemBinding?.ivPlaceholder?.hide()
- return false
- }
- })
- .into(it)
- }
- holder.getRoot()?.let {
- it.setOnClickListener { mListener?.onItemClick(position) }
- }
- }
-
- override fun getItemCount(): Int {
- return list.size
- }
-
- fun setOnItemClickListener(listener: OnItemClickListener) {
- mListener = listener
- }
-
- interface OnItemClickListener {
- fun onItemClick(pos: Int)
- }
-
- class VH(itemView: View) : RecyclerView.ViewHolder(itemView) {
-
- var mItemBinding: ItemPreviewBinding? = null
-
- constructor(binding: ItemPreviewBinding) : this(binding.root) {
- this.mItemBinding = binding
- }
-
- fun getRoot(): View? {
- return mItemBinding?.root
- }
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/ImageGridAdapter.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/ImageGridAdapter.kt
index 1dcaa5f..54eef8e 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/ImageGridAdapter.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/ImageGridAdapter.kt
@@ -13,19 +13,17 @@ import com.bumptech.glide.request.target.Target
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestListener
import com.cute.girl.hd.pink.img.wallpaper.databinding.ItemImageBinding
-import com.cute.girl.hd.pink.img.wallpaper.entity.CategoryData
-import com.cute.girl.hd.pink.img.wallpaper.entity.Data
-import com.cute.girl.hd.pink.img.wallpaper.entity.GImage
+import com.cute.girl.hd.pink.img.wallpaper.db.Data
import com.cute.girl.hd.pink.img.wallpaper.utils.DeviceUtil
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.dp2PxInt
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.hide
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.show
-class ImageGridAdapter(private val ctx: Context, private var list: List) :
+class ImageGridAdapter(private val ctx: Context) :
RecyclerView.Adapter() {
private var mListener: OnItemClickListener? = null
-
+ private var list: List = emptyList()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
return VH(ItemImageBinding.inflate(LayoutInflater.from(ctx), parent, false))
}
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/ImagePagerAdapter.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/ImagePagerAdapter.kt
index e21a855..77ebc26 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/ImagePagerAdapter.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/adapter/ImagePagerAdapter.kt
@@ -13,8 +13,7 @@ import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import com.cute.girl.hd.pink.img.wallpaper.databinding.ItemPreviewBinding
-import com.cute.girl.hd.pink.img.wallpaper.entity.Data
-import com.cute.girl.hd.pink.img.wallpaper.entity.GImage
+import com.cute.girl.hd.pink.img.wallpaper.db.Data
import com.cute.girl.hd.pink.img.wallpaper.utils.DownloadUtil
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.hide
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.show
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/Category.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/Category.kt
new file mode 100644
index 0000000..a60e52e
--- /dev/null
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/Category.kt
@@ -0,0 +1,15 @@
+package com.cute.girl.hd.pink.img.wallpaper.db
+
+import androidx.room.Entity
+import androidx.room.PrimaryKey
+import com.cute.girl.hd.pink.img.wallpaper.MyApp
+import java.io.Serializable
+
+@Entity(tableName = MyApp.DB_Table_category)
+class Category(
+ @PrimaryKey(autoGenerate = true)
+ var id: Long = 0,
+ var title: String,
+ var covert:String
+):Serializable{
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/CategoryDao.java b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/CategoryDao.java
new file mode 100644
index 0000000..91eca5b
--- /dev/null
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/CategoryDao.java
@@ -0,0 +1,28 @@
+package com.cute.girl.hd.pink.img.wallpaper.db;
+
+import androidx.lifecycle.LiveData;
+import androidx.room.Dao;
+import androidx.room.Insert;
+import androidx.room.OnConflictStrategy;
+import androidx.room.Query;
+
+import java.util.List;
+
+@Dao
+public interface CategoryDao {
+
+ @Insert(onConflict = OnConflictStrategy.IGNORE)
+ long insertData(Category data);
+
+
+ @Query("select * from category order by id desc")
+ LiveData> queryAll();
+
+ @Query("select * from category where title = :mtitle")
+ Category queryCateId(String mtitle);
+
+ @Query("select * from category order by id desc")
+ List queryAllData();
+
+
+}
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/Data.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/Data.kt
new file mode 100644
index 0000000..8f4e4c2
--- /dev/null
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/Data.kt
@@ -0,0 +1,61 @@
+package com.cute.girl.hd.pink.img.wallpaper.db
+
+import android.util.Log
+import androidx.room.Entity
+import androidx.room.ForeignKey
+import androidx.room.Index
+import androidx.room.PrimaryKey
+import com.cute.girl.hd.pink.img.wallpaper.MyApp
+import java.io.Serializable
+
+//class Data(var previewURl: String, var sourceURl: String) : Serializable {
+//
+// fun getTag(): String {
+// val lastIndex1 = sourceURl.lastIndexOf("/")
+//
+// val lastIndex2 = sourceURl.lastIndexOf(".")
+//
+// val substring = sourceURl.substring(lastIndex1+1, lastIndex2)
+// Log.d("-----------","------TAG----$substring")
+//
+// return substring
+//
+// }
+//
+//
+//
+//}
+
+@Entity(
+ tableName = MyApp.DB_Table_wallpaper, foreignKeys = arrayOf(
+ ForeignKey(
+ entity = Category::class,
+ parentColumns = arrayOf("id"),
+ childColumns = arrayOf("categoryId"),
+ onDelete = ForeignKey.CASCADE
+ )
+ ),
+ indices = [Index(value = ["id"], unique = true), Index(value = ["categoryId"])]
+)
+class Data(
+ @PrimaryKey(autoGenerate = true)
+ var id: Long = 0,
+ var categoryId: Long = 0,
+ var sourceURl: String,
+ var previewURl: String,
+ var sourceCache: String?= null,
+ var like: Boolean = false
+) : Serializable {
+
+
+ fun getTag(): String {
+ val lastIndex1 = sourceURl.lastIndexOf("/")
+
+ val lastIndex2 = sourceURl.lastIndexOf(".")
+
+ val substring = sourceURl.substring(lastIndex1+1, lastIndex2)
+ Log.d("-----------","------TAG----$substring")
+ return substring
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/MyDatabase.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/MyDatabase.kt
new file mode 100644
index 0000000..4121009
--- /dev/null
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/MyDatabase.kt
@@ -0,0 +1,29 @@
+package com.cute.girl.hd.pink.img.wallpaper.db
+
+import androidx.room.Database
+import androidx.room.Room
+import androidx.room.RoomDatabase
+import com.cute.girl.hd.pink.img.wallpaper.MyApp
+
+
+@Database(
+ entities = [Category::class, Data::class],
+ version = MyApp.DB_VERSION,
+ exportSchema = false
+)
+abstract class MyDatabase : RoomDatabase() {
+
+ abstract fun CategoryDao(): CategoryDao
+ abstract fun WallpaperDao(): WallpaperDao
+
+
+ companion object {
+ val myDatabase: MyDatabase by lazy {
+ Room.databaseBuilder(
+ MyApp.app, MyDatabase::class.java,
+ MyApp.DB_NAME
+ ).build()
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/WallpaperDao.java b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/WallpaperDao.java
new file mode 100644
index 0000000..5d09949
--- /dev/null
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/db/WallpaperDao.java
@@ -0,0 +1,32 @@
+package com.cute.girl.hd.pink.img.wallpaper.db;
+
+import androidx.lifecycle.LiveData;
+import androidx.room.Dao;
+import androidx.room.Insert;
+import androidx.room.OnConflictStrategy;
+import androidx.room.Query;
+import androidx.room.Update;
+
+import java.util.List;
+
+@Dao
+public interface WallpaperDao {
+
+ @Insert(onConflict = OnConflictStrategy.IGNORE)
+ void insertWallpaper(Data prank);
+
+
+ @Query("select * from wallpaper where `like` ==:mlike")
+ LiveData> queryAllLike(boolean mlike );
+
+ @Query("select * from wallpaper where categoryId ==:mCategoryId")
+ LiveData> queryList(long mCategoryId);
+
+ @Query("select * from wallpaper where categoryId ==:mCategoryId")
+ List queryCategoryList(long mCategoryId);
+
+ @Query("select * from wallpaper where id ==:mId")
+ LiveData queryWallpaper(long mId);
+ @Update
+ void updateWallpaper(Data wallpaper);
+}
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/entity/CategoryData.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/entity/CategoryData.kt
deleted file mode 100644
index 8f1c0f9..0000000
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/entity/CategoryData.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.cute.girl.hd.pink.img.wallpaper.entity
-
-import java.io.Serializable
-
-class CategoryData(var title:String,var data:List):Serializable
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/entity/Data.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/entity/Data.kt
deleted file mode 100644
index 15cb7c6..0000000
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/entity/Data.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.cute.girl.hd.pink.img.wallpaper.entity
-
-import android.util.Log
-import java.io.Serializable
-
-class Data(var previewURl: String, var sourceURl: String) : Serializable {
-
- fun getTag(): String {
- val lastIndex1 = sourceURl.lastIndexOf("/")
-
- val lastIndex2 = sourceURl.lastIndexOf(".")
-
- val substring = sourceURl.substring(lastIndex1+1, lastIndex2)
- Log.d("-----------","------TAG----$substring")
-
- return substring
-
- }
-
-
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/CategoryAbility.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/CategoryAbility.kt
index 58d6f35..a4e632d 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/CategoryAbility.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/CategoryAbility.kt
@@ -3,23 +3,25 @@ package com.cute.girl.hd.pink.img.wallpaper.page
import android.content.Context
import android.content.Intent
import android.os.Bundle
-import android.text.TextUtils
import androidx.appcompat.app.AppCompatActivity
+import androidx.lifecycle.ViewModelProvider
+import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import com.cute.girl.hd.pink.img.wallpaper.adapter.CategoryDetailAdapter
import com.cute.girl.hd.pink.img.wallpaper.databinding.AbilityCategoryBinding
-import com.cute.girl.hd.pink.img.wallpaper.entity.CategoryData
+import com.cute.girl.hd.pink.img.wallpaper.db.Category
import com.cute.girl.hd.pink.img.wallpaper.entity.CategoryPreviewBean
-import com.cute.girl.hd.pink.img.wallpaper.entity.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.Data
import com.cute.girl.hd.pink.img.wallpaper.entity.GCategoryDetail
import com.cute.girl.hd.pink.img.wallpaper.entity.IntentConstants
//import com.cute.girl.hd.pink.img.wallpaper.net.base.BaseListener
//import com.cute.girl.hd.pink.img.wallpaper.net.base.ServiceImage
//import com.cute.girl.hd.pink.img.wallpaper.net.response.ResponseCategoryDetail
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.hide
-import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.onMain
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.show
import com.cute.girl.hd.pink.img.wallpaper.view.CustomItemDecoration
+import com.cute.girl.hd.pink.img.wallpaper.viewmodel.CategoryListViewModel
+import com.cute.girl.hd.pink.img.wallpaper.viewmodel.CategoryViewModel
import java.util.concurrent.atomic.AtomicBoolean
class CategoryAbility : AppCompatActivity() {
@@ -29,13 +31,13 @@ class CategoryAbility : AppCompatActivity() {
// private var mService: ServiceImage? = null
private var isLoading = AtomicBoolean(false)
private var mPage = 1
- private lateinit var mCid :CategoryData
+ private lateinit var mCid : Category
private var mCName = ""
-
+ private lateinit var mViewModel: CategoryListViewModel
companion object {
- fun start(context: Context, categoryData: CategoryData) {
+ fun start(context: Context, category: Category) {
val intent = Intent(context, CategoryAbility::class.java)
- intent.putExtra(IntentConstants.KEY_STRING, categoryData)
+ intent.putExtra(IntentConstants.KEY_STRING, category)
// intent.putExtra(IntentConstants.KEY_STRING2, cName)
context.startActivity(intent)
}
@@ -44,6 +46,9 @@ class CategoryAbility : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = AbilityCategoryBinding.inflate(layoutInflater)
+
+ mViewModel = ViewModelProvider(this).get(CategoryListViewModel::class.java)
+
setContentView(binding.root)
setupViews()
binding.ivBack.setOnClickListener {
@@ -54,21 +59,17 @@ class CategoryAbility : AppCompatActivity() {
private fun setupViews() {
if (intent.hasExtra(IntentConstants.KEY_STRING)) {
if (intent.getSerializableExtra(IntentConstants.KEY_STRING) != null) {
- mCid = intent.getSerializableExtra(IntentConstants.KEY_STRING) as CategoryData
+ mCid = intent.getSerializableExtra(IntentConstants.KEY_STRING) as Category
+ mViewModel.queryData(mCid.id)
}
}
-// if (intent.hasExtra(IntentConstants.KEY_STRING2)) {
-// if (intent.getStringExtra(IntentConstants.KEY_STRING2) != null) {
-// mCName = intent.getStringExtra(IntentConstants.KEY_STRING2)!!
-// }
-// }
-// if (TextUtils.isEmpty(mCid)) {
-// finish()
-// return
-// }
binding.tvTitle.text = mCid.title
- mAdapter = CategoryDetailAdapter(this, mCid.data)
+ mAdapter = CategoryDetailAdapter(this)
+
+ mViewModel.listLiveData.observe(this){
+ mAdapter?.updateData(it)
+ }
mAdapter?.setOnItemClickListener(object :
CategoryDetailAdapter.OnItemClickListener {
override fun onItemClick(pos: Data) {
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/CategoryPage.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/CategoryPage.kt
index d0fbdd3..5bb671e 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/CategoryPage.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/CategoryPage.kt
@@ -1,24 +1,27 @@
package com.cute.girl.hd.pink.img.wallpaper.page
import android.os.Bundle
+import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
+import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.GridLayoutManager
import com.cute.girl.hd.pink.img.wallpaper.MyApp
import com.cute.girl.hd.pink.img.wallpaper.adapter.CategoryAdapter
import com.cute.girl.hd.pink.img.wallpaper.databinding.PageRecentBinding
-import com.cute.girl.hd.pink.img.wallpaper.entity.CategoryData
+import com.cute.girl.hd.pink.img.wallpaper.db.Category
import com.cute.girl.hd.pink.img.wallpaper.entity.GCategory
import com.cute.girl.hd.pink.img.wallpaper.topon.AdManager
//import com.cute.girl.hd.pink.img.wallpaper.net.base.BaseListener
//import com.cute.girl.hd.pink.img.wallpaper.net.base.ServiceImage
//import com.cute.girl.hd.pink.img.wallpaper.net.response.ResponseCategory
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.hide
-import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.onMain
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.show
import com.cute.girl.hd.pink.img.wallpaper.view.CustomItemDecoration
+import com.cute.girl.hd.pink.img.wallpaper.viewmodel.CategoryViewModel
+import com.cute.girl.hd.pink.img.wallpaper.viewmodel.PopularViewModel
import java.util.concurrent.atomic.AtomicBoolean
class CategoryPage : Fragment() {
@@ -28,13 +31,15 @@ class CategoryPage : Fragment() {
// private var mService: ServiceImage? = null
private var isLoading = AtomicBoolean(false)
-
+ private lateinit var mViewModel: CategoryViewModel
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = PageRecentBinding.inflate(layoutInflater)
+
+ mViewModel = ViewModelProvider(this).get(CategoryViewModel::class.java)
return binding.root
}
@@ -44,13 +49,14 @@ class CategoryPage : Fragment() {
}
private fun setupViews() {
-
- val subList = MyApp.myData.subList(3, MyApp.myData.size)
-
- mAdapter = CategoryAdapter(requireActivity(), subList)
+ mAdapter = CategoryAdapter(requireActivity())
+ mViewModel.listLiveData.observe(viewLifecycleOwner){
+ Log.d(MyApp.TAG,"-----Category--data--${it.size}")
+ mAdapter?.update(it)
+ }
mAdapter?.setOnItemClickListener(object :
CategoryAdapter.OnItemClickListener {
- override fun onItemClick(pos: CategoryData) {
+ override fun onItemClick(pos: Category) {
toDetail(pos)
}
})
@@ -60,87 +66,18 @@ class CategoryPage : Fragment() {
)
binding.rv.adapter = mAdapter!!
- //下拉刷新
-// binding.refreshLayout.setOnRefreshListener {
-// if (isLoading.get()) {
-// return@setOnRefreshListener
-// }
-// refresh()
-// }
-
- refresh()
- }
-
- private fun refresh() {
-// if (mService == null) {
-// mService = ServiceImage()
-// }
-// if (isLoading.get()) {
-// return
-// }
-// isLoading.set(true)
-// mService?.let { service ->
-// val call = service.mApi.getCategory()
-// service.callEnqueue(call, object : BaseListener {
-// override fun onResponse(t: ResponseCategory?) {
-// if (t != null) {
-// if (t.MaterialWallpaper != null && t.MaterialWallpaper.isNotEmpty()) {
-// mList.clear()
-// mList.addAll(t.MaterialWallpaper.toMutableList())
-// isLoading.set(false)
-// onMain {
-// mAdapter?.notifyDataSetChanged()
-// updateView()
-// }
-// } else {
-// onMain {
-// updateView()
-// }
-// }
-// } else {
-// onMain {
-// updateView()
-// }
-// }
-// }
-//
-// override fun onFail(e: String?) {
-// isLoading.set(false)
-// onMain {
-// mAdapter?.notifyDataSetChanged()
-// updateView()
-// }
-// }
-// })
-// }
- }
-
- fun updateView() {
-// binding.refreshLayout.finishRefresh()
-// binding.refreshLayout.finishLoadMore()
- if (mList.isNotEmpty()) {
- binding.tvEmpty.hide()
- } else {
- binding.tvEmpty.show()
- }
}
- fun toDetail(pos: CategoryData) {
+
+
+ fun toDetail(pos: Category) {
if (activity != null) {
- showTopOn{
+ AdManager.showTopOn(requireActivity()){
CategoryAbility.start(requireActivity(), pos)
}
-
}
}
- private fun showTopOn(action: () -> Unit) {
- AdManager.showAD(requireActivity()) { integer: Int ->
- if (integer == AdManager.type_show_close || integer == AdManager.type_no_cache || integer == AdManager.type_show_fail) {
- action.invoke()
- }
- }
- }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/FeaturePage.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/FavoritPage.kt
similarity index 59%
rename from app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/FeaturePage.kt
rename to app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/FavoritPage.kt
index 891b9a7..b9636ec 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/FeaturePage.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/FavoritPage.kt
@@ -1,37 +1,43 @@
package com.cute.girl.hd.pink.img.wallpaper.page
import android.os.Bundle
+import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
+import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.GridLayoutManager
import com.cute.girl.hd.pink.img.wallpaper.MyApp
+import com.cute.girl.hd.pink.img.wallpaper.R
import com.cute.girl.hd.pink.img.wallpaper.adapter.ImageGridAdapter
import com.cute.girl.hd.pink.img.wallpaper.databinding.PageRecentBinding
-import com.cute.girl.hd.pink.img.wallpaper.entity.Data
-import com.cute.girl.hd.pink.img.wallpaper.entity.GImage
-import com.cute.girl.hd.pink.img.wallpaper.entity.PreviewBean
+import com.cute.girl.hd.pink.img.wallpaper.db.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.MyDatabase
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.hide
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.show
import com.cute.girl.hd.pink.img.wallpaper.view.CustomItemDecoration
+import com.cute.girl.hd.pink.img.wallpaper.viewmodel.CategoryViewModel
+import com.cute.girl.hd.pink.img.wallpaper.viewmodel.FavoriteViewModel
import java.util.concurrent.atomic.AtomicBoolean
-class FeaturePage : Fragment() {
+class FavoritPage : Fragment() {
private lateinit var binding: PageRecentBinding
- private var mList: MutableList = mutableListOf()
+ private lateinit var mList: List
private var mAdapter: ImageGridAdapter? = null
// private var mService: ServiceImage? = null
private var isLoading = AtomicBoolean(false)
private var mPage = 1
-
+ private lateinit var mViewModel: FavoriteViewModel
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = PageRecentBinding.inflate(layoutInflater)
+ mViewModel = ViewModelProvider(this).get(FavoriteViewModel::class.java)
return binding.root
}
@@ -41,61 +47,46 @@ class FeaturePage : Fragment() {
}
private fun setupViews() {
+ binding.tvEmpty.setText(getString(R.string.no_like))
+ binding.tvEmpty.isVisible = true
+ mAdapter = ImageGridAdapter(requireActivity())
- mAdapter = ImageGridAdapter(requireActivity(), MyApp.myData[0].data)
+ MyDatabase.myDatabase.WallpaperDao().queryAllLike(true).observe(requireActivity()){
+ Log.d(MyApp.TAG,"----------like=${it.size}")
+ if(it.isNotEmpty()){
+ binding.tvEmpty.isVisible = false
+ }
+ mAdapter?.refresh(it)
+ }
mAdapter?.setOnItemClickListener(object :
ImageGridAdapter.OnItemClickListener {
override fun onItemClick(pos: Data) {
-
toPreview(pos)
}
})
+
+
binding.rv.layoutManager = GridLayoutManager(requireActivity(), 3)
binding.rv.addItemDecoration(
CustomItemDecoration(1, 2)
)
binding.rv.adapter = mAdapter!!
-// //下拉刷新
-// binding.refreshLayout.setOnRefreshListener {
-// if (isLoading.get()) {
-// return@setOnRefreshListener
-// }
-// refresh()
-// }
-//
-// //上拉加载
-// binding.refreshLayout.setOnLoadMoreListener {
-// if (isLoading.get()) {
-// return@setOnLoadMoreListener
-// }
-// loadMore()
-// }
-
}
- fun updateView() {
-// binding.refreshLayout.finishRefresh()
-// binding.refreshLayout.finishLoadMore()
- if (mList.isNotEmpty()) {
- binding.tvEmpty.hide()
- } else {
- binding.tvEmpty.show()
- }
- }
- fun toPreview(pos: Data) {
-// if (pos < 0 || pos >= mList.size) {
-// return
-// }
+
+
+
+ fun toPreview(data: Data) {
if (activity != null) {
- val listBean = PreviewBean()
- listBean.list = mList
- PreviewAbility.start(requireActivity(), pos)
+// val listBean = PreviewBean()
+// listBean.list = mList
+ PreviewAbility.start(requireActivity(), data)
}
}
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/MainAbility.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/MainAbility.kt
index afdcf4e..9fef43b 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/MainAbility.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/MainAbility.kt
@@ -11,6 +11,7 @@ import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.cute.girl.hd.pink.img.wallpaper.R
import com.cute.girl.hd.pink.img.wallpaper.databinding.AbilityMainBinding
+import com.cute.girl.hd.pink.img.wallpaper.topon.AdManager
class MainAbility : AppCompatActivity() {
private lateinit var binding: AbilityMainBinding
@@ -22,19 +23,18 @@ class MainAbility : AppCompatActivity() {
super.onCreate(savedInstanceState)
binding = AbilityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
+ AdManager.loadAllAd()
setupViews()
}
private fun setupViews() {
binding.tvVersion.text = "v${getAppVersionName()}"
- mTitles.add("Recent")
- mTitles.add("Popular")
- mTitles.add("Feature")
- mTitles.add("Category")
- mFragments.add(RecentPage())
+ mTitles.add(getString(R.string.title_popular))
+ mTitles.add(getString(R.string.title_cate))
+ mTitles.add(getString(R.string.title_fav))
mFragments.add(PopularPage())
- mFragments.add(FeaturePage())
mFragments.add(CategoryPage())
+ mFragments.add(FavoritPage())
mAdapter = MyPagerAdapter(supportFragmentManager)
binding.viewPager.adapter = mAdapter!!
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PopularPage.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PopularPage.kt
index d0ff30b..b15b02d 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PopularPage.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PopularPage.kt
@@ -1,50 +1,59 @@
package com.cute.girl.hd.pink.img.wallpaper.page
import android.os.Bundle
+import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
+import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.GridLayoutManager
import com.cute.girl.hd.pink.img.wallpaper.MyApp
import com.cute.girl.hd.pink.img.wallpaper.adapter.ImageGridAdapter
import com.cute.girl.hd.pink.img.wallpaper.databinding.PageRecentBinding
-import com.cute.girl.hd.pink.img.wallpaper.entity.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.MyDatabase
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.hide
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.show
import com.cute.girl.hd.pink.img.wallpaper.view.CustomItemDecoration
+import com.cute.girl.hd.pink.img.wallpaper.viewmodel.PopularViewModel
import java.util.concurrent.atomic.AtomicBoolean
class PopularPage : Fragment() {
private lateinit var binding: PageRecentBinding
private lateinit var mList: List
private var mAdapter: ImageGridAdapter? = null
-// private var mService: ServiceImage? = null
+
+ // private var mService: ServiceImage? = null
private var isLoading = AtomicBoolean(false)
private var mPage = 1
+ private lateinit var mViewModel: PopularViewModel
+
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = PageRecentBinding.inflate(layoutInflater)
+ Log.d(MyApp.TAG,"-------onCreateView--")
+ mViewModel = ViewModelProvider(this).get(PopularViewModel::class.java)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- mList = MyApp.myData[2].data
setupViews()
}
-
-
private fun setupViews() {
- mAdapter = ImageGridAdapter(requireActivity(), mList)
+ mAdapter = ImageGridAdapter(requireActivity())
+ mViewModel.listLiveData.observe(viewLifecycleOwner){
+ Log.d(MyApp.TAG,"-----Popular--data--${it.size}")
+ mAdapter?.refresh(it)
+ }
mAdapter?.setOnItemClickListener(object :
ImageGridAdapter.OnItemClickListener {
override fun onItemClick(pos: Data) {
-
toPreview(pos)
}
})
@@ -54,124 +63,11 @@ class PopularPage : Fragment() {
)
binding.rv.adapter = mAdapter!!
-// //下拉刷新
-// binding.refreshLayout.setOnRefreshListener {
-// if (isLoading.get()) {
-// return@setOnRefreshListener
-// }
-// refresh()
-// }
-//
-// //上拉加载
-// binding.refreshLayout.setOnLoadMoreListener {
-// if (isLoading.get()) {
-// return@setOnLoadMoreListener
-// }
-// loadMore()
-// }
-
- refresh()
}
- private fun refresh() {
-// if (mService == null) {
-// mService = ServiceImage()
-// }
-// if (isLoading.get()) {
-// return
-// }
-// isLoading.set(true)
-// mPage = 1
-// mService?.let { service ->
-// val call = service.mApi.getPopular(1)
-// service.callEnqueue(call, object : BaseListener {
-// override fun onResponse(t: ResponseImage?) {
-// if (t != null) {
-// if (t.MaterialWallpaper != null && t.MaterialWallpaper.isNotEmpty()) {
-// mList.clear()
-// mList.addAll(t.MaterialWallpaper.toMutableList())
-// isLoading.set(false)
-// onMain {
-// mAdapter?.notifyDataSetChanged()
-// updateView()
-// }
-// } else {
-// onMain {
-// updateView()
-// }
-// }
-// } else {
-// onMain {
-// updateView()
-// }
-// }
-// }
-//
-// override fun onFail(e: String?) {
-// isLoading.set(false)
-// onMain {
-// mAdapter?.notifyDataSetChanged()
-// updateView()
-// }
-// }
-// })
-// }
- }
- private fun loadMore() {
-// if (mService == null) {
-// mService = ServiceImage()
-// }
-// if (isLoading.get()) {
-// return
-// }
-// isLoading.set(true)
-// val newPage = mPage + 1
-// mService?.let { service ->
-// val call = service.mApi.getPopular(newPage)
-// service.callEnqueue(call, object : BaseListener {
-// override fun onResponse(t: ResponseImage?) {
-// if (t != null) {
-// if (t.MaterialWallpaper != null && t.MaterialWallpaper.isNotEmpty()) {
-// mList.addAll(t.MaterialWallpaper.toMutableList())
-// isLoading.set(false)
-// mPage = newPage
-// onMain {
-// mAdapter?.notifyDataSetChanged()
-// updateView()
-// }
-// } else {
-// onMain {
-// updateView()
-// }
-// }
-// } else {
-// onMain {
-// updateView()
-// }
-// }
-// }
-//
-// override fun onFail(e: String?) {
-// isLoading.set(false)
-// onMain {
-// mAdapter?.notifyDataSetChanged()
-// updateView()
-// }
-// }
-// })
-// }
- }
- fun updateView() {
-// binding.refreshLayout.finishRefresh()
-// binding.refreshLayout.finishLoadMore()
- if (mList.isNotEmpty()) {
- binding.tvEmpty.hide()
- } else {
- binding.tvEmpty.show()
- }
- }
+
fun toPreview(pos: Data) {
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PreviewAbility.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PreviewAbility.kt
index b8ef136..a5e3872 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PreviewAbility.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PreviewAbility.kt
@@ -16,7 +16,8 @@ import com.cute.girl.hd.pink.img.wallpaper.MyApp
import com.cute.girl.hd.pink.img.wallpaper.R
import com.cute.girl.hd.pink.img.wallpaper.adapter.ImagePagerAdapter
import com.cute.girl.hd.pink.img.wallpaper.databinding.AbilityPreviewBinding
-import com.cute.girl.hd.pink.img.wallpaper.entity.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.MyDatabase
import com.cute.girl.hd.pink.img.wallpaper.entity.IntentConstants
import com.cute.girl.hd.pink.img.wallpaper.topon.AdManager
import com.cute.girl.hd.pink.img.wallpaper.utils.DownloadUtil
@@ -27,6 +28,8 @@ import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.show
import com.cute.girl.hd.pink.img.wallpaper.utils.MediaUtil
import com.cute.girl.hd.pink.img.wallpaper.utils.PermissionUtil
import com.cute.girl.hd.pink.img.wallpaper.view.SetAsDialog
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import pub.devrel.easypermissions.EasyPermissions
import java.io.File
@@ -39,6 +42,8 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
private var mSetAsDialog: SetAsDialog? = null
private var mAction = 0//0设置壁纸 1下载壁纸
+ var listBean: Data? = null
+
companion object {
fun start(context: Context, bean: Data) {
@@ -52,16 +57,14 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = AbilityPreviewBinding.inflate(layoutInflater)
+ AdManager.loadAllAd()
setContentView(binding.root)
-
setupViews()
}
private fun showTopOn(action: () -> Unit) {
- AdManager.showAD(this@PreviewAbility) { integer: Int ->
- if (integer == AdManager.type_show_close || integer == AdManager.type_no_cache || integer == AdManager.type_show_fail) {
+ AdManager.showTopOn(this@PreviewAbility) {
action.invoke()
- }
}
}
@@ -74,10 +77,11 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
initData()
setUpView()
+ onClick()
}
+
private fun initData() {
- var listBean: Data? = null
if (intent.hasExtra(IntentConstants.KEY_LIST)) {
listBean = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getSerializableExtra(IntentConstants.KEY_LIST, Data::class.java)
@@ -89,8 +93,12 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
finish()
return
}
+ MyDatabase.myDatabase.WallpaperDao().queryWallpaper(listBean!!.id).observe(this){
+ binding.imLike.isSelected = it.like
+ }
+
mList.clear()
- mList.add(listBean)
+ mList.add(listBean!!)
if (mList.size == 0) {
finish()
@@ -123,21 +131,51 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
})
+
+ }
+
+ private fun onClick(){
binding.ivBack.setOnClickListener {
finish()
}
binding.tvSet.setOnClickListener {
- mAction = 0
- if (isExist()) {
- set4KWallpaper()
- } else {
- startDownload()
+ showTopOn {
+ mAction = 0
+ if (isExist()) {
+ set4KWallpaper()
+ } else {
+ startDownload()
+ }
}
+
}
binding.tvDownload.setOnClickListener {
+ showTopOn{
doSave()
+ }
+
+ }
+
+ binding.imLike.setOnClickListener {
+ showTopOn{
+ binding.imLike.isSelected = !binding.imLike.isSelected
+ if(binding.imLike.isSelected){
+ Toast.makeText(
+ this@PreviewAbility,
+ R.string.add_like.getString(),
+ Toast.LENGTH_SHORT
+ ).show()
+ }else{
+ Toast.makeText(
+ this@PreviewAbility,
+ R.string.cancel_like.getString(),
+ Toast.LENGTH_SHORT
+ ).show()
+ }
+ }
+
}
}
@@ -163,6 +201,11 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
)
val file = File(path)
if (!file.exists()) {
+ Toast.makeText(
+ this@PreviewAbility,
+ R.string.re_download.getString(),
+ Toast.LENGTH_SHORT
+ ).show()
return
}
val wallpaperManager = WallpaperManager.getInstance(this)
@@ -170,7 +213,6 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
mSetAsDialog = SetAsDialog(this) {
onClickHomeScreen = {
- showTopOn {
lifecycleScope.launch {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
wallpaperManager.setStream(file.inputStream())
@@ -190,13 +232,13 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
).show()
}
}
- }
+
}
onClickLockScreen = {
- showTopOn {
+
lifecycleScope.launch {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
wallpaperManager.setStream(file.inputStream())
@@ -216,12 +258,12 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
).show()
}
}
- }
+
}
onClickBoth = {
- showTopOn {
+
lifecycleScope.launch {
wallpaperManager.setStream(file.inputStream())//FLAG_SYSTEM | FLAG_LOCK)
onMain {
@@ -232,8 +274,6 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
).show()
}
}
- }
-
}
}
}
@@ -301,9 +341,12 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
DownloadUtil.getFilePath(
image.getTag()
)
- val saved = MediaUtil.saveImageToSystemAlbum(path, this@PreviewAbility)
+ val file = File(path)
+
+ val savedUri = MediaUtil.saveToGallery(this@PreviewAbility,file)
+// val saved = MediaUtil.saveImageToSystemAlbum(path,this@PreviewAbility)
if (!isFinishing) {
- if (saved) {
+ if (savedUri!= null) {
Toast.makeText(
this@PreviewAbility,
R.string.saved_to_album,
@@ -321,6 +364,18 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
}
+ override fun onPause() {
+ super.onPause()
+ val selected = binding.imLike.isSelected
+ CoroutineScope(Dispatchers.IO).launch{
+ MyDatabase.myDatabase.WallpaperDao().updateWallpaper(listBean?.apply {
+ like = selected
+ })
+ }
+
+
+ }
+
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array,
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PrivacyAbility.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PrivacyAbility.kt
index ab0a8fa..9b1696d 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PrivacyAbility.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/PrivacyAbility.kt
@@ -5,29 +5,35 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
+import android.util.Log
import android.view.View
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
+import com.cute.girl.hd.pink.img.wallpaper.MyApp
import com.cute.girl.hd.pink.img.wallpaper.R
import com.cute.girl.hd.pink.img.wallpaper.databinding.AbilityPrivacyBinding
+import com.cute.girl.hd.pink.img.wallpaper.topon.AdManager
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.getString
class PrivacyAbility : AppCompatActivity() {
private lateinit var binding: AbilityPrivacyBinding
companion object {
- const val URL_PRIVACY: String = "https://artwallpaper.bitbucket.io/privacy.html"
+
fun start(context: Context) {
context.startActivity(Intent(context, PrivacyAbility::class.java))
}
}
+ private val URL_PRIVACY: String = "file:///android_asset/ArtWallpaper_PrivacyPolicy.html"
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = AbilityPrivacyBinding.inflate(layoutInflater)
+ AdManager.loadAllAd()
setContentView(binding.root)
setupViews()
}
@@ -39,30 +45,10 @@ class PrivacyAbility : AppCompatActivity() {
val webSettings: WebSettings = binding.webView.settings
webSettings.javaScriptEnabled = true // enable javascript
webSettings.javaScriptCanOpenWindowsAutomatically = true
- binding.webView.webViewClient = object : WebViewClient() {
- override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
- if (url.startsWith("http:") || url.startsWith("https:")) {
- return false
- }
- val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
- startActivity(intent)
- return true
- }
-
- override fun onReceivedError(
- view: WebView,
- errorCode: Int,
- description: String,
- failingUrl: String
- ) {
- }
- }
-
binding.webView.loadUrl(URL_PRIVACY)
- binding.ivBack.visibility = View.VISIBLE
binding.ivBack.setOnClickListener {
- onBackPressed()
+ finish()
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/RecentPage.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/RecentPage.kt
deleted file mode 100644
index bd89685..0000000
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/RecentPage.kt
+++ /dev/null
@@ -1,193 +0,0 @@
-package com.cute.girl.hd.pink.img.wallpaper.page
-
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.fragment.app.Fragment
-import androidx.recyclerview.widget.GridLayoutManager
-import com.cute.girl.hd.pink.img.wallpaper.MyApp
-import com.cute.girl.hd.pink.img.wallpaper.adapter.ImageGridAdapter
-import com.cute.girl.hd.pink.img.wallpaper.databinding.PageRecentBinding
-import com.cute.girl.hd.pink.img.wallpaper.entity.Data
-import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.hide
-import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.show
-import com.cute.girl.hd.pink.img.wallpaper.view.CustomItemDecoration
-import java.util.concurrent.atomic.AtomicBoolean
-
-class RecentPage : Fragment() {
- private lateinit var binding: PageRecentBinding
- private lateinit var mList: List
- private var mAdapter: ImageGridAdapter? = null
-// private var mService: ServiceImage? = null
- private var isLoading = AtomicBoolean(false)
- private var mPage = 1
-
-
- override fun onCreateView(
- inflater: LayoutInflater,
- container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View? {
- binding = PageRecentBinding.inflate(layoutInflater)
- return binding.root
- }
-
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- mList = MyApp.myData[1].data
- setupViews()
- }
-
- private fun setupViews() {
- mAdapter = ImageGridAdapter(requireActivity(), mList)
- mAdapter?.setOnItemClickListener(object :
- ImageGridAdapter.OnItemClickListener {
- override fun onItemClick(pos: Data) {
-
- toPreview(pos)
- }
- })
- binding.rv.layoutManager = GridLayoutManager(requireActivity(), 3)
- binding.rv.addItemDecoration(
- CustomItemDecoration(1, 2)
- )
- binding.rv.adapter = mAdapter!!
-
-// //下拉刷新
-// binding.refreshLayout.setOnRefreshListener {
-// if (isLoading.get()) {
-// return@setOnRefreshListener
-// }
-// refresh()
-// }
-//
-// //上拉加载
-// binding.refreshLayout.setOnLoadMoreListener {
-// if (isLoading.get()) {
-// return@setOnLoadMoreListener
-// }
-// loadMore()
-// }
-
-// refresh()
- }
- private fun refresh(){
- val shuffled = mList.shuffled()
- mAdapter?.refresh(shuffled)
-
- }
-// private fun refresh() {
-// if (mService == null) {
-// mService = ServiceImage()
-// }
-// if (isLoading.get()) {
-// return
-// }
-// isLoading.set(true)
-// mPage = 1
-// mService?.let { service ->
-// val call = service.mApi.getRecent(1)
-// service.callEnqueue(call, object : BaseListener {
-// override fun onResponse(t: ResponseImage?) {
-// if (t != null) {
-// if (t.MaterialWallpaper != null && t.MaterialWallpaper.isNotEmpty()) {
-// mList.clear()
-// mList.addAll(t.MaterialWallpaper.toMutableList())
-// isLoading.set(false)
-// onMain {
-// mAdapter?.notifyDataSetChanged()
-// updateView()
-// }
-// } else {
-// onMain {
-// updateView()
-// }
-// }
-// } else {
-// onMain {
-// updateView()
-// }
-// }
-// }
-//
-// override fun onFail(e: String?) {
-// isLoading.set(false)
-// onMain {
-// mAdapter?.notifyDataSetChanged()
-// updateView()
-// }
-// }
-// })
-// }
-// }
-
- private fun loadMore(){
-
- }
-
-// private fun loadMore() {
-// if (mService == null) {
-// mService = ServiceImage()
-// }
-// if (isLoading.get()) {
-// return
-// }
-// isLoading.set(true)
-// val newPage = mPage + 1
-// mService?.let { service ->
-// val call = service.mApi.getRecent(newPage)
-// service.callEnqueue(call, object : BaseListener {
-// override fun onResponse(t: ResponseImage?) {
-// if (t != null) {
-// if (t.MaterialWallpaper != null && t.MaterialWallpaper.isNotEmpty()) {
-// mList.addAll(t.MaterialWallpaper.toMutableList())
-// isLoading.set(false)
-// mPage = newPage
-// onMain {
-// mAdapter?.notifyDataSetChanged()
-// updateView()
-// }
-// } else {
-// onMain {
-// updateView()
-// }
-// }
-// } else {
-// onMain {
-// updateView()
-// }
-// }
-// }
-//
-// override fun onFail(e: String?) {
-// isLoading.set(false)
-// onMain {
-// mAdapter?.notifyDataSetChanged()
-// updateView()
-// }
-// }
-// })
-// }
-// }
-
- fun updateView() {
-// binding.refreshLayout.finishRefresh()
-// binding.refreshLayout.finishLoadMore()
- if (mList.isNotEmpty()) {
- binding.tvEmpty.hide()
- } else {
- binding.tvEmpty.show()
- }
- }
-
-
- fun toPreview(data: Data) {
- if (activity != null) {
-// val listBean = PreviewBean()
-// listBean.list = mList
- PreviewAbility.start(requireActivity(), data)
- }
- }
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/StartAbility.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/StartAbility.kt
index 107f653..87e1aa2 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/StartAbility.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/page/StartAbility.kt
@@ -6,24 +6,33 @@ import android.os.CountDownTimer
import androidx.appcompat.app.AppCompatActivity
import com.cute.girl.hd.pink.img.wallpaper.databinding.AbilityStartBinding
import com.cute.girl.hd.pink.img.wallpaper.topon.AdManager
+import kotlin.math.roundToInt
class StartAbility : AppCompatActivity() {
private lateinit var binding: AbilityStartBinding
private var time = 11000L
-
private var countDownTimer: CountDownTimer? = null
-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = AbilityStartBinding.inflate(layoutInflater)
setContentView(binding.root)
- countDownTimer = AdManager.showWelcomeAd(this@StartAbility, time) {
- setupViews()
- }
+
+ countDownTimer =
+ AdManager.showWelcomeAd(this@StartAbility, time, { millisUntilFinished ->
+ val percentage: Float = 100 - millisUntilFinished.toFloat() / time * 100
+ val round = percentage.roundToInt()
+ binding.progressbar.progress = round
+ if (AdManager.place1LoadFail && AdManager.place2LoadFail && AdManager.place3LoadFail) {
+ countDownTimer?.cancel()
+ setupViews()
+ }
+ }, {
+ setupViews()
+ })
countDownTimer?.start()
}
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/topon/AdListener.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/topon/AdListener.kt
index 3357e2f..b94a460 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/topon/AdListener.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/topon/AdListener.kt
@@ -1,6 +1,8 @@
package com.cute.girl.hd.pink.img.wallpaper.topon
interface AdListener {
+
+ fun loadFail(placeId: String)
fun showSuccess()
fun showFail()
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/topon/AdManager.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/topon/AdManager.kt
index b2992d2..737c09b 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/topon/AdManager.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/topon/AdManager.kt
@@ -13,21 +13,28 @@ import com.cute.girl.hd.pink.img.wallpaper.MyApp
object AdManager {
+
const val type_no_cache = 0
const val type_has_cache = 1
const val type_show_success = 2
const val type_show_close = 3
const val type_show_fail = 4
- /***
- * n66978a7938950
- * n66978a6a2a132
- * n66978a40971a3
+ /**
+ n66978a7938950
+ n66978a6a2a132
+ n66978a40971a3
*/
+
const val place1Id = "n66978a7938950"
const val place2Id = "n66978a6a2a132"
const val place3Id = "n66978a40971a3"
+
+ var place1LoadFail = false
+ var place2LoadFail = false
+ var place3LoadFail = false
+
val list = mutableListOf()
@@ -43,7 +50,19 @@ object AdManager {
}
for (ad in list) {
if (!ad.isAdReady) {
- setCallBack(ad,object : AdListener {
+ setCallBack(ad, object : AdListener {
+ override fun loadFail(placeId: String) {
+ if (placeId == place1Id) {
+ place1LoadFail = true
+ }
+ if (placeId == place2Id) {
+ place2LoadFail = true
+ }
+ if (placeId == place3Id) {
+ place3LoadFail = true
+ }
+ }
+
override fun showSuccess() {
}
@@ -63,23 +82,32 @@ object AdManager {
}
+
@JvmStatic
fun getReadyAd(): ATInterstitial? {
list.shuffle()
for (ad in list) {
if (ad.isAdReady) {
+ Log.d(MyApp.TAG, "-有广告------------")
return ad
}
}
+ Log.d(MyApp.TAG, "-没有广告------------")
return null
}
@JvmStatic
- fun showWelcomeAd(activity: Activity,totalTim: Long, goMain: () -> Unit): CountDownTimer {
+ fun showWelcomeAd(
+ activity: Activity,
+ totalTim: Long,
+ countAction: (millisUntilFinished: Long) -> Unit,
+ goMain: () -> Unit
+ ): CountDownTimer {
var alreadyShow = false
var timer = object : CountDownTimer(totalTim, 100) {
override fun onTick(millisUntilFinished: Long) {
+ countAction.invoke(millisUntilFinished)
if (!alreadyShow) {
showAD(activity) {
if (it == type_has_cache) {
@@ -129,7 +157,6 @@ object AdManager {
}
override fun onInterstitialAdClose(p0: ATAdInfo?) {
- Log.d(MyApp.TAG, "AdClose ${p0?.showId} ")
listener.showClose()
}
@@ -150,14 +177,19 @@ object AdManager {
@JvmStatic
- fun showAD(activity: Activity, action: (type: Int) -> Unit) {
+ private fun showAD(activity: Activity, action: (type: Int) -> Unit) {
val readyAd = getReadyAd()
- if (readyAd!= null) {
+ if (readyAd != null) {
Log.d(MyApp.TAG, "readyAd ${readyAd.mPlacementId} ")
action.invoke(type_has_cache)
- setCallBack(readyAd,object : AdListener {
+ setCallBack(readyAd, object : AdListener {
+ override fun loadFail(placeId: String) {
+
+ }
+
override fun showSuccess() {
action.invoke(type_show_success)
+
}
override fun showFail() {
@@ -171,11 +203,17 @@ object AdManager {
})
readyAd.show(activity)
} else {
- Log.d(MyApp.TAG, "showAD type_no_cache ")
action.invoke(type_no_cache)
}
}
-
+ @JvmStatic
+ fun showTopOn(activity: Activity, listener: onActionListener) {
+ showAD(activity) { type ->
+ if (type == type_no_cache || type == type_show_close || type == type_show_fail) {
+ listener.onAction()
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/topon/onActionListener.java b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/topon/onActionListener.java
new file mode 100644
index 0000000..d5c0336
--- /dev/null
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/topon/onActionListener.java
@@ -0,0 +1,6 @@
+package com.cute.girl.hd.pink.img.wallpaper.topon;
+
+public interface onActionListener {
+
+ void onAction();
+}
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/utils/DownloadUtil.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/utils/DownloadUtil.kt
index 16bbcc3..f7f738e 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/utils/DownloadUtil.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/utils/DownloadUtil.kt
@@ -4,6 +4,8 @@ import android.net.Uri
import android.text.TextUtils
import android.util.Log
import androidx.annotation.MainThread
+import com.cute.girl.hd.pink.img.wallpaper.MyApp
+import com.cute.girl.hd.pink.img.wallpaper.R
import okhttp3.Call
import okhttp3.Callback
import okhttp3.OkHttpClient
@@ -33,13 +35,11 @@ object DownloadUtil {
/**
* 获取文件下载路径
- * path:/storage/emulated/0/Android/data/com.lux.sound.pranks.hilarious.effects/X4D/download/hairclipper_4.jpg
- *
- * /storage/emulated/0/Android/data/com.wallart.art.wallpapers.hd/files/PrankSound/download//c189c2a257a0591c3ff5060c235c7342
+ * /data/user/0/com.wallart.art.wallpapers.hd.test/cache/289e1219ab8467f96c5c347c30292256.jpeg
*/
fun getFilePath(tag: String?): String {
-
- val s = FileUtil.getDownloadDirectory() + File.separator + tag
+ val s =
+ MyApp.app.cacheDir.absolutePath + File.separator + tag+".jpeg"
Log.d("-----------", "----getFilePath--$s")
return s
}
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/utils/MediaUtil.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/utils/MediaUtil.kt
index d429974..8b9f2f2 100644
--- a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/utils/MediaUtil.kt
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/utils/MediaUtil.kt
@@ -9,6 +9,7 @@ import android.os.Environment
import android.provider.MediaStore
import java.io.File
import java.io.FileInputStream
+import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
@@ -202,4 +203,49 @@ object MediaUtil {
return false
}
+
+
+ fun saveToGallery(context: Context, photoFile: File): Uri? {
+ val displayName = "${System.currentTimeMillis()}.jpg"
+ val contentValues = ContentValues().apply {
+ put(MediaStore.Images.Media.DISPLAY_NAME, displayName)
+ put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg")
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ put(MediaStore.Images.Media.IS_PENDING, 1)
+ }
+ }
+
+ val contentResolver = context.contentResolver
+ val collectionUri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
+ } else {
+ MediaStore.Images.Media.EXTERNAL_CONTENT_URI
+ }
+
+ val imageUri = contentResolver.insert(collectionUri, contentValues)
+
+ imageUri?.let { uri ->
+ try {
+ contentResolver.openOutputStream(uri)?.use { outputStream ->
+ val inputStream = FileInputStream(photoFile)
+ inputStream.copyTo(outputStream)
+ inputStream.close()
+ outputStream.close()
+ }
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ contentValues.clear()
+ contentValues.put(MediaStore.Images.Media.IS_PENDING, 0)
+ contentResolver.update(uri, contentValues, null, null)
+ } else {
+
+ }
+ return uri
+ } catch (e: IOException) {
+ return null
+ }
+ } ?: run {
+ return null
+ }
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/CategoryListViewModel.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/CategoryListViewModel.kt
new file mode 100644
index 0000000..35165ec
--- /dev/null
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/CategoryListViewModel.kt
@@ -0,0 +1,31 @@
+package com.cute.girl.hd.pink.img.wallpaper.viewmodel
+
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+import com.cute.girl.hd.pink.img.wallpaper.db.Category
+import com.cute.girl.hd.pink.img.wallpaper.db.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.MyDatabase
+
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+
+class CategoryListViewModel : ViewModel() {
+
+
+
+
+ private val _list = MutableLiveData>()
+ val listLiveData: LiveData> = _list
+
+
+ fun queryData(categorId:Long){
+ CoroutineScope(Dispatchers.IO).launch {
+ val queryCate = MyDatabase.myDatabase.WallpaperDao().queryCategoryList(categorId)
+ _list.postValue(queryCate)
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/CategoryViewModel.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/CategoryViewModel.kt
new file mode 100644
index 0000000..fb856d2
--- /dev/null
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/CategoryViewModel.kt
@@ -0,0 +1,28 @@
+package com.cute.girl.hd.pink.img.wallpaper.viewmodel
+
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+import com.cute.girl.hd.pink.img.wallpaper.db.Category
+import com.cute.girl.hd.pink.img.wallpaper.db.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.MyDatabase
+
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+
+class CategoryViewModel : ViewModel() {
+
+
+ private val _list = MutableLiveData>()
+ val listLiveData: LiveData> = _list
+ init {
+ CoroutineScope(Dispatchers.IO).launch {
+ val queryCate = MyDatabase.myDatabase.CategoryDao().queryAllData()
+ _list.postValue(queryCate)
+ }
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/FavoriteViewModel.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/FavoriteViewModel.kt
new file mode 100644
index 0000000..552f95a
--- /dev/null
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/FavoriteViewModel.kt
@@ -0,0 +1,28 @@
+package com.cute.girl.hd.pink.img.wallpaper.viewmodel
+
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+import com.cute.girl.hd.pink.img.wallpaper.db.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.MyDatabase
+
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+
+class FavoriteViewModel : ViewModel() {
+
+
+
+ private val _list = MutableLiveData>()
+ val listLiveData: LiveData> = _list
+// init {
+// CoroutineScope(Dispatchers.IO).launch {
+// val queryList = MyDatabase.myDatabase.WallpaperDao().queryAllLike(true)
+// _list.postValue(queryList)
+// }
+//
+// }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/PopularViewModel.kt b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/PopularViewModel.kt
new file mode 100644
index 0000000..76fdfa9
--- /dev/null
+++ b/app/src/main/java/com/cute/girl/hd/pink/img/wallpaper/viewmodel/PopularViewModel.kt
@@ -0,0 +1,24 @@
+package com.cute.girl.hd.pink.img.wallpaper.viewmodel
+
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+import com.cute.girl.hd.pink.img.wallpaper.db.Category
+import com.cute.girl.hd.pink.img.wallpaper.db.Data
+import com.cute.girl.hd.pink.img.wallpaper.db.MyDatabase
+
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+
+class PopularViewModel : ViewModel() {
+ private val _list = MutableLiveData>()
+ val listLiveData: LiveData> = _list
+ init {
+ CoroutineScope(Dispatchers.IO).launch {
+ val queryCateId = MyDatabase.myDatabase.CategoryDao().queryCateId("popular")
+ val queryList = MyDatabase.myDatabase.WallpaperDao().queryCategoryList(queryCateId.id)
+ _list.postValue(queryList)
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_back_black.xml b/app/src/main/res/drawable/ic_back_black.xml
new file mode 100644
index 0000000..7d9c10b
--- /dev/null
+++ b/app/src/main/res/drawable/ic_back_black.xml
@@ -0,0 +1,12 @@
+
+
+
diff --git a/app/src/main/res/drawable/im_download.xml b/app/src/main/res/drawable/im_download.xml
new file mode 100644
index 0000000..23a2df7
--- /dev/null
+++ b/app/src/main/res/drawable/im_download.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/im_like_false.xml b/app/src/main/res/drawable/im_like_false.xml
new file mode 100644
index 0000000..63ebd08
--- /dev/null
+++ b/app/src/main/res/drawable/im_like_false.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/im_like_true.xml b/app/src/main/res/drawable/im_like_true.xml
new file mode 100644
index 0000000..b252c46
--- /dev/null
+++ b/app/src/main/res/drawable/im_like_true.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/im_set_wallpaper.xml b/app/src/main/res/drawable/im_set_wallpaper.xml
new file mode 100644
index 0000000..5dae071
--- /dev/null
+++ b/app/src/main/res/drawable/im_set_wallpaper.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/progressbar.xml b/app/src/main/res/drawable/progressbar.xml
new file mode 100644
index 0000000..2a52770
--- /dev/null
+++ b/app/src/main/res/drawable/progressbar.xml
@@ -0,0 +1,41 @@
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/selctor_like.xml b/app/src/main/res/drawable/selctor_like.xml
new file mode 100644
index 0000000..41bda02
--- /dev/null
+++ b/app/src/main/res/drawable/selctor_like.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/selector_set_wallpaper.xml b/app/src/main/res/drawable/selector_set_wallpaper.xml
new file mode 100644
index 0000000..9cfb391
--- /dev/null
+++ b/app/src/main/res/drawable/selector_set_wallpaper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/ability_main.xml b/app/src/main/res/layout/ability_main.xml
index e48a2ae..4092190 100644
--- a/app/src/main/res/layout/ability_main.xml
+++ b/app/src/main/res/layout/ability_main.xml
@@ -50,6 +50,7 @@
app:tl_indicator_height="3dp"
app:tl_indicator_width="20dp"
app:tl_textBold="BOTH"
+ app:tl_tab_space_equal="true"
app:tl_textSelectColor="@color/theme_white"
app:tl_textUnselectColor="@color/theme_gray"
app:tl_textsize="18sp" />
diff --git a/app/src/main/res/layout/ability_preview.xml b/app/src/main/res/layout/ability_preview.xml
index c21c96b..fc09115 100644
--- a/app/src/main/res/layout/ability_preview.xml
+++ b/app/src/main/res/layout/ability_preview.xml
@@ -15,36 +15,70 @@
-
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1">
-
+
+
+
+
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1">
+
+
+
+
+
+
+
+
@@ -74,8 +108,8 @@
android:id="@+id/flDownload"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="gone"
- android:gravity="center">
+ android:gravity="center"
+ android:visibility="gone">
+ android:layout_height="56dp">
+ android:textColor="@color/black"
+ android:textSize="21sp" />
-
-
+
+
+
+
+ android:layout_height="10dp"
+ android:layout_alignParentBottom="true"
+ android:layout_marginStart="33dp"
+ android:layout_marginEnd="33dp"
+ android:layout_marginBottom="60dp"
+ android:progress="2"
+ android:progressDrawable="@drawable/progressbar" />
-
-
-
-
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/page_recent.xml b/app/src/main/res/layout/page_recent.xml
index 0e41bfb..70f1d60 100644
--- a/app/src/main/res/layout/page_recent.xml
+++ b/app/src/main/res/layout/page_recent.xml
@@ -5,14 +5,7 @@
android:layout_height="match_parent"
android:background="@color/theme_white">
-
-
-
-
-
-
-
@@ -25,6 +18,7 @@
android:fontFamily="@font/fredoka"
android:layout_gravity="center"
android:gravity="center"
+ android:visibility="gone"
android:text="@string/empty_data_txt"
android:textColor="@color/theme_gray"
android:textSize="14sp" />
@@ -36,11 +30,6 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 2a756f7..ac14cb3 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -6,4 +6,7 @@
#EBF6F5
#ED99B2
#D8D8D8
+ #B3B3B3
+ #ED99B2
+ #EFCED8
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index dc1aa11..9e284d5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -3,6 +3,7 @@
Image loading failed, please pull down to refresh and reload.
Downloading HD Image...
Set Wallpaper
+ There is an exception in the wallpaper file, please try again
Wallpaper set successfully
Home Screen
Lock Screen
@@ -14,4 +15,11 @@
Rate Us
Saved to album
Save failed
+ Favorite
+ Category
+ Popular
+ You haven not added any favorite wallpapers yet
+
+ Added to favorites successfully
+ Successfully canceled the collection
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 1a28f31..884c92d 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -2,6 +2,7 @@
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.jetbrainsKotlinAndroid) apply false
+ kotlin("kapt") version "2.0.0"
id("com.google.gms.google-services") version "4.3.15" apply false
id ("com.google.firebase.crashlytics") version "2.9.2" apply false
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index daa506f..55a3777 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue May 28 15:35:37 CST 2024
+#Thu Aug 15 15:09:54 CST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/keystore.properties b/keystore.properties
new file mode 100644
index 0000000..1037745
--- /dev/null
+++ b/keystore.properties
@@ -0,0 +1,6 @@
+app_name=Art Wallpaper
+package_name=com.wallart.art.wallpapers.hd
+keystoreFile=app/ArtWallpaper.jks
+key_alias=ArtWallpaperkey0
+key_store_password=ArtWallpaper
+key_password=ArtWallpaper